libata: assume no device is attached if both IDENTIFYs are aborted

This is to fix bugzilla #10254. QSI cdrom attached to pata_sis as
secondary master appears as phantom device for the slave.
Interestingly, instead of not setting DRQ after IDENTIFY which
triggers NODEV_HINT, it aborts both IDENTIFY and IDENTIFY PACKET which
makes EH retry.

Modify EH such that it assumes no device is attached if both flavors
of IDENTIFY are aborted by the device. There really isn't much point
in retrying when the device actively aborts the commands.

While at it, convert NODEV detection message to ata_dev_printk() to
help debugging obscure detection problems.

This problem was reported by Jan Bücken.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Jan Bücken <jb.faq@gmx.de>
Acked-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by Tejun Heo and committed by Jeff Garzik 1ffc151f b63b1331

+24 -14
+24 -14
drivers/ata/libata-core.c
··· 2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2093 if (err_mask) { 2094 if (err_mask & AC_ERR_NODEV_HINT) { 2095 - DPRINTK("ata%u.%d: NODEV after polling detection\n", 2096 - ap->print_id, dev->devno); 2097 return -ENOENT; 2098 } 2099 2100 - /* Device or controller might have reported the wrong 2101 - * device class. Give a shot at the other IDENTIFY if 2102 - * the current one is aborted by the device. 2103 - */ 2104 - if (may_fallback && 2105 - (err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2106 - may_fallback = 0; 2107 2108 - if (class == ATA_DEV_ATA) 2109 - class = ATA_DEV_ATAPI; 2110 - else 2111 - class = ATA_DEV_ATA; 2112 - goto retry; 2113 } 2114 2115 rc = -EIO;
··· 2092 id, sizeof(id[0]) * ATA_ID_WORDS, 0); 2093 if (err_mask) { 2094 if (err_mask & AC_ERR_NODEV_HINT) { 2095 + ata_dev_printk(dev, KERN_DEBUG, 2096 + "NODEV after polling detection\n"); 2097 return -ENOENT; 2098 } 2099 2100 + if ((err_mask == AC_ERR_DEV) && (tf.feature & ATA_ABORTED)) { 2101 + /* Device or controller might have reported 2102 + * the wrong device class. Give a shot at the 2103 + * other IDENTIFY if the current one is 2104 + * aborted by the device. 2105 + */ 2106 + if (may_fallback) { 2107 + may_fallback = 0; 2108 2109 + if (class == ATA_DEV_ATA) 2110 + class = ATA_DEV_ATAPI; 2111 + else 2112 + class = ATA_DEV_ATA; 2113 + goto retry; 2114 + } 2115 + 2116 + /* Control reaches here iff the device aborted 2117 + * both flavors of IDENTIFYs which happens 2118 + * sometimes with phantom devices. 2119 + */ 2120 + ata_dev_printk(dev, KERN_DEBUG, 2121 + "both IDENTIFYs aborted, assuming NODEV\n"); 2122 + return -ENOENT; 2123 } 2124 2125 rc = -EIO;