PERFORCE change 97407 for review
Scott Long
scottl at FreeBSD.org
Thu May 18 14:49:07 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=97407
Change 97407 by scottl at scottl-x64 on 2006/05/18 14:48:08
Introduce the xpt_lock and protect the fields in the xpt_softc with
it.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#32 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#32 (text+ko) ====
@@ -249,6 +249,8 @@
u_int bus_generation;
struct intr_config_hook *xpt_config_hook;
+
+ struct mtx xpt_lock;
};
static const char quantum[] = "QUANTUM";
@@ -1375,6 +1377,7 @@
xsoftc.num_highpower = CAM_MAX_HIGHPOWER;
mtx_init(&cam_bioq_lock, "CAM BIOQ lock", NULL, MTX_DEF);
+ mtx_init(&xsoftc.xpt_lock, "XPT lock", NULL, MTX_DEF);
/*
* The xpt layer is, itself, the equivelent of a SIM.
@@ -1488,7 +1491,7 @@
splx(s);
}
- xsoftc.xpt_generation++;
+ atomic_add_int(&xsoftc.xpt_generation, 1);
return (status);
}
@@ -1519,7 +1522,7 @@
splx(s);
}
- xsoftc.xpt_generation++;
+ atomic_add_int(&xsoftc.xpt_generation, 1);
}
@@ -2637,15 +2640,19 @@
retval = 1;
+ mtx_lock(&xsoftc.xpt_lock);
for (bus = (start_bus ? start_bus : TAILQ_FIRST(&xsoftc.xpt_busses));
bus != NULL;
bus = next_bus) {
next_bus = TAILQ_NEXT(bus, links);
+ mtx_unlock(&xsoftc.xpt_lock);
retval = tr_func(bus, arg);
if (retval == 0)
return(retval);
+ mtx_lock(&xsoftc.xpt_lock);
}
+ mtx_unlock(&xsoftc.xpt_lock);
return(retval);
}
@@ -3895,6 +3902,7 @@
if ((work_ccb->ccb_h.flags & CAM_HIGH_POWER) != 0) {
+ mtx_lock(&xsoftc.xpt_lock);
if (xsoftc.num_highpower <= 0) {
/*
* We got a high power command, but we
@@ -3916,6 +3924,7 @@
*/
xsoftc.num_highpower--;
}
+ mtx_unlock(&xsoftc.xpt_lock);
}
devq->active_dev = device;
cam_ccbq_remove_ccb(&device->ccbq, work_ccb);
@@ -4394,6 +4403,7 @@
new_bus->refcount = 1; /* Held until a bus_deregister event */
new_bus->generation = 0;
s = splcam();
+ mtx_lock(&xsoftc.xpt_lock);
old_bus = TAILQ_FIRST(&xsoftc.xpt_busses);
while (old_bus != NULL
&& old_bus->path_id < new_bus->path_id)
@@ -4403,6 +4413,7 @@
else
TAILQ_INSERT_TAIL(&xsoftc.xpt_busses, new_bus, links);
xsoftc.bus_generation++;
+ mtx_unlock(&xsoftc.xpt_lock);
splx(s);
/* Notify interested parties */
@@ -4497,6 +4508,7 @@
const char *strval;
pathid = 0;
+ mtx_lock(&xsoftc.xpt_lock);
bus = TAILQ_FIRST(&xsoftc.xpt_busses);
retry:
/* Find an unoccupied pathid */
@@ -4506,6 +4518,7 @@
pathid++;
bus = TAILQ_NEXT(bus, links);
}
+ mtx_unlock(&xsoftc.xpt_lock);
/*
* Ensure that this pathid is not reserved for
@@ -4514,6 +4527,7 @@
if (resource_string_value("scbus", pathid, "at", &strval) == 0) {
++pathid;
/* Start the search over */
+ mtx_lock(&xsoftc.xpt_lock);
goto retry;
}
return (pathid);
@@ -4999,8 +5013,10 @@
s = splcam();
if ((--bus->refcount == 0)
&& (TAILQ_FIRST(&bus->et_entries) == NULL)) {
+ mtx_lock(&xsoftc.xpt_lock);
TAILQ_REMOVE(&xsoftc.xpt_busses, bus, links);
xsoftc.bus_generation++;
+ mtx_unlock(&xsoftc.xpt_lock);
splx(s);
free(bus, M_CAMXPT);
} else
@@ -5230,6 +5246,7 @@
{
struct cam_eb *bus;
+ mtx_lock(&xsoftc.xpt_lock);
for (bus = TAILQ_FIRST(&xsoftc.xpt_busses);
bus != NULL;
bus = TAILQ_NEXT(bus, links)) {
@@ -5238,6 +5255,7 @@
break;
}
}
+ mtx_unlock(&xsoftc.xpt_lock);
return (bus);
}
@@ -7125,6 +7143,7 @@
struct highpowerlist *hphead;
union ccb *send_ccb;
+ mtx_lock(&xsoftc.xpt_lock);
hphead = &xsoftc.highpowerq;
send_ccb = (union ccb *)STAILQ_FIRST(hphead);
@@ -7133,6 +7152,7 @@
* Increment the count since this command is done.
*/
xsoftc.num_highpower++;
+ mtx_unlock(&xsoftc.xpt_lock);
/*
* Any high powered commands queued up?
More information about the p4-projects
mailing list