PERFORCE change 118045 for review
Scott Long
scottl at FreeBSD.org
Fri Apr 13 19:54:44 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=118045
Change 118045 by scottl at scottl-y1 on 2007/04/13 19:54:06
Switch the XPT SIM to using its own mutex. Remove dead code.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#56 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#56 (text+ko) ====
@@ -262,6 +262,7 @@
struct intr_config_hook *xpt_config_hook;
+ struct mtx xpt_topo_lock;
struct mtx xpt_lock;
};
@@ -819,11 +820,6 @@
static void xptaction(struct cam_sim *sim, union ccb *work_ccb);
static void xptpoll(struct cam_sim *sim);
static void camisr(void *);
-#if 0
-static void xptstart(struct cam_periph *periph, union ccb *work_ccb);
-static void xptasync(struct cam_periph *periph,
- u_int32_t code, cam_path *path);
-#endif
static dev_match_ret xptbusmatch(struct dev_match_pattern *patterns,
u_int num_patterns, struct cam_eb *bus);
static dev_match_ret xptdevicematch(struct dev_match_pattern *patterns,
@@ -862,16 +858,8 @@
static xpt_devicefunc_t xptdefdevicefunc;
static xpt_periphfunc_t xptdefperiphfunc;
static int xpt_for_all_busses(xpt_busfunc_t *tr_func, void *arg);
-#ifdef notusedyet
-static int xpt_for_all_targets(xpt_targetfunc_t *tr_func,
- void *arg);
-#endif
static int xpt_for_all_devices(xpt_devicefunc_t *tr_func,
void *arg);
-#ifdef notusedyet
-static int xpt_for_all_periphs(xpt_periphfunc_t *tr_func,
- void *arg);
-#endif
static xpt_devicefunc_t xptsetasyncfunc;
static xpt_busfunc_t xptsetasyncbusfunc;
static cam_status xptregister(struct cam_periph *periph,
@@ -1190,9 +1178,7 @@
/*
* This is an immediate CCB, we can send it on directly.
*/
- CAM_SIM_LOCK(bus->sim);
xpt_action(inccb);
- CAM_SIM_UNLOCK(bus->sim);
/*
* Map the buffers back into user space.
@@ -1429,7 +1415,7 @@
* processed.
*/
xpt_lock_buses();
- msleep(&xsoftc.ccb_scanq, &xsoftc.xpt_lock, PRIBIO,
+ msleep(&xsoftc.ccb_scanq, &xsoftc.xpt_topo_lock, PRIBIO,
"ccb_scanq", 0);
TAILQ_INIT(&queue);
TAILQ_CONCAT(&queue, &xsoftc.ccb_scanq, sim_links.tqe);
@@ -1492,6 +1478,7 @@
mtx_init(&cam_bioq_lock, "CAM BIOQ lock", NULL, MTX_DEF);
mtx_init(&xsoftc.xpt_lock, "XPT lock", NULL, MTX_DEF);
+ mtx_init(&xsoftc.xpt_topo_lock, "XPT topology lock", NULL, MTX_DEF);
/*
* The xpt layer is, itself, the equivelent of a SIM.
@@ -1505,7 +1492,7 @@
"xpt",
/*softc*/NULL,
/*unit*/0,
- /*mtx*/&Giant,
+ /*mtx*/&xsoftc.xpt_lock,
/*max_dev_transactions*/0,
/*max_tagged_dev_transactions*/0,
devq);
@@ -1513,7 +1500,8 @@
return (ENOMEM);
xpt_sim->max_ccbs = 16;
-
+
+ mtx_lock(&xsoftc.xpt_lock);
if ((status = xpt_bus_register(xpt_sim, /*bus #*/0)) != CAM_SUCCESS) {
printf("xpt_init: xpt_bus_register failed with status %#x,"
" failing attach\n", status);
@@ -1536,6 +1524,7 @@
cam_periph_alloc(xptregister, NULL, NULL, NULL, "xpt", CAM_PERIPH_BIO,
path, NULL, 0, xpt_sim);
xpt_free_path(path);
+ mtx_unlock(&xsoftc.xpt_lock);
/*
* Register a callback for when interrupts are enabled.
@@ -2662,21 +2651,21 @@
retval = 1;
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_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);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
mtx_lock(bus->sim->mtx);
retval = tr_func(bus, arg);
mtx_unlock(bus->sim->mtx);
if (retval == 0)
return(retval);
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
}
- mtx_unlock(&xsoftc.xpt_lock);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
return(retval);
}
@@ -2887,23 +2876,6 @@
return(xptbustraverse(NULL, xptdefbusfunc, &tr_config));
}
-#ifdef notusedyet
-/*
- * Execute the given function for every target in the EDT.
- */
-static int
-xpt_for_all_targets(xpt_targetfunc_t *tr_func, void *arg)
-{
- struct xpt_traverse_config tr_config;
-
- tr_config.depth = XPT_DEPTH_TARGET;
- tr_config.tr_func = tr_func;
- tr_config.tr_arg = arg;
-
- return(xptbustraverse(NULL, xptdefbusfunc, &tr_config));
-}
-#endif /* notusedyet */
-
/*
* Execute the given function for every device in the EDT.
*/
@@ -2919,23 +2891,6 @@
return(xptbustraverse(NULL, xptdefbusfunc, &tr_config));
}
-#ifdef notusedyet
-/*
- * Execute the given function for every peripheral in the EDT.
- */
-static int
-xpt_for_all_periphs(xpt_periphfunc_t *tr_func, void *arg)
-{
- struct xpt_traverse_config tr_config;
-
- tr_config.depth = XPT_DEPTH_PERIPH;
- tr_config.tr_func = tr_func;
- tr_config.tr_arg = arg;
-
- return(xptbustraverse(NULL, xptdefbusfunc, &tr_config));
-}
-#endif /* notusedyet */
-
static int
xptsetasyncfunc(struct cam_ed *device, void *arg)
{
@@ -4072,9 +4027,6 @@
void
xpt_setup_ccb(struct ccb_hdr *ccb_h, struct cam_path *path, u_int32_t priority)
{
-#if 0
- mtx_assert(path->bus->sim->mtx, MA_OWNED);
-#endif
CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_setup_ccb\n"));
ccb_h->pinfo.priority = priority;
@@ -4242,9 +4194,6 @@
void
xpt_free_path(struct cam_path *path)
{
-#if 0
- mtx_assert(path->bus->sim->mtx, MA_OWNED);
-#endif
CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_free_path\n"));
xpt_release_path(path);
@@ -4406,9 +4355,6 @@
struct cam_sim *
xpt_path_sim(struct cam_path *path)
{
-#if 0
- mtx_assert(path->bus->sim->mtx, MA_OWNED);
-#endif
return (path->bus->sim);
}
@@ -4512,7 +4458,7 @@
new_bus->refcount = 1; /* Held until a bus_deregister event */
new_bus->generation = 0;
s = splcam();
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
old_bus = TAILQ_FIRST(&xsoftc.xpt_busses);
while (old_bus != NULL
&& old_bus->path_id < new_bus->path_id)
@@ -4522,7 +4468,7 @@
else
TAILQ_INSERT_TAIL(&xsoftc.xpt_busses, new_bus, links);
xsoftc.bus_generation++;
- mtx_unlock(&xsoftc.xpt_lock);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
splx(s);
/* Notify interested parties */
@@ -4616,7 +4562,7 @@
const char *strval;
pathid = 0;
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
bus = TAILQ_FIRST(&xsoftc.xpt_busses);
retry:
/* Find an unoccupied pathid */
@@ -4625,7 +4571,7 @@
pathid++;
bus = TAILQ_NEXT(bus, links);
}
- mtx_unlock(&xsoftc.xpt_lock);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
/*
* Ensure that this pathid is not reserved for
@@ -4634,7 +4580,7 @@
if (resource_string_value("scbus", pathid, "at", &strval) == 0) {
++pathid;
/* Start the search over */
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
goto retry;
}
return (pathid);
@@ -5125,10 +5071,10 @@
s = splcam();
if ((--bus->refcount == 0)
&& (TAILQ_FIRST(&bus->et_entries) == NULL)) {
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
TAILQ_REMOVE(&xsoftc.xpt_busses, bus, links);
xsoftc.bus_generation++;
- mtx_unlock(&xsoftc.xpt_lock);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
splx(s);
free(bus, M_CAMXPT);
} else
@@ -5354,7 +5300,7 @@
{
struct cam_eb *bus;
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
for (bus = TAILQ_FIRST(&xsoftc.xpt_busses);
bus != NULL;
bus = TAILQ_NEXT(bus, links)) {
@@ -5363,7 +5309,7 @@
break;
}
}
- mtx_unlock(&xsoftc.xpt_lock);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
return (bus);
}
@@ -7103,6 +7049,11 @@
#endif /* CAM_DEBUG_FLAGS */
#ifdef CAM_DEBUG_BUS
if (cam_dflags != CAM_DEBUG_NONE) {
+ /*
+ * Locking is specifically omitted here. No SIMs have
+ * registered yet, so xpt_create_path will only be searching
+ * empty lists of targets and devices.
+ */
if (xpt_create_path(&cam_dpath, xpt_periph,
CAM_DEBUG_BUS, CAM_DEBUG_TARGET,
CAM_DEBUG_LUN) != CAM_REQ_CMP) {
@@ -7276,13 +7227,13 @@
void
xpt_lock_buses(void)
{
- mtx_lock(&xsoftc.xpt_lock);
+ mtx_lock(&xsoftc.xpt_topo_lock);
}
void
xpt_unlock_buses(void)
{
- mtx_unlock(&xsoftc.xpt_lock);
+ mtx_unlock(&xsoftc.xpt_topo_lock);
}
static void
More information about the p4-projects
mailing list