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.
DRQ is not asserted). Closes kern/9346.
- Change the "fake identify before the real one" by a delay(). The real cause
of the problem is that the drive is unresponsive just after a reset.
The real problem (and the solution) showed up after the first change.
- If UDMA 2 is failing try UDMA 1 first, it helps in some cases
- downgrade if we get an error in the first 4000 xfers, or if we get
4 errors in 4000 xfers if the first 4000 went without troubles.
While I'm there commit a local change I have since some time to get my CD
probed: issue a "blanck" IDENTIFY before the one used to detect slave ghosts,
with my drive the first IDENTIFY following a controller reset fails with an
aborted command ...
- fix printing of Ultra-DMA modes (shows up when the drive supports highther
modes than the controller).
- Don't use C_NEEDDONE anymore. We were setting this flag in a possibly
freed wdc_xfer (this didn't create problems, as it was free'd in the POLL
case only, while IRQs are blocked, but it's not good practice anyway
and pool(9) complains about it ;)
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.
Constantine Sapuntzakis confirmed by Bill Sommerfeld. Although nothing is
supposed to call wakeup on this without setting AT_DONE, it's good practice to
do it this way (the process may be waken up by a setrunnable() call).
false matches on controllers which properly respond to a WDCC_RECAL command.
Should close PR port-i386/7702 (the author tested this patch, and said it
solves his problem).
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
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.
IDENTIFY said so: it doesn't help for the drive this was supposed helping,
and seems to break another device.
In interrupt routine, don't return 0 if we are polling: this should fix the
"panic: wdc_exec_command: polled command not done" some people reported
(kern/7269).
DRIVE_OLD, DRIVE_ATA or DRIVE_ATAPI based on register signatures.
The attach routine will issue a IDENTIFY command for ATA/ATAPI disk,
to detect flase matches by the probe routine.
probe/attach should now be fully compliant with ata-4/ata-5. As a side
effect, ATAPI drives which improperly use ATA register signatures should now
be attached as ATAPI.
need to downgrade, downgrade to PIO, as it has been shown if we got CRC errors
in Ultra-DMA mode, we will have silent data corruption in multiword DMA mode
(isn't IDE wonderfull ? :).
Set timeout to 1s for "normal" ata I/O, to minimise the effects of missed
interrupts.
the disk is ready to transfer data, and in ATA-5 the DSC has been obsoleted.
So only wait for DRQ to transfer data. This can be made conditional on the
ATA version if it's proven to break with some drives (worked with all the
drives I have access to).
While I'm there correct a few typos.
In wdc_probe_caps() add code to guess the ATA revision supported (if
ATA4 if Ultra-DMA, ATA2 if PIO mode > 2). We can't rely on param.atap_ata_major
here, at last one Ultra-DMA drive claims to support only ATA-3.
Use the ATA version in ata_perror(), and to try a flush cache command
in a shutdown hook for IDE drives.
- keep the modes supported by the drive in struct ata_drive_datas (will be
later used for downgrading the DMA/PIO mode on error)
- use config flags to force/disable PIO/DMA/UDMA modes
- For the CMD PCI0643/6 setup DMA mode to DMA Read multiple.
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.
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.
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.
the capacity based on the c/h/s numbers. In fact, don't use the c/h/s
numbers for much of anything.
For ATA-4 drives or later, always use LBA mode, since it's now required.
Collectively, this allows >8GB disks (like the 12GB Bigfoot) to work.
Compute the disk block addr at command queing time rather than exec time.
This fix a bug which could lead to data corruption on disk: when a command
was reexecuted after an error condition (from wdcunwedge), the partition
offset was re-added to the block addr, leading to a transfert at the wrong
disk block.
This should fix the problem reported by some laptop's users, where the
first disk read after a suspend/resume returned garbage.
the "stream" busification functions.
In the architecture as the BeBox(CPU is big endian, have ISA bus),
These methods would be used where "raw" data needs to {read,write,set}
unchanged.
Add #ifndef __BUS_SPACE_NEED_STREAM_METHODS (define that on NetBSD/bebox),
if not define __BUS_SPACE_NEED_STREAM_METHODS,
define "stream" busification functions to normal busification functions.
* Fix bug in wdc that would overflow ATAPI transfer length.
* Improve wdc probe code so that 'wdc' is probed in if present
even if there are no drives attached, and so that it works
properly even if the only device is an ATAPI slave.
* bus_space-ify.
* split the ISA attachment from the wdc driver, and remove
ISA dependencies from non-ISA files.
* claim that wd and wdc are now machine-independent (probably not
completely true, but mostly so; they at least work on arm32 and
i386).
* Various other minor fixups and cleanups, some of which were pointed
out by Kazuki Sakamoto.
- clean up debug code
- Don't check ATAPI signature when probing ATA drives, ATAPI devices were
detected before
- Reset controller after disks probes. The probe, with some combinations of
ATA/ATAPI device keep it in a mostly working, but strange state (with busy
led on)
- The WDCF_IRQ_WAIT flag is now cleared by wdc_ata_intr and wdc_atapi_intr
when appropriate (helps recover from failure conditions)
- In wdcunwedge, send ATAPI_SOFT_RESET to non-ata drives
(helps recover from failure conditions)
- in wdctimeout be a bit more verbose when we missed an interrupt
- Always Increment xfer->c_skip where it should be
- Set the ITSDONE flag when a polled command completed.
- at end of attach, explicitely select an existing drive. This fixes hangs
some users reported (such as the one reported in port-i386/4247).
- Some atapi cdrom drives (e.g. Nec 24x) don't enables their registers before
a controller reset is issued. The controller probe routine is changed as
follow: issue a controller reset. If fail, test atapi signature on slave.
If fail, wait 5s and retry a reset. If the second reset fail, return(0).
If the first reset succeed, test presence of a master drive:
atapi signature, and if this fail RO/RW registers test. If no master, test
atapi signature on slave. If no slave, return 0.
be probed several times. This fixes the "ATAPI CD probed as wd drive" problem.
Thanks to Geoff Wing <mason@primenet.com.au> for testing this on his hardware.
looking what's the autoconfig do on strange harware, and ATAPI_DEBUG2 is
for debuging data transfers (and is really verbose once the machine has booted
from an IDE disk).
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.