Subject: change to scsipi_periph_timed_thaw
To: Manuel Bouyer <bouyer@antioche.eu.org>
From: Matthew Jacob <mjacob@feral.com>
List: tech-kern
Date: 09/16/2001 11:32:55
There was this SCSIPI_CHAN_CALLBACK defined- but it seems to me that because
this is a public i/f and can only be busy with one callback at a time, that it
was worth devoting an extra bit to having scsipi_periph_timed_thaw have the
completion thread do the queue running.

Here are the diffs- seems to work (ignore the 'printf' in the completion
thread- this is WIP).

-matt
Index: dev/scsipi/scsipi_base.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/scsipi/scsipi_base.c,v
retrieving revision 1.55
diff -u -r1.55 scsipi_base.c
--- dev/scsipi/scsipi_base.c	2001/09/01 00:54:38	1.55
+++ dev/scsipi/scsipi_base.c	2001/09/16 18:28:00
@@ -636,17 +636,20 @@
 scsipi_periph_timed_thaw(arg)
 	void *arg;
 {
+	int s;
 	struct scsipi_periph *periph = arg;

 	callout_stop(&periph->periph_callout);
+
+	s = splbio();
 	scsipi_periph_thaw(periph, 1);

 	/*
-	 * Kick the channel's queue here.  Note, we're running in
-	 * interrupt context (softclock), so the adapter driver
-	 * had better not sleep.
+	 * Tell the completion thread to kick the channel's queue here.
 	 */
-	scsipi_run_queue(periph->periph_channel);
+	periph->periph_channel->chan_flags |= SCSIPI_CHAN_KICK;
+	wakeup(&periph->periph_channel->chan_complete);
+	splx(s);
 }

 /*
@@ -1947,16 +1950,25 @@
 		xs = TAILQ_FIRST(&chan->chan_complete);
 		if (xs == NULL &&
 		    (chan->chan_flags &
-		     (SCSIPI_CHAN_SHUTDOWN | SCSIPI_CHAN_CALLBACK)) == 0) {
+		     (SCSIPI_CHAN_SHUTDOWN | SCSIPI_CHAN_CALLBACK |
+		     SCSIPI_CHAN_KICK)) == 0) {
 			(void) tsleep(&chan->chan_complete, PRIBIO,
 			    "sccomp", 0);
 			splx(s);
 			continue;
 		}
+printf("*");
 		if (chan->chan_flags & SCSIPI_CHAN_CALLBACK) {
 			/* call chan_callback from thread context */
 			chan->chan_flags &= ~SCSIPI_CHAN_CALLBACK;
 			chan->chan_callback(chan, chan->chan_callback_arg);
+			splx(s);
+			continue;
+		}
+		if (chan->chan_flags & SCSIPI_CHAN_KICK) {
+			/* explicitly run the queues for this channel */
+			chan->chan_flags &= ~SCSIPI_CHAN_KICK;
+			scsipi_run_queue(chan);
 			splx(s);
 			continue;
 		}
Index: dev/scsipi/scsipiconf.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/scsipi/scsipiconf.h,v
retrieving revision 1.57
diff -u -r1.57 scsipiconf.h
--- dev/scsipi/scsipiconf.h	2001/09/02 13:11:53	1.57
+++ dev/scsipi/scsipiconf.h	2001/09/16 18:28:00
@@ -305,6 +305,7 @@
 #define	SCSIPI_CHAN_CANGROW	0x04	/* channel can grow resources */
 #define	SCSIPI_CHAN_NOSETTLE	0x08	/* don't wait for devices to settle */
 #define	SCSIPI_CHAN_CALLBACK	0x10	/* has to call chan_callback() */
+#define	SCSIPI_CHAN_KICK	0x20	/* need to run queues */

 #define	SCSIPI_CHAN_MAX_PERIPH(chan)					\
 	(((chan)->chan_flags & SCSIPI_CHAN_OPENINGS) ?			\