]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
libata: improve phantom device detection
authorTejun Heo <tj@kernel.org>
Thu, 13 Nov 2008 01:04:46 +0000 (10:04 +0900)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 13 Dec 2008 23:29:11 +0000 (15:29 -0800)
commit 6a6b97d360702b98c02c7fca4c4e088dcf3a2985 upstream.

Currently libata uses four methods to detect device presence.

1. PHY status if available.
2. TF register R/W test (only promotes presence, never demotes)
3. device signature after reset
4. IDENTIFY failure detection in SFF state machine

Combination of the above works well in most cases but recently there
have been a few reports where a phantom device causes unnecessary
delay during probe.  In both cases, PHY status wasn't available.  In
one case, it passed #2 and #3 and failed IDENTIFY with ATA_ERR which
didn't qualify as #4.  The other failed #2 but as it passed #3 and #4,
it still caused failure.

In both cases, phantom device reported diagnostic failure, so these
cases can be safely worked around by considering any !ATA_DRQ IDENTIFY
failure as NODEV_HINT if diagnostic failure is set.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/ata/libata-sff.c

index 2a4c516894f0018c7c370168b4ae004f25598546..bb26a26f3bf63b3eda7d24fefe0dcd452daf96d2 100644 (file)
@@ -1227,10 +1227,19 @@ fsm_start:
                        /* ATA PIO protocol */
                        if (unlikely((status & ATA_DRQ) == 0)) {
                                /* handle BSY=0, DRQ=0 as error */
-                               if (likely(status & (ATA_ERR | ATA_DF)))
+                               if (likely(status & (ATA_ERR | ATA_DF))) {
                                        /* device stops HSM for abort/error */
                                        qc->err_mask |= AC_ERR_DEV;
-                               else {
+
+                                       /* If diagnostic failed and this is
+                                        * IDENTIFY, it's likely a phantom
+                                        * device.  Mark hint.
+                                        */
+                                       if (qc->dev->horkage &
+                                           ATA_HORKAGE_DIAGNOSTIC)
+                                               qc->err_mask |=
+                                                       AC_ERR_NODEV_HINT;
+                               } else {
                                        /* HSM violation. Let EH handle this.
                                         * Phantom devices also trigger this
                                         * condition.  Mark hint.