diff options
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/ata/libata-eh.c | 38 |
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 | ||
| 2982 | static 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 | |||
| 2978 | static int ata_eh_schedule_probe(struct ata_device *dev) | 2995 | static 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 | ||
