Subject: Re: kern/22869: Slave IDE drive not detected
To: Charles M. Hannum <abuse@spamalicious.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 09/22/2003 20:36:57
On Mon, Sep 22, 2003 at 04:17:40PM +0000, Charles M. Hannum wrote:
> 
> > We should get the contents of the drive 0 registers, not all 0.
> >...
> > Now, a command send to drive 1, when there's only one master, shoud not time
> > out, it should be aborted immediatly by the drive. If it times out maybe
> > we have a problem with the code sending the command.
> 
> I point you to section 9.16.1, "Device 0 only configurations", of the
> ATA-4 spec.  It says (emphasis added):
> 
> "In a single device configuration where Device 0 is the only device
> and the host selects Device 1, Device 0 shall respond as follows:
> ...
> "3) A write to the Command register SHALL BE IGNORED, except for
> EXECUTE DEVICE DIAGNOSTIC;
> ...
> "5) A read of the Status or Alternate status register shall return the
> value 00h."
> 
> So, we clearly cannot rely on the command being "aborted" -- that just
> doesn't happen.

I'm sure I saw this somewhere :)
ATA-3 allowed both behavior.

> 
> One thing to note is that, after a reset, if BSY is clear, we *should*
> see that DRDY gets set.  Unfortunately, we might have to wait up to
> 30s to see *that* transition.

Hum, not for ATAPI devices, DRDY will always be 0 after a reset.
And sure, for ATA drives, a ghost will never assert DRDY (at last with some
ATA revs, I didn't check them all) so we may have a long timeout here.

> 
> Note that, somehow, BIOSes manage this without waiting forever, so it
> must be possible.

They may do it in backgroud, while doing others tasks. Also, A bios with
all devices turned to "auto" will take longer than with unexistent devices
turned off.
For add-on adapters (where the probe can only start when the main BIOS
gives them control), it takes several seconds to probe the channels
(both promises and HPT).

It may be possible to speed up ghost detection via a command:
- we may have a ghost only if we have the same signature for device 0 and
  device 1 after a reset
- if we may have a ghost, issue IDENTIFY or ATAPI_IDENTIFY as appropriate.
  After that, we should have either BSY set, or DRQ set, or an aborted
  command. If the status register remains all 0, then this isn't a real
  device.
Note that we have to IDENTIFY both device, as in a slave-only config the
controller may fake a master.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 24 ans d'experience feront toujours la difference
--