Commit Graph

603 Commits

Author SHA1 Message Date
bouyer fae9929734 - Add some debug printf (WDCPROBE) in _wdcreset_wait(), I've needed these
2 times in the past
- Set up timeout per xfer instead of per interrupt. This helps with
  PIO transfer (we would call timeout()/untimout() several times for a
  transfer).
- If we missed an interrupt for a PIO transfer, reset and restart it
  immedialy, don't try to recover and continue. If we missed an interrupt we
  may have lost a read/write cycle on the IDE bus. If this happens 1) we
  corrupt data and 2) we enter an interrupt loop at the end of the xfer, as
  the drive has some more data to read/write, but the host thinks the xfer is
  done.
This last change fix the (or at last some of the) 'lookup after lost interrupt'
some peoples have been experiencing.
1999-08-06 12:00:23 +00:00
explorer 8fa3d8be55 make the JVC 2626 match more than one version, since all seem to be
returning errors on the LUN probe.
1999-07-26 22:43:13 +00:00
thorpej 40d9e23179 Define the Volume Tag format. 1999-07-22 17:43:53 +00:00
tron 62af9404e6 Skip LUN check for all versions of the UMAX Astra 1220S as suggested
by Dan McMahill in PR kern/7991.
1999-07-14 22:34:18 +00:00
bouyer e5d15c0dc6 Add another CD to the quirk table. 1999-07-08 14:24:42 +00:00
thorpej 59da37b37e Go to splbio() when calling scsipi_free_xs(), just like the SCSI counterpart.
Fixes PR #7853, Paul Dokas <dokas@cs.umn.edu>.
1999-06-25 18:58:54 +00:00
mjacob 92f90fcb92 STK 9490 && SD-3 drives incorrectly quirked as not supporting the LOAD command.
Anyway, just because a drive doesn't support the LOAD (to BOT) command does
not mean that the drive doesn't support the UNLOAD command. Also note and
print errors in rewinds and unloads (and errors in writing closing filemarks
for same).
1999-06-17 04:20:55 +00:00
pk b6429ec3c5 In scsipi_done(), call scsipi_free_xs() at splbio(). 1999-06-16 07:35:31 +00:00
pk 5b4a75d281 scsipi_free_xs() wants to be called at splbio; do it. 1999-06-12 11:19:00 +00:00
lukem 7d44fa2e6e * use format_bytes() to display the disk size
* wrap a couple of printf()s
1999-05-31 12:05:39 +00:00
bouyer b87dbb8918 in cdclose(), ignore "media change" when calling scsipi_prevent(), after
a 'eject -l' some ATAPI drives report this instead of illegal request.
1999-05-27 11:19:04 +00:00
thorpej f98d358a1f Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m).  The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary.  Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.
1999-05-18 23:52:51 +00:00
perry f8e8703b5e Add patch from Manuel Bouyer -- his mail message said:
By code inspection I found 2 bugs in the ATAPI code, one may be the cause
of your problem: A counter is not reset when issuing the request_sense
command. This is c_skip, the counter used to track the offset in the data
buffer when a data tranfer needs multiple phases. The effect of this is that
the sense data transfered may be stored outside the sense buffer (sense buffer
+ some, potentially several KB, offset). This can only occur in PIO mode,
DMA is not affected.
This doesn't occur in "normal" use because when reading a data CD, either
the sense is issued for a non-data command (in which case c_skip stays to
0), or an error occured and no data has been transfered, and c_skip is still 0.
I can't see a case where a data READ/WRITE could cause a sense tranfer without
error.

The second problem is that b_resid can be set to a false value (resulting of
the sense tranfer and not the data transfer). Again this is not a problem with
usual data tranfers because both values ends up being 0 when no error occurs.
1999-05-05 21:35:15 +00:00
bouyer b5f3e628a3 If setting to pio mode < 3 fails, try to set pio mode 3 before returning
EIO. The spec says ATAPI devices should support "PIO 3 or better".
They are supposed to support less as well. Setting the device to a highter
mode than the controller shoul'nt be a problem, and this is likely what
happens with legaty ISA controllers.
Solve problem reported by Ruey-Shyang Guo.
1999-04-15 16:21:27 +00:00
bouyer e91bdf1c67 Add SCSI_IGNORE_NOT_READY to the flags for CDIOCCLOSE: some devices will
attempt to spin up, and report an error if there's no CD. Fixes port-i386/7345.
1999-04-08 16:12:31 +00:00
bouyer c2752835f7 Fix a long-standing bug with the ACAP_* flags:
- the cap field is a u_int8_t, so none of the defined flags would fit in.
  Looks like nobody had a drive using 16 bytes commands.
- the ACAP_DRQ_* flags are all wrong. Just remove them and use the definitions
  from ata/atareg.h, there's no need to duplicate theses. The effect of this
  was that we were always polling for the command phase, even for drives
  with interrupt DRQ. This didn't break until the code was changed to support
  shared interrupts.

Should fix the lookup problems or 'boot hangs' reported by some users, and
kern/7111.
1999-04-08 11:29:01 +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
mycroft 7a304dfe1b If scsipi_command() fails, always print out the error code. 1999-04-05 19:19:34 +00:00
bouyer bf88fc82eb Adjust timeout for 'ielem' to match the comment: 5 mn (not 5s) per element +
10mn initial.
1999-04-04 12:20:48 +00:00
bouyer b43b844f6f - change the interrupt routines to take a 3rd arguments, set to 1 if we
are called from the interrupt or timeout handler, 0 otherwise.
- use this to know if we can busy-wait for wait_for_unbusy or wait_for_ready
This fixes a bug where CDs withot the DRQ_INTR capability would not busy-wait
for the CMDOUT phase.
While I'm there change 2 delay() to DELAY() for consistency, and
garbage-collect some old code from wdcintr() which has been ifdef'd out
for some time now.
1999-04-01 21:46:28 +00:00
bouyer 1ff88ee466 Avoid busy-waiting when possible if we are not polling (real IRQ or timeout
callback). Shared PCI IRQ should now work (but still untested).
1999-03-25 16:17:36 +00:00
explorer 3ebb419571 Update to slightly altered rnd_attach_source() api 1999-02-28 17:08:05 +00:00
jwise 8ef8f5c8fb Fix typo.
Fixes last part of PR bin/6883 from Soren S. Jorvang <soren@t.dk>.
1999-02-24 18:54:03 +00:00
hubertf ed418e30a2 Only define WDCDEBUG if not already define (e.g. by kernel option) 1999-02-21 00:52:04 +00:00
bouyer 13e811e874 Revert to 1.23, this was not supposed to be checked in yet. 1999-02-15 18:43:08 +00:00
bouyer 18496766b2 For CDIOCCLOSE, ignore media changes, as some drive seems to return this
info here.
1999-02-15 18:41:04 +00:00
bouyer 379429d4df If the REQUEST_SENSE command fails, issue a reset instead of XS_DRIVER_STUFFUP.
If REQUEST_SENSE succeeds but doens't return any data, return XS_SHORTSENSE
as the sense field will just contain a copy or the error register.
1999-02-15 18:40:01 +00:00
bouyer 6dd47fe65f Abort transfer if b_blkno is negative. Closes PR kern/5553 by Johan Danielsson. 1999-02-10 12:29:50 +00:00
bouyer f6f9f8a965 Change DIOCEJECT to do what's needed to eject a device before the eject
command (unlock for sd and cd) if no other partitions are open, return
EBUSY otherwise. DIOCEJECT will have the old semantic if its argument is not
0. The old ioctl has been renamed to ODIOCEJECT for binary compatibility.
1999-02-08 16:33:16 +00:00
sommerfe 0d3a9dfce7 Don't bring scsi/atapi common files in under the "atapi" attribute.
Bring them in under atapibus since they're not needed unless something
attached to an atapibus is also attached.
Tested on i386 and arm32.
1999-02-07 22:58:43 +00:00
bouyer 0075c51a23 Bump CDRETRIES to 4. Now if a DMA error occurs, the driver should downgrade
to PIO mode and the command be retried properly.
1999-02-02 13:02:49 +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 2bf6a99afb For IDE/ATAPI protocols botches, reset the bus and return XS_RESET
instead of XS_DRIVER_STUFFUP.
1999-02-02 12:59:31 +00:00
bouyer ce870816e0 Cosmetic changes, from Soren S. Jorvan. 1999-01-29 11:36:20 +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 f52c71b0e8 Allows the raw partition to be open()'ed, even when scsipi_start() fails
(no media or other ...) so that we can always send ioctl's to the device.
1999-01-26 13:59:44 +00:00
bouyer cafe97da38 Another CD drive that doesn't support REQUEST SENSE, from Patrick Welche. 1999-01-26 10:00:08 +00:00
bouyer d86a570eac Add a mitsumi CD that can't handle REQUEST SENSE command. From
Johan Danielsson <joda@pdc.kth.se>.
1999-01-21 10:31:39 +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
bouyer f10115b632 "Memorex CRW-2642" CD-R can't properly handle REQUEST SENSE command.
Add it to the quick table, per PR kern/6844.
1999-01-19 09:31:58 +00:00
thorpej ae8a556ce5 Add missing XS_SELTIMEOUT case in user command completion path, returning
SCCMD_TIMEOUT.  Based on PR #6720, Andreas Wrede.
1999-01-11 22:07:08 +00:00
tron 3fbb44a7bb Make MTIOCRDSPOS, MTIOCSLOCATE, etc. work with write protected tapes.
Patch supplied by Dave Huang in PR kern/5305.
1999-01-10 21:46:39 +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 268eb959c4 Make this compile again after the void * arith changes. 1999-01-09 03:16:17 +00:00
augustss 332d7c138f Avoid arithmetic on `void *' since that's not ANSI C. 1999-01-08 18:10:35 +00:00
is bfb7f2aaf3 Multisession-CD-Support, by Torsten Duwe <duwe@ns.lst.de>. 1999-01-04 15:32:08 +00:00
dbj 3fec12a459 Added parens around ADD_BYTES_LIM() macro definition to protects its
use of the low precedence ?: conditional operator.  This fixes a bug
in scsipi_interpret_sense when printing out debugging info.
1998-12-30 11:17:34 +00:00
leo c81639d273 Change quirk entry: "FX320S", "", " q01" to: "FX320S", "", "q01". This
space does seem to matter...
1998-12-21 21:40:12 +00:00
gibbs c9eb836a6a Return ENODEV when the device capability check fails for MOVE and EXCHANGE
operations.
1998-12-17 22:28:07 +00:00
gibbs 1b30d7e440 Correct the definition of the changer device capabilities page. The
previous definition confused some reserved bytes for exchange capabilities.
1998-12-17 22:27:18 +00:00
bouyer 85078af6c4 Add a new quirk flags, "ADEV_NOSENSE", for devices that don't
handle properly the request sense command. Add <FX320S, , q01> as being
sense-unfriendly in the quirk table.
1998-12-17 13:05:05 +00:00
bouyer 945acd7834 Leave some room for the string-terminating char in temp. buffers.
Pointed out by Scott Presnell (thanks !).
1998-12-16 13:06:52 +00:00
bouyer c37bf0ccb4 Keep track of DMA errors, and downgrade the transert mode (UDMA ->DMA,
DMA->PIO) in case of 2 consecutive errors. Don't downgrade if the
PIO/DMA/UDMA modes were forced by a config flag.
1998-12-16 13:02:03 +00:00
mycroft 95aa0d0b7d Simplify the copy loops a bit. 1998-12-12 16:58:10 +00:00
mjacob 7f5c8f7db2 add Adaptec RAID units as devices that do not return geometry pages 1998-12-10 18:13:29 +00:00
thorpej 10d50739c7 Actually, restructure scsipi_wait_drain() slightly. 1998-12-08 00:26:22 +00:00
thorpej 8ebf1e8824 Remove xs_free_list; it no longer exists. 1998-12-08 00:20:16 +00:00
thorpej 624619a881 When closing, wait for pending xfers to drain before deleting the reference
to the adapter.
1998-12-08 00:19:27 +00:00
thorpej dcc5f32c2b When closing, wait for pending xfers to drain before unlocking the door,
and wait again before deleting the reference to the adapter.
1998-12-08 00:18:46 +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 98194169ea When allocating a device's scsipi_link, initialize the pending_xfers
queue.
1998-12-08 00:14:41 +00:00
thorpej 126dc6bfcc - Remove the "free_list" member from scsipi_xfer. Add "adapter_q" and
"device_q" TAILQ entries.  The former is for use by the adapter driver,
  as it sees fit.  The latter is for the scsipi middle layer to track
  pending xfers per device.
- Add a pending_xfers queue to scsipi_link, to track pending xfers per
  device.
- Grow scsipi_link's flags to int, and add SDEV_WAITDRAIN, to indicate that
  we're waiting for the pending_xfers queue to empty.
1998-12-08 00:13:58 +00:00
mjacob 337eb43541 NOMODESENSE for all Seagate ST19171- not just FC 1998-12-05 20:52:47 +00:00
mjacob 4b8245a959 Add a max_lun property to match with the max_target property. Shorten
max_target to int16.
1998-12-05 19:41:31 +00:00
mjacob 33fde1ad76 Eliminate the moreluns entry as it makes no sense for fat SCSI busses (e.g,
FC loops). Change the semantics of scsi_probedev so that it returns 1 if
you should continue probing at this target, else 0 for not.

Replace the blanket use of '7' with the use of the new sc_maxlun property
that is now gathered from HBAs. Allocate scsipi_link arrays based upon this.
Fix a really nasty and silly bug that has been there for a while where the
number of first level scsipi_link structures was one less than it needed
to be.
1998-12-05 19:39:23 +00:00
leo bea7038c02 The IOMEGA ZIP 100, J.03 does not grok LUN's. 1998-11-26 13:39:14 +00:00
drochner 3e38051bc5 in wdc_softc: access the per-channel data via a pointer array instead of
an array of fixed-sized channel_softc elements. This way IDE controllers
which more than 1 channel (pciide) can extend the channel data easily
for private needs.
To avoid the double dereference at runtime, change the argument of
wdcstart() to the channel data pointer instead of the array index.
1998-11-21 15:41:41 +00:00
thorpej 6a60e078ee Add adapter reference counting for SCSI and ATAPI devices. 1998-11-20 00:35:39 +00:00
thorpej baec89716d Add a reference to the adapter when the scsibus is opened, and delete it
when it is closed.
1998-11-19 22:28:20 +00:00
thorpej 54b52fb5f6 Add a reference to the adapter before probing the bus, and delete it
once we are done probing.
1998-11-19 22:25:56 +00:00
thorpej 3b068a6c78 Adapt to the new scsipi_adapter interface. 1998-11-19 21:53:32 +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
thorpej fd684d874c Protect against multiple inclusion. 1998-11-19 03:45:39 +00:00
bouyer 0af9847a2d The ATAPI-specific hack is not needed any more. 1998-11-17 14:46:26 +00:00
bouyer 0d0ff884e5 In atapi_wdc.c, issue a 'REQUEST SENSE' command when appropriate.
Return XS_SENSE when the full sense info has been retrieved, or
XS_SHORTSENSE if only the sense key was available (from the error register)
Make atapi_interpret_sense() deal with this, and call scsipi_interpret_sense()
for XS_SENSE. (XXX sd_interpret_sense() and the ioctl code needs to be made
aware of XS_SHORTSENSE too ! sense hanlding for these is now less broken for
devices that support 'REQUEST SENSE')
All the ATAPI devices I have access to seems to honnor the SENSE_REQUEST
command, but I suspect some ATAPI devices will not (althouh it's mandatory).
The code should be able to deal with this, but is untested ...
1998-11-17 14:45:39 +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 ed473183ef Define the FORMAT UNIT command, and several related structures. 1998-10-30 02:07:15 +00:00
thorpej c0ba12768e Fix a sight open flags buglet pointed out by Matthias Scheler. 1998-10-20 22:26:04 +00:00
bouyer f6f8ba3446 Allow uk to attach at atapibus. 1998-10-19 12:28:52 +00:00
bouyer 5f723da8af Move the "warning: bcount value is %d after io" message in a WDCDEBUG_PRINT.
Ifdef DIAGNOSTIC, print the above message only if bcount is < 0.
1998-10-19 12:28:03 +00:00
thorpej d153ad6324 Some const poisioning. 1998-10-15 07:06:47 +00:00
thorpej 859b5d88a6 Protect kernel prototypes w/ #ifdef _KERNEL. 1998-10-15 05:11:52 +00:00
thorpej 2ebdceb3f7 Forward decl of struct proc. 1998-10-15 05:10:20 +00:00
bouyer e8322de657 Add a new drive flag, DRIVE_MODE, set when the drive properly reported its
PIO/DMA modes. Don't try a SET_FEATURE if it didn't report its mode.
1998-10-13 15:18:46 +00:00
bouyer 7545a59b8c In debug message, always print controller:channel:drive 1998-10-13 15:02:41 +00:00
bouyer ff0134b99f Properly separate DEBUF_XFERS and DEBUG_FUNCS: DEBUF_XFERS is for data
transfers (may be called often), where DEBUG_FUNCS is for setup functions
(not used for normal contitions).
1998-10-13 09:33:59 +00:00
bouyer da5d0a6f17 pciide.c: don't define WDCDEBUG, so it compiles on alpha. Correct a bogon
in the printing of DMA mode (piix3/4 only)
others: set the debug_mask to 0, so that debug messages are turned off by
default but can be easily turned on.
Reset drive_flags to 0 for unconfigured devices, so that they are ignored
later. For configured devices, reset state to 0 after probe/attach.
1998-10-13 08:59:45 +00:00
kim cd7e3136ad Use ETHERTYPE_ATALK instead of ETHERTYPE_AT. The former seems more common.
Our other constants also use "ATALK".

Added many new ETHERTYPE constants to sys/net/ethertypes.h, including the
ones from libpcap and tcpdump "ethertype.h" files.
1998-10-13 02:34:31 +00:00
enami 13b8051475 Make this file compile again with -DATAPI_DEBUG_PROBE. 1998-10-13 02:09:47 +00:00
bouyer 19fddaeeb5 Merge bouyer-ide 1998-10-12 16:09:10 +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
thorpej 16cf223098 Enforce open-for-writing on ioctls that change the bus's state.
Implement ioctl pass-through to the host bus adapter, allowing both
SCBUS* ioctls handled at that level and host adapter-specific ioctls
to be implemented.  Implement SCBUSIORESET as a pass-through.

Inspired by PR #6090, from Matt Jacob.
1998-10-10 03:33:01 +00:00
thorpej 45bf57f8a6 Garbage-collect the SCIOCREPROBE and OSCIOCREPROBE ioctls. This is a
bus-oriented command.  (How much sense does it make to open a device
to rescan the bus?!)
1998-10-10 02:35:30 +00:00
thorpej 1e2b6a99ed Implement the SCBUSIOSCAN ioctl. Rescans the bus for new devices. 1998-10-10 02:34:15 +00:00
thorpej e3fb94a7b4 Add the open/close/ioctl entry points for the SCSI bus, i.e. /dev/scsibusN. 1998-10-10 01:14:26 +00:00
thorpej dda872c16a Define an additional host adapter return code, XS_RESET, indicating
that the bus was reset while the command was pending.  The middle
layer may choose to retry the command.
1998-10-10 00:36:13 +00:00
thorpej 29d472f53d Garbage-collect the open_target_lu and close_target_lu entry points from
struct scsipi_adapter; they were not used.

Add a scsipi_ioctl entry point to struct scsipi_adapter.  This will be
used to issue ioctl commands to the host adapters.

Inspired by PR #6090, from Matt Jacob.
1998-10-10 00:28:28 +00:00
thorpej b69841d26a Add a NOSYNCCACHE quirk for the Micropolis 2217-15MQ1091501, as reported
by Matt Jacob, PR #6027.
1998-10-08 20:24:10 +00:00
thorpej 39f4d1c239 Handle devices that have the SDEV_NOSYNCCACHE quirk. 1998-10-08 20:21:13 +00:00
thorpej 7be31bed79 Add a "NOSYNCCACHE" quirk, as suggested by Matt Jacob in PR #6027. 1998-10-08 20:17:52 +00:00