Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
[pandora-kernel.git] / drivers / scsi / sata_nv.c
index cb832b0..bbbb55e 100644 (file)
  *  NV-specific details such as register offsets, SATA phy location,
  *  hotplug info, etc.
  *
+ *  0.10
+ *     - Fixed spurious interrupts issue seen with the Maxtor 6H500F0 500GB
+ *       drive.  Also made the check_hotplug() callbacks return whether there
+ *       was a hotplug interrupt or not.  This was not the source of the
+ *       spurious interrupts, but is the right thing to do anyway.
+ *
  *  0.09
  *     - Fixed bug introduced by 0.08's MCP51 and MCP55 support.
  *
@@ -61,7 +67,7 @@
 #include <linux/blkdev.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
-#include "scsi.h"
+#include <linux/device.h>
 #include <scsi/scsi_host.h>
 #include <linux/libata.h>
 
@@ -124,10 +130,10 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
 static void nv_host_stop (struct ata_host_set *host_set);
 static void nv_enable_hotplug(struct ata_probe_ent *probe_ent);
 static void nv_disable_hotplug(struct ata_host_set *host_set);
-static void nv_check_hotplug(struct ata_host_set *host_set);
+static int nv_check_hotplug(struct ata_host_set *host_set);
 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent);
 static void nv_disable_hotplug_ck804(struct ata_host_set *host_set);
-static void nv_check_hotplug_ck804(struct ata_host_set *host_set);
+static int nv_check_hotplug_ck804(struct ata_host_set *host_set);
 
 enum nv_host_type
 {
@@ -137,7 +143,7 @@ enum nv_host_type
        CK804
 };
 
-static struct pci_device_id nv_pci_tbl[] = {
+static const struct pci_device_id nv_pci_tbl[] = {
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
                PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
        { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
@@ -176,7 +182,7 @@ struct nv_host_desc
        enum nv_host_type       host_type;
        void                    (*enable_hotplug)(struct ata_probe_ent *probe_ent);
        void                    (*disable_hotplug)(struct ata_host_set *host_set);
-       void                    (*check_hotplug)(struct ata_host_set *host_set);
+       int                     (*check_hotplug)(struct ata_host_set *host_set);
 
 };
 static struct nv_host_desc nv_device_tbl[] = {
@@ -218,7 +224,7 @@ static struct pci_driver nv_pci_driver = {
        .remove                 = ata_pci_remove_one,
 };
 
-static Scsi_Host_Template nv_sht = {
+static struct scsi_host_template nv_sht = {
        .module                 = THIS_MODULE,
        .name                   = DRV_NAME,
        .ioctl                  = ata_scsi_ioctl,
@@ -235,10 +241,9 @@ static Scsi_Host_Template nv_sht = {
        .dma_boundary           = ATA_DMA_BOUNDARY,
        .slave_configure        = ata_scsi_slave_config,
        .bios_param             = ata_std_bios_param,
-       .ordered_flush          = 1,
 };
 
-static struct ata_port_operations nv_ops = {
+static const struct ata_port_operations nv_ops = {
        .port_disable           = ata_port_disable,
        .tf_load                = ata_tf_load,
        .tf_read                = ata_tf_read,
@@ -310,12 +315,16 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
                        qc = ata_qc_from_tag(ap, ap->active_tag);
                        if (qc && (!(qc->tf.ctl & ATA_NIEN)))
                                handled += ata_host_intr(ap, qc);
+                       else
+                               // No request pending?  Clear interrupt status
+                               // anyway, in case there's one pending.
+                               ap->ops->check_status(ap);
                }
 
        }
 
        if (host->host_desc->check_hotplug)
-               host->host_desc->check_hotplug(host_set);
+               handled += host->host_desc->check_hotplug(host_set);
 
        spin_unlock_irqrestore(&host_set->lock, flags);
 
@@ -331,7 +340,7 @@ static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
                return 0xffffffffU;
 
        if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
-               return readl((void*)ap->ioaddr.scr_addr + (sc_reg * 4));
+               return readl((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
        else
                return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
 }
@@ -345,7 +354,7 @@ static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
                return;
 
        if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
-               writel(val, (void*)ap->ioaddr.scr_addr + (sc_reg * 4));
+               writel(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
        else
                outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
 }
@@ -383,7 +392,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
                        return -ENODEV;
 
        if (!printed_version++)
-               printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
+               dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
 
        rc = pci_enable_device(pdev);
        if (rc)
@@ -405,7 +414,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
        rc = -ENOMEM;
 
        ppi = &nv_port_info;
-       probe_ent = ata_pci_init_native_mode(pdev, &ppi);
+       probe_ent = ata_pci_init_native_mode(pdev, &ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
        if (!probe_ent)
                goto err_out_regions;
 
@@ -498,7 +507,7 @@ static void nv_disable_hotplug(struct ata_host_set *host_set)
        outb(intr_mask, host_set->ports[0]->ioaddr.scr_addr + NV_INT_ENABLE);
 }
 
-static void nv_check_hotplug(struct ata_host_set *host_set)
+static int nv_check_hotplug(struct ata_host_set *host_set)
 {
        u8 intr_status;
 
@@ -523,7 +532,11 @@ static void nv_check_hotplug(struct ata_host_set *host_set)
                if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
                        printk(KERN_WARNING "nv_sata: "
                                "Secondary device removed\n");
+
+               return 1;
        }
+
+       return 0;
 }
 
 static void nv_enable_hotplug_ck804(struct ata_probe_ent *probe_ent)
@@ -561,7 +574,7 @@ static void nv_disable_hotplug_ck804(struct ata_host_set *host_set)
        pci_write_config_byte(pdev, NV_MCP_SATA_CFG_20, regval);
 }
 
-static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
+static int nv_check_hotplug_ck804(struct ata_host_set *host_set)
 {
        u8 intr_status;
 
@@ -586,7 +599,11 @@ static void nv_check_hotplug_ck804(struct ata_host_set *host_set)
                if (intr_status & NV_INT_STATUS_SDEV_REMOVED)
                        printk(KERN_WARNING "nv_sata: "
                                "Secondary device removed\n");
+
+               return 1;
        }
+
+       return 0;
 }
 
 static int __init nv_init(void)