[libata] improve device scan even more
authorJeff Garzik <jgarzik@pobox.com>
Tue, 4 Oct 2005 01:36:41 +0000 (21:36 -0400)
committerJeff Garzik <jgarzik@pobox.com>
Tue, 4 Oct 2005 01:36:41 +0000 (21:36 -0400)
Since our max_lun is unconditionally set to 1, we might as well
hardcode a LUN 0 probe, rather than a wildcard LUN scan.

The ide-scsi driver sets max_lun to a value greater than under
certain conditions:

        if ((drive->id->last_lun & 0x7) != 7)
                host->max_lun = (drive->id->last_lun & 0x7) + 1;
        else
                host->max_lun = 1;

last_lun is Word 126 of IDENTIFY PACKET DEVICE, marked as obsolete
and undocumented in non-ancient specs.  We'll leave it out for now.
Should the need arise to support multi-LUN ATAPI devices, we'll
probably want to add the above code.

Finally, there have been reports of REPORT LUNS commands locking up
ATAPI drives.  Eliminating the wildcard LUN scan could help reduce
the trouble from problematic drives.

drivers/scsi/libata-scsi.c

index 4fc0134d4272d86b0eb3b48fe0a6659a3b874748..8295a656e521f65af1a6058097866e85167dfcdd 100644 (file)
@@ -1680,13 +1680,17 @@ void ata_scsi_simulate(u16 *id,
 
 void ata_scsi_scan_host(struct ata_port *ap)
 {
+       struct ata_device *dev;
        unsigned int i;
 
        if (ap->flags & ATA_FLAG_PORT_DISABLED)
                return;
 
-       for (i = 0; i < ATA_MAX_DEVICES; i++)
-               if (ata_dev_present(&ap->device[i]))
-                       scsi_scan_target(&ap->host->shost_gendev, 0, i, ~0, 0);
+       for (i = 0; i < ATA_MAX_DEVICES; i++) {
+               dev = &ap->device[i];
+
+               if (ata_dev_present(dev))
+                       scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
+       }
 }