PERFORCE change 96413 for review

Scott Long scottl at FreeBSD.org
Sun Apr 30 16:48:14 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=96413

Change 96413 by scottl at scottl-junior on 2006/04/30 16:47:26

	Revert the previous attempt at a CAM topology lock.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/cam.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_ccb.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_debug.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#8 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_queue.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_queue.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#20 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_periph.h#7 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_sim.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#8 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_dvcfg.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_iu.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_low.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_low.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_low_pisa.c#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_low_pisa.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_message.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pt.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pt.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ses.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ses.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_targ_bh.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_target.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_targetio.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi.h#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_cnfg.h#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_fc.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_inb.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_init.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_ioc.h#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_lan.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_log_fc.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_log_sas.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_raid.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_sas.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_targ.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_tool.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpilib/mpi_type.h#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt.h#8 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_cam.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_cam.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_debug.c#8 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_pci.c#8 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_raid.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_raid.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/mpt/mpt_reg.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/FILES#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/dsbr100io.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ehci.c#9 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ehci_pci.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ehcireg.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ehcivar.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/hid.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/hid.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_aue.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_auereg.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_axe.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_axereg.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_cdce.c#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_cdcereg.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_cue.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_cuereg.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_kue.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_kuereg.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_rue.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_ruereg.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_udav.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_udavreg.h#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_ural.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_uralreg.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/if_uralvar.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/kue_fw.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ohci.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ohci_pci.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ohcireg.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ohcivar.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/rio500_usb.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/sl811hs.c#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/sl811hsreg.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/sl811hsvar.h#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/slhci_pccard.c#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ubsa.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ubser.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ubser.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ucom.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ucomvar.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ucycom.c#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/udbp.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/udbp.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ufm.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ufoma.c#2 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uftdi.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uftdireg.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ugen.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ugraphire_rdesc.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uhci.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uhci_pci.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uhcireg.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uhcivar.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uhid.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uhub.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ukbd.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ulpt.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/umass.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/umct.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/umodem.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/ums.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uplcom.c#7 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/urio.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_ethersubr.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_ethersubr.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_if.m#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_mem.c#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_mem.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_port.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_quirks.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_quirks.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usb_subr.c#8 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbcdc.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdevs#9 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdi.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdi.h#4 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdi_util.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdi_util.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbdivar.h#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/usbhid.h#3 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uscanner.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uvisor.c#6 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uvscom.c#5 integrate
.. //depot/projects/scottl-camlock/src/sys/dev/usb/uxb360gp_rdesc.h#2 integrate

Differences ...

==== //depot/projects/scottl-camlock/src/sys/cam/cam.c#4 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_ccb.h#5 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_debug.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#8 (text+ko) ====

@@ -121,6 +121,7 @@
 	lun_id_t	lun_id;
 	cam_status	status;
 	u_int		init_level;
+	int s;
 
 	init_level = 0;
 	/*
@@ -185,7 +186,7 @@
 	if (status != CAM_REQ_CMP)
 		goto failure;
 
-	mtx_lock(&cam_topo_lock);
+	s = splsoftcam();
 	cur_periph = TAILQ_FIRST(&(*p_drv)->units);
 	while (cur_periph != NULL
 	    && cur_periph->unit_number < periph->unit_number)
@@ -197,7 +198,8 @@
 		TAILQ_INSERT_TAIL(&(*p_drv)->units, periph, unit_links);
 		(*p_drv)->generation++;
 	}
-	mtx_unlock(&cam_topo_lock);
+
+	splx(s);
 
 	init_level++;
 
@@ -212,9 +214,9 @@
 		/* Initialized successfully */
 		break;
 	case 3:
-		mtx_lock(&cam_topo_lock);
+		s = splsoftcam();
 		TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
-		mtx_unlock(&cam_topo_lock);
+		splx(s);
 		xpt_remove_periph(periph);
 		/* FALLTHROUGH */
 	case 2:
@@ -242,20 +244,21 @@
 {
 	struct periph_driver **p_drv;
 	struct cam_periph *periph;
+	int s;
 
 	for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
 
 		if (name != NULL && (strcmp((*p_drv)->driver_name, name) != 0))
 			continue;
 
-		mtx_lock(&cam_topo_lock);
+		s = splsoftcam();
 		TAILQ_FOREACH(periph, &(*p_drv)->units, unit_links) {
 			if (xpt_path_comp(periph->path, path) == 0) {
-				mtx_unlock(&cam_topo_lock);
+				splx(s);
 				return(periph);
 			}
 		}
-		mtx_unlock(&cam_topo_lock);
+		splx(s);
 		if (name != NULL)
 			return(NULL);
 	}
@@ -265,14 +268,14 @@
 cam_status
 cam_periph_acquire(struct cam_periph *periph)
 {
+	int s;
 
 	if (periph == NULL)
 		return(CAM_REQ_CMP_ERR);
 
-	/* XXX atomic increment instead? */
-	mtx_lock(&cam_topo_lock);
+	s = splsoftcam();
 	periph->refcount++;
-	mtx_unlock(&cam_topo_lock);
+	splx(s);
 
 	return(CAM_REQ_CMP);
 }
@@ -280,17 +283,17 @@
 void
 cam_periph_release(struct cam_periph *periph)
 {
+	int s;
 
 	if (periph == NULL)
 		return;
 
-	/* camperiphfree() will release the mutex. */
-	mtx_lock(&cam_topo_lock);
+	s = splsoftcam();
 	if ((--periph->refcount == 0)
 	 && (periph->flags & CAM_PERIPH_INVALID)) {
 		camperiphfree(periph);
-	} else
-		mtx_unlock(&cam_topo_lock);
+	}
+	splx(s);
 
 }
 
@@ -308,10 +311,11 @@
 {
 	struct	cam_periph *periph;
 	char	*periph_name;
+	int	s;
 	int	i, val, dunit, r;
 	const char *dname, *strval;
 
-	mtx_lock(&cam_topo_lock);
+	s = splsoftcam();
 	periph_name = p_drv->driver_name;
 	for (;;newunit++) {
 
@@ -357,7 +361,7 @@
 		if (r != 0)
 			break;
 	}
-	mtx_unlock(&cam_topo_lock);
+	splx(s);
 	return (newunit);
 }
 
@@ -412,7 +416,9 @@
 void
 cam_periph_invalidate(struct cam_periph *periph)
 {
+	int s;
 
+	s = splsoftcam();
 	/*
 	 * We only call this routine the first time a peripheral is
 	 * invalidated.  The oninvalidate() routine is always called at
@@ -425,43 +431,36 @@
 	periph->flags |= CAM_PERIPH_INVALID;
 	periph->flags &= ~CAM_PERIPH_NEW_DEV_FOUND;
 
-	/* camperiphfree() will release the mutex. */
-	mtx_lock(&cam_topo_lock);
 	if (periph->refcount == 0)
 		camperiphfree(periph);
-	else if (periph->refcount < 0) {
-		mtx_unlock(&cam_topo_lock);
+	else if (periph->refcount < 0)
 		printf("cam_invalidate_periph: refcount < 0!!\n");
-	}
+	splx(s);
 }
 
-/*
- * The topology lock must be held on entry and will be released before return.
- */
 static void
 camperiphfree(struct cam_periph *periph)
 {
+	int s;
 	struct periph_driver **p_drv;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
-
 	for (p_drv = periph_drivers; *p_drv != NULL; p_drv++) {
-		if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0) {
-			TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
-			(*p_drv)->generation++;
+		if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
 			break;
-		}
 	}
-	mtx_unlock(&cam_topo_lock);
-
 	if (*p_drv == NULL) {
 		printf("camperiphfree: attempt to free non-existant periph\n");
 		return;
 	}
-
+	
 	if (periph->periph_dtor != NULL)
 		periph->periph_dtor(periph);
 	
+	s = splsoftcam();
+	TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
+	(*p_drv)->generation++;
+	splx(s);
+
 	xpt_remove_periph(periph);
 
 	if (periph->flags & CAM_PERIPH_NEW_DEV_FOUND) {

==== //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#5 (text+ko) ====

@@ -129,21 +129,6 @@
 	struct buf	*bp[CAM_PERIPH_MAXMAPS];
 };
 
-typedef enum {
-	WORK_EXECUTE_CCB,
-	WORK_XPT_SCHED,
-	WORK_PERIPH_SCHED
-} cam_periph_workflags;
-
-struct cam_periph_workitem {
-	TAILQ_ENTRY(cam_periph_workitem) work_link;
-	cam_periph_workflags		command;
-	void				*data1;
-	void				*data2;
-	void				(*cbfcnp)(void *);
-	void				*cbdata;
-};
-
 cam_status cam_periph_alloc(periph_ctor_t *periph_ctor,
 			    periph_oninv_t *periph_oninvalidate,
 			    periph_dtor_t *periph_dtor,

==== //depot/projects/scottl-camlock/src/sys/cam/cam_queue.c#4 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_queue.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_sim.c#4 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#20 (text+ko) ====

@@ -635,7 +635,6 @@
 typedef TAILQ_HEAD(cam_isrq, ccb_hdr) cam_isrq_t;
 static cam_isrq_t cam_bioq;
 static struct mtx cam_bioq_lock;
-struct mtx cam_topo_lock;
 
 /* "Pool" of inactive ccbs managed by xpt_alloc_ccb and xpt_free_ccb */
 static SLIST_HEAD(,ccb_hdr) ccb_freeq;
@@ -1419,7 +1418,6 @@
 	STAILQ_INIT(&highpowerq);
 
 	mtx_init(&cam_bioq_lock, "CAM BIOQ lock", NULL, MTX_DEF);
-	mtx_init(&cam_topo_lock, "XPT Topology lock", NULL, MTX_DEF);
 
 	/*
 	 * The xpt layer is, itself, the equivelent of a SIM.
@@ -1555,7 +1553,7 @@
 		s = splsoftcam();
 		camq_resize(&device->drvq, device->drvq.array_size - 1);
 
-		atomic_add_int(&device->generation, 1);
+		device->generation++;
 
 		SLIST_REMOVE(periph_head, periph, cam_periph, periph_links);
 
@@ -3348,6 +3346,7 @@
 	}
 	case XPT_DEV_MATCH:
 	{
+		int s;
 		dev_pos_type position_type;
 		struct ccb_dev_match *cdm;
 
@@ -3356,7 +3355,7 @@
 		/*
 		 * Prevent EDT changes while we traverse it.
 		 */
-		mtx_lock(&cam_topo_lock);
+		s = splcam();
 		/*
 		 * There are two ways of getting at information in the EDT.
 		 * The first way is via the primary EDT tree.  It starts
@@ -3404,7 +3403,7 @@
 			break;
 		}
 
-		mtx_unlock(&cam_topo_lock);
+		splx(s);
 
 		if (cdm->status == CAM_DEV_MATCH_ERROR)
 			start_ccb->ccb_h.status = CAM_REQ_CMP_ERR;
@@ -3467,7 +3466,6 @@
 			csa->ccb_h.path->device->refcount++;
 		}
 
-		mtx_lock(&cam_topo_lock);
 		if ((added & AC_FOUND_DEVICE) != 0) {
 			/*
 			 * Get this peripheral up to date with all
@@ -3482,7 +3480,6 @@
 			 */
 			xpt_for_all_busses(xptsetasyncbusfunc, cur_entry);
 		}
-		mtx_unlock(&cam_topo_lock);
 		splx(s);
 		start_ccb->ccb_h.status = CAM_REQ_CMP;
 		break;
@@ -4028,6 +4025,7 @@
 void
 xpt_merge_ccb(union ccb *master_ccb, union ccb *slave_ccb)
 {
+	GIANT_REQUIRED;
 
 	/*
 	 * Pull fields that are valid for peripheral drivers to set
@@ -4044,6 +4042,7 @@
 void
 xpt_setup_ccb(struct ccb_hdr *ccb_h, struct cam_path *path, u_int32_t priority)
 {
+	GIANT_REQUIRED;
 
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_setup_ccb\n"));
 	ccb_h->pinfo.priority = priority;
@@ -4055,7 +4054,7 @@
 		ccb_h->target_id = CAM_TARGET_WILDCARD;
 	if (path->device) {
 		ccb_h->target_lun = path->device->lun_id;
-		atomic_add_int(&ccb_h->pinfo.generation, 1);
+		ccb_h->pinfo.generation = ++path->device->ccbq.queue.generation;
 	} else {
 		ccb_h->target_lun = CAM_TARGET_WILDCARD;
 	}
@@ -4071,6 +4070,8 @@
 	struct	   cam_path *path;
 	cam_status status;
 
+	GIANT_REQUIRED;
+
 	path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_NOWAIT);
 
 	if (path == NULL) {
@@ -4087,33 +4088,6 @@
 }
 
 static cam_status
-xpt_clone_path(struct cam_path *old_path_ptr, struct cam_path **new_path_ptr)
-{
-	struct cam_path *path;
-
-	path = (struct cam_path *)malloc(sizeof(*path), M_CAMXPT, M_NOWAIT);
-
-	if (path == NULL)
-		return (CAM_RESRC_UNAVAIL);
-
-	mtx_lock(&cam_topo_lock);
-	path->periph = old_path_ptr->periph;
-	path->bus = old_path_ptr->bus;
-	path->target = old_path_ptr->target;
-	path->device = old_path_ptr->device;
-	if (path->bus != NULL)
-		path->bus->refcount++;
-	if (path->target != NULL)
-		path->target->refcount++;
-	if (path->device != NULL)
-		path->device->refcount++;
-	mtx_unlock(&cam_topo_lock);
-
-	*new_path_ptr = path;
-	return (CAM_REQ_CMP);
-}
-
-static cam_status
 xpt_compile_path(struct cam_path *new_path, struct cam_periph *perph,
 		 path_id_t path_id, target_id_t target_id, lun_id_t lun_id)
 {
@@ -4121,6 +4095,7 @@
 	struct	     cam_et *target;
 	struct	     cam_ed *device;
 	cam_status   status;
+	int	     s;
 
 	status = CAM_REQ_CMP;	/* Completed without error */
 	target = NULL;		/* Wildcarded */
@@ -4130,7 +4105,7 @@
 	 * We will potentially modify the EDT, so block interrupts
 	 * that may attempt to create cam paths.
 	 */
-	mtx_lock(&cam_topo_lock);
+	s = splcam();
 	bus = xpt_find_bus(path_id);
 	if (bus == NULL) {
 		status = CAM_PATH_INVALID;
@@ -4164,7 +4139,7 @@
 			}
 		}
 	}
-	mtx_unlock(&cam_topo_lock);
+	splx(s);
 
 	/*
 	 * Only touch the user's data if we are successful.
@@ -4176,14 +4151,12 @@
 		new_path->device = device;
 		CAM_DEBUG(new_path, CAM_DEBUG_TRACE, ("xpt_compile_path\n"));
 	} else {
-		mtx_lock(&cam_topo_lock);
 		if (device != NULL)
 			xpt_release_device(bus, target, device);
 		if (target != NULL)
 			xpt_release_target(bus, target);
 		if (bus != NULL)
 			xpt_release_bus(bus);
-		mtx_unlock(&cam_topo_lock);
 	}
 	return (status);
 }
@@ -4192,8 +4165,6 @@
 xpt_release_path(struct cam_path *path)
 {
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_release_path\n"));
-
-	mtx_lock(&cam_topo_lock);
 	if (path->device != NULL) {
 		xpt_release_device(path->bus, path->target, path->device);
 		path->device = NULL;
@@ -4206,12 +4177,12 @@
 		xpt_release_bus(path->bus);
 		path->bus = NULL;
 	}
-	mtx_unlock(&cam_topo_lock);
 }
 
 void
 xpt_free_path(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_free_path\n"));
 	xpt_release_path(path);
@@ -4226,6 +4197,7 @@
 int
 xpt_path_comp(struct cam_path *path1, struct cam_path *path2)
 {
+	GIANT_REQUIRED;
 
 	int retval = 0;
 
@@ -4261,6 +4233,7 @@
 void
 xpt_print_path(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	if (path == NULL)
 		printf("(nopath): ");
@@ -4295,6 +4268,8 @@
 {
 	struct sbuf sb;
 
+	GIANT_REQUIRED;
+
 	sbuf_new(&sb, str, str_len, 0);
 
 	if (path == NULL)
@@ -4331,6 +4306,7 @@
 path_id_t
 xpt_path_path_id(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	return(path->bus->path_id);
 }
@@ -4338,6 +4314,7 @@
 target_id_t
 xpt_path_target_id(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	if (path->target != NULL)
 		return (path->target->target_id);
@@ -4348,6 +4325,7 @@
 lun_id_t
 xpt_path_lun_id(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	if (path->device != NULL)
 		return (path->device->lun_id);
@@ -4358,6 +4336,7 @@
 struct cam_sim *
 xpt_path_sim(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	return (path->bus->sim);
 }
@@ -4365,6 +4344,7 @@
 struct cam_periph*
 xpt_path_periph(struct cam_path *path)
 {
+	GIANT_REQUIRED;
 
 	return (path->periph);
 }
@@ -4541,9 +4521,7 @@
 	}
 
 	/* Release the reference count held while registered. */
-	mtx_lock(&cam_topo_lock);
 	xpt_release_bus(bus_path.bus);
-	mtx_unlock(&cam_topo_lock);
 	xpt_release_path(&bus_path);
 
 	/* Recheck for more completed CCBs. */
@@ -4627,9 +4605,8 @@
 }
 
 void
-xpt_async(u_int32_t async_code, struct cam_path *opath, void *async_arg)
+xpt_async(u_int32_t async_code, struct cam_path *path, void *async_arg)
 {
-	struct cam_path *path;
 	struct cam_eb *bus;
 	struct cam_et *target, *next_target;
 	struct cam_ed *device, *next_device;
@@ -4640,13 +4617,6 @@
 	CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_async\n"));
 
 	/*
-	 * The caller owns the path object that was passed in.  Clone
-	 * it so that we don't risk having it disappear on us.
-	 */
-	if (xpt_clone_path(opath, &path) != CAM_REQ_CMP)
-		return;
-
-	/*
 	 * Most async events come from a CAM interrupt context.  In
 	 * a few cases, the error recovery code at the peripheral layer,
 	 * which may run from our SWI or a process context, may signal
@@ -4713,7 +4683,6 @@
 		xpt_async_bcast(&xpt_periph->path->device->asyncs, async_code,
 				path, async_arg);
 	splx(s);
-	xpt_free_path(path);
 }
 
 static void
@@ -4945,7 +4914,6 @@
 					  sim->c_handle);
 				sim->flags &= ~CAM_SIM_REL_TIMEOUT_PENDING;
 			}
-			mtx_lock(&cam_topo_lock);
 			bus = xpt_find_bus(sim->path_id);
 			splx(s);
 
@@ -4953,12 +4921,9 @@
 				/*
 				 * Now that we are unfrozen run the send queue.
 				 */
-				mtx_unlock(&cam_topo_lock);
 				xpt_run_dev_sendq(bus);
-				mtx_lock(&cam_topo_lock);
 			}
 			xpt_release_bus(bus);
-			mtx_unlock(&cam_topo_lock);
 		} else
 			splx(s);
 	} else
@@ -5009,6 +4974,8 @@
 {
 	union ccb *new_ccb;
 
+	GIANT_REQUIRED;
+
 	new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_WAITOK);
 	return (new_ccb);
 }
@@ -5018,6 +4985,8 @@
 {
 	union ccb *new_ccb;
 
+	GIANT_REQUIRED;
+
 	new_ccb = malloc(sizeof(*new_ccb), M_CAMXPT, M_NOWAIT);
 	return (new_ccb);
 }
@@ -5066,14 +5035,17 @@
 static void
 xpt_release_bus(struct cam_eb *bus)
 {
+	int s;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
+	s = splcam();
 	if ((--bus->refcount == 0)
 	 && (TAILQ_FIRST(&bus->et_entries) == NULL)) {
 		TAILQ_REMOVE(&xpt_busses, bus, links);
 		bus_generation++;
+		splx(s);
 		free(bus, M_CAMXPT);
-	}
+	} else
+		splx(s);
 }
 
 static struct cam_et *
@@ -5081,7 +5053,6 @@
 {
 	struct cam_et *target;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
 	target = (struct cam_et *)malloc(sizeof(*target), M_CAMXPT, M_NOWAIT);
 	if (target != NULL) {
 		struct cam_et *cur_target;
@@ -5116,15 +5087,18 @@
 static void
 xpt_release_target(struct cam_eb *bus, struct cam_et *target)
 {
+	int s;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
+	s = splcam();
 	if ((--target->refcount == 0)
 	 && (TAILQ_FIRST(&target->ed_entries) == NULL)) {
 		TAILQ_REMOVE(&bus->et_entries, target, links);
 		bus->generation++;
+		splx(s);
 		free(target, M_CAMXPT);
 		xpt_release_bus(bus);
-	}
+	} else
+		splx(s);
 }
 
 static struct cam_ed *
@@ -5137,7 +5111,6 @@
 	struct	   cam_devq *devq;
 	cam_status status;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
 	if (SIM_DEAD(bus->sim))
 		return (NULL);
 
@@ -5233,8 +5206,9 @@
 xpt_release_device(struct cam_eb *bus, struct cam_et *target,
 		   struct cam_ed *device)
 {
+	int s;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
+	s = splcam();
 	if ((--device->refcount == 0)
 	 && ((device->flags & CAM_DEV_UNCONFIGURED) != 0)) {
 		struct cam_devq *devq;
@@ -5255,11 +5229,13 @@
 			devq = bus->sim->devq;
 			cam_devq_resize(devq, devq->alloc_queue.array_size - 1);
 		}
+		splx(s);
 		camq_fini(&device->drvq);
 		camq_fini(&device->ccbq.queue);
 		free(device, M_CAMXPT);
 		xpt_release_target(bus, target);
-	}
+	} else
+		splx(s);
 }
 
 static u_int32_t
@@ -5292,7 +5268,6 @@
 {
 	struct cam_eb *bus;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
 	for (bus = TAILQ_FIRST(&xpt_busses);
 	     bus != NULL;
 	     bus = TAILQ_NEXT(bus, links)) {
@@ -5309,7 +5284,6 @@
 {
 	struct cam_et *target;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
 	for (target = TAILQ_FIRST(&bus->et_entries);
 	     target != NULL;
 	     target = TAILQ_NEXT(target, links)) {
@@ -5326,7 +5300,6 @@
 {
 	struct cam_ed *device;
 
-	mtx_assert(&cam_topo_lock, MA_OWNED);
 	for (device = TAILQ_FIRST(&target->ed_entries);
 	     device != NULL;
 	     device = TAILQ_NEXT(device, links)) {
@@ -7016,12 +6989,10 @@
 	/*
 	 * Scan all installed busses.
 	 */
-	mtx_lock(&cam_topo_lock);
 	xpt_for_all_busses(xptconfigbuscountfunc, NULL);
 
 	if (busses_to_config == 0) {
 		/* Call manually because we don't have any busses */
-		mtx_unlock(&cam_topo_lock);
 		xpt_finishconfig(xpt_periph, NULL);
 	} else  {
 		if (busses_to_reset > 0 && scsi_delay >= 2000) {
@@ -7029,7 +7000,6 @@
 			       "devices to settle\n", scsi_delay/1000);
 		}
 		xpt_for_all_busses(xptconfigfunc, NULL);
-		mtx_unlock(&cam_topo_lock);
 	}
 }
 
@@ -7095,9 +7065,7 @@
 		 * attached.  For any devices like that, announce the
 		 * passthrough driver so the user will see something.
 		 */
-		mtx_lock(&cam_topo_lock);
 		xpt_for_all_devices(xptpassannouncefunc, NULL);
-		mtx_unlock(&cam_topo_lock);
 
 		/* Release our hook so that the boot can continue. */
 		config_intrhook_disestablish(xpt_config_hook);

==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_periph.h#7 (text+ko) ====

@@ -37,9 +37,6 @@
 
 /* Functions accessed by the peripheral drivers */
 #ifdef _KERNEL
-
-extern struct mtx cam_topo_lock;
-
 void		xpt_polled_action(union ccb *ccb);
 union ccb	*xpt_alloc_ccb(void);
 union ccb	*xpt_alloc_ccb_nowait(void);

==== //depot/projects/scottl-camlock/src/sys/cam/cam_xpt_sim.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.c#4 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_all.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.c#6 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_cd.h#2 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.c#5 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_ch.h#3 (text+ko) ====


==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#8 (text+ko) ====

@@ -44,9 +44,6 @@
 #include <sys/eventhandler.h>
 #include <sys/malloc.h>
 #include <sys/cons.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/kthread.h>
 
 #include <machine/md_var.h>
 
@@ -516,13 +513,6 @@
 
 static SLIST_HEAD(,da_softc) softc_list;
 
-static struct proc *da_proc;
-static struct mtx da_workmtx;
-static int da_workflags;
-static TAILQ_HEAD(, cam_periph_workitem) da_worklist;
-
-#define DA_FLAG_EXIT	0x1
-
 static int
 daopen(struct disk *dp)
 {
@@ -815,64 +805,13 @@
 }
 
 static void
-dawork(void *dummy)
-{
-	struct cam_periph_workitem *work;
-
-	mtx_lock(&da_workmtx);
-	while ((da_workflags & DA_FLAG_EXIT) == 0) {
-		if ((work = TAILQ_FIRST(&da_worklist)) == NULL) {
-			msleep(&da_worklist, &da_workmtx, PRIBIO, "dawork", 0);
-			continue;
-		}
-		TAILQ_REMOVE(&da_worklist, work, work_link);
-		mtx_unlock(&da_workmtx);
-
-		switch(work->command) {
-		case WORK_EXECUTE_CCB:
-			mtx_lock(&Giant);
-			xpt_action((union ccb *)work->data1);
-			mtx_unlock(&Giant);
-			break;
-		case WORK_XPT_SCHED:
-			mtx_lock(&Giant);
-			xpt_schedule((struct cam_periph *)work->data1,
-				     (uint32_t)(uintptr_t)(work->data2));
-			mtx_unlock(&Giant);
-			break;
-#if 0
-		case WORK_PERIPH_SCHED:
-			mtx_lock(&Giant);
-			daschedule((struct cam_periph *)work-data1);
-			mtx_unlock(&Giant);
-			break;
-#endif
-		default:
-			panic("Unknown CAM work item %d\n", work->command);
-		}
-
-		if (work->cbfcnp != NULL)
-			work->cbfcnp(work->cbdata);
-		mtx_unlock(&da_workmtx);
-	}
-	mtx_unlock(&da_workmtx);
-
-	kthread_exit(0);
-}
-
-static void

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list