PERFORCE change 100057 for review
Scott Long
scottl at FreeBSD.org
Mon Jun 26 20:13:19 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=100057
Change 100057 by scottl at scottl-wv1u on 2006/06/26 13:56:19
First cut at ahd driver locking
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic79xx_osm.c#8 edit
.. //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic79xx_osm.h#8 edit
.. //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic_osm_lib.c#4 edit
.. //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic_osm_lib.h#5 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic79xx_osm.c#8 (text+ko) ====
@@ -95,7 +95,7 @@
/* Hook up our interrupt handler */
error = bus_setup_intr(ahd->dev_softc, ahd->platform_data->irq,
- INTR_TYPE_CAM, ahd_platform_intr, ahd,
+ INTR_TYPE_CAM|INTR_MPSAFE, ahd_platform_intr, ahd,
&ahd->platform_data->ih);
if (error != 0)
device_printf(ahd->dev_softc, "bus_setup_intr() failed: %d\n",
@@ -114,13 +114,17 @@
struct cam_devq *devq;
struct cam_sim *sim;
struct cam_path *path;
- long s;
+ u_long s;
int count;
count = 0;
devq = NULL;
sim = NULL;
+ ahd_lockinit(ahd);
+ ahd_done_lockinit(ahd);
+ ahd_list_lockinit();
+
/*
* Create a thread to perform all recovery.
*/
@@ -143,7 +147,7 @@
*/
sim = cam_sim_alloc(ahd_action, ahd_poll, "ahd", ahd,
device_get_unit(ahd->dev_softc),
- &Giant, M_NOWAIT, 1, /*XXX*/256, devq);
+ &ahd->platform_data->mtx, M_NOWAIT, 1, /*XXX*/256, devq);
if (sim == NULL) {
cam_simq_free(devq);
goto fail;
@@ -348,7 +352,6 @@
#endif
u_int target_id;
u_int our_id;
- long s;
CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("ahd_action\n"));
@@ -382,13 +385,11 @@
}
if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) {
- ahd_lock(ahd, &s);
SLIST_INSERT_HEAD(&lstate->accept_tios, &ccb->ccb_h,
sim_links.sle);
ccb->ccb_h.status = CAM_REQ_INPROG;
if ((ahd->flags & AHD_TQINFIFO_BLOCKED) != 0)
ahd_run_tqinfifo(ahd, /*paused*/FALSE);
- ahd_unlock(ahd, &s);
break;
}
@@ -422,7 +423,6 @@
/*
* get an scb to use.
*/
- ahd_lock(ahd, &s);
tinfo = ahd_fetch_transinfo(ahd, 'A', our_id,
target_id, &tstate);
if ((ccb->ccb_h.flags & CAM_TAG_ACTION_VALID) == 0
@@ -437,12 +437,10 @@
xpt_freeze_simq(sim, /*count*/1);
ahd->flags |= AHD_RESOURCE_SHORTAGE;
- ahd_unlock(ahd, &s);
ccb->ccb_h.status = CAM_REQUEUE_REQ;
xpt_done(ccb);
return;
}
- ahd_unlock(ahd, &s);
hscb = scb->hscb;
@@ -530,20 +528,16 @@
}
case XPT_SET_TRAN_SETTINGS:
{
- ahd_lock(ahd, &s);
ahd_set_tran_settings(ahd, SIM_SCSI_ID(ahd, sim),
SIM_CHANNEL(ahd, sim), &ccb->cts);
- ahd_unlock(ahd, &s);
xpt_done(ccb);
break;
}
case XPT_GET_TRAN_SETTINGS:
/* Get default/user set transfer settings for the target */
{
- ahd_lock(ahd, &s);
ahd_get_tran_settings(ahd, SIM_SCSI_ID(ahd, sim),
SIM_CHANNEL(ahd, sim), &ccb->cts);
- ahd_unlock(ahd, &s);
xpt_done(ccb);
break;
}
@@ -557,10 +551,8 @@
{
int found;
- ahd_lock(ahd, &s);
found = ahd_reset_channel(ahd, SIM_CHANNEL(ahd, sim),
/*initiate reset*/TRUE);
- ahd_unlock(ahd, &s);
if (bootverbose) {
xpt_print_path(SIM_PATH(ahd, sim));
printf("SCSI bus reset delivered. "
@@ -978,7 +970,6 @@
case AC_LOST_DEVICE:
{
struct ahd_devinfo devinfo;
- long s;
ahd_compile_devinfo(&devinfo, SIM_SCSI_ID(ahd, sim),
xpt_path_target_id(path),
@@ -990,13 +981,11 @@
* Revert to async/narrow transfers
* for the next device.
*/
- ahd_lock(ahd, &s);
ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
AHD_TRANS_GOAL|AHD_TRANS_CUR, /*paused*/FALSE);
ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
/*ppr_options*/0, AHD_TRANS_GOAL|AHD_TRANS_CUR,
/*paused*/FALSE);
- ahd_unlock(ahd, &s);
break;
}
default:
@@ -1014,7 +1003,6 @@
struct ahd_initiator_tinfo *tinfo;
struct ahd_tmode_tstate *tstate;
u_int mask;
- u_long s;
scb = (struct scb *)arg;
ccb = scb->io_ctx;
@@ -1027,9 +1015,7 @@
aic_set_transaction_status(scb, CAM_REQ_CMP_ERR);
if (nsegments != 0)
bus_dmamap_unload(ahd->buffer_dmat, scb->dmamap);
- ahd_lock(ahd, &s);
ahd_free_scb(ahd, scb);
- ahd_unlock(ahd, &s);
xpt_done(ccb);
return;
}
@@ -1067,8 +1053,6 @@
}
}
- ahd_lock(ahd, &s);
-
/*
* Last time we need to check if this SCB needs to
* be aborted.
@@ -1078,7 +1062,6 @@
bus_dmamap_unload(ahd->buffer_dmat,
scb->dmamap);
ahd_free_scb(ahd, scb);
- ahd_unlock(ahd, &s);
xpt_done(ccb);
return;
}
@@ -1128,7 +1111,6 @@
ahd_queue_scb(ahd, scb);
}
- ahd_unlock(ahd, &s);
}
static void
@@ -1155,7 +1137,6 @@
if (hscb->cdb_len > MAX_CDB_LEN
&& (ccb_h->flags & CAM_CDB_PHYS) == 0) {
- u_long s;
/*
* Should CAM start to support CDB sizes
@@ -1164,9 +1145,7 @@
*/
aic_set_transaction_status(scb,
CAM_REQ_INVALID);
- ahd_lock(ahd, &s);
ahd_free_scb(ahd, scb);
- ahd_unlock(ahd, &s);
xpt_done((union ccb *)csio);
return;
}
@@ -1183,13 +1162,10 @@
}
} else {
if (hscb->cdb_len > MAX_CDB_LEN) {
- u_long s;
aic_set_transaction_status(scb,
CAM_REQ_INVALID);
- ahd_lock(ahd, &s);
ahd_free_scb(ahd, scb);
- ahd_unlock(ahd, &s);
xpt_done((union ccb *)csio);
return;
}
@@ -1468,7 +1444,6 @@
{
struct ahd_softc *ahd;
u_long l;
- u_long s;
ahd_list_lock(&l);
device_printf(dev, "detaching device\n");
@@ -1481,10 +1456,8 @@
}
TAILQ_REMOVE(&ahd_tailq, ahd, links);
ahd_list_unlock(&l);
- ahd_lock(ahd, &s);
ahd_intr_enable(ahd, FALSE);
bus_teardown_intr(dev, ahd->platform_data->irq, ahd->platform_data->ih);
- ahd_unlock(ahd, &s);
ahd_free(ahd);
return (0);
}
==== //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic79xx_osm.h#8 (text+ko) ====
@@ -137,6 +137,7 @@
void *ih;
eventhandler_tag eh;
struct proc *recovery_thread;
+ struct mtx mtx;
};
struct scb_platform_data {
@@ -209,18 +210,19 @@
static __inline void
ahd_lockinit(struct ahd_softc *ahd)
{
+ mtx_init(&ahd->platform_data->mtx, "ahd_lock", NULL, MTX_DEF);
}
static __inline void
ahd_lock(struct ahd_softc *ahd, unsigned long *flags)
{
- *flags = splcam();
+ mtx_lock(&ahd->platform_data->mtx);
}
static __inline void
ahd_unlock(struct ahd_softc *ahd, unsigned long *flags)
{
- splx(*flags);
+ mtx_unlock(&ahd->platform_data->mtx);
}
/* Lock held during command compeletion to the upper layer */
==== //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic_osm_lib.c#4 (text+ko) ====
@@ -106,7 +106,7 @@
* Sleep on a slightly different location
* for this interlock just for added safety.
*/
- tsleep(aic->platform_data, PUSER, "thtrm", 0);
+ msleep(aic->platform_data, &aic->platform_data->mtx, PUSER, "thtrm", 0);
aic_unlock(aic, &s);
}
@@ -125,7 +125,7 @@
if (LIST_EMPTY(&aic->timedout_scbs) != 0
&& (aic->flags & AIC_SHUTDOWN_RECOVERY) == 0)
- tsleep(aic, PUSER, "idle", 0);
+ msleep(aic, &aic->platform_data->mtx, PUSER, "idle", 0);
if ((aic->flags & AIC_SHUTDOWN_RECOVERY) != 0)
break;
==== //depot/projects/scottl-camlock/src/sys/dev/aic7xxx/aic_osm_lib.h#5 (text+ko) ====
@@ -143,7 +143,7 @@
bus_dma_tag_create(parent_tag, alignment, boundary, \
lowaddr, highaddr, filter, filterarg, \
maxsize, nsegments, maxsegsz, flags, \
- busdma_lock_mutex, &Giant, \
+ busdma_lock_mutex, &aic->platform_data->mtx, \
dma_tagp)
#else
#define aic_dma_tag_create(aic, parent_tag, alignment, boundary, \
More information about the p4-projects
mailing list