NetBSD/sys/dev
scottr 10640f1bfc Fix a problem uncovered when we started to use the pool allocator to manage
scsipi_xfer structures.

When scsipi_execute_xs() calls the driver's scsi_cmd function, it assumes
that it can still dereference a pointer to the scsipi_xfer struct.  Since
scsipi_done() has already been called, which in turn has called
scsipi_free_xs(), the struct has already been returned to the pool!  In
other words, xs->flags has been compromised, but we are still testing it.

These changes resolve the problem by doing the following:

- In scsipi_execute_xs(), if the lower-level driver's scsi_cmd function
  returns SUCCESSFULLY_QUEUED and SCSI_NOSLEEP is set in xs->flags, set a
  new flag (SCSI_ASYNCREQ).  This indicates that scsipi_done() should free
  the scsipi_xfer struct.

  If the lower-level driver's scsi_cmd function returns SUCCESSFULLY_QUEUED
  but SCSI_NOSLEEP is not set, we wait (via tsleep()) for the request to
  complete, then fall through to the COMPLETE case.

  If the lower-level driver's scsi_cmd function returns COMPLETE, we now
  simply return any actual errors, or 0 if none occurred.  (Previously,
  we may have returned EJUSTRETURN, of which the sole effect was to
  avoid freeing the scsipi_xfer struct in our caller.  No code seems
  to depend on this behavior, however.)

- In scsipi_done(), only free the scsipi_xfer struct for async requests.
  The contents of the struct will otherwise remain valid until the
  function that initiated the transfer frees it.

With this change, responsibility for freeing the struct now lies in two
places, depending on the type of the request:

- For synchronous requests, the routine calling scsipi_execute_xs()
  must clean up.

- For asynchronous requests, scsipi_done() cleans up (as it always has).

[Note:  this change also corrects a problem with sddump():  scsipi_done()
was attempting to return a static scsipi_xfer struct to the pool!  Since
dumps are performed synchronously, we now handle this correctly.]

This solution was provided by Jason Thorpe, after I got him to look at
some related (but insufficient) attempts of my own.
1998-09-14 05:49:20 +00:00
..
ata make the default disklabel consistent to the SCSI/ATAPI case 1998-09-07 21:28:22 +00:00
dec Kickoff xmit interrupts, needed on chip DC7201. 1998-08-10 14:41:16 +00:00
eisa Assign my copyrights to TNF. 1998-08-17 00:26:32 +00:00
i2c Rework the way kernel include files are installed. In the new method, 1998-06-12 23:22:30 +00:00
ic Make sure all voices are deallocated on close. 1998-09-13 04:41:34 +00:00
isa Add arc as a target platform. 1998-09-11 19:39:28 +00:00
isapnp Regen. 1998-09-12 21:49:51 +00:00
microcode Adjust copyright notice to reflect that Qlogic still owns this. 1998-09-08 07:13:11 +00:00
mii Assign copyright to TNF. 1998-09-05 14:42:05 +00:00
ofisa Add ofisa attachment for the ISA joystick driver. 1998-08-20 07:02:32 +00:00
ofw Add common OpenFirmware network interface functions. Currently supports 1998-07-22 22:04:14 +00:00
pci add more general probe to regular more operation stuff 1998-09-08 07:30:32 +00:00
pckbc Can't use pckbc_enqueue_cmd() in attach() because pckbc's initialization 1998-09-02 20:01:15 +00:00
pcmcia Regen 1998-09-10 19:57:20 +00:00
rcons Rework the way kernel include files are installed. In the new method, 1998-06-12 23:22:30 +00:00
sbus add bustype tag to softc 1998-09-08 07:36:26 +00:00
scsipi Fix a problem uncovered when we started to use the pool allocator to manage 1998-09-14 05:49:20 +00:00
sun make "struct sun_dkpart" the same for sparc/sparc64 (sparc64 must have been broken?) 1998-08-22 14:55:28 +00:00
tc Merge paddr_t changes into the main branch. 1998-08-13 02:10:37 +00:00
usb Regen. 1998-09-07 08:19:31 +00:00
vme make struct xd_iocmd's block member an u_int not a u_long 1998-08-22 15:11:02 +00:00
wscons -add italian layout, from Dante Profeta <dante@mclink.it> 1998-09-01 18:11:13 +00:00
Makefile Add `sbus' to SUBDIRS. 1998-07-28 00:36:31 +00:00
auconv.c Add trivial conversions between 8 and 16 bits. 1997-08-24 22:20:24 +00:00
auconv.h Fix tipo inherited from old version of TNF copyright template. 1997-10-09 07:37:50 +00:00
audio.c Move some debugging output to more useful levels. 1998-09-01 07:27:06 +00:00
audio_if.h * Redo the way the way the MIDI driver attaches to audio devices. 1998-08-17 21:16:09 +00:00
audiovar.h Avoid the name free so the MALLOCLOG option works again. 1998-03-03 09:16:15 +00:00
ccd.c Use the pool allocator for component buffer headers. 1998-07-31 01:23:56 +00:00
ccdvar.h Use the pool allocator for component buffer headers. 1998-07-31 01:23:56 +00:00
clock_subr.c Minor improvement to avoid re-defining days_in_month(). 1997-10-14 17:25:57 +00:00
clock_subr.h New ARP system, supports IPv4 over any hardware link. 1997-03-15 18:09:08 +00:00
cninit.c Keep cn_tab NULL until an appropriate console is found (avoids interrupt 1998-06-21 22:36:46 +00:00
cons.c
cons.h
md.c Make this file compile again by removing no longer used `struct 1998-09-01 06:13:33 +00:00
md.h
midi.c Make sure the buffers are synchronized on open. 1998-09-13 06:30:25 +00:00
midi_if.h Write MIDI data from the sequencer to the device in a more sane way. 1998-08-24 17:59:25 +00:00
midisyn.c Make sure all voices are deallocated on close. 1998-09-13 04:41:34 +00:00
midisynvar.h * Redo the way the way the MIDI driver attaches to audio devices. 1998-08-17 21:16:09 +00:00
midivar.h * Redo the way the way the MIDI driver attaches to audio devices. 1998-08-17 21:16:09 +00:00
mulaw.c But seriously... 1998-08-09 21:41:45 +00:00
mulaw.h Add mulaw_to_slinear16 and alaw_to_slinear16. 1998-08-09 19:22:15 +00:00
rnd.c Move RND_ENTROPY_THRESHOLD to sys/rnd.h. Use sha1 rather than md5, and 1998-05-27 00:59:14 +00:00
rndpool.c missed one constant '20' to RND_ENTROPY_THRESHOLD change 1998-05-27 01:29:13 +00:00
sequencer.c Write MIDI data from the sequencer to the device in a more sane way. 1998-08-24 17:59:25 +00:00
sequencervar.h Remove some leftover fluff. 1998-08-13 00:13:56 +00:00
vnd.c Use the pool allocator for vndxfer and vndbuf structures. 1998-07-31 02:24:26 +00:00
vndvar.h Use the pool allocator for vndxfer and vndbuf structures. 1998-07-31 02:24:26 +00:00