From russb@emc.com Mon Aug 15 12:22:45 2005 From: russb@emc.com (Brett M Russ) To: Greg KH CC: Jeff Garzik , Subject: [PATCH 2.6.13-rc6] PCI/libata INTx cleanup Message-Id: <20050815192341.6600220FF7@lns1058.lss.emc.com> Date: Mon, 15 Aug 2005 15:23:41 -0400 (EDT) Simple cleanup to eliminate X copies of the pci_enable_intx() function in libata. Moved ahci.c's pci_intx() to pci.c and use it throughout libata and msi.c. Signed-off-by: Brett Russ Signed-off-by: Greg Kroah-Hartman --- drivers/pci/msi.c | 10 ++-------- drivers/pci/pci.c | 26 ++++++++++++++++++++++++++ drivers/scsi/ahci.c | 16 ---------------- drivers/scsi/ata_piix.c | 14 +------------- drivers/scsi/sata_sis.c | 14 +------------- drivers/scsi/sata_uli.c | 14 +------------- include/linux/pci.h | 1 + 7 files changed, 32 insertions(+), 63 deletions(-) --- gregkh-2.6.orig/drivers/scsi/sata_sis.c 2005-08-15 11:58:12.000000000 -0700 +++ gregkh-2.6/drivers/scsi/sata_sis.c 2005-08-15 23:36:08.000000000 -0700 @@ -186,18 +186,6 @@ outl(val, ap->ioaddr.scr_addr + (sc_reg * 4)); } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_enable_intx(struct pci_dev *pdev) -{ - u16 pci_command; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - if (pci_command & PCI_COMMAND_INTX_DISABLE) { - pci_command &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_command); - } -} - static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { struct ata_probe_ent *probe_ent = NULL; @@ -254,7 +242,7 @@ } pci_set_master(pdev); - pci_enable_intx(pdev); + pci_intx(pdev, 1); /* FIXME: check ata_device_add return value */ ata_device_add(probe_ent); --- gregkh-2.6.orig/drivers/scsi/ahci.c 2005-08-15 11:58:12.000000000 -0700 +++ gregkh-2.6/drivers/scsi/ahci.c 2005-08-15 23:36:08.000000000 -0700 @@ -862,22 +862,6 @@ return 0; } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_intx(struct pci_dev *pdev, int enable) -{ - u16 pci_command, new; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - - if (enable) - new = pci_command & ~PCI_COMMAND_INTX_DISABLE; - else - new = pci_command | PCI_COMMAND_INTX_DISABLE; - - if (new != pci_command) - pci_write_config_word(pdev, PCI_COMMAND, pci_command); -} - static void ahci_print_info(struct ata_probe_ent *probe_ent) { struct ahci_host_priv *hpriv = probe_ent->private_data; --- gregkh-2.6.orig/drivers/scsi/ata_piix.c 2005-08-15 11:58:12.000000000 -0700 +++ gregkh-2.6/drivers/scsi/ata_piix.c 2005-08-15 23:36:08.000000000 -0700 @@ -548,18 +548,6 @@ } } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_enable_intx(struct pci_dev *pdev) -{ - u16 pci_command; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - if (pci_command & PCI_COMMAND_INTX_DISABLE) { - pci_command &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_command); - } -} - #define AHCI_PCI_BAR 5 #define AHCI_GLOBAL_CTL 0x04 #define AHCI_ENABLE (1 << 31) @@ -658,7 +646,7 @@ * message-signalled interrupts currently). */ if (port_info[0]->host_flags & PIIX_FLAG_CHECKINTR) - pci_enable_intx(pdev); + pci_intx(pdev, 1); if (combined) { port_info[sata_chan] = &piix_port_info[ent->driver_data]; --- gregkh-2.6.orig/drivers/pci/msi.c 2005-08-15 23:35:41.000000000 -0700 +++ gregkh-2.6/drivers/pci/msi.c 2005-08-15 23:36:08.000000000 -0700 @@ -446,10 +446,7 @@ } if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { /* PCI Express Endpoint device detected */ - u16 cmd; - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd |= PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(dev, PCI_COMMAND, cmd); + pci_intx(dev, 0); /* disable intx */ } } @@ -468,10 +465,7 @@ } if (pci_find_capability(dev, PCI_CAP_ID_EXP)) { /* PCI Express Endpoint device detected */ - u16 cmd; - pci_read_config_word(dev, PCI_COMMAND, &cmd); - cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(dev, PCI_COMMAND, cmd); + pci_intx(dev, 1); /* enable intx */ } } --- gregkh-2.6.orig/drivers/pci/pci.c 2005-08-15 23:35:52.000000000 -0700 +++ gregkh-2.6/drivers/pci/pci.c 2005-08-15 23:36:08.000000000 -0700 @@ -796,6 +796,31 @@ } } +/** + * pci_intx - enables/disables PCI INTx for device dev + * @dev: the PCI device to operate on + * @enable: boolean + * + * Enables/disables PCI INTx for device dev + */ +void +pci_intx(struct pci_dev *pdev, int enable) +{ + u16 pci_command, new; + + pci_read_config_word(pdev, PCI_COMMAND, &pci_command); + + if (enable) { + new = pci_command & ~PCI_COMMAND_INTX_DISABLE; + } else { + new = pci_command | PCI_COMMAND_INTX_DISABLE; + } + + if (new != pci_command) { + pci_write_config_word(pdev, PCI_COMMAND, pci_command); + } +} + #ifndef HAVE_ARCH_PCI_SET_DMA_MASK /* * These can be overridden by arch-specific implementations @@ -873,6 +898,7 @@ EXPORT_SYMBOL(pci_set_master); EXPORT_SYMBOL(pci_set_mwi); EXPORT_SYMBOL(pci_clear_mwi); +EXPORT_SYMBOL_GPL(pci_intx); EXPORT_SYMBOL(pci_set_dma_mask); EXPORT_SYMBOL(pci_set_consistent_dma_mask); EXPORT_SYMBOL(pci_assign_resource); --- gregkh-2.6.orig/include/linux/pci.h 2005-08-15 23:36:02.000000000 -0700 +++ gregkh-2.6/include/linux/pci.h 2005-08-15 23:36:08.000000000 -0700 @@ -382,6 +382,7 @@ #define HAVE_PCI_SET_MWI int pci_set_mwi(struct pci_dev *dev); void pci_clear_mwi(struct pci_dev *dev); +void pci_intx(struct pci_dev *dev, int enable); int pci_set_dma_mask(struct pci_dev *dev, u64 mask); int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); --- gregkh-2.6.orig/drivers/scsi/sata_uli.c 2005-08-15 11:58:12.000000000 -0700 +++ gregkh-2.6/drivers/scsi/sata_uli.c 2005-08-15 23:36:08.000000000 -0700 @@ -171,18 +171,6 @@ uli_scr_cfg_write(ap, sc_reg, val); } -/* move to PCI layer, integrate w/ MSI stuff */ -static void pci_enable_intx(struct pci_dev *pdev) -{ - u16 pci_command; - - pci_read_config_word(pdev, PCI_COMMAND, &pci_command); - if (pci_command & PCI_COMMAND_INTX_DISABLE) { - pci_command &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(pdev, PCI_COMMAND, pci_command); - } -} - static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) { struct ata_probe_ent *probe_ent; @@ -255,7 +243,7 @@ } pci_set_master(pdev); - pci_enable_intx(pdev); + pci_intx(pdev, 1); /* FIXME: check ata_device_add return value */ ata_device_add(probe_ent);