aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-01-29 06:31:34 -0500
committerJeff Garzik <jgarzik@redhat.com>2009-02-02 23:03:34 -0500
commitc2c7a89c5eabaea8c0c2aa0c1069e510144513ab (patch)
tree4cec432ebd36a103e366d56d2d62221674df5a99 /drivers/ata
parenta07d499b4759881db1359dd8812eecd00b0e0a28 (diff)
libata: improve probe failure handling
When link is flaky at high speed, it isn't uncommon for a device to repeatedly fail probing sequence early after successfully negotiating high link speed. This often leads to consecutive hotplug events without successful probing. This patch improves libata EH such that it remembers probing trials and if there have been more than two unsuccessful trials in the past 60 seconds, slows down link speed to 1.5Gbps. As link speed negotiation is the duty of the PHY layer proper, the goal of this fallback mechanism is to provide the last resort when everything else fails, which unfortunately happens not too infrequently, so no fancy 6->3->1.5 speeding down or highest successful transmission speed seen kind of logics (yet). Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/libata-eh.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 685509bc7ff0..caa1e9fde3c9 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -82,6 +82,10 @@ enum {
82 ATA_EH_FASTDRAIN_INTERVAL = 3000, 82 ATA_EH_FASTDRAIN_INTERVAL = 3000,
83 83
84 ATA_EH_UA_TRIES = 5, 84 ATA_EH_UA_TRIES = 5,
85
86 /* probe speed down parameters, see ata_eh_schedule_probe() */
87 ATA_EH_PROBE_TRIAL_INTERVAL = 60000, /* 1 min */
88 ATA_EH_PROBE_TRIALS = 2,
85}; 89};
86 90
87/* The following table determines how we sequence resets. Each entry 91/* The following table determines how we sequence resets. Each entry
@@ -2975,9 +2979,24 @@ static int ata_eh_skip_recovery(struct ata_link *link)
2975 return 1; 2979 return 1;
2976} 2980}
2977 2981
2982static int ata_count_probe_trials_cb(struct ata_ering_entry *ent, void *void_arg)
2983{
2984 u64 interval = msecs_to_jiffies(ATA_EH_PROBE_TRIAL_INTERVAL);
2985 u64 now = get_jiffies_64();
2986 int *trials = void_arg;
2987
2988 if (ent->timestamp < now - min(now, interval))
2989 return -1;
2990
2991 (*trials)++;
2992 return 0;
2993}
2994
2978static int ata_eh_schedule_probe(struct ata_device *dev) 2995static int ata_eh_schedule_probe(struct ata_device *dev)
2979{ 2996{
2980 struct ata_eh_context *ehc = &dev->link->eh_context; 2997 struct ata_eh_context *ehc = &dev->link->eh_context;
2998 struct ata_link *link = ata_dev_phys_link(dev);
2999 int trials = 0;
2981 3000
2982 if (!(ehc->i.probe_mask & (1 << dev->devno)) || 3001 if (!(ehc->i.probe_mask & (1 << dev->devno)) ||
2983 (ehc->did_probe_mask & (1 << dev->devno))) 3002 (ehc->did_probe_mask & (1 << dev->devno)))
@@ -2990,6 +3009,25 @@ static int ata_eh_schedule_probe(struct ata_device *dev)
2990 ehc->saved_xfer_mode[dev->devno] = 0; 3009 ehc->saved_xfer_mode[dev->devno] = 0;
2991 ehc->saved_ncq_enabled &= ~(1 << dev->devno); 3010 ehc->saved_ncq_enabled &= ~(1 << dev->devno);
2992 3011
3012 /* Record and count probe trials on the ering. The specific
3013 * error mask used is irrelevant. Because a successful device
3014 * detection clears the ering, this count accumulates only if
3015 * there are consecutive failed probes.
3016 *
3017 * If the count is equal to or higher than ATA_EH_PROBE_TRIALS
3018 * in the last ATA_EH_PROBE_TRIAL_INTERVAL, link speed is
3019 * forced to 1.5Gbps.
3020 *
3021 * This is to work around cases where failed link speed
3022 * negotiation results in device misdetection leading to
3023 * infinite DEVXCHG or PHRDY CHG events.
3024 */
3025 ata_ering_record(&dev->ering, 0, AC_ERR_OTHER);
3026 ata_ering_map(&dev->ering, ata_count_probe_trials_cb, &trials);
3027
3028 if (trials > ATA_EH_PROBE_TRIALS)
3029 sata_down_spd_limit(link, 1);
3030
2993 return 1; 3031 return 1;
2994} 3032}
2995 3033