Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62014
b: refs/heads/master
c: 1ae4631
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Jul 20, 2007
1 parent 721d546 commit b36b50a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f1545154a5c96590b1992aac8ee1e2c445e301ed
refs/heads/master: 1ae463171cc1b1ea6dad7bcb298e96c073e7373e
2 changes: 1 addition & 1 deletion trunk/drivers/ata/libata-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -6453,7 +6453,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];

ata_scsi_scan_host(ap);
ata_scsi_scan_host(ap, 1);
}

return 0;
Expand Down
63 changes: 47 additions & 16 deletions trunk/drivers/ata/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2947,17 +2947,22 @@ int ata_scsi_add_hosts(struct ata_host *host, struct scsi_host_template *sht)
return rc;
}

void ata_scsi_scan_host(struct ata_port *ap)
void ata_scsi_scan_host(struct ata_port *ap, int sync)
{
int tries = 5;
struct ata_device *last_failed_dev = NULL;
struct ata_device *dev;
unsigned int i;

if (ap->flags & ATA_FLAG_DISABLED)
return;

repeat:
for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i];
struct scsi_device *sdev;

dev = &ap->device[i];

if (!ata_dev_enabled(dev) || dev->sdev)
continue;

Expand All @@ -2967,6 +2972,45 @@ void ata_scsi_scan_host(struct ata_port *ap)
scsi_device_put(sdev);
}
}

/* If we scanned while EH was in progress or allocation
* failure occurred, scan would have failed silently. Check
* whether all devices are attached.
*/
for (i = 0; i < ATA_MAX_DEVICES; i++) {
dev = &ap->device[i];
if (ata_dev_enabled(dev) && !dev->sdev)
break;
}
if (i == ATA_MAX_DEVICES)
return;

/* we're missing some SCSI devices */
if (sync) {
/* If caller requested synchrnous scan && we've made
* any progress, sleep briefly and repeat.
*/
if (dev != last_failed_dev) {
msleep(100);
last_failed_dev = dev;
goto repeat;
}

/* We might be failing to detect boot device, give it
* a few more chances.
*/
if (--tries) {
msleep(100);
goto repeat;
}

ata_port_printk(ap, KERN_ERR, "WARNING: synchronous SCSI scan "
"failed without making any progress,\n"
" switching to async\n");
}

queue_delayed_work(ata_aux_wq, &ap->hotplug_task,
round_jiffies_relative(HZ));
}

/**
Expand Down Expand Up @@ -3093,20 +3137,7 @@ void ata_scsi_hotplug(struct work_struct *work)
}

/* scan for new ones */
ata_scsi_scan_host(ap);

/* If we scanned while EH was in progress, scan would have
* failed silently. Requeue if there are enabled but
* unattached devices.
*/
for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i];
if (ata_dev_enabled(dev) && !dev->sdev) {
queue_delayed_work(ata_aux_wq, &ap->hotplug_task,
round_jiffies_relative(HZ));
break;
}
}
ata_scsi_scan_host(ap, 0);

DPRINTK("EXIT\n");
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/ata/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static inline int ata_acpi_on_devcfg(struct ata_device *adev) { return 0; }
/* libata-scsi.c */
extern int ata_scsi_add_hosts(struct ata_host *host,
struct scsi_host_template *sht);
extern void ata_scsi_scan_host(struct ata_port *ap);
extern void ata_scsi_scan_host(struct ata_port *ap, int sync);
extern int ata_scsi_offline_dev(struct ata_device *dev);
extern void ata_scsi_hotplug(struct work_struct *work);
extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
Expand Down

0 comments on commit b36b50a

Please sign in to comment.