]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/ahci.c
[SCSI] iscsi update: rm conn lock
[linux-2.6-omap-h63xx.git] / drivers / scsi / ahci.c
index 4e96ec5f2ff94f003a5fe06ee75d92ae5603ec54..a800fb51168b0bb64b0540fdb133545ac881e4cf 100644 (file)
@@ -48,7 +48,7 @@
 #include <asm/io.h>
 
 #define DRV_NAME       "ahci"
-#define DRV_VERSION    "1.01"
+#define DRV_VERSION    "1.2"
 
 
 enum {
@@ -214,7 +214,6 @@ static struct scsi_host_template ahci_sht = {
        .dma_boundary           = AHCI_DMA_BOUNDARY,
        .slave_configure        = ata_scsi_slave_config,
        .bios_param             = ata_std_bios_param,
-       .ordered_flush          = 1,
 };
 
 static const struct ata_port_operations ahci_ops = {
@@ -243,7 +242,7 @@ static const struct ata_port_operations ahci_ops = {
        .port_stop              = ahci_port_stop,
 };
 
-static struct ata_port_info ahci_port_info[] = {
+static const struct ata_port_info ahci_port_info[] = {
        /* board_ahci */
        {
                .sht            = &ahci_sht,
@@ -277,6 +276,20 @@ static const struct pci_device_id ahci_pci_tbl[] = {
          board_ahci }, /* ESB2 */
        { PCI_VENDOR_ID_INTEL, 0x27c6, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
          board_ahci }, /* ICH7-M DH */
+       { PCI_VENDOR_ID_INTEL, 0x2821, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* ICH8 */
+       { PCI_VENDOR_ID_INTEL, 0x2822, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* ICH8 */
+       { PCI_VENDOR_ID_INTEL, 0x2824, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* ICH8 */
+       { PCI_VENDOR_ID_INTEL, 0x2829, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* ICH8M */
+       { PCI_VENDOR_ID_INTEL, 0x282a, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* ICH8M */
+       { 0x197b, 0x2360, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* JMicron JMB360 */
+       { 0x197b, 0x2363, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+         board_ahci }, /* JMicron JMB363 */
        { }     /* terminate list */
 };
 
@@ -558,13 +571,26 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
        pp->cmd_slot[0].opts |= cpu_to_le32(n_elem << 16);
 }
 
-static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
+static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
 {
        void __iomem *mmio = ap->host_set->mmio_base;
        void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
        u32 tmp;
        int work;
 
+       if ((ap->device[0].class != ATA_DEV_ATAPI) ||
+           ((irq_stat & PORT_IRQ_TF_ERR) == 0))
+               printk(KERN_WARNING "ata%u: port reset, "
+                      "p_is %x is %x pis %x cmd %x tf %x ss %x se %x\n",
+                       ap->id,
+                       irq_stat,
+                       readl(mmio + HOST_IRQ_STAT),
+                       readl(port_mmio + PORT_IRQ_STAT),
+                       readl(port_mmio + PORT_CMD),
+                       readl(port_mmio + PORT_TFDATA),
+                       readl(port_mmio + PORT_SCR_STAT),
+                       readl(port_mmio + PORT_SCR_ERR));
+
        /* stop DMA */
        tmp = readl(port_mmio + PORT_CMD);
        tmp &= ~PORT_CMD_START;
@@ -602,8 +628,6 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
        tmp |= PORT_CMD_START;
        writel(tmp, port_mmio + PORT_CMD);
        readl(port_mmio + PORT_CMD); /* flush */
-
-       printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->id);
 }
 
 static void ahci_eng_timeout(struct ata_port *ap)
@@ -614,17 +638,17 @@ static void ahci_eng_timeout(struct ata_port *ap)
        struct ata_queued_cmd *qc;
        unsigned long flags;
 
-       DPRINTK("ENTER\n");
+       printk(KERN_WARNING "ata%u: handling error/timeout\n", ap->id);
 
        spin_lock_irqsave(&host_set->lock, flags);
 
-       ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
-
        qc = ata_qc_from_tag(ap, ap->active_tag);
        if (!qc) {
                printk(KERN_ERR "ata%u: BUG: timeout without command\n",
                       ap->id);
        } else {
+               ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT));
+
                /* hack alert!  We cannot use the supplied completion
                 * function from inside the ->eh_strategy_handler() thread.
                 * libata is the only user of ->eh_strategy_handler() in
@@ -632,7 +656,8 @@ static void ahci_eng_timeout(struct ata_port *ap)
                 * not being called from the SCSI EH.
                 */
                qc->scsidone = scsi_finish_command;
-               ata_qc_complete(qc, AC_ERR_OTHER);
+               qc->err_mask |= AC_ERR_OTHER;
+               ata_qc_complete(qc);
        }
 
        spin_unlock_irqrestore(&host_set->lock, flags);
@@ -653,15 +678,28 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
        ci = readl(port_mmio + PORT_CMD_ISSUE);
        if (likely((ci & 0x1) == 0)) {
                if (qc) {
-                       ata_qc_complete(qc, 0);
+                       assert(qc->err_mask == 0);
+                       ata_qc_complete(qc);
                        qc = NULL;
                }
        }
 
        if (status & PORT_IRQ_FATAL) {
-               ahci_intr_error(ap, status);
-               if (qc)
-                       ata_qc_complete(qc, AC_ERR_OTHER);
+               unsigned int err_mask;
+               if (status & PORT_IRQ_TF_ERR)
+                       err_mask = AC_ERR_DEV;
+               else if (status & PORT_IRQ_IF_ERR)
+                       err_mask = AC_ERR_ATA_BUS;
+               else
+                       err_mask = AC_ERR_HOST_BUS;
+
+               /* command processing has stopped due to error; restart */
+               ahci_restart_port(ap, status);
+
+               if (qc) {
+                       qc->err_mask |= AC_ERR_OTHER;
+                       ata_qc_complete(qc);
+               }
        }
 
        return 1;
@@ -768,7 +806,6 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
        struct pci_dev *pdev = to_pci_dev(probe_ent->dev);
        void __iomem *mmio = probe_ent->mmio_base;
        u32 tmp, cap_save;
-       u16 tmp16;
        unsigned int i, j, using_dac;
        int rc;
        void __iomem *port_mmio;
@@ -802,9 +839,13 @@ static int ahci_host_init(struct ata_probe_ent *probe_ent)
        writel(0xf, mmio + HOST_PORTS_IMPL);
        (void) readl(mmio + HOST_PORTS_IMPL);   /* flush */
 
-       pci_read_config_word(pdev, 0x92, &tmp16);
-       tmp16 |= 0xf;
-       pci_write_config_word(pdev, 0x92, tmp16);
+       if (pdev->vendor == PCI_VENDOR_ID_INTEL) {
+               u16 tmp16;
+
+               pci_read_config_word(pdev, 0x92, &tmp16);
+               tmp16 |= 0xf;
+               pci_write_config_word(pdev, 0x92, tmp16);
+       }
 
        hpriv->cap = readl(mmio + HOST_CAP);
        hpriv->port_map = readl(mmio + HOST_PORTS_IMPL);
@@ -1048,6 +1089,10 @@ static int ahci_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        if (have_msi)
                hpriv->flags |= AHCI_FLAG_MSI;
 
+       /* JMicron-specific fixup: make sure we're in AHCI mode */
+       if (pdev->vendor == 0x197b)
+               pci_write_config_byte(pdev, 0x41, 0xa1);
+
        /* initialize adapter */
        rc = ahci_host_init(probe_ent);
        if (rc)