]> err.no Git - linux-2.6/blobdiff - drivers/ata/libata-eh.c
ata_piix: SATA 2port controller port map fix
[linux-2.6] / drivers / ata / libata-eh.c
index 687419b6670867ca794e69a3cfc660876683cee6..2eaa39fc65d031d5f44519e3ec43e9a80d3cb34b 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <linux/kernel.h>
+#include <linux/pci.h>
 #include <scsi/scsi.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_eh.h>
@@ -1249,7 +1250,7 @@ static unsigned int ata_read_log_page(struct ata_device *dev,
        tf.protocol = ATA_PROT_PIO;
 
        err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
-                                    buf, sectors * ATA_SECT_SIZE);
+                                    buf, sectors * ATA_SECT_SIZE, 0);
 
        DPRINTK("EXIT, err_mask=%x\n", err_mask);
        return err_mask;
@@ -1363,7 +1364,7 @@ static unsigned int atapi_eh_request_sense(struct ata_queued_cmd *qc)
        }
 
        return ata_exec_internal(dev, &tf, cdb, DMA_FROM_DEVICE,
-                                sense_buf, SCSI_SENSE_BUFFERSIZE);
+                                sense_buf, SCSI_SENSE_BUFFERSIZE, 0);
 }
 
 /**
@@ -1868,6 +1869,9 @@ static void ata_eh_link_report(struct ata_link *link)
        char tries_buf[6];
        int tag, nr_failed = 0;
 
+       if (ehc->i.flags & ATA_EHI_QUIET)
+               return;
+
        desc = NULL;
        if (ehc->i.desc[0] != '\0')
                desc = ehc->i.desc;
@@ -1911,6 +1915,27 @@ static void ata_eh_link_report(struct ata_link *link)
                        ata_link_printk(link, KERN_ERR, "%s\n", desc);
        }
 
+       if (ehc->i.serror)
+               ata_port_printk(ap, 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 " : "",
+                 ehc->i.serror & SERR_DATA ? "UnrecovData " : "",
+                 ehc->i.serror & SERR_PERSISTENT ? "Persist " : "",
+                 ehc->i.serror & SERR_PROTOCOL ? "Proto " : "",
+                 ehc->i.serror & SERR_INTERNAL ? "HostInt " : "",
+                 ehc->i.serror & SERR_PHYRDY_CHG ? "PHYRdyChg " : "",
+                 ehc->i.serror & SERR_PHY_INT_ERR ? "PHYInt " : "",
+                 ehc->i.serror & SERR_COMM_WAKE ? "CommWake " : "",
+                 ehc->i.serror & SERR_10B_8B_ERR ? "10B8B " : "",
+                 ehc->i.serror & SERR_DISPARITY ? "Dispar " : "",
+                 ehc->i.serror & SERR_CRC ? "BadCRC " : "",
+                 ehc->i.serror & SERR_HANDSHAKE ? "Handshk " : "",
+                 ehc->i.serror & SERR_LINK_SEQ_ERR ? "LinkSeq " : "",
+                 ehc->i.serror & SERR_TRANS_ST_ERROR ? "TrStaTrns " : "",
+                 ehc->i.serror & SERR_UNRECOG_FIS ? "UnrecFIS " : "",
+                 ehc->i.serror & SERR_DEV_XCHG ? "DevExch " : "" );
+
        for (tag = 0; tag < ATA_MAX_QUEUE; tag++) {
                static const char *dma_str[] = {
                        [DMA_BIDIRECTIONAL]     = "bidi",
@@ -1942,6 +1967,30 @@ static void ata_eh_link_report(struct ata_link *link)
                        res->hob_lbal, res->hob_lbam, res->hob_lbah,
                        res->device, qc->err_mask, ata_err_string(qc->err_mask),
                        qc->err_mask & AC_ERR_NCQ ? " <F>" : "");
+
+               if (res->command & (ATA_BUSY | ATA_DRDY | ATA_DF | ATA_DRQ |
+                                   ATA_ERR) ) {
+                       if (res->command & ATA_BUSY)
+                               ata_dev_printk(qc->dev, KERN_ERR,
+                                 "status: { Busy }\n" );
+                       else
+                               ata_dev_printk(qc->dev, KERN_ERR,
+                                 "status: { %s%s%s%s}\n",
+                                 res->command & ATA_DRDY ? "DRDY " : "",
+                                 res->command & ATA_DF ? "DF " : "",
+                                 res->command & ATA_DRQ ? "DRQ " : "",
+                                 res->command & ATA_ERR ? "ERR " : "" );
+               }
+
+               if (cmd->command != ATA_CMD_PACKET &&
+                   (res->feature & (ATA_ICRC | ATA_UNC | ATA_IDNF |
+                                    ATA_ABORTED)))
+                       ata_dev_printk(qc->dev, KERN_ERR,
+                         "error: { %s%s%s%s}\n",
+                         res->feature & ATA_ICRC ? "ICRC " : "",
+                         res->feature & ATA_UNC ? "UNC " : "",
+                         res->feature & ATA_IDNF ? "IDNF " : "",
+                         res->feature & ATA_ABORTED ? "ABRT " : "" );
        }
 }
 
@@ -2015,6 +2064,7 @@ int ata_eh_reset(struct ata_link *link, int classify,
                 ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
                 ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
 {
+       struct ata_port *ap = link->ap;
        struct ata_eh_context *ehc = &link->eh_context;
        unsigned int *classes = ehc->classes;
        int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
@@ -2023,9 +2073,14 @@ int ata_eh_reset(struct ata_link *link, int classify,
        unsigned long deadline;
        unsigned int action;
        ata_reset_fn_t reset;
+       unsigned long flags;
        int rc;
 
        /* about to reset */
+       spin_lock_irqsave(ap->lock, flags);
+       ap->pflags |= ATA_PFLAG_RESETTING;
+       spin_unlock_irqrestore(ap->lock, flags);
+
        ata_eh_about_to_do(link, NULL, ehc->i.action & ATA_EH_RESET_MASK);
 
        /* Determine which reset to use and record in ehc->i.action.
@@ -2135,7 +2190,8 @@ int ata_eh_reset(struct ata_link *link, int classify,
                                "(errno=%d), retrying in %u secs\n",
                                rc, (jiffies_to_msecs(delta) + 999) / 1000);
 
-                       schedule_timeout_uninterruptible(delta);
+                       while (delta)
+                               delta = schedule_timeout_uninterruptible(delta);
                }
 
                if (rc == -EPIPE ||
@@ -2182,6 +2238,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
  out:
        /* clear hotplug flag */
        ehc->i.flags &= ~ATA_EHI_HOTPLUGGED;
+
+       spin_lock_irqsave(ap->lock, flags);
+       ap->pflags &= ~ATA_PFLAG_RESETTING;
+       spin_unlock_irqrestore(ap->lock, flags);
+
        return rc;
 }
 
@@ -2209,6 +2270,8 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
                        readid_flags |= ATA_READID_POSTRESET;
 
                if ((action & ATA_EH_REVALIDATE) && ata_dev_enabled(dev)) {
+                       WARN_ON(dev->class == ATA_DEV_PMP);
+
                        if (ata_link_offline(link)) {
                                rc = -EIO;
                                goto err;
@@ -2234,8 +2297,11 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
                           ata_class_enabled(ehc->classes[dev->devno])) {
                        dev->class = ehc->classes[dev->devno];
 
-                       rc = ata_dev_read_id(dev, &dev->class, readid_flags,
-                                            dev->id);
+                       if (dev->class == ATA_DEV_PMP)
+                               rc = sata_pmp_attach(dev);
+                       else
+                               rc = ata_dev_read_id(dev, &dev->class,
+                                                    readid_flags, dev->id);
                        switch (rc) {
                        case 0:
                                new_mask |= 1 << dev->devno;
@@ -2264,7 +2330,8 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,
         * device detection messages backwards.
         */
        ata_link_for_each_dev(dev, link) {
-               if (!(new_mask & (1 << dev->devno)))
+               if (!(new_mask & (1 << dev->devno)) ||
+                   dev->class == ATA_DEV_PMP)
                        continue;
 
                ehc->i.flags |= ATA_EHI_PRINTINFO;
@@ -2491,7 +2558,11 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
 
        /* reset */
        if (reset) {
-               ata_eh_freeze_port(ap);
+               /* if PMP is attached, this function only deals with
+                * downstream links, port should stay thawed.
+                */
+               if (!ap->nr_pmp_links)
+                       ata_eh_freeze_port(ap);
 
                ata_port_for_each_link(link, ap) {
                        struct ata_eh_context *ehc = &link->eh_context;
@@ -2509,7 +2580,8 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
                        }
                }
 
-               ata_eh_thaw_port(ap);
+               if (!ap->nr_pmp_links)
+                       ata_eh_thaw_port(ap);
        }
 
        /* the rest */
@@ -2521,6 +2593,12 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
                if (rc)
                        goto dev_fail;
 
+               /* if PMP got attached, return, pmp EH will take care of it */
+               if (link->device->class == ATA_DEV_PMP) {
+                       ehc->i.action = 0;
+                       return 0;
+               }
+
                /* configure transfer mode if necessary */
                if (ehc->i.flags & ATA_EHI_SETMODE) {
                        rc = ata_set_mode(link, &dev);
@@ -2538,8 +2616,14 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
                if (ata_eh_handle_dev_fail(dev, rc))
                        nr_disabled_devs++;
 
-               if (ap->pflags & ATA_PFLAG_FROZEN)
+               if (ap->pflags & ATA_PFLAG_FROZEN) {
+                       /* PMP reset requires working host port.
+                        * Can't retry if it's frozen.
+                        */
+                       if (ap->nr_pmp_links)
+                               goto out;
                        break;
+               }
        }
 
        if (nr_failed_devs) {