Subject: Need to force SCSI_POLL when cold
To: None <tech-kern@NetBSD.ORG>
From: Gordon W. Ross <gwr@mc.com>
List: tech-kern
Date: 03/24/1997 16:30:40
I'm somewhat dissatisfied with the need for every SCSI driver to
force SCSI_POLL when cold, as in the change shown here:

*** ncr53c9x.c.~1~	Mon Mar 17 12:12:53 1997
--- ncr53c9x.c	Mon Mar 24 12:13:26 1997
***************
*** 517,522 ****
--- 518,531 ----
  	    sc_link->target));
  
  	flags = xs->flags;
+ 	/*
+ 	 * XXX: Hack: During autoconfig, force polling mode.
+ 	 * Needed as long as sdsize() can be called while cold,
+ 	 * otherwise timeouts will never call back (grumble).
+ 	 */
+ 	if (cold)
+ 		flags |= SCSI_POLL;
+ 
  	if ((ecb = ncr53c9x_get_ecb(sc, flags)) == NULL) {
  		xs->error = XS_DRIVER_STUFFUP;
  		return TRY_AGAIN_LATER;

Without this, swapconf() ends up calling tsleep, with no way to
ever make progress because interrupts are not yet enabled.

Here is an idea for improving this situation:

With a slight change to kern/init_main.c we could arrange to do
the setroot, swapconf, dumpconf work AFTER procinit and such is
done (and cpu_initclocks) so that tsleep and timeouts work the
normal way.  I think this might work if we just moved the code
for setroot/swapconf/dumpconf into a new function (cpu_start2?)
that is called just before the vfs_mountroot stuff.

My hope is that things like the SCSI drivers would then be called
in only two system conditions: (1) autoconfig, (2) fully-running
so we would no longer need the "force SCSI_POLL" hack above.

Do you think this idea is worth pursuing?

Gordon