NetBSD/sys/dev/scsipi
scottr f2c6836685 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 the structure 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 hardware driver's scsi_cmd function
  returns SUCCESSFULLY_QUEUED, set a new flag (SCSI_ASYNCREQ) in xs->flags.
  Since the request will be handled asynchronously, we will need the
  scsipi_xfer struct to be freed in scsipi_done().

  If the hardware 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.)

- 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:21 +00:00
..
atapi_all.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
atapi_base.c Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
atapi_cd.h Those tabs sure are excitable!! 1998-07-13 16:50:56 +00:00
atapi_disk.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
atapiconf.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
atapiconf.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
cd_atapi.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
cd_scsi.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
cd.c Assign my copyrights to TNF. 1998-08-17 00:49:01 +00:00
cdvar.h Improve generation of default disklabels: 1998-08-05 16:29:04 +00:00
ch.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
files.scsipi opt_scsiverbose.h now is opt_scsi.h and contains the defopted 1998-07-30 00:49:19 +00:00
if_se.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
Makefile Rework the way kernel include files are installed. In the new method, 1998-06-12 23:22:30 +00:00
scsi_all.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsi_base.c Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
scsi_cd.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsi_changer.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsi_ctron_ether.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsi_disk.h Define the SYNCHRONIZE CACHE command. 1998-06-09 19:03:24 +00:00
scsi_message.h RCSID Police. 1998-01-05 07:31:05 +00:00
scsi_scanner.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsi_tape.h Assign my copyrights to TNF. 1998-08-17 00:49:01 +00:00
scsi_verbose.c Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
scsiconf.c Reflect changes in quirk flags, and also now add case post retrieval 1998-09-08 07:34:02 +00:00
scsiconf.h Assign my copyrights to TNF. 1998-08-17 00:49:01 +00:00
scsipi_all.h Clarify that Sense Key 1 is a "RECOVERED ERROR"- not just an error. 1998-07-11 00:52:09 +00:00
scsipi_base.c Fix a problem uncovered when we started to use the pool allocator to manage 1998-09-14 05:49:20 +00:00
scsipi_base.h Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
scsipi_cd.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsipi_debug.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsipi_disk.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
scsipi_ioctl.c Assign my copyrights to TNF. 1998-08-17 00:49:01 +00:00
scsipi_verbose.c Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
scsipiconf.c Assign my copyrights to TNF. 1998-08-17 00:49:01 +00:00
scsipiconf.h Fix a problem uncovered when we started to use the pool allocator to manage 1998-09-14 05:49:21 +00:00
sd_atapi.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
sd_scsi.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
sd.c Only mark the disk dirty if we write. 1998-08-17 19:30:38 +00:00
sdvar.h Assign my copyrights to TNF. 1998-08-17 00:49:01 +00:00
ss_mustek.c Implement two macros, scsipi_command() and scsipi_command_direct(), and 1997-10-18 19:50:51 +00:00
ss_mustek.h Backout previous change, and rather, remove all protection but the one 1998-02-13 08:28:16 +00:00
ss_scanjet.c Set a flag during auto-configuration, so SCSI_AUTOCONF can be passed 1998-04-22 19:44:18 +00:00
ss.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00
ssvar.h Set a flag during auto-configuration, so SCSI_AUTOCONF can be passed 1998-04-22 19:44:18 +00:00
st.c keren/6128: add an entry for the TDC 4200. Full density code set isn't known. 1998-09-11 20:10:15 +00:00
su.c Merge scsipi branch in the mainline. This add support for ATAPI devices 1997-08-27 11:22:52 +00:00
uk.c kill the last remnants of __BROKEN_INDIRECT_CONFIG. (only the pica port 1998-08-31 22:28:04 +00:00