Commit 8c3c52a8 authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

libata: IDENTIFY backwards for drive side cable detection

For drive side cable detection to work correctly, drives need to be
identified backwards such that the slave device releases PDIAG- before
the mater drive tries to detect cable type.  ata_bus_probe() was fixed
by commit f31f0cc2 but the new EH path
wasn't fixed.  This patch makes new EH path do IDENTIFY backwards.

ata_dev_configure() for new devices are still performed master first.
This is to keep the detection messages in forward order.
Signed-off-by: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 55a61604
...@@ -1743,12 +1743,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1743,12 +1743,17 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
{ {
struct ata_eh_context *ehc = &ap->eh_context; struct ata_eh_context *ehc = &ap->eh_context;
struct ata_device *dev; struct ata_device *dev;
unsigned int new_mask = 0;
unsigned long flags; unsigned long flags;
int i, rc = 0; int i, rc = 0;
DPRINTK("ENTER\n"); DPRINTK("ENTER\n");
for (i = 0; i < ATA_MAX_DEVICES; i++) { /* For PATA drive side cable detection to work, IDENTIFY must
* be done backwards such that PDIAG- is released by the slave
* device before the master device is identified.
*/
for (i = ATA_MAX_DEVICES - 1; i >= 0; i--) {
unsigned int action, readid_flags = 0; unsigned int action, readid_flags = 0;
dev = &ap->device[i]; dev = &ap->device[i];
...@@ -1760,13 +1765,13 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1760,13 +1765,13 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) { if (action & ATA_EH_REVALIDATE && ata_dev_ready(dev)) {
if (ata_port_offline(ap)) { if (ata_port_offline(ap)) {
rc = -EIO; rc = -EIO;
break; goto err;
} }
ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE); ata_eh_about_to_do(ap, dev, ATA_EH_REVALIDATE);
rc = ata_dev_revalidate(dev, readid_flags); rc = ata_dev_revalidate(dev, readid_flags);
if (rc) if (rc)
break; goto err;
ata_eh_done(ap, dev, ATA_EH_REVALIDATE); ata_eh_done(ap, dev, ATA_EH_REVALIDATE);
...@@ -1784,26 +1789,40 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1784,26 +1789,40 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
rc = ata_dev_read_id(dev, &dev->class, readid_flags, rc = ata_dev_read_id(dev, &dev->class, readid_flags,
dev->id); dev->id);
if (rc == 0) { switch (rc) {
ehc->i.flags |= ATA_EHI_PRINTINFO; case 0:
rc = ata_dev_configure(dev); new_mask |= 1 << i;
ehc->i.flags &= ~ATA_EHI_PRINTINFO; break;
} else if (rc == -ENOENT) { case -ENOENT:
/* IDENTIFY was issued to non-existent /* IDENTIFY was issued to non-existent
* device. No need to reset. Just * device. No need to reset. Just
* thaw and kill the device. * thaw and kill the device.
*/ */
ata_eh_thaw_port(ap); ata_eh_thaw_port(ap);
dev->class = ATA_DEV_UNKNOWN;
rc = 0;
}
if (rc) {
dev->class = ATA_DEV_UNKNOWN; dev->class = ATA_DEV_UNKNOWN;
break; break;
default:
dev->class = ATA_DEV_UNKNOWN;
goto err;
}
}
} }
if (ata_dev_enabled(dev)) { /* Configure new devices forward such that user doesn't see
* device detection messages backwards.
*/
for (i = 0; i < ATA_MAX_DEVICES; i++) {
dev = &ap->device[i];
if (!(new_mask & (1 << i)))
continue;
ehc->i.flags |= ATA_EHI_PRINTINFO;
rc = ata_dev_configure(dev);
ehc->i.flags &= ~ATA_EHI_PRINTINFO;
if (rc)
goto err;
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG; ap->pflags |= ATA_PFLAG_SCSI_HOTPLUG;
spin_unlock_irqrestore(ap->lock, flags); spin_unlock_irqrestore(ap->lock, flags);
...@@ -1811,13 +1830,12 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap, ...@@ -1811,13 +1830,12 @@ static int ata_eh_revalidate_and_attach(struct ata_port *ap,
/* new device discovered, configure xfermode */ /* new device discovered, configure xfermode */
ehc->i.flags |= ATA_EHI_SETMODE; ehc->i.flags |= ATA_EHI_SETMODE;
} }
}
}
if (rc) return 0;
*r_failed_dev = dev;
DPRINTK("EXIT\n"); err:
*r_failed_dev = dev;
DPRINTK("EXIT rc=%d\n", rc);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment