Commit Graph

54 Commits

Author SHA1 Message Date
mjacob 18e1071fce Add table value for Ultra3, so configuring an Ultra3 disk shows:
sd1: sync (12.5ns offset 14), 16-bit (160.000MB/s) transfers, tagged queueing enabled

instead of:

sd1: sync (36.0ns offset 14), 16-bit (55.554MB/s) transfers, tagged queueing enabled
2001-09-01 00:54:38 +00:00
ad ab54b70cae Cosmetic change. 2001-08-20 11:20:51 +00:00
ad 52449ef3bf Medium Not Present has number of defined ASCQs. Pointed out by Sergey
Svishchev <svs@ropnet.ru> in PR 8326.
2001-08-20 07:47:01 +00:00
yamt 75ed9ccf7f fix scsipi_target_detach with wildcard target. 2001-08-19 14:05:13 +00:00
bouyer f2cacede49 Adn scsipi_target_detach() and scsipi_thread_call_callback() as discussed
on tech-kern. scsipi_target_detach() accept wildcard target/lun as requested.
2001-07-18 20:19:24 +00:00
thorpej 03746a443a bzero -> memset 2001-07-18 18:21:04 +00:00
bouyer c399f05222 scsipi_set_xfer_mode(): issue a ADAPTER_REQ_SET_XFER_MODE request to adapter
only if we succesfully attached at last one device for this I_T.
2001-07-13 20:00:23 +00:00
ross f54fe9f3b1 compile tweak for non-SCSIVERBOSE 2001-06-27 23:14:26 +00:00
bouyer 4fadc33006 Better diagnostic when a REQUEST SENSE is terminated with CHECK CONDITION. 2001-06-27 13:21:30 +00:00
bouyer 90d0e67408 Add a XS_CTL_SILENT_NODEV flag: if the sense info is "not ready, medium
not present" don't print any message but still return ENODEV.
Use this in cd driver to allow open of character raw partition even if
the drive is empty (older drives fails at LOAD_UNLOAD time, newer
ones fail at TEST_UNIT_READY time).
2001-06-26 15:32:02 +00:00
bjh21 4bc5a3b295 Add explicit support for IDE and SCSI adaptors which don't support interrupts.
On such adaptors, all transfers are done in polling mode.

OK'ed by Manuel on tech-kern.
2001-06-13 18:17:38 +00:00
bouyer 72b4ba8aed In scsipi_channel_thaw(), if the count drops to 0, call scsipi_run_queue(). 2001-05-23 15:50:32 +00:00
enami e4334b830d Don't capitalize the word sync or async. It's inconsistient with other
messages.
2001-05-18 16:25:07 +00:00
bouyer 8b5bf22895 Workaround for broken drives (explained to me by Chris G. Demetriou):
some devices can't handle tag number larger than some values and always
reject commands with QUEUE FULL if the tag number is larger than this.
Under some circonstances the scsipi system may not decrease periph_openings
(as a workaround of other odd behavior) and we may end up requeuing the command
with a hight tag value again, and the driver could loop on this.
Workaround: in case of queue full, decrease periph_openings to
min(periph_active - 1, periph_openings - 1) so that, after some iteration,
periph_openings is less than the max tag value acceptable by the device.

Solves the problem with tagged queuing on ncr53c9x for me.
2001-05-18 12:56:28 +00:00
bouyer bc980d7eba Use SCSI/ATAPI common definition for MODE_{SELECT,SENSE}{,_BIG}. Define
functions to send theses commands in scsipi_base.c and use them instead
of ad-hoc commands setups.
2001-05-14 20:35:27 +00:00
bouyer 74b15b27a2 Don't forget to call psw_done() ! 2001-04-27 21:36:58 +00:00
bouyer 937a7a3ed9 Pull up the thorpej_scsipi branch to main branch.
This is a completely rewritten scsipi_xfer execution engine, and the
associated changes to HBA drivers. Overview of changes & features:
- All xfers are queued in the mid-layer, rather than doing so in an
  ad-hoc fashion in individual adapter drivers.
- Adapter/channel resource management in the mid-layer, avoids even trying
  to start running an xfer if the adapter/channel doesn't have the resources.
- Better communication between the mid-layer and the adapters.
- Asynchronous event notification mechanism from adapter to mid-layer and
  peripherals.
- Better peripheral queue management: freeze/thaw, sorted requeueing during
  recovery, etc.
- Clean separation of peripherals, adapters, and adapter channels (no more
  scsipi_link).
- Kernel thread for each scsipi_channel makes error recovery much easier
  (no more dealing with interrupt context when recovering from an error).
- Mid-layer support for tagged queueing: commands can have the tag type
  set explicitly, tag IDs are allocated in the mid-layer (thus eliminating
  the need to use buggy tag ID allocation schemes in many adapter drivers).
- support for QUEUE FULL and CHECK CONDITION status in mid-layer; the command
  will be requeued, or a REQUEST SENSE will be sent as appropriate.

Just before the merge syssrc has been tagged with thorpej_scsipi_beforemerge
2001-04-25 17:53:04 +00:00
enami 5a4b9fcbbf Prevent a process being swapped out during I/O if the data buffer is
allocated on stack.  This potential problem is noticed by Noriyuki Soda
and the idea and sample code to fix is given by Jason R. Thorpe.
2000-06-09 08:54:19 +00:00
fvdl c0f99cc74a Initialize xs_status to 0 after allocating a scsipi_xfer struct. Makes life
easier for driver debugging.
2000-05-31 11:14:25 +00:00
fvdl cb5289547f At least try to do something useful in the XS_BUSY case; don't cause
a panic by sleeping in an interrupt context.
2000-05-27 23:59:58 +00:00
bouyer 373582e298 scsipi_get_xs(): if we have XS_CTL_URGENT, return an xfer even if
active >= openings. An XS_CTL_URGENT command could otherwise fail, especially
if openings == 1.
2000-05-23 10:16:43 +00:00
enami c560e9a77b When killing pending xfers on device detach, we can't expect scsipi_done
to remove all xfers from the pending queue.  It removes only xfers for
asynchronous transactions.  So, simply loop over all pending xfers
with calling scsipi_done and wait xfers to drain.  Addresses PR#9703.
2000-04-03 03:37:33 +00:00
enami ae8fb348b3 Fold long line. 2000-04-03 01:40:51 +00:00
augustss 7246364f07 With SCSIVERBOSE, only print sense data if there actually is a problem. 2000-04-02 17:58:17 +00:00
enami 28d49dce4e Add missing protect from disk interrupt while calling scsipi_free_xs. 2000-04-02 03:05:55 +00:00
thorpej fc96443d15 New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
  resource allocation.
- Insertion and removal of callouts is constant time, important as
  this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
2000-03-23 07:01:25 +00:00
bouyer e51ae5d23a Use SCSIPIRETRIES instead of hard-coded value '2' for number of retries in
common routines. Define SCSIPIRETRIES as 4, so that the command will finally
succeed after several consecutive downgrades from UDMA2 to PIO4.
2000-01-17 17:59:48 +00:00
mjacob 4cb8fbf10d Print out the contents of an otherwise unreported undecodable
sense data buffer. This helps catch adapter breakage mostly.
2000-01-14 02:40:45 +00:00
enami a2369d8e97 Cancel active transfers on aic/wdc detach.
Also makes LS-120 drive works for me again.
1999-10-20 15:22:24 +00:00
enami de4b3a819a ENODEV is not a value supposed to be assigned to xs->error. Use
XS_DRIVER_STUFFUP instead.
1999-10-17 06:13:01 +00:00
mjacob 51a4d18f0f If we're discovering, don't tsleep on lbolt if we had a busy status. 1999-10-06 05:01:05 +00:00
thorpej 16a9d90e17 Cleanup the scsipi_xfer flags:
- `flags' is now gone, replaced with `xs_control' and `xs_status'.
- Massive cleanup of the control flags.  Now we explicitly say that
  a job is to complete asynchronously, rather than relying on side-effects,
  and use a new flag to now that device discovery is being performed.
- Do SCSI device discovery interrupt-driven.
1999-09-30 22:57:52 +00:00
thorpej e8dded5513 Implement a function to kill off all commands pending for a given
scsipi_link.
1999-09-11 21:39:53 +00:00
pk b6429ec3c5 In scsipi_done(), call scsipi_free_xs() at splbio(). 1999-06-16 07:35:31 +00:00
bouyer 29936d77d4 Now that we do real use of CDIOCCLOSE, we can have SSS_START|SSS_LOEJ
in scsipi_start(). Adjust test so that timeout will let enouth time to
the drive to spin up.
1999-04-07 12:47:27 +00:00
bouyer c0e7b6c5cb If sense_key == UNIT_ATTENTION and ASC/ASQ == "Power On, Reset, or Bus Device
Reset", retry the command instead of returning an error. XS_RESET is useless
without this, as the retryed command will die with this unit attention.
1999-02-02 13:01:36 +00:00
bouyer 12868a7d80 Return ENODEV instead of EIO when we are trying to open a device without media
in the drive. restrict "opening of empty drive" to character devices only
(reading a block device returns a short read instead of ENODEV, which can lead
to confusion).
1999-01-29 11:17:58 +00:00
bouyer d8f58a3506 Move test for SDEV_NOSTARTUNIT quirk from sd.c to scsipi_start().
Add a SDEV_NOSTARTUNIT quirk entry for BCD-16X 1997-04-25", "", "VER 2.2"
CD-rom (from Michael Santos).
1999-01-19 10:57:11 +00:00
mjacob ec1a086c80 Make the error condition of neither 0x70 or 0x71 error codes a tad
more informative than the lower case 'error code %d'.
1999-01-10 06:26:23 +00:00
thorpej 10d50739c7 Actually, restructure scsipi_wait_drain() slightly. 1998-12-08 00:26:22 +00:00
thorpej 1ddd2ffec0 - When allocating a scsipi_xfer, add it to the specified device's
pending_xfers queue.
- When freeing a scsipi_xfer, remove it from the device's pending_xfers
  queue.  If the queue is empty, and SDEV_WAITDRAIN is set, wakeup
  those waiting for the queue to drain.
- Implement scsipi_wait_drain(), which waits for a device's pending_xfers
  queue to drain.
1998-12-08 00:17:21 +00:00
thorpej e87fa217f4 Add support for reference counting and enabling/disabling SCSI and
ATAPI controllers.  This will eventually be used for power management
of e.g. PCMCIA SCSI and IDE controller cards.
1998-11-19 20:08:52 +00:00
bouyer 00d93f776b Rename scsi_interpret_sense() to scsipi_interpret_sense() and move it from
scsi_base.c to scsipi_base.c. Rename the functions from scsi_verbose.c
too, and rename the file itself. Cleaup includes too (scsi_*.h should not
be #included in scsipi_*.h files, which are supposed to be
common to atapi and scsi).
1998-11-17 14:38:42 +00:00
thorpej fe56f257b2 If the adapter returned XS_RESET and the xfer specifies a retry count,
attempt to reissue the command (which was destroyed by the bus reset).

Slightly modified from PR #6090, from Matt Jacob.
1998-10-10 03:42:53 +00:00
scottr c797d52571 SCSI_ASYNCREQ turns out to be redundant; we can simply free the scsipi_xfer
in scsipi_done() if the transfer is asynchronous.  This reduces the size
of the critical section in scsipi_execute_xs() somewhat (in fact,
back to its original size).
1998-09-18 05:53:07 +00:00
scottr 4963603d0f Found a race in scsipi_execute_xs(): if an asynchronous transfer completes
(probably due to an interrupt) between the time it is scheduled and the
time we get around to setting the SCSI_ASYNCREQ flag, we can lose the xs.

Fix this by checking to see if the transfer has already completed after
the scsi_cmd function returns SUCCESSFULLY_QUEUED, and just return to the
caller if so.
1998-09-16 05:35:50 +00:00
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
mycroft 6dc903202f Assign my copyrights to TNF. 1998-08-15 10:10:47 +00:00
scottr 396881cc5d Eliminate a potential (but not common) NULL dereference. 1998-08-11 05:47:43 +00:00
thorpej 03ffe0a516 Use the pool allocator for scsipi_xfer structures. 1998-07-31 03:00:51 +00:00