]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/ata/libata-eh.c
block: unify request timeout handling
[mirror_ubuntu-artful-kernel.git] / drivers / ata / libata-eh.c
index 58bdc538d229d400b78fd2c0a46317c1a84d943c..bd0b2bc76f1077761fb1aa56d4d238305468abb6 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/blkdev.h>
 #include <linux/pci.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
@@ -457,29 +458,29 @@ static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev,
  *     RETURNS:
  *     EH_HANDLED or EH_NOT_HANDLED
  */
-enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
+enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd)
 {
        struct Scsi_Host *host = cmd->device->host;
        struct ata_port *ap = ata_shost_to_port(host);
        unsigned long flags;
        struct ata_queued_cmd *qc;
-       enum scsi_eh_timer_return ret;
+       enum blk_eh_timer_return ret;
 
        DPRINTK("ENTER\n");
 
        if (ap->ops->error_handler) {
-               ret = EH_NOT_HANDLED;
+               ret = BLK_EH_NOT_HANDLED;
                goto out;
        }
 
-       ret = EH_HANDLED;
+       ret = BLK_EH_HANDLED;
        spin_lock_irqsave(ap->lock, flags);
        qc = ata_qc_from_tag(ap, ap->link.active_tag);
        if (qc) {
                WARN_ON(qc->scsicmd != cmd);
                qc->flags |= ATA_QCFLAG_EH_SCHEDULED;
                qc->err_mask |= AC_ERR_TIMEOUT;
-               ret = EH_NOT_HANDLED;
+               ret = BLK_EH_NOT_HANDLED;
        }
        spin_unlock_irqrestore(ap->lock, flags);
 
@@ -831,7 +832,7 @@ void ata_qc_schedule_eh(struct ata_queued_cmd *qc)
         * Note that ATA_QCFLAG_FAILED is unconditionally set after
         * this function completes.
         */
-       scsi_req_abort_cmd(qc->scsicmd);
+       blk_abort_request(qc->scsicmd->request);
 }
 
 /**
@@ -2040,7 +2041,7 @@ static void ata_eh_link_report(struct ata_link *link)
        }
 
        if (ehc->i.serror)
-               ata_port_printk(ap, KERN_ERR,
+               ata_link_printk(link, KERN_ERR,
                  "SError: { %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}\n",
                  ehc->i.serror & SERR_DATA_RECOVERED ? "RecovData " : "",
                  ehc->i.serror & SERR_COMM_RECOVERED ? "RecovComm " : "",
@@ -2171,18 +2172,12 @@ static int ata_do_reset(struct ata_link *link, ata_reset_fn_t reset,
 }
 
 static int ata_eh_followup_srst_needed(struct ata_link *link,
-                                      int rc, int classify,
-                                      const unsigned int *classes)
+                                      int rc, const unsigned int *classes)
 {
        if ((link->flags & ATA_LFLAG_NO_SRST) || ata_link_offline(link))
                return 0;
-       if (rc == -EAGAIN) {
-               if (classify)
-                       return 1;
-               rc = 0;
-       }
-       if (rc != 0)
-               return 0;
+       if (rc == -EAGAIN)
+               return 1;
        if (sata_pmp_supported(link->ap) && ata_is_host_link(link))
                return 1;
        return 0;
@@ -2210,6 +2205,10 @@ int ata_eh_reset(struct ata_link *link, int classify,
         */
        while (ata_eh_reset_timeouts[max_tries] != ULONG_MAX)
                max_tries++;
+       if (link->flags & ATA_LFLAG_NO_HRST)
+               hardreset = NULL;
+       if (link->flags & ATA_LFLAG_NO_SRST)
+               softreset = NULL;
 
        now = jiffies;
        deadline = ata_deadline(ehc->last_reset, ATA_EH_RESET_COOL_DOWN);
@@ -2247,10 +2246,10 @@ int ata_eh_reset(struct ata_link *link, int classify,
        ehc->i.action &= ~ATA_EH_RESET;
        if (hardreset) {
                reset = hardreset;
-               ehc->i.action = ATA_EH_HARDRESET;
+               ehc->i.action |= ATA_EH_HARDRESET;
        } else if (softreset) {
                reset = softreset;
-               ehc->i.action = ATA_EH_SOFTRESET;
+               ehc->i.action |= ATA_EH_SOFTRESET;
        }
 
        if (prereset) {
@@ -2305,9 +2304,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
                        ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
 
                rc = ata_do_reset(link, reset, classes, deadline);
+               if (rc && rc != -EAGAIN)
+                       goto fail;
 
                if (reset == hardreset &&
-                   ata_eh_followup_srst_needed(link, rc, classify, classes)) {
+                   ata_eh_followup_srst_needed(link, rc, classes)) {
                        /* okay, let's do follow-up softreset */
                        reset = softreset;
 
@@ -2322,10 +2323,6 @@ int ata_eh_reset(struct ata_link *link, int classify,
                        ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
                        rc = ata_do_reset(link, reset, classes, deadline);
                }
-
-               /* -EAGAIN can happen if we skipped followup SRST */
-               if (rc && rc != -EAGAIN)
-                       goto fail;
        } else {
                if (verbose)
                        ata_link_printk(link, KERN_INFO, "no reset method "