Merge tag 'mac80211-for-davem-2016-06-09' of git://git.kernel.org/pub/scm/linux/kerne...
[cascardo/linux.git] / drivers / ata / libata-eh.c
index e4e0e2e..61dc7a9 100644 (file)
@@ -1660,7 +1660,7 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc,
                return;
        }
 
-       if (!cmd)
+       if (!cmd || qc->flags & ATA_QCFLAG_SENSE_VALID)
                return;
 
        if (!ata_id_sense_reporting_enabled(dev->id)) {
@@ -1679,7 +1679,7 @@ static void ata_eh_request_sense(struct ata_queued_cmd *qc,
        err_mask = ata_exec_internal(dev, &tf, NULL, DMA_NONE, NULL, 0, 0);
        /* Ignore err_mask; ATA_ERR might be set */
        if (tf.command & ATA_SENSE) {
-               ata_scsi_set_sense(cmd, tf.lbah, tf.lbam, tf.lbal);
+               ata_scsi_set_sense(dev, cmd, tf.lbah, tf.lbam, tf.lbal);
                qc->flags |= ATA_QCFLAG_SENSE_VALID;
        } else {
                ata_dev_warn(dev, "request sense failed stat %02x emask %x\n",
@@ -1849,13 +1849,13 @@ void ata_eh_analyze_ncq_error(struct ata_link *link)
        memcpy(&qc->result_tf, &tf, sizeof(tf));
        qc->result_tf.flags = ATA_TFLAG_ISADDR | ATA_TFLAG_LBA | ATA_TFLAG_LBA48;
        qc->err_mask |= AC_ERR_DEV | AC_ERR_NCQ;
-       if (qc->result_tf.auxiliary) {
+       if ((qc->result_tf.command & ATA_SENSE) || qc->result_tf.auxiliary) {
                char sense_key, asc, ascq;
 
                sense_key = (qc->result_tf.auxiliary >> 16) & 0xff;
                asc = (qc->result_tf.auxiliary >> 8) & 0xff;
                ascq = qc->result_tf.auxiliary & 0xff;
-               ata_scsi_set_sense(qc->scsicmd, sense_key, asc, ascq);
+               ata_scsi_set_sense(dev, qc->scsicmd, sense_key, asc, ascq);
                ata_scsi_set_sense_information(dev, qc->scsicmd,
                                               &qc->result_tf);
                qc->flags |= ATA_QCFLAG_SENSE_VALID;
@@ -1920,20 +1920,31 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc,
                        tmp = atapi_eh_request_sense(qc->dev,
                                                qc->scsicmd->sense_buffer,
                                                qc->result_tf.feature >> 4);
-                       if (!tmp) {
-                               /* ATA_QCFLAG_SENSE_VALID is used to
-                                * tell atapi_qc_complete() that sense
-                                * data is already valid.
-                                *
-                                * TODO: interpret sense data and set
-                                * appropriate err_mask.
-                                */
+                       if (!tmp)
                                qc->flags |= ATA_QCFLAG_SENSE_VALID;
-                       else
+                       else
                                qc->err_mask |= tmp;
                }
        }
 
+       if (qc->flags & ATA_QCFLAG_SENSE_VALID) {
+               int ret = scsi_check_sense(qc->scsicmd);
+               /*
+                * SUCCESS here means that the sense code could
+                * evaluated and should be passed to the upper layers
+                * for correct evaluation.
+                * FAILED means the sense code could not interpreted
+                * and the device would need to be reset.
+                * NEEDS_RETRY and ADD_TO_MLQUEUE means that the
+                * command would need to be retried.
+                */
+               if (ret == NEEDS_RETRY || ret == ADD_TO_MLQUEUE) {
+                       qc->flags |= ATA_QCFLAG_RETRY;
+                       qc->err_mask |= AC_ERR_OTHER;
+               } else if (ret != SUCCESS) {
+                       qc->err_mask |= AC_ERR_HSM;
+               }
+       }
        if (qc->err_mask & (AC_ERR_HSM | AC_ERR_TIMEOUT | AC_ERR_ATA_BUS))
                action |= ATA_EH_RESET;
 
@@ -2471,6 +2482,8 @@ const char *ata_get_cmd_descript(u8 command)
                { ATA_CMD_CFA_WRITE_MULT_NE,    "CFA WRITE MULTIPLE WITHOUT ERASE" },
                { ATA_CMD_REQ_SENSE_DATA,       "REQUEST SENSE DATA EXT" },
                { ATA_CMD_SANITIZE_DEVICE,      "SANITIZE DEVICE" },
+               { ATA_CMD_ZAC_MGMT_IN,          "ZAC MANAGEMENT IN" },
+               { ATA_CMD_ZAC_MGMT_OUT,         "ZAC MANAGEMENT OUT" },
                { ATA_CMD_READ_LONG,            "READ LONG (with retries)" },
                { ATA_CMD_READ_LONG_ONCE,       "READ LONG (without retries)" },
                { ATA_CMD_WRITE_LONG,           "WRITE LONG (with retries)" },