aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRandy Dunlap <randy.dunlap@oracle.com>2007-07-09 14:55:54 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-11 19:02:11 -0400
commit694625c0b322905d6892fad873029f764cd4823f (patch)
treec48ac2c0095f2ac4044bd12b27ea318eb6156c73
parentf5609d7e679db3f29433f56e1f2e397a2f815288 (diff)
PCI: add pci_try_set_mwi
As suggested by Andrew, add pci_try_set_mwi(), which does not require return-value checking. - add pci_try_set_mwi() without __must_check - make it return 0 on success, errno if the "try" failed or error - review callers Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--Documentation/pci.txt5
-rw-r--r--drivers/ata/pata_cs5530.c2
-rw-r--r--drivers/ide/pci/cs5530.c2
-rw-r--r--drivers/net/cassini.c4
-rw-r--r--drivers/net/starfire.c2
-rw-r--r--drivers/net/tulip/tulip_core.c2
-rw-r--r--drivers/net/wireless/prism54/islpci_hotplug.c3
-rw-r--r--drivers/pci/pci.c28
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c5
-rw-r--r--drivers/usb/gadget/net2280.c2
-rw-r--r--include/linux/pci.h1
11 files changed, 38 insertions, 18 deletions
diff --git a/Documentation/pci.txt b/Documentation/pci.txt
index 7d3da30ff0b4..7754f5aea4e9 100644
--- a/Documentation/pci.txt
+++ b/Documentation/pci.txt
@@ -296,7 +296,10 @@ If the PCI device can use the PCI Memory-Write-Invalidate transaction,
296call pci_set_mwi(). This enables the PCI_COMMAND bit for Mem-Wr-Inval 296call pci_set_mwi(). This enables the PCI_COMMAND bit for Mem-Wr-Inval
297and also ensures that the cache line size register is set correctly. 297and also ensures that the cache line size register is set correctly.
298Check the return value of pci_set_mwi() as not all architectures 298Check the return value of pci_set_mwi() as not all architectures
299or chip-sets may support Memory-Write-Invalidate. 299or chip-sets may support Memory-Write-Invalidate. Alternatively,
300if Mem-Wr-Inval would be nice to have but is not required, call
301pci_try_set_mwi() to have the system do its best effort at enabling
302Mem-Wr-Inval.
300 303
301 304
3023.2 Request MMIO/IOP resources 3053.2 Request MMIO/IOP resources
diff --git a/drivers/ata/pata_cs5530.c b/drivers/ata/pata_cs5530.c
index 3fca5898642b..68f150a1e2f4 100644
--- a/drivers/ata/pata_cs5530.c
+++ b/drivers/ata/pata_cs5530.c
@@ -266,7 +266,7 @@ static int cs5530_init_chip(void)
266 } 266 }
267 267
268 pci_set_master(cs5530_0); 268 pci_set_master(cs5530_0);
269 pci_set_mwi(cs5530_0); 269 pci_try_set_mwi(cs5530_0);
270 270
271 /* 271 /*
272 * Set PCI CacheLineSize to 16-bytes: 272 * Set PCI CacheLineSize to 16-bytes:
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index 1eec1f308d16..b5c00d15a704 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -236,7 +236,7 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch
236 */ 236 */
237 237
238 pci_set_master(cs5530_0); 238 pci_set_master(cs5530_0);
239 pci_set_mwi(cs5530_0); 239 pci_try_set_mwi(cs5530_0);
240 240
241 /* 241 /*
242 * Set PCI CacheLineSize to 16-bytes: 242 * Set PCI CacheLineSize to 16-bytes:
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 805924fc077a..f6e4030c73d1 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -4917,13 +4917,13 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4917 pci_cmd &= ~PCI_COMMAND_SERR; 4917 pci_cmd &= ~PCI_COMMAND_SERR;
4918 pci_cmd |= PCI_COMMAND_PARITY; 4918 pci_cmd |= PCI_COMMAND_PARITY;
4919 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); 4919 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
4920 if (pci_set_mwi(pdev)) 4920 if (pci_try_set_mwi(pdev))
4921 printk(KERN_WARNING PFX "Could not enable MWI for %s\n", 4921 printk(KERN_WARNING PFX "Could not enable MWI for %s\n",
4922 pci_name(pdev)); 4922 pci_name(pdev));
4923 4923
4924 /* 4924 /*
4925 * On some architectures, the default cache line size set 4925 * On some architectures, the default cache line size set
4926 * by pci_set_mwi reduces perforamnce. We have to increase 4926 * by pci_try_set_mwi reduces perforamnce. We have to increase
4927 * it for this case. To start, we'll print some configuration 4927 * it for this case. To start, we'll print some configuration
4928 * data. 4928 * data.
4929 */ 4929 */
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 786d4b9c07ec..2f69d5c5dfa6 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -740,7 +740,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
740 pci_set_master(pdev); 740 pci_set_master(pdev);
741 741
742 /* enable MWI -- it vastly improves Rx performance on sparc64 */ 742 /* enable MWI -- it vastly improves Rx performance on sparc64 */
743 pci_set_mwi(pdev); 743 pci_try_set_mwi(pdev);
744 744
745#ifdef ZEROCOPY 745#ifdef ZEROCOPY
746 /* Starfire can do TCP/UDP checksumming */ 746 /* Starfire can do TCP/UDP checksumming */
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 1a9e911b86a2..7dcd138b0fed 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1155,7 +1155,7 @@ static void __devinit tulip_mwi_config (struct pci_dev *pdev,
1155 /* set or disable MWI in the standard PCI command bit. 1155 /* set or disable MWI in the standard PCI command bit.
1156 * Check for the case where mwi is desired but not available 1156 * Check for the case where mwi is desired but not available
1157 */ 1157 */
1158 if (csr0 & MWI) pci_set_mwi(pdev); 1158 if (csr0 & MWI) pci_try_set_mwi(pdev);
1159 else pci_clear_mwi(pdev); 1159 else pci_clear_mwi(pdev);
1160 1160
1161 /* read result from hardware (in case bit refused to enable) */ 1161 /* read result from hardware (in case bit refused to enable) */
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index 25d6c80c9bab..af2e4f2405f2 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -166,8 +166,7 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
166 pci_set_master(pdev); 166 pci_set_master(pdev);
167 167
168 /* enable MWI */ 168 /* enable MWI */
169 if (!pci_set_mwi(pdev)) 169 pci_try_set_mwi(pdev);
170 printk(KERN_INFO "%s: pci_set_mwi(pdev) succeeded\n", DRV_NAME);
171 170
172 /* setup the network device interface and its structure */ 171 /* setup the network device interface and its structure */
173 if (!(ndev = islpci_setup(pdev))) { 172 if (!(ndev = islpci_setup(pdev))) {
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d9fc1bd1f3e8..35fa30aa3065 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1186,6 +1186,11 @@ int pci_set_mwi(struct pci_dev *dev)
1186 return 0; 1186 return 0;
1187} 1187}
1188 1188
1189int pci_try_set_mwi(struct pci_dev *dev)
1190{
1191 return 0;
1192}
1193
1189void pci_clear_mwi(struct pci_dev *dev) 1194void pci_clear_mwi(struct pci_dev *dev)
1190{ 1195{
1191} 1196}
@@ -1242,9 +1247,7 @@ pci_set_cacheline_size(struct pci_dev *dev)
1242 * pci_set_mwi - enables memory-write-invalidate PCI transaction 1247 * pci_set_mwi - enables memory-write-invalidate PCI transaction
1243 * @dev: the PCI device for which MWI is enabled 1248 * @dev: the PCI device for which MWI is enabled
1244 * 1249 *
1245 * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND, 1250 * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND.
1246 * and then calls @pcibios_set_mwi to do the needed arch specific
1247 * operations or a generic mwi-prep function.
1248 * 1251 *
1249 * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 1252 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
1250 */ 1253 */
@@ -1260,7 +1263,8 @@ pci_set_mwi(struct pci_dev *dev)
1260 1263
1261 pci_read_config_word(dev, PCI_COMMAND, &cmd); 1264 pci_read_config_word(dev, PCI_COMMAND, &cmd);
1262 if (! (cmd & PCI_COMMAND_INVALIDATE)) { 1265 if (! (cmd & PCI_COMMAND_INVALIDATE)) {
1263 pr_debug("PCI: Enabling Mem-Wr-Inval for device %s\n", pci_name(dev)); 1266 pr_debug("PCI: Enabling Mem-Wr-Inval for device %s\n",
1267 pci_name(dev));
1264 cmd |= PCI_COMMAND_INVALIDATE; 1268 cmd |= PCI_COMMAND_INVALIDATE;
1265 pci_write_config_word(dev, PCI_COMMAND, cmd); 1269 pci_write_config_word(dev, PCI_COMMAND, cmd);
1266 } 1270 }
@@ -1269,6 +1273,21 @@ pci_set_mwi(struct pci_dev *dev)
1269} 1273}
1270 1274
1271/** 1275/**
1276 * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
1277 * @dev: the PCI device for which MWI is enabled
1278 *
1279 * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND.
1280 * Callers are not required to check the return value.
1281 *
1282 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
1283 */
1284int pci_try_set_mwi(struct pci_dev *dev)
1285{
1286 int rc = pci_set_mwi(dev);
1287 return rc;
1288}
1289
1290/**
1272 * pci_clear_mwi - disables Memory-Write-Invalidate for device dev 1291 * pci_clear_mwi - disables Memory-Write-Invalidate for device dev
1273 * @dev: the PCI device to disable 1292 * @dev: the PCI device to disable
1274 * 1293 *
@@ -1600,6 +1619,7 @@ EXPORT_SYMBOL(pci_release_selected_regions);
1600EXPORT_SYMBOL(pci_request_selected_regions); 1619EXPORT_SYMBOL(pci_request_selected_regions);
1601EXPORT_SYMBOL(pci_set_master); 1620EXPORT_SYMBOL(pci_set_master);
1602EXPORT_SYMBOL(pci_set_mwi); 1621EXPORT_SYMBOL(pci_set_mwi);
1622EXPORT_SYMBOL(pci_try_set_mwi);
1603EXPORT_SYMBOL(pci_clear_mwi); 1623EXPORT_SYMBOL(pci_clear_mwi);
1604EXPORT_SYMBOL_GPL(pci_intx); 1624EXPORT_SYMBOL_GPL(pci_intx);
1605EXPORT_SYMBOL(pci_set_dma_mask); 1625EXPORT_SYMBOL(pci_set_dma_mask);
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index dcb4ba0ecee1..955b2e48d041 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -1578,10 +1578,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1578 INIT_LIST_HEAD(&phba->fc_nodes); 1578 INIT_LIST_HEAD(&phba->fc_nodes);
1579 1579
1580 pci_set_master(pdev); 1580 pci_set_master(pdev);
1581 retval = pci_set_mwi(pdev); 1581 pci_try_set_mwi(pdev);
1582 if (retval)
1583 dev_printk(KERN_WARNING, &pdev->dev,
1584 "Warning: pci_set_mwi returned %d\n", retval);
1585 1582
1586 if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0) 1583 if (pci_set_dma_mask(phba->pcidev, DMA_64BIT_MASK) != 0)
1587 if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0) 1584 if (pci_set_dma_mask(phba->pcidev, DMA_32BIT_MASK) != 0)
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index d975ecf18e00..00fda334dc72 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2964,7 +2964,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2964 , &dev->pci->pcimstctl); 2964 , &dev->pci->pcimstctl);
2965 /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */ 2965 /* erratum 0115 shouldn't appear: Linux inits PCI_LATENCY_TIMER */
2966 pci_set_master (pdev); 2966 pci_set_master (pdev);
2967 pci_set_mwi (pdev); 2967 pci_try_set_mwi (pdev);
2968 2968
2969 /* ... also flushes any posted pci writes */ 2969 /* ... also flushes any posted pci writes */
2970 dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff; 2970 dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a6657b7f245d..a5602e26f4dd 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -545,6 +545,7 @@ void pci_set_master(struct pci_dev *dev);
545int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state); 545int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state);
546#define HAVE_PCI_SET_MWI 546#define HAVE_PCI_SET_MWI
547int __must_check pci_set_mwi(struct pci_dev *dev); 547int __must_check pci_set_mwi(struct pci_dev *dev);
548int pci_try_set_mwi(struct pci_dev *dev);
548void pci_clear_mwi(struct pci_dev *dev); 549void pci_clear_mwi(struct pci_dev *dev);
549void pci_intx(struct pci_dev *dev, int enable); 550void pci_intx(struct pci_dev *dev, int enable);
550void pci_msi_off(struct pci_dev *dev); 551void pci_msi_off(struct pci_dev *dev);