diff options
Diffstat (limited to 'drivers/ata/libata-eh.c')
-rw-r--r-- | drivers/ata/libata-eh.c | 254 |
1 files changed, 219 insertions, 35 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index e48302eae55f..5e590504f3aa 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -57,6 +57,7 @@ enum { | |||
57 | /* error flags */ | 57 | /* error flags */ |
58 | ATA_EFLAG_IS_IO = (1 << 0), | 58 | ATA_EFLAG_IS_IO = (1 << 0), |
59 | ATA_EFLAG_DUBIOUS_XFER = (1 << 1), | 59 | ATA_EFLAG_DUBIOUS_XFER = (1 << 1), |
60 | ATA_EFLAG_OLD_ER = (1 << 31), | ||
60 | 61 | ||
61 | /* error categories */ | 62 | /* error categories */ |
62 | ATA_ECAT_NONE = 0, | 63 | ATA_ECAT_NONE = 0, |
@@ -396,14 +397,9 @@ static struct ata_ering_entry *ata_ering_top(struct ata_ering *ering) | |||
396 | return NULL; | 397 | return NULL; |
397 | } | 398 | } |
398 | 399 | ||
399 | static void ata_ering_clear(struct ata_ering *ering) | 400 | int ata_ering_map(struct ata_ering *ering, |
400 | { | 401 | int (*map_fn)(struct ata_ering_entry *, void *), |
401 | memset(ering, 0, sizeof(*ering)); | 402 | void *arg) |
402 | } | ||
403 | |||
404 | static int ata_ering_map(struct ata_ering *ering, | ||
405 | int (*map_fn)(struct ata_ering_entry *, void *), | ||
406 | void *arg) | ||
407 | { | 403 | { |
408 | int idx, rc = 0; | 404 | int idx, rc = 0; |
409 | struct ata_ering_entry *ent; | 405 | struct ata_ering_entry *ent; |
@@ -422,6 +418,17 @@ static int ata_ering_map(struct ata_ering *ering, | |||
422 | return rc; | 418 | return rc; |
423 | } | 419 | } |
424 | 420 | ||
421 | int ata_ering_clear_cb(struct ata_ering_entry *ent, void *void_arg) | ||
422 | { | ||
423 | ent->eflags |= ATA_EFLAG_OLD_ER; | ||
424 | return 0; | ||
425 | } | ||
426 | |||
427 | static void ata_ering_clear(struct ata_ering *ering) | ||
428 | { | ||
429 | ata_ering_map(ering, ata_ering_clear_cb, NULL); | ||
430 | } | ||
431 | |||
425 | static unsigned int ata_eh_dev_action(struct ata_device *dev) | 432 | static unsigned int ata_eh_dev_action(struct ata_device *dev) |
426 | { | 433 | { |
427 | struct ata_eh_context *ehc = &dev->link->eh_context; | 434 | struct ata_eh_context *ehc = &dev->link->eh_context; |
@@ -456,6 +463,41 @@ static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev, | |||
456 | } | 463 | } |
457 | 464 | ||
458 | /** | 465 | /** |
466 | * ata_eh_acquire - acquire EH ownership | ||
467 | * @ap: ATA port to acquire EH ownership for | ||
468 | * | ||
469 | * Acquire EH ownership for @ap. This is the basic exclusion | ||
470 | * mechanism for ports sharing a host. Only one port hanging off | ||
471 | * the same host can claim the ownership of EH. | ||
472 | * | ||
473 | * LOCKING: | ||
474 | * EH context. | ||
475 | */ | ||
476 | void ata_eh_acquire(struct ata_port *ap) | ||
477 | { | ||
478 | mutex_lock(&ap->host->eh_mutex); | ||
479 | WARN_ON_ONCE(ap->host->eh_owner); | ||
480 | ap->host->eh_owner = current; | ||
481 | } | ||
482 | |||
483 | /** | ||
484 | * ata_eh_release - release EH ownership | ||
485 | * @ap: ATA port to release EH ownership for | ||
486 | * | ||
487 | * Release EH ownership for @ap if the caller. The caller must | ||
488 | * have acquired EH ownership using ata_eh_acquire() previously. | ||
489 | * | ||
490 | * LOCKING: | ||
491 | * EH context. | ||
492 | */ | ||
493 | void ata_eh_release(struct ata_port *ap) | ||
494 | { | ||
495 | WARN_ON_ONCE(ap->host->eh_owner != current); | ||
496 | ap->host->eh_owner = NULL; | ||
497 | mutex_unlock(&ap->host->eh_mutex); | ||
498 | } | ||
499 | |||
500 | /** | ||
459 | * ata_scsi_timed_out - SCSI layer time out callback | 501 | * ata_scsi_timed_out - SCSI layer time out callback |
460 | * @cmd: timed out SCSI command | 502 | * @cmd: timed out SCSI command |
461 | * | 503 | * |
@@ -572,19 +614,19 @@ void ata_scsi_error(struct Scsi_Host *host) | |||
572 | int nr_timedout = 0; | 614 | int nr_timedout = 0; |
573 | 615 | ||
574 | spin_lock_irqsave(ap->lock, flags); | 616 | spin_lock_irqsave(ap->lock, flags); |
575 | 617 | ||
576 | /* This must occur under the ap->lock as we don't want | 618 | /* This must occur under the ap->lock as we don't want |
577 | a polled recovery to race the real interrupt handler | 619 | a polled recovery to race the real interrupt handler |
578 | 620 | ||
579 | The lost_interrupt handler checks for any completed but | 621 | The lost_interrupt handler checks for any completed but |
580 | non-notified command and completes much like an IRQ handler. | 622 | non-notified command and completes much like an IRQ handler. |
581 | 623 | ||
582 | We then fall into the error recovery code which will treat | 624 | We then fall into the error recovery code which will treat |
583 | this as if normal completion won the race */ | 625 | this as if normal completion won the race */ |
584 | 626 | ||
585 | if (ap->ops->lost_interrupt) | 627 | if (ap->ops->lost_interrupt) |
586 | ap->ops->lost_interrupt(ap); | 628 | ap->ops->lost_interrupt(ap); |
587 | 629 | ||
588 | list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) { | 630 | list_for_each_entry_safe(scmd, tmp, &host->eh_cmd_q, eh_entry) { |
589 | struct ata_queued_cmd *qc; | 631 | struct ata_queued_cmd *qc; |
590 | 632 | ||
@@ -628,15 +670,17 @@ void ata_scsi_error(struct Scsi_Host *host) | |||
628 | ap->eh_tries = ATA_EH_MAX_TRIES; | 670 | ap->eh_tries = ATA_EH_MAX_TRIES; |
629 | } else | 671 | } else |
630 | spin_unlock_wait(ap->lock); | 672 | spin_unlock_wait(ap->lock); |
631 | 673 | ||
632 | /* If we timed raced normal completion and there is nothing to | 674 | /* If we timed raced normal completion and there is nothing to |
633 | recover nr_timedout == 0 why exactly are we doing error recovery ? */ | 675 | recover nr_timedout == 0 why exactly are we doing error recovery ? */ |
634 | 676 | ||
635 | repeat: | ||
636 | /* invoke error handler */ | 677 | /* invoke error handler */ |
637 | if (ap->ops->error_handler) { | 678 | if (ap->ops->error_handler) { |
638 | struct ata_link *link; | 679 | struct ata_link *link; |
639 | 680 | ||
681 | /* acquire EH ownership */ | ||
682 | ata_eh_acquire(ap); | ||
683 | repeat: | ||
640 | /* kill fast drain timer */ | 684 | /* kill fast drain timer */ |
641 | del_timer_sync(&ap->fastdrain_timer); | 685 | del_timer_sync(&ap->fastdrain_timer); |
642 | 686 | ||
@@ -711,6 +755,7 @@ void ata_scsi_error(struct Scsi_Host *host) | |||
711 | host->host_eh_scheduled = 0; | 755 | host->host_eh_scheduled = 0; |
712 | 756 | ||
713 | spin_unlock_irqrestore(ap->lock, flags); | 757 | spin_unlock_irqrestore(ap->lock, flags); |
758 | ata_eh_release(ap); | ||
714 | } else { | 759 | } else { |
715 | WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); | 760 | WARN_ON(ata_qc_from_tag(ap, ap->link.active_tag) == NULL); |
716 | ap->ops->eng_timeout(ap); | 761 | ap->ops->eng_timeout(ap); |
@@ -772,7 +817,7 @@ void ata_port_wait_eh(struct ata_port *ap) | |||
772 | 817 | ||
773 | /* make sure SCSI EH is complete */ | 818 | /* make sure SCSI EH is complete */ |
774 | if (scsi_host_in_recovery(ap->scsi_host)) { | 819 | if (scsi_host_in_recovery(ap->scsi_host)) { |
775 | msleep(10); | 820 | ata_msleep(ap, 10); |
776 | goto retry; | 821 | goto retry; |
777 | } | 822 | } |
778 | } | 823 | } |
@@ -1573,9 +1618,9 @@ static void ata_eh_analyze_serror(struct ata_link *link) | |||
1573 | * host links. For disabled PMP links, only N bit is | 1618 | * host links. For disabled PMP links, only N bit is |
1574 | * considered as X bit is left at 1 for link plugging. | 1619 | * considered as X bit is left at 1 for link plugging. |
1575 | */ | 1620 | */ |
1576 | hotplug_mask = 0; | 1621 | if (link->lpm_policy != ATA_LPM_MAX_POWER) |
1577 | 1622 | hotplug_mask = 0; /* hotplug doesn't work w/ LPM */ | |
1578 | if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) | 1623 | else if (!(link->flags & ATA_LFLAG_DISABLED) || ata_is_host_link(link)) |
1579 | hotplug_mask = SERR_PHYRDY_CHG | SERR_DEV_XCHG; | 1624 | hotplug_mask = SERR_PHYRDY_CHG | SERR_DEV_XCHG; |
1580 | else | 1625 | else |
1581 | hotplug_mask = SERR_PHYRDY_CHG; | 1626 | hotplug_mask = SERR_PHYRDY_CHG; |
@@ -1755,7 +1800,7 @@ static int speed_down_verdict_cb(struct ata_ering_entry *ent, void *void_arg) | |||
1755 | struct speed_down_verdict_arg *arg = void_arg; | 1800 | struct speed_down_verdict_arg *arg = void_arg; |
1756 | int cat; | 1801 | int cat; |
1757 | 1802 | ||
1758 | if (ent->timestamp < arg->since) | 1803 | if ((ent->eflags & ATA_EFLAG_OLD_ER) || (ent->timestamp < arg->since)) |
1759 | return -1; | 1804 | return -1; |
1760 | 1805 | ||
1761 | cat = ata_eh_categorize_error(ent->eflags, ent->err_mask, | 1806 | cat = ata_eh_categorize_error(ent->eflags, ent->err_mask, |
@@ -2777,8 +2822,9 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2777 | ata_eh_done(link, NULL, ATA_EH_RESET); | 2822 | ata_eh_done(link, NULL, ATA_EH_RESET); |
2778 | if (slave) | 2823 | if (slave) |
2779 | ata_eh_done(slave, NULL, ATA_EH_RESET); | 2824 | ata_eh_done(slave, NULL, ATA_EH_RESET); |
2780 | ehc->last_reset = jiffies; /* update to completion time */ | 2825 | ehc->last_reset = jiffies; /* update to completion time */ |
2781 | ehc->i.action |= ATA_EH_REVALIDATE; | 2826 | ehc->i.action |= ATA_EH_REVALIDATE; |
2827 | link->lpm_policy = ATA_LPM_UNKNOWN; /* reset LPM state */ | ||
2782 | 2828 | ||
2783 | rc = 0; | 2829 | rc = 0; |
2784 | out: | 2830 | out: |
@@ -2810,8 +2856,10 @@ int ata_eh_reset(struct ata_link *link, int classify, | |||
2810 | "reset failed (errno=%d), retrying in %u secs\n", | 2856 | "reset failed (errno=%d), retrying in %u secs\n", |
2811 | rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); | 2857 | rc, DIV_ROUND_UP(jiffies_to_msecs(delta), 1000)); |
2812 | 2858 | ||
2859 | ata_eh_release(ap); | ||
2813 | while (delta) | 2860 | while (delta) |
2814 | delta = schedule_timeout_uninterruptible(delta); | 2861 | delta = schedule_timeout_uninterruptible(delta); |
2862 | ata_eh_acquire(ap); | ||
2815 | } | 2863 | } |
2816 | 2864 | ||
2817 | if (try == max_tries - 1) { | 2865 | if (try == max_tries - 1) { |
@@ -3204,6 +3252,124 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev) | |||
3204 | return rc; | 3252 | return rc; |
3205 | } | 3253 | } |
3206 | 3254 | ||
3255 | /** | ||
3256 | * ata_eh_set_lpm - configure SATA interface power management | ||
3257 | * @link: link to configure power management | ||
3258 | * @policy: the link power management policy | ||
3259 | * @r_failed_dev: out parameter for failed device | ||
3260 | * | ||
3261 | * Enable SATA Interface power management. This will enable | ||
3262 | * Device Interface Power Management (DIPM) for min_power | ||
3263 | * policy, and then call driver specific callbacks for | ||
3264 | * enabling Host Initiated Power management. | ||
3265 | * | ||
3266 | * LOCKING: | ||
3267 | * EH context. | ||
3268 | * | ||
3269 | * RETURNS: | ||
3270 | * 0 on success, -errno on failure. | ||
3271 | */ | ||
3272 | static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, | ||
3273 | struct ata_device **r_failed_dev) | ||
3274 | { | ||
3275 | struct ata_port *ap = ata_is_host_link(link) ? link->ap : NULL; | ||
3276 | struct ata_eh_context *ehc = &link->eh_context; | ||
3277 | struct ata_device *dev, *link_dev = NULL, *lpm_dev = NULL; | ||
3278 | unsigned int hints = ATA_LPM_EMPTY | ATA_LPM_HIPM; | ||
3279 | unsigned int err_mask; | ||
3280 | int rc; | ||
3281 | |||
3282 | /* if the link or host doesn't do LPM, noop */ | ||
3283 | if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm)) | ||
3284 | return 0; | ||
3285 | |||
3286 | /* | ||
3287 | * DIPM is enabled only for MIN_POWER as some devices | ||
3288 | * misbehave when the host NACKs transition to SLUMBER. Order | ||
3289 | * device and link configurations such that the host always | ||
3290 | * allows DIPM requests. | ||
3291 | */ | ||
3292 | ata_for_each_dev(dev, link, ENABLED) { | ||
3293 | bool hipm = ata_id_has_hipm(dev->id); | ||
3294 | bool dipm = ata_id_has_dipm(dev->id); | ||
3295 | |||
3296 | /* find the first enabled and LPM enabled devices */ | ||
3297 | if (!link_dev) | ||
3298 | link_dev = dev; | ||
3299 | |||
3300 | if (!lpm_dev && (hipm || dipm)) | ||
3301 | lpm_dev = dev; | ||
3302 | |||
3303 | hints &= ~ATA_LPM_EMPTY; | ||
3304 | if (!hipm) | ||
3305 | hints &= ~ATA_LPM_HIPM; | ||
3306 | |||
3307 | /* disable DIPM before changing link config */ | ||
3308 | if (policy != ATA_LPM_MIN_POWER && dipm) { | ||
3309 | err_mask = ata_dev_set_feature(dev, | ||
3310 | SETFEATURES_SATA_DISABLE, SATA_DIPM); | ||
3311 | if (err_mask && err_mask != AC_ERR_DEV) { | ||
3312 | ata_dev_printk(dev, KERN_WARNING, | ||
3313 | "failed to disable DIPM, Emask 0x%x\n", | ||
3314 | err_mask); | ||
3315 | rc = -EIO; | ||
3316 | goto fail; | ||
3317 | } | ||
3318 | } | ||
3319 | } | ||
3320 | |||
3321 | if (ap) { | ||
3322 | rc = ap->ops->set_lpm(link, policy, hints); | ||
3323 | if (!rc && ap->slave_link) | ||
3324 | rc = ap->ops->set_lpm(ap->slave_link, policy, hints); | ||
3325 | } else | ||
3326 | rc = sata_pmp_set_lpm(link, policy, hints); | ||
3327 | |||
3328 | /* | ||
3329 | * Attribute link config failure to the first (LPM) enabled | ||
3330 | * device on the link. | ||
3331 | */ | ||
3332 | if (rc) { | ||
3333 | if (rc == -EOPNOTSUPP) { | ||
3334 | link->flags |= ATA_LFLAG_NO_LPM; | ||
3335 | return 0; | ||
3336 | } | ||
3337 | dev = lpm_dev ? lpm_dev : link_dev; | ||
3338 | goto fail; | ||
3339 | } | ||
3340 | |||
3341 | /* host config updated, enable DIPM if transitioning to MIN_POWER */ | ||
3342 | ata_for_each_dev(dev, link, ENABLED) { | ||
3343 | if (policy == ATA_LPM_MIN_POWER && ata_id_has_dipm(dev->id)) { | ||
3344 | err_mask = ata_dev_set_feature(dev, | ||
3345 | SETFEATURES_SATA_ENABLE, SATA_DIPM); | ||
3346 | if (err_mask && err_mask != AC_ERR_DEV) { | ||
3347 | ata_dev_printk(dev, KERN_WARNING, | ||
3348 | "failed to enable DIPM, Emask 0x%x\n", | ||
3349 | err_mask); | ||
3350 | rc = -EIO; | ||
3351 | goto fail; | ||
3352 | } | ||
3353 | } | ||
3354 | } | ||
3355 | |||
3356 | link->lpm_policy = policy; | ||
3357 | if (ap && ap->slave_link) | ||
3358 | ap->slave_link->lpm_policy = policy; | ||
3359 | return 0; | ||
3360 | |||
3361 | fail: | ||
3362 | /* if no device or only one more chance is left, disable LPM */ | ||
3363 | if (!dev || ehc->tries[dev->devno] <= 2) { | ||
3364 | ata_link_printk(link, KERN_WARNING, | ||
3365 | "disabling LPM on the link\n"); | ||
3366 | link->flags |= ATA_LFLAG_NO_LPM; | ||
3367 | } | ||
3368 | if (r_failed_dev) | ||
3369 | *r_failed_dev = dev; | ||
3370 | return rc; | ||
3371 | } | ||
3372 | |||
3207 | static int ata_link_nr_enabled(struct ata_link *link) | 3373 | static int ata_link_nr_enabled(struct ata_link *link) |
3208 | { | 3374 | { |
3209 | struct ata_device *dev; | 3375 | struct ata_device *dev; |
@@ -3288,6 +3454,16 @@ static int ata_eh_schedule_probe(struct ata_device *dev) | |||
3288 | ehc->saved_xfer_mode[dev->devno] = 0; | 3454 | ehc->saved_xfer_mode[dev->devno] = 0; |
3289 | ehc->saved_ncq_enabled &= ~(1 << dev->devno); | 3455 | ehc->saved_ncq_enabled &= ~(1 << dev->devno); |
3290 | 3456 | ||
3457 | /* the link maybe in a deep sleep, wake it up */ | ||
3458 | if (link->lpm_policy > ATA_LPM_MAX_POWER) { | ||
3459 | if (ata_is_host_link(link)) | ||
3460 | link->ap->ops->set_lpm(link, ATA_LPM_MAX_POWER, | ||
3461 | ATA_LPM_EMPTY); | ||
3462 | else | ||
3463 | sata_pmp_set_lpm(link, ATA_LPM_MAX_POWER, | ||
3464 | ATA_LPM_EMPTY); | ||
3465 | } | ||
3466 | |||
3291 | /* Record and count probe trials on the ering. The specific | 3467 | /* Record and count probe trials on the ering. The specific |
3292 | * error mask used is irrelevant. Because a successful device | 3468 | * error mask used is irrelevant. Because a successful device |
3293 | * detection clears the ering, this count accumulates only if | 3469 | * detection clears the ering, this count accumulates only if |
@@ -3389,8 +3565,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3389 | { | 3565 | { |
3390 | struct ata_link *link; | 3566 | struct ata_link *link; |
3391 | struct ata_device *dev; | 3567 | struct ata_device *dev; |
3392 | int nr_failed_devs; | 3568 | int rc, nr_fails; |
3393 | int rc; | ||
3394 | unsigned long flags, deadline; | 3569 | unsigned long flags, deadline; |
3395 | 3570 | ||
3396 | DPRINTK("ENTER\n"); | 3571 | DPRINTK("ENTER\n"); |
@@ -3431,7 +3606,6 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3431 | 3606 | ||
3432 | retry: | 3607 | retry: |
3433 | rc = 0; | 3608 | rc = 0; |
3434 | nr_failed_devs = 0; | ||
3435 | 3609 | ||
3436 | /* if UNLOADING, finish immediately */ | 3610 | /* if UNLOADING, finish immediately */ |
3437 | if (ap->pflags & ATA_PFLAG_UNLOADING) | 3611 | if (ap->pflags & ATA_PFLAG_UNLOADING) |
@@ -3501,8 +3675,10 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3501 | if (time_before_eq(deadline, now)) | 3675 | if (time_before_eq(deadline, now)) |
3502 | break; | 3676 | break; |
3503 | 3677 | ||
3678 | ata_eh_release(ap); | ||
3504 | deadline = wait_for_completion_timeout(&ap->park_req_pending, | 3679 | deadline = wait_for_completion_timeout(&ap->park_req_pending, |
3505 | deadline - now); | 3680 | deadline - now); |
3681 | ata_eh_acquire(ap); | ||
3506 | } while (deadline); | 3682 | } while (deadline); |
3507 | ata_for_each_link(link, ap, EDGE) { | 3683 | ata_for_each_link(link, ap, EDGE) { |
3508 | ata_for_each_dev(dev, link, ALL) { | 3684 | ata_for_each_dev(dev, link, ALL) { |
@@ -3516,13 +3692,17 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3516 | } | 3692 | } |
3517 | 3693 | ||
3518 | /* the rest */ | 3694 | /* the rest */ |
3519 | ata_for_each_link(link, ap, EDGE) { | 3695 | nr_fails = 0; |
3696 | ata_for_each_link(link, ap, PMP_FIRST) { | ||
3520 | struct ata_eh_context *ehc = &link->eh_context; | 3697 | struct ata_eh_context *ehc = &link->eh_context; |
3521 | 3698 | ||
3699 | if (sata_pmp_attached(ap) && ata_is_host_link(link)) | ||
3700 | goto config_lpm; | ||
3701 | |||
3522 | /* revalidate existing devices and attach new ones */ | 3702 | /* revalidate existing devices and attach new ones */ |
3523 | rc = ata_eh_revalidate_and_attach(link, &dev); | 3703 | rc = ata_eh_revalidate_and_attach(link, &dev); |
3524 | if (rc) | 3704 | if (rc) |
3525 | goto dev_fail; | 3705 | goto rest_fail; |
3526 | 3706 | ||
3527 | /* if PMP got attached, return, pmp EH will take care of it */ | 3707 | /* if PMP got attached, return, pmp EH will take care of it */ |
3528 | if (link->device->class == ATA_DEV_PMP) { | 3708 | if (link->device->class == ATA_DEV_PMP) { |
@@ -3534,7 +3714,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3534 | if (ehc->i.flags & ATA_EHI_SETMODE) { | 3714 | if (ehc->i.flags & ATA_EHI_SETMODE) { |
3535 | rc = ata_set_mode(link, &dev); | 3715 | rc = ata_set_mode(link, &dev); |
3536 | if (rc) | 3716 | if (rc) |
3537 | goto dev_fail; | 3717 | goto rest_fail; |
3538 | ehc->i.flags &= ~ATA_EHI_SETMODE; | 3718 | ehc->i.flags &= ~ATA_EHI_SETMODE; |
3539 | } | 3719 | } |
3540 | 3720 | ||
@@ -3547,7 +3727,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3547 | continue; | 3727 | continue; |
3548 | rc = atapi_eh_clear_ua(dev); | 3728 | rc = atapi_eh_clear_ua(dev); |
3549 | if (rc) | 3729 | if (rc) |
3550 | goto dev_fail; | 3730 | goto rest_fail; |
3551 | } | 3731 | } |
3552 | } | 3732 | } |
3553 | 3733 | ||
@@ -3557,21 +3737,25 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, | |||
3557 | continue; | 3737 | continue; |
3558 | rc = ata_eh_maybe_retry_flush(dev); | 3738 | rc = ata_eh_maybe_retry_flush(dev); |
3559 | if (rc) | 3739 | if (rc) |
3560 | goto dev_fail; | 3740 | goto rest_fail; |
3561 | } | 3741 | } |
3562 | 3742 | ||
3743 | config_lpm: | ||
3563 | /* configure link power saving */ | 3744 | /* configure link power saving */ |
3564 | if (ehc->i.action & ATA_EH_LPM) | 3745 | if (link->lpm_policy != ap->target_lpm_policy) { |
3565 | ata_for_each_dev(dev, link, ALL) | 3746 | rc = ata_eh_set_lpm(link, ap->target_lpm_policy, &dev); |
3566 | ata_dev_enable_pm(dev, ap->pm_policy); | 3747 | if (rc) |
3748 | goto rest_fail; | ||
3749 | } | ||
3567 | 3750 | ||
3568 | /* this link is okay now */ | 3751 | /* this link is okay now */ |
3569 | ehc->i.flags = 0; | 3752 | ehc->i.flags = 0; |
3570 | continue; | 3753 | continue; |
3571 | 3754 | ||
3572 | dev_fail: | 3755 | rest_fail: |
3573 | nr_failed_devs++; | 3756 | nr_fails++; |
3574 | ata_eh_handle_dev_fail(dev, rc); | 3757 | if (dev) |
3758 | ata_eh_handle_dev_fail(dev, rc); | ||
3575 | 3759 | ||
3576 | if (ap->pflags & ATA_PFLAG_FROZEN) { | 3760 | if (ap->pflags & ATA_PFLAG_FROZEN) { |
3577 | /* PMP reset requires working host port. | 3761 | /* PMP reset requires working host port. |
@@ -3583,7 +3767,7 @@ dev_fail: | |||
3583 | } | 3767 | } |
3584 | } | 3768 | } |
3585 | 3769 | ||
3586 | if (nr_failed_devs) | 3770 | if (nr_fails) |
3587 | goto retry; | 3771 | goto retry; |
3588 | 3772 | ||
3589 | out: | 3773 | out: |