From 2fdfc7c6dcb209deb801c6cef1e057580051dfa4 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Thu, 29 Jan 2009 20:31:34 +0900 Subject: [PATCH] --- yaml --- r: 130815 b: refs/heads/master c: c2c7a89c5eabaea8c0c2aa0c1069e510144513ab h: refs/heads/master i: 130813: 83e4d2e77251ae4876f89ff009a9c0fd8627cc42 130811: f6cee8138986f164aaa0b7557cc7376362fb40d9 130807: 2b71bb00730aa560f0e6100ce91e0f758a94e63e 130799: 684f09ea419bfc58197a05e136209de717ef40b6 130783: 719f019bd5af7a857c21d1c331edd8df8e13b5c7 130751: 4b63be376ff55b52dfd057f20708b3ec0312be9c 130687: b1ab60a419ef903cb782bb8109798127f7e7d808 130559: 8813e85455b51189188fd60e81270afea0483bca v: v3 --- [refs] | 2 +- trunk/drivers/ata/libata-eh.c | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index ea249b49e6e1..65d61dcaed5e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a07d499b4759881db1359dd8812eecd00b0e0a28 +refs/heads/master: c2c7a89c5eabaea8c0c2aa0c1069e510144513ab diff --git a/trunk/drivers/ata/libata-eh.c b/trunk/drivers/ata/libata-eh.c index 685509bc7ff0..caa1e9fde3c9 100644 --- a/trunk/drivers/ata/libata-eh.c +++ b/trunk/drivers/ata/libata-eh.c @@ -82,6 +82,10 @@ enum { ATA_EH_FASTDRAIN_INTERVAL = 3000, ATA_EH_UA_TRIES = 5, + + /* probe speed down parameters, see ata_eh_schedule_probe() */ + ATA_EH_PROBE_TRIAL_INTERVAL = 60000, /* 1 min */ + ATA_EH_PROBE_TRIALS = 2, }; /* The following table determines how we sequence resets. Each entry @@ -2975,9 +2979,24 @@ static int ata_eh_skip_recovery(struct ata_link *link) return 1; } +static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg) +{ + u64 interval = msecs_to_jiffies(ATA_EH_PROBE_TRIAL_INTERVAL); + u64 now = get_jiffies_64(); + int *trials = void_arg; + + if (ent->timestamp < now - min(now, interval)) + return -1; + + (*trials)++; + return 0; +} + static int ata_eh_schedule_probe(struct ata_device *dev) { struct ata_eh_context *ehc = &dev->link->eh_context; + struct ata_link *link = ata_dev_phys_link(dev); + int trials = 0; if (!(ehc->i.probe_mask & (1 << dev->devno)) || (ehc->did_probe_mask & (1 << dev->devno))) @@ -2990,6 +3009,25 @@ static int ata_eh_schedule_probe(struct ata_device *dev) ehc->saved_xfer_mode[dev->devno] = 0; ehc->saved_ncq_enabled &= ~(1 << dev->devno); + /* Record and count probe trials on the ering. The specific + * error mask used is irrelevant. Because a successful device + * detection clears the ering, this count accumulates only if + * there are consecutive failed probes. + * + * If the count is equal to or higher than ATA_EH_PROBE_TRIALS + * in the last ATA_EH_PROBE_TRIAL_INTERVAL, link speed is + * forced to 1.5Gbps. + * + * This is to work around cases where failed link speed + * negotiation results in device misdetection leading to + * infinite DEVXCHG or PHRDY CHG events. + */ + ata_ering_record(&dev->ering, 0, AC_ERR_OTHER); + ata_ering_map(&dev->ering, ata_count_probe_trials_cb, &trials); + + if (trials > ATA_EH_PROBE_TRIALS) + sata_down_spd_limit(link, 1); + return 1; }