PERFORCE change 50842 for review

Scott Long scottl at FreeBSD.org
Sun Apr 11 08:34:03 PDT 2004


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

Change 50842 by scottl at scottl-junior-camlock on 2004/04/11 08:33:51

	Instead of calling xpt_schedule() in each stage of probedone(),
	call probeschedule1() to queue a WORK_XPT_SCHED workitem.  This
	will result in probestart() being called from the desired context,
	and removes the need to do an xpt action workitem from there.
	It's unclear whether probeschedule() and probeschedule1() should
	be combined, or whether the whole workitem framework should be
	moved into xpt_schedule.

Affected files ...

.. //depot/projects/scottl-camlock/src/sys/cam/cam_probe.c#5 edit

Differences ...

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

@@ -82,12 +82,14 @@
 
 typedef enum {
 	WORK_EXECUTE_CCB = 0x1,
+	WORK_XPT_SCHED = 0x2,
 } cam_workflags;
 
 struct cam_workitem {
 	TAILQ_ENTRY(cam_workitem)	work_links;
 	cam_workflags			command;
-	void				*data;
+	void				*data1;
+	uintptr_t			data2;
 	void				(*cbfcnp)(void *);
 };
 
@@ -133,6 +135,19 @@
 }
 
 static void
+probeschedule1(struct cam_periph *periph, uint32_t priority)
+{
+	probe_softc *softc;
+
+	softc = (probe_softc *)periph->softc;
+	softc->work->command = WORK_XPT_SCHED;
+	softc->work->data1 = periph;
+	softc->work->data2 = (uintptr_t)priority;
+	softc->work->cbfcnp = NULL;
+	probe_queue_work(softc->work);
+}
+
+static void
 probe_work(void *dummy)
 {
 	struct cam_workitem *work;
@@ -150,7 +165,13 @@
 		switch (work->command) {
 		case WORK_EXECUTE_CCB:
 			mtx_lock(&Giant);
-			xpt_action((union ccb *)work->data);
+			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)(work->data2));
 			mtx_unlock(&Giant);
 			break;
 		default:
@@ -158,7 +179,7 @@
 		}
 
 		if (work->cbfcnp != NULL)
-			work->cbfcnp(work->data);
+			work->cbfcnp(work->data1);
 
 		mtx_lock(&probe_workmtx);
 	}
@@ -418,10 +439,7 @@
 	}
 	}
 
-	softc->work->command = WORK_EXECUTE_CCB;
-	softc->work->data = start_ccb;
-	softc->work->cbfcnp = NULL;
-	probe_queue_work(softc->work);
+	xpt_action(start_ccb);
 }
 
 static void
@@ -476,7 +494,7 @@
 		}
 		softc->action = PROBE_INQUIRY;
 		xpt_release_ccb(done_ccb);
-		xpt_schedule(periph, priority);
+		probeschedule1(periph, priority);
 		return;
 	}
 	case PROBE_INQUIRY:
@@ -511,7 +529,7 @@
 				 && alen > (SHORT_INQUIRY_LENGTH - 4)) {
 					softc->action = PROBE_FULL_INQUIRY;
 					xpt_release_ccb(done_ccb);
-					xpt_schedule(periph, priority);
+					probeschedule1(periph, priority);
 					return;
 				}
 
@@ -528,7 +546,7 @@
 				path->device->flags &= ~CAM_DEV_UNCONFIGURED;
 
 				xpt_release_ccb(done_ccb);
-				xpt_schedule(periph, priority);
+				probeschedule1(periph, priority);
 				return;
 			}
 			default:
@@ -589,7 +607,7 @@
 		xpt_release_ccb(done_ccb);
 		free(mode_hdr, M_TEMP);
 		softc->action = PROBE_SERIAL_NUM;
-		xpt_schedule(periph, priority);
+		probeschedule1(periph, priority);
 		return;
 	}
 	case PROBE_SERIAL_NUM:
@@ -695,7 +713,7 @@
 			 * perform any necessary transfer negotiation.
 			 */
 			softc->action = PROBE_TUR_FOR_NEGOTIATION;
-			xpt_schedule(periph, priority);
+			probeschedule1(periph, priority);
 			return;
 		}
 		xpt_release_ccb(done_ccb);


More information about the p4-projects mailing list