PERFORCE change 99050 for review

Scott Long scottl at FreeBSD.org
Mon Jun 12 14:00:58 UTC 2006


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

Change 99050 by scottl at scottl-x64 on 2006/06/12 13:58:16

	Checkpoint sim lock handling in the da periph and camisr.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.c#10 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_periph.h#7 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_sim.h#7 edit
.. //depot/projects/scottl-camlock/src/sys/cam/cam_xpt.c#35 edit
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_da.c#10 edit

Differences ...

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

@@ -114,6 +114,7 @@
 		 ac_callback_t *ac_callback, ac_code code, void *arg)
 {
 	struct		periph_driver **p_drv;
+	struct		cam_sim *sim;
 	struct		cam_periph *periph;
 	struct		cam_periph *cur_periph;
 	path_id_t	path_id;
@@ -159,7 +160,8 @@
 		if (strcmp((*p_drv)->driver_name, name) == 0)
 			break;
 	}
-	
+
+	sim = xpt_path_sim(path);
 	path_id = xpt_path_path_id(path);
 	target_id = xpt_path_target_id(path);
 	lun_id = xpt_path_lun_id(path);
@@ -173,6 +175,7 @@
 	periph->unit_number = camperiphunit(*p_drv, path_id, target_id, lun_id);
 	periph->immediate_priority = CAM_PRIORITY_NONE;
 	periph->refcount = 0;
+	periph->sim = sim;
 	SLIST_INIT(&periph->ccb_list);
 	status = xpt_create_path(&path, periph, path_id, target_id, lun_id);
 	if (status != CAM_REQ_CMP)

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

@@ -104,6 +104,7 @@
 	char			*periph_name;
 	struct cam_path		*path;	/* Compiled path to device */
 	void			*softc;
+	struct cam_sim		*sim;
 	u_int32_t		 unit_number;
 	cam_periph_type		 type;
 	u_int32_t		 flags;

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

@@ -116,6 +116,9 @@
 
 };
 
+#define CAM_SIM_LOCK(sim)	mtx_lock((sim)->mtx);
+#define CAM_SIM_UNLOCK(sim)	mtx_unlock((sim)->mtx);
+
 static __inline u_int32_t
 cam_sim_path(struct cam_sim *sim)
 {

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

@@ -83,9 +83,6 @@
 SLIST_HEAD(async_list, async_node);
 SLIST_HEAD(periph_list, cam_periph);
 
-#define CAM_SIM_LOCK(sim)	mtx_lock((sim)->mtx);
-#define CAM_SIM_UNLOCK(sim)	mtx_unlock((sim)->mtx);
-
 /*
  * This is the maximum number of high powered commands (e.g. start unit)
  * that can be outstanding at a particular time.
@@ -1460,7 +1457,7 @@
 	}
 
 	/* Install our software interrupt handlers */
-	swi_add(NULL, "cambio", camisr, &cam_bioq, SWI_CAMBIO, 0, &cambio_ih);
+	swi_add(NULL, "cambio", camisr, &cam_bioq, SWI_CAMBIO, INTR_MPSAFE, &cambio_ih);
 }
 
 static cam_status
@@ -7201,6 +7198,7 @@
 		int	runq;
 
 		TAILQ_REMOVE(&queue, ccb_h, sim_links.tqe);
+		mtx_lock(ccb_h->path->bus->sim->mtx);
 		ccb_h->pinfo.index = CAM_UNQUEUED_INDEX;
 		splx(s);
 
@@ -7290,6 +7288,7 @@
 		(*ccb_h->cbfcnp)(ccb_h->path->periph, (union ccb *)ccb_h);
 
 		/* Raise IPL for while test */
+		mtx_unlock(ccb_h->path->bus->sim->mtx);
 		s = splcam();
 	}
 	splx(s);

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

@@ -37,6 +37,8 @@
 #include <sys/bio.h>
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
 #endif /* _KERNEL */
 
 #include <sys/devicestat.h>
@@ -61,6 +63,7 @@
 #include <cam/cam_ccb.h>
 #include <cam/cam_periph.h>
 #include <cam/cam_xpt_periph.h>
+#include <cam/cam_sim.h>
 
 #include <cam/scsi/scsi_message.h>
 
@@ -528,6 +531,8 @@
 		splx(s);
 		return (ENXIO);	
 	}
+	mtx_lock(periph->sim->mtx);
+
 	unit = periph->unit_number;
 
 	softc = (struct da_softc *)periph->softc;
@@ -539,8 +544,10 @@
 	if ((error = cam_periph_lock(periph, PRIBIO|PCATCH)) != 0)
 		return (error); /* error code from tsleep */
 
-	if (cam_periph_acquire(periph) != CAM_REQ_CMP)
+	if (cam_periph_acquire(periph) != CAM_REQ_CMP) {
+		mtx_unlock(periph->sim->mtx);
 		return(ENXIO);
+	}
 	softc->flags |= DA_FLAG_OPEN;
 
 	if ((softc->flags & DA_FLAG_PACK_INVALID) != 0) {
@@ -571,6 +578,7 @@
 		cam_periph_release(periph);
 	}
 	cam_periph_unlock(periph);
+	mtx_unlock(periph->sim->mtx);
 	return (error);
 }
 
@@ -585,9 +593,11 @@
 	if (periph == NULL)
 		return (ENXIO);	
 
+	mtx_lock(periph->sim->mtx);
 	softc = (struct da_softc *)periph->softc;
 
 	if ((error = cam_periph_lock(periph, PRIBIO)) != 0) {
+		mtx_unlock(periph->sim->mtx);
 		return (error); /* error code from tsleep */
 	}
 
@@ -655,6 +665,7 @@
 	softc->flags &= ~DA_FLAG_OPEN;
 	cam_periph_unlock(periph);
 	cam_periph_release(periph);
+	mtx_unlock(periph->sim->mtx);
 	return (0);	
 }
 
@@ -676,6 +687,9 @@
 		return;
 	}
 	softc = (struct da_softc *)periph->softc;
+
+	mtx_lock(periph->sim->mtx);
+
 #if 0
 	/*
 	 * check it's not too big a transfer for our adapter
@@ -695,6 +709,7 @@
 	 */
 	if ((softc->flags & DA_FLAG_PACK_INVALID)) {
 		splx(s);
+		mtx_unlock(periph->sim->mtx);
 		biofinish(bp, NULL, ENXIO);
 		return;
 	}
@@ -710,6 +725,7 @@
 	 * Schedule ourselves for performing the work.
 	 */
 	xpt_schedule(periph, /* XXX priority */1);
+	mtx_unlock(periph->sim->mtx);
 
 	return;
 }
@@ -1164,7 +1180,7 @@
 	softc->disk->d_drv1 = periph;
 	softc->disk->d_maxsize = DFLTPHYS; /* XXX: probably not arbitrary */
 	softc->disk->d_unit = periph->unit_number;
-	softc->disk->d_flags = DISKFLAG_NEEDSGIANT;
+	softc->disk->d_flags = 0;
 	disk_create(softc->disk, DISK_VERSION);
 
 	/*


More information about the p4-projects mailing list