Merge branch 'for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
[sfrench/cifs-2.6.git] / drivers / ata / libata-eh.c
index ece6fd91a947674f6f9c8cb46e46f5c4c22a1a86..11c3137d7b0af5dda9cc3c45364f7677d7fa892d 100644 (file)
@@ -2264,8 +2264,8 @@ static void ata_eh_link_autopsy(struct ata_link *link)
                if (dev->flags & ATA_DFLAG_DUBIOUS_XFER)
                        eflags |= ATA_EFLAG_DUBIOUS_XFER;
                ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask);
+               trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
        }
-       trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
        DPRINTK("EXIT\n");
 }
 
@@ -3454,9 +3454,9 @@ static int ata_eh_maybe_retry_flush(struct ata_device *dev)
  *     @r_failed_dev: out parameter for failed device
  *
  *     Enable SATA Interface power management.  This will enable
- *     Device Interface Power Management (DIPM) for min_power
- *     policy, and then call driver specific callbacks for
- *     enabling Host Initiated Power management.
+ *     Device Interface Power Management (DIPM) for min_power and
+ *     medium_power_with_dipm policies, and then call driver specific
+ *     callbacks for enabling Host Initiated Power management.
  *
  *     LOCKING:
  *     EH context.
@@ -3502,7 +3502,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
                        hints &= ~ATA_LPM_HIPM;
 
                /* disable DIPM before changing link config */
-               if (policy != ATA_LPM_MIN_POWER && dipm) {
+               if (policy < ATA_LPM_MED_POWER_WITH_DIPM && dipm) {
                        err_mask = ata_dev_set_feature(dev,
                                        SETFEATURES_SATA_DISABLE, SATA_DIPM);
                        if (err_mask && err_mask != AC_ERR_DEV) {
@@ -3545,7 +3545,7 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
 
        /* host config updated, enable DIPM if transitioning to MIN_POWER */
        ata_for_each_dev(dev, link, ENABLED) {
-               if (policy == ATA_LPM_MIN_POWER && !no_dipm &&
+               if (policy >= ATA_LPM_MED_POWER_WITH_DIPM && !no_dipm &&
                    ata_id_has_dipm(dev->id)) {
                        err_mask = ata_dev_set_feature(dev,
                                        SETFEATURES_SATA_ENABLE, SATA_DIPM);
@@ -3711,9 +3711,11 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
        case -ENODEV:
                /* device missing or wrong IDENTIFY data, schedule probing */
                ehc->i.probe_mask |= (1 << dev->devno);
+               /* fall through */
        case -EINVAL:
                /* give it just one more chance */
                ehc->tries[dev->devno] = min(ehc->tries[dev->devno], 1);
+               /* fall through */
        case -EIO:
                if (ehc->tries[dev->devno] == 1) {
                        /* This is the last chance, better to slow