Commit Graph

86 Commits

Author SHA1 Message Date
bouyer 4849b82163 Make the xxstart() functions reentrant again, as some drivers HBA can call
scsipi_done() from their scsipi_request().
For this, add a struct scsipi_xfer * argument to scsipi_command().
If not NULL scsipi_command() will use this to enqueue this xfer, otherwise
it'll try to allocate a new one. This scsipi_xfer has to be allocated
and initialised by scsipi_make_xs() or equivalent.
In xxstart(), allocate a scsipi_xfer using scsipi_make_xs(), and if not NULL,
dequeue the buffer before calling scsipi_command(). This makes sure that
scsipi_command() will not fail, and also makes sure that xxstart() won't
be called again between the BUFQ_PEEK() and BUFQ_GET().

Fix "dequeued wrong buf" panics reported by Juergen Hannken-Illjes in
private mail and Andreas Wrede on current-users@.
Thanks to Jason Thorpe and Chuck Silver for review, and Andreas Wrede for
testing the patch.
2004-09-09 19:35:30 +00:00
thorpej cb3eb355e7 Const poison scsipi_dtype(). 2004-08-21 21:30:29 +00:00
thorpej 3a4c3c0872 - De-__P.
- Use ANSI function decls.
2004-08-21 20:40:36 +00:00
bouyer 751597cddb cbd -> cdb
Command Block Descriptor -> Command Descriptor Block
Pointed out by Allen Briggs.
2004-03-16 19:10:43 +00:00
bouyer 542c876565 Extract the code printing the CBD from scsipi_print_sense(), so that it's
usable in other context.
Use the new scsipi_print_cbd() to dump the command in case of timeout
in siop/esiop.
2004-03-15 22:43:43 +00:00
bouyer 285ce8d78e Indent. 2004-03-15 22:28:30 +00:00
mycroft 289d7af075 Remove PQUIRK_CDROM. It is definitely not correct -- witness that no other
OS needs such a hack, and the same drive works fine on Suns -- and is much
more likely to be a bug in the host adapter driver (which is corroborated by
the PQUIRK_NOLUNS).
2004-02-22 07:26:15 +00:00
mycroft 9dbb8c86d4 Merge the geometry and cache handling code for all direct access and optical
devices, as it's general to all SCSI MMC devices.  In the process, remove
PQUIRK_NO_FLEX_PAGE.
2003-09-18 00:06:31 +00:00
mycroft b2d9db1002 Remove PQUIRK_BYTE5_ZERO. 2003-09-17 19:14:56 +00:00
mycroft 06fca94595 Exorcise PQUIRK_NODOORLOCK. 2003-09-09 02:37:55 +00:00
mycroft 648730c4cf Do a START UNIT only if the TEST UNIT READY reports that the device is not
ready.  This avoids gratuitously starting the motor on floppy and CD-ROM
drives, and eliminates the need for the audio playing test in cdopen().

Therefore, also remove PQUIRK_NOSTARTUNIT.
2003-09-08 18:51:33 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
wiz 1ffa7b76c4 DMA, not dma nor Dma. 2003-05-03 18:10:37 +00:00
fvdl a434795392 Add a PCAP_NODT quirk. I have two older Quantum Atlas drives that work
fine at U2W, but barf at U160, with different controllers. Unfortunately
sometimes just being initialized at U160 does the trick, so setting them
to lower speed in the BIOS may also be needed.
2003-04-19 19:16:06 +00:00
fvdl 8103646465 Check RAW_PART against the media size instead of the disklabel.
Add the media size in 512-byte sectors to the softc, to avoid
some 64 bit computations. Bump the capacity stored in softcs
for disks to 64 bits.
2003-04-03 22:18:23 +00:00
mjacob 3c709b448c Fixes kern/18709 (correcting some typos in comments) 2002-10-19 18:41:34 +00:00
jmc c7258354f0 Force the initial probes to happen within the newly forked off kthread.
This eliminates problems where the underlying interrupt handler isn't the
specific layer calling scsipi_complete() for a given scsi transaction.
This avoids deadlocks where the kthread that called the autoconf routines
to configure a scsibus shouldn't be the one put to sleep waiting on a
scsipi_complete (only the scsibus's kthread should be doing that).

To avoid jitter this will force the scsibus's to probe in the order they
run through autoconf (so machines with multiple bus's don't move sd* devices
around on every reboot).
2002-09-19 08:31:05 +00:00
thorpej f4cc1100b0 Don't use a 2-dimensional array for the channel's periph table. Instead,
hash the target and lun together and use a hash table.  This will be
necessary in order to support very large (64-bit) LUN number spaces.
2002-05-16 02:54:20 +00:00
bouyer 3d5ee1e719 Change PQUIRK_CAP_SYNC to set PERIPH_CAP_SYNC aslo for devices that
improperly claim to only support DT clocking.
Add a PQUIRK_CAP_WIDE16 quirk.
Add a quirk for IBM DXHS36D SCSI disk (claims to only support DT).
2002-05-15 11:43:22 +00:00
bouyer e49057af19 Report SPC-2 features (DT clocking, quick arbitration and selection,
information unit transfers) though periph_cap.
2002-04-23 09:09:55 +00:00
bouyer 4940346b10 Add a chan_name to struct scsipi_channel, holding the channel's name.
Set this to dv_xname for scsibus and atapibus.
Set the name of the kernel thread to chan_name instead of controller's
name:channel number (so that we can use this name for controller-specific
threads).
2002-04-01 20:37:41 +00:00
bouyer 4809ad42cb Clean up attach of wd/atapibus:
kill ata_atapi_attach. Change atapibus to use a struct scsipi_channel instead
of ata_atapi_attach as attach arch. Create a ata_device, compatible with
scsipi_channel, to attach wd.
2001-12-02 22:44:32 +00:00
tsutsui 859356d03b Add a new quirk value PQUIRK_CAP_SYNC for SCSI1 devices which support
sync transfers, and set PERIPH_CAP_SYNC for them in scsi_probe_device().
As per discussion on tech-kern.
2001-11-19 22:50:00 +00:00
tsutsui c8f45396b3 Fix formatting of scsi_quirk_patterns[] and wrap long lines. 2001-11-18 17:22:43 +00:00
bouyer a84535fd3e Call ADAPTER_REQ_GROW_RESOURCES from the completion thread, if possible.
This allows HBA drivers to call bus_dmamem_map() safely.
2001-10-14 20:31:24 +00:00
bouyer ce6aaa187a Split channel flags in chan_flags used for communications between
scsipi and HBA, and chan_tflags used for communications between scsipi
and its kernel thread. No functionnal change.
2001-10-14 19:03:43 +00:00
mjacob 79d74959da Restore previous definitions. 2001-09-27 18:07:51 +00:00
fvdl 000902fbf6 Unfortunately, the previous change seems to make most (all?) configurations
using the ahc driver hang when probing scsi devices. The problem may be in
the ahc driver and not in this change, but back it out until this has been
fixed anyway.
2001-09-21 13:54:47 +00:00
mjacob 849eac52f2 Rather than run a periph's queue from scsipi_periph_timed_thaw which is
called via a callout, kick the completion thread to run it for us (uses
a new flag, SCSIPI_CHAN_KICK).

If we've received BUSY status and we haven't started the completion
thread yet, don't freeze do a callout to scsipi_periph_timed_thaw which
then will try and kick the completion thread- instead treat the command
as if it were a polled command and just call delay for 1 second.

If DIAGNOSTIC is defined, and the periph qfreeze count is less than
zero, panic because some HBA has corrupted the periph structure's
accounting.
2001-09-18 20:20:26 +00:00
tsutsui 354cce66e5 Use be16toh(), be32toh(), le16toh() and le32toh() rather than
ntohs(), ntohl() or homegrown bswap() functions.

XXX Does anyone use drives with PQUIRK_LITTLETOC on big endian machines?
2001-09-02 13:11:53 +00:00
augustss 60ffafe273 Add a new quirk, PQUIRK_NOBIGMODESENSE, for devices that need big
SCSI ops, but still fails on big mode sense.
Makes M-Sys DiskOnKey work.
2001-08-31 07:09:41 +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
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
mjacob 3462fe5d99 Remove reference to adapter_q in scsipi structure. Comment about the
usage of channel_q.
2001-05-21 15:50:46 +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 28d47d8db3 Use same type for first field of struct ata_atapi_attach and struct
scsipi_channel, so umass has better chances of working on big-endian systems.
2001-05-02 09:47:45 +00:00
lukem 85772a1cef remove some lint 2001-04-30 02:34: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
augustss 93b623b541 Extend quirks to 32 bits. Add two new ATAPI quirks, one to
deal with a bad byte5 of the capacity descriptor, one to
handle devices that lack the flex geometry page.
2001-03-20 22:39:08 +00:00
ad 382141e2f7 Add a new, optional method to scsipi_adapter (scsipi_accesschk()), and use
it when considering whether to attach devices. This is to facilitate
`non-SCSI' RAID controller drivers that want to provide SCSI pass-through
services to the kernel.
2000-09-22 16:45:17 +00:00
mjacob b47890a934 Reserve top nibble of status for use by the HBA. It's up to the
HBA to set or clear it.
2000-07-06 01:56:23 +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
augustss 72684ce3ec Add a method, scsipi_getgeom, to the adapter struct. If this method is
present it will be used to get the drive geometry if the MODE SENSE fails.
2000-05-31 09:15:48 +00:00
augustss 997c3c5b8a Add a quirk, SDEV_ONLYBIG, which implies that the device cannot handle
the 6 byte versions of READ, WRITE, and MODE_SENSE.
This greatly simplifies the UFI (USB Floppy) handling.
2000-05-30 01:08:23 +00:00
bouyer 405302008d ADEV_CDROM -> SDEV_CDROM, for consistency. 2000-05-29 20:13:06 +00:00
augustss 7797648425 Change the initial field in struct ata_atapi_attach and struct scsipi_link
slightly to allow scsibus and atapibus to attach to the same device.
Furthermore, only attach a scsibus when the bus type is BUS_SCSI.
2000-04-02 17:25:52 +00:00
augustss fc4d9ff403 Get rid of register declarations. 2000-03-30 00:00: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