Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101328
b: refs/heads/master
c: 0a2c0f5
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Jul 14, 2008
1 parent ee9fb78 commit 0b0da63
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 29 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: 341c2c958ec7bdd9f54733a8b0b432fe76842a82
refs/heads/master: 0a2c0f56159999e20015241d3b8fa89b1ab14309
38 changes: 20 additions & 18 deletions trunk/drivers/ata/libata-eh.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ enum {
ATA_ECAT_DUBIOUS_UNK_DEV = 7,
ATA_ECAT_NR = 8,

/* always put at least this amount of time between resets */
ATA_EH_RESET_COOL_DOWN = 5000,

/* Waiting in ->prereset can never be reliable. It's
* sometimes nice to wait there but it can't be depended upon;
* otherwise, we wouldn't be resetting. Just give it enough
Expand Down Expand Up @@ -485,6 +488,9 @@ void ata_scsi_error(struct Scsi_Host *host)
if (ata_ncq_enabled(dev))
ehc->saved_ncq_enabled |= 1 << devno;
}

/* set last reset timestamp to some time in the past */
ehc->last_reset = jiffies - 60 * HZ;
}

ap->pflags |= ATA_PFLAG_EH_IN_PROGRESS;
Expand Down Expand Up @@ -2088,11 +2094,17 @@ int ata_eh_reset(struct ata_link *link, int classify,
/*
* Prepare to reset
*/
now = jiffies;
deadline = ata_deadline(ehc->last_reset, ATA_EH_RESET_COOL_DOWN);
if (time_before(now, deadline))
schedule_timeout_uninterruptible(deadline - now);

spin_lock_irqsave(ap->lock, flags);
ap->pflags |= ATA_PFLAG_RESETTING;
spin_unlock_irqrestore(ap->lock, flags);

ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
ehc->last_reset = jiffies;

ata_link_for_each_dev(dev, link) {
/* If we issue an SRST then an ATA drive (not ATAPI)
Expand Down Expand Up @@ -2158,6 +2170,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
/*
* Perform reset
*/
ehc->last_reset = jiffies;
if (ata_is_host_link(link))
ata_eh_freeze_port(ap);

Expand Down Expand Up @@ -2278,6 +2291,7 @@ int ata_eh_reset(struct ata_link *link, int classify,

/* reset successful, schedule revalidation */
ata_eh_done(link, NULL, ATA_EH_RESET);
ehc->last_reset = jiffies;
ehc->i.action |= ATA_EH_REVALIDATE;

rc = 0;
Expand All @@ -2304,9 +2318,9 @@ int ata_eh_reset(struct ata_link *link, int classify,
if (time_before(now, deadline)) {
unsigned long delta = deadline - now;

ata_link_printk(link, KERN_WARNING, "reset failed "
"(errno=%d), retrying in %u secs\n",
rc, (jiffies_to_msecs(delta) + 999) / 1000);
ata_link_printk(link, KERN_WARNING,
"reset failed (errno=%d), retrying in %u secs\n",
rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000));

while (delta)
delta = schedule_timeout_uninterruptible(delta);
Expand Down Expand Up @@ -2623,7 +2637,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
{
struct ata_link *link;
struct ata_device *dev;
int nr_failed_devs, nr_disabled_devs;
int nr_failed_devs;
int rc;
unsigned long flags;

Expand Down Expand Up @@ -2666,7 +2680,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
retry:
rc = 0;
nr_failed_devs = 0;
nr_disabled_devs = 0;

/* if UNLOADING, finish immediately */
if (ap->pflags & ATA_PFLAG_UNLOADING)
Expand Down Expand Up @@ -2733,8 +2746,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,

dev_fail:
nr_failed_devs++;
if (ata_eh_handle_dev_fail(dev, rc))
nr_disabled_devs++;
ata_eh_handle_dev_fail(dev, rc);

if (ap->pflags & ATA_PFLAG_FROZEN) {
/* PMP reset requires working host port.
Expand All @@ -2746,18 +2758,8 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
}
}

if (nr_failed_devs) {
if (nr_failed_devs != nr_disabled_devs) {
ata_port_printk(ap, KERN_WARNING, "failed to recover "
"some devices, retrying in 5 secs\n");
ssleep(5);
} else {
/* no device left to recover, repeat fast */
msleep(500);
}

if (nr_failed_devs)
goto retry;
}

out:
if (rc && r_failed_link)
Expand Down
10 changes: 0 additions & 10 deletions trunk/drivers/ata/libata-pmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,19 +727,12 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,
}

if (tries) {
int sleep = ehc->i.flags & ATA_EHI_DID_RESET;

/* consecutive revalidation failures? speed down */
if (reval_failed)
sata_down_spd_limit(link);
else
reval_failed = 1;

ata_dev_printk(dev, KERN_WARNING,
"retrying reset%s\n",
sleep ? " in 5 secs" : "");
if (sleep)
ssleep(5);
ehc->i.action |= ATA_EH_RESET;
goto retry;
} else {
Expand Down Expand Up @@ -991,10 +984,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap)
goto retry;

if (--pmp_tries) {
ata_port_printk(ap, KERN_WARNING,
"failed to recover PMP, retrying in 5 secs\n");
pmp_ehc->i.action |= ATA_EH_RESET;
ssleep(5);
goto retry;
}

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/libata.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ struct ata_eh_context {
unsigned int did_probe_mask;
unsigned int saved_ncq_enabled;
u8 saved_xfer_mode[ATA_MAX_DEVICES];
/* timestamp for the last reset attempt or success */
unsigned long last_reset;
};

struct ata_acpi_drive
Expand Down

0 comments on commit 0b0da63

Please sign in to comment.