aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 16:20:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-12 16:20:24 -0400
commit7550cfab3d4053b54f16e2fe337affde71d1eb51 (patch)
treedcbd567925a92ceec1174b91f50653bf914a89c7 /drivers/pci/pci.c
parent19c1940feab777bb037c665a09f495d08a6c4e6c (diff)
parent38a6148248e199a4a960bbaa6b8eb14f138b73e1 (diff)
Merge tag 'pci-v3.16-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull more PCI updates from Bjorn Helgaas: "Here are some more things I'd like to see in v3.16-rc1: - DMA alias iterator, part of some work to fix IOMMU issues - MVEBU, Tegra, DesignWare changes that I forgot to include before - Some whitespace code cleanup Details: IOMMU - Add DMA alias iterator (Alex Williamson) - Add DMA alias quirks for ASMedia, ITE, Tundra bridges (Alex Williamson) - Add DMA alias quirks for Marvell, Ricoh devices (Alex Williamson) - Add DMA alias quirk for HighPoint devices (Jérôme Carretero) MSI - Fix leak in free_msi_irqs() (Alexei Starovoitov) Marvell MVEBU - Remove unnecessary use of 'conf_lock' spinlock (Andrew Murray) - Avoid setting an undefined window size (Jason Gunthorpe) - Allow several windows with the same target/attribute (Thomas Petazzoni) - Split PCIe BARs into multiple MBus windows when needed (Thomas Petazzoni) - Fix off-by-one in the computed size of the mbus windows (Willy Tarreau) NVIDIA Tegra - Use new OF interrupt mapping when possible (Lucas Stach) Synopsys DesignWare - Remove unnecessary use of 'conf_lock' spinlock (Andrew Murray) - Use new OF interrupt mapping when possible (Lucas Stach) - Split Exynos and i.MX bindings (Lucas Stach) - Fix comment for setting number of lanes (Mohit Kumar) - Fix iATU programming for cfg1, io and mem viewport (Mohit Kumar) Miscellaneous - EXPORT_SYMBOL cleanup (Ryan Desfosses) - Whitespace cleanup (Ryan Desfosses) - Merge multi-line quoted strings (Ryan Desfosses)" * tag 'pci-v3.16-changes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (21 commits) PCI: Add function 1 DMA alias quirk for HighPoint RocketRaid 642L PCI/MSI: Fix memory leak in free_msi_irqs() PCI: Merge multi-line quoted strings PCI: Whitespace cleanup PCI: Move EXPORT_SYMBOL so it immediately follows function/variable PCI: Add bridge DMA alias quirk for ITE bridge PCI: designware: Split Exynos and i.MX bindings PCI: Add bridge DMA alias quirk for ASMedia and Tundra bridges PCI: Add support for PCIe-to-PCI bridge DMA alias quirks PCI: Add function 1 DMA alias quirk for Marvell devices PCI: Add function 0 DMA alias quirk for Ricoh devices PCI: Add support for DMA alias quirks PCI: Convert pci_dev_flags definitions to bit shifts PCI: Add DMA alias iterator PCI: mvebu: Use '%pa' for printing 'phys_addr_t' type PCI: mvebu: Remove unnecessary use of 'conf_lock' spinlock PCI: designware: Remove unnecessary use of 'conf_lock' spinlock PCI: designware: Use new OF interrupt mapping when possible PCI: designware: Fix iATU programming for cfg1, io and mem viewport PCI: designware: Fix comment for setting number of lanes ...
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c195
1 files changed, 85 insertions, 110 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 212c63d780e7..63a54a340863 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -114,7 +114,7 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus)
114 max = bus->busn_res.end; 114 max = bus->busn_res.end;
115 list_for_each_entry(tmp, &bus->children, node) { 115 list_for_each_entry(tmp, &bus->children, node) {
116 n = pci_bus_max_busnr(tmp); 116 n = pci_bus_max_busnr(tmp);
117 if(n > max) 117 if (n > max)
118 max = n; 118 max = n;
119 } 119 }
120 return max; 120 return max;
@@ -226,6 +226,7 @@ int pci_find_capability(struct pci_dev *dev, int cap)
226 226
227 return pos; 227 return pos;
228} 228}
229EXPORT_SYMBOL(pci_find_capability);
229 230
230/** 231/**
231 * pci_bus_find_capability - query for devices' capabilities 232 * pci_bus_find_capability - query for devices' capabilities
@@ -253,6 +254,7 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
253 254
254 return pos; 255 return pos;
255} 256}
257EXPORT_SYMBOL(pci_bus_find_capability);
256 258
257/** 259/**
258 * pci_find_next_ext_capability - Find an extended capability 260 * pci_find_next_ext_capability - Find an extended capability
@@ -403,8 +405,8 @@ EXPORT_SYMBOL_GPL(pci_find_ht_capability);
403 * For given resource region of given device, return the resource 405 * For given resource region of given device, return the resource
404 * region of parent bus the given region is contained in. 406 * region of parent bus the given region is contained in.
405 */ 407 */
406struct resource * 408struct resource *pci_find_parent_resource(const struct pci_dev *dev,
407pci_find_parent_resource(const struct pci_dev *dev, struct resource *res) 409 struct resource *res)
408{ 410{
409 const struct pci_bus *bus = dev->bus; 411 const struct pci_bus *bus = dev->bus;
410 struct resource *r; 412 struct resource *r;
@@ -436,6 +438,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
436 } 438 }
437 return NULL; 439 return NULL;
438} 440}
441EXPORT_SYMBOL(pci_find_parent_resource);
439 442
440/** 443/**
441 * pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos 444 * pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
@@ -470,8 +473,7 @@ int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask)
470 * Restore the BAR values for a given device, so as to make it 473 * Restore the BAR values for a given device, so as to make it
471 * accessible by its driver. 474 * accessible by its driver.
472 */ 475 */
473static void 476static void pci_restore_bars(struct pci_dev *dev)
474pci_restore_bars(struct pci_dev *dev)
475{ 477{
476 int i; 478 int i;
477 479
@@ -496,7 +498,7 @@ static inline bool platform_pci_power_manageable(struct pci_dev *dev)
496} 498}
497 499
498static inline int platform_pci_set_power_state(struct pci_dev *dev, 500static inline int platform_pci_set_power_state(struct pci_dev *dev,
499 pci_power_t t) 501 pci_power_t t)
500{ 502{
501 return pci_platform_pm ? pci_platform_pm->set_state(dev, t) : -ENOSYS; 503 return pci_platform_pm ? pci_platform_pm->set_state(dev, t) : -ENOSYS;
502} 504}
@@ -553,8 +555,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
553 */ 555 */
554 if (state != PCI_D0 && dev->current_state <= PCI_D3cold 556 if (state != PCI_D0 && dev->current_state <= PCI_D3cold
555 && dev->current_state > state) { 557 && dev->current_state > state) {
556 dev_err(&dev->dev, "invalid power transition " 558 dev_err(&dev->dev, "invalid power transition (from state %d to %d)\n",
557 "(from state %d to %d)\n", dev->current_state, state); 559 dev->current_state, state);
558 return -EINVAL; 560 return -EINVAL;
559 } 561 }
560 562
@@ -601,8 +603,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
601 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 603 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
602 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); 604 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
603 if (dev->current_state != state && printk_ratelimit()) 605 if (dev->current_state != state && printk_ratelimit())
604 dev_info(&dev->dev, "Refused to change power state, " 606 dev_info(&dev->dev, "Refused to change power state, currently in D%d\n",
605 "currently in D%d\n", dev->current_state); 607 dev->current_state);
606 608
607 /* 609 /*
608 * According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT 610 * According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT
@@ -846,6 +848,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
846 848
847 return error; 849 return error;
848} 850}
851EXPORT_SYMBOL(pci_set_power_state);
849 852
850/** 853/**
851 * pci_choose_state - Choose the power state of a PCI device 854 * pci_choose_state - Choose the power state of a PCI device
@@ -884,12 +887,10 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
884 } 887 }
885 return PCI_D0; 888 return PCI_D0;
886} 889}
887
888EXPORT_SYMBOL(pci_choose_state); 890EXPORT_SYMBOL(pci_choose_state);
889 891
890#define PCI_EXP_SAVE_REGS 7 892#define PCI_EXP_SAVE_REGS 7
891 893
892
893static struct pci_cap_saved_state *_pci_find_saved_cap(struct pci_dev *pci_dev, 894static struct pci_cap_saved_state *_pci_find_saved_cap(struct pci_dev *pci_dev,
894 u16 cap, bool extended) 895 u16 cap, bool extended)
895{ 896{
@@ -1001,8 +1002,7 @@ static void pci_restore_pcix_state(struct pci_dev *dev)
1001 * pci_save_state - save the PCI configuration space of a device before suspending 1002 * pci_save_state - save the PCI configuration space of a device before suspending
1002 * @dev: - PCI device that we're dealing with 1003 * @dev: - PCI device that we're dealing with
1003 */ 1004 */
1004int 1005int pci_save_state(struct pci_dev *dev)
1005pci_save_state(struct pci_dev *dev)
1006{ 1006{
1007 int i; 1007 int i;
1008 /* XXX: 100% dword access ok here? */ 1008 /* XXX: 100% dword access ok here? */
@@ -1017,6 +1017,7 @@ pci_save_state(struct pci_dev *dev)
1017 return i; 1017 return i;
1018 return 0; 1018 return 0;
1019} 1019}
1020EXPORT_SYMBOL(pci_save_state);
1020 1021
1021static void pci_restore_config_dword(struct pci_dev *pdev, int offset, 1022static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
1022 u32 saved_val, int retry) 1023 u32 saved_val, int retry)
@@ -1028,8 +1029,8 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
1028 return; 1029 return;
1029 1030
1030 for (;;) { 1031 for (;;) {
1031 dev_dbg(&pdev->dev, "restoring config space at offset " 1032 dev_dbg(&pdev->dev, "restoring config space at offset %#x (was %#x, writing %#x)\n",
1032 "%#x (was %#x, writing %#x)\n", offset, val, saved_val); 1033 offset, val, saved_val);
1033 pci_write_config_dword(pdev, offset, saved_val); 1034 pci_write_config_dword(pdev, offset, saved_val);
1034 if (retry-- <= 0) 1035 if (retry-- <= 0)
1035 return; 1036 return;
@@ -1087,6 +1088,7 @@ void pci_restore_state(struct pci_dev *dev)
1087 1088
1088 dev->state_saved = false; 1089 dev->state_saved = false;
1089} 1090}
1091EXPORT_SYMBOL(pci_restore_state);
1090 1092
1091struct pci_saved_state { 1093struct pci_saved_state {
1092 u32 config_space[16]; 1094 u32 config_space[16];
@@ -1231,6 +1233,7 @@ int pci_reenable_device(struct pci_dev *dev)
1231 return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1); 1233 return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1);
1232 return 0; 1234 return 0;
1233} 1235}
1236EXPORT_SYMBOL(pci_reenable_device);
1234 1237
1235static void pci_enable_bridge(struct pci_dev *dev) 1238static void pci_enable_bridge(struct pci_dev *dev)
1236{ 1239{
@@ -1305,6 +1308,7 @@ int pci_enable_device_io(struct pci_dev *dev)
1305{ 1308{
1306 return pci_enable_device_flags(dev, IORESOURCE_IO); 1309 return pci_enable_device_flags(dev, IORESOURCE_IO);
1307} 1310}
1311EXPORT_SYMBOL(pci_enable_device_io);
1308 1312
1309/** 1313/**
1310 * pci_enable_device_mem - Initialize a device for use with Memory space 1314 * pci_enable_device_mem - Initialize a device for use with Memory space
@@ -1318,6 +1322,7 @@ int pci_enable_device_mem(struct pci_dev *dev)
1318{ 1322{
1319 return pci_enable_device_flags(dev, IORESOURCE_MEM); 1323 return pci_enable_device_flags(dev, IORESOURCE_MEM);
1320} 1324}
1325EXPORT_SYMBOL(pci_enable_device_mem);
1321 1326
1322/** 1327/**
1323 * pci_enable_device - Initialize device before it's used by a driver. 1328 * pci_enable_device - Initialize device before it's used by a driver.
@@ -1334,6 +1339,7 @@ int pci_enable_device(struct pci_dev *dev)
1334{ 1339{
1335 return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO); 1340 return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO);
1336} 1341}
1342EXPORT_SYMBOL(pci_enable_device);
1337 1343
1338/* 1344/*
1339 * Managed PCI resources. This manages device on/off, intx/msi/msix 1345 * Managed PCI resources. This manages device on/off, intx/msi/msix
@@ -1416,6 +1422,7 @@ int pcim_enable_device(struct pci_dev *pdev)
1416 } 1422 }
1417 return rc; 1423 return rc;
1418} 1424}
1425EXPORT_SYMBOL(pcim_enable_device);
1419 1426
1420/** 1427/**
1421 * pcim_pin_device - Pin managed PCI device 1428 * pcim_pin_device - Pin managed PCI device
@@ -1434,6 +1441,7 @@ void pcim_pin_device(struct pci_dev *pdev)
1434 if (dr) 1441 if (dr)
1435 dr->pinned = 1; 1442 dr->pinned = 1;
1436} 1443}
1444EXPORT_SYMBOL(pcim_pin_device);
1437 1445
1438/* 1446/*
1439 * pcibios_add_device - provide arch specific hooks when adding device dev 1447 * pcibios_add_device - provide arch specific hooks when adding device dev
@@ -1443,7 +1451,7 @@ void pcim_pin_device(struct pci_dev *pdev)
1443 * devices are added. This is the default implementation. Architecture 1451 * devices are added. This is the default implementation. Architecture
1444 * implementations can override this. 1452 * implementations can override this.
1445 */ 1453 */
1446int __weak pcibios_add_device (struct pci_dev *dev) 1454int __weak pcibios_add_device(struct pci_dev *dev)
1447{ 1455{
1448 return 0; 1456 return 0;
1449} 1457}
@@ -1515,8 +1523,7 @@ void pci_disable_enabled_device(struct pci_dev *dev)
1515 * Note we don't actually disable the device until all callers of 1523 * Note we don't actually disable the device until all callers of
1516 * pci_enable_device() have called pci_disable_device(). 1524 * pci_enable_device() have called pci_disable_device().
1517 */ 1525 */
1518void 1526void pci_disable_device(struct pci_dev *dev)
1519pci_disable_device(struct pci_dev *dev)
1520{ 1527{
1521 struct pci_devres *dr; 1528 struct pci_devres *dr;
1522 1529
@@ -1534,6 +1541,7 @@ pci_disable_device(struct pci_dev *dev)
1534 1541
1535 dev->is_busmaster = 0; 1542 dev->is_busmaster = 0;
1536} 1543}
1544EXPORT_SYMBOL(pci_disable_device);
1537 1545
1538/** 1546/**
1539 * pcibios_set_pcie_reset_state - set reset state for device dev 1547 * pcibios_set_pcie_reset_state - set reset state for device dev
@@ -1562,6 +1570,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
1562{ 1570{
1563 return pcibios_set_pcie_reset_state(dev, state); 1571 return pcibios_set_pcie_reset_state(dev, state);
1564} 1572}
1573EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
1565 1574
1566/** 1575/**
1567 * pci_check_pme_status - Check if given device has generated PME. 1576 * pci_check_pme_status - Check if given device has generated PME.
@@ -1641,6 +1650,7 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state)
1641 1650
1642 return !!(dev->pme_support & (1 << state)); 1651 return !!(dev->pme_support & (1 << state));
1643} 1652}
1653EXPORT_SYMBOL(pci_pme_capable);
1644 1654
1645static void pci_pme_list_scan(struct work_struct *work) 1655static void pci_pme_list_scan(struct work_struct *work)
1646{ 1656{
@@ -1745,6 +1755,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
1745 1755
1746 dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled"); 1756 dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled");
1747} 1757}
1758EXPORT_SYMBOL(pci_pme_active);
1748 1759
1749/** 1760/**
1750 * __pci_enable_wake - enable PCI device as wakeup event source 1761 * __pci_enable_wake - enable PCI device as wakeup event source
@@ -1830,6 +1841,7 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable)
1830 pci_enable_wake(dev, PCI_D3cold, enable) : 1841 pci_enable_wake(dev, PCI_D3cold, enable) :
1831 pci_enable_wake(dev, PCI_D3hot, enable); 1842 pci_enable_wake(dev, PCI_D3hot, enable);
1832} 1843}
1844EXPORT_SYMBOL(pci_wake_from_d3);
1833 1845
1834/** 1846/**
1835 * pci_target_state - find an appropriate low power state for a given PCI dev 1847 * pci_target_state - find an appropriate low power state for a given PCI dev
@@ -1908,6 +1920,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
1908 1920
1909 return error; 1921 return error;
1910} 1922}
1923EXPORT_SYMBOL(pci_prepare_to_sleep);
1911 1924
1912/** 1925/**
1913 * pci_back_from_sleep - turn PCI device on during system-wide transition into working state 1926 * pci_back_from_sleep - turn PCI device on during system-wide transition into working state
@@ -1920,6 +1933,7 @@ int pci_back_from_sleep(struct pci_dev *dev)
1920 pci_enable_wake(dev, PCI_D0, false); 1933 pci_enable_wake(dev, PCI_D0, false);
1921 return pci_set_power_state(dev, PCI_D0); 1934 return pci_set_power_state(dev, PCI_D0);
1922} 1935}
1936EXPORT_SYMBOL(pci_back_from_sleep);
1923 1937
1924/** 1938/**
1925 * pci_finish_runtime_suspend - Carry out PCI-specific part of runtime suspend. 1939 * pci_finish_runtime_suspend - Carry out PCI-specific part of runtime suspend.
@@ -2415,8 +2429,7 @@ u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin)
2415 return (((pin - 1) + slot) % 4) + 1; 2429 return (((pin - 1) + slot) % 4) + 1;
2416} 2430}
2417 2431
2418int 2432int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
2419pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
2420{ 2433{
2421 u8 pin; 2434 u8 pin;
2422 2435
@@ -2478,6 +2491,7 @@ void pci_release_region(struct pci_dev *pdev, int bar)
2478 if (dr) 2491 if (dr)
2479 dr->region_mask &= ~(1 << bar); 2492 dr->region_mask &= ~(1 << bar);
2480} 2493}
2494EXPORT_SYMBOL(pci_release_region);
2481 2495
2482/** 2496/**
2483 * __pci_request_region - Reserved PCI I/O and memory resource 2497 * __pci_request_region - Reserved PCI I/O and memory resource
@@ -2498,8 +2512,8 @@ void pci_release_region(struct pci_dev *pdev, int bar)
2498 * Returns 0 on success, or %EBUSY on error. A warning 2512 * Returns 0 on success, or %EBUSY on error. A warning
2499 * message is also printed on failure. 2513 * message is also printed on failure.
2500 */ 2514 */
2501static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_name, 2515static int __pci_request_region(struct pci_dev *pdev, int bar,
2502 int exclusive) 2516 const char *res_name, int exclusive)
2503{ 2517{
2504 struct pci_devres *dr; 2518 struct pci_devres *dr;
2505 2519
@@ -2510,8 +2524,7 @@ static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_n
2510 if (!request_region(pci_resource_start(pdev, bar), 2524 if (!request_region(pci_resource_start(pdev, bar),
2511 pci_resource_len(pdev, bar), res_name)) 2525 pci_resource_len(pdev, bar), res_name))
2512 goto err_out; 2526 goto err_out;
2513 } 2527 } else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
2514 else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
2515 if (!__request_mem_region(pci_resource_start(pdev, bar), 2528 if (!__request_mem_region(pci_resource_start(pdev, bar),
2516 pci_resource_len(pdev, bar), res_name, 2529 pci_resource_len(pdev, bar), res_name,
2517 exclusive)) 2530 exclusive))
@@ -2548,6 +2561,7 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
2548{ 2561{
2549 return __pci_request_region(pdev, bar, res_name, 0); 2562 return __pci_request_region(pdev, bar, res_name, 0);
2550} 2563}
2564EXPORT_SYMBOL(pci_request_region);
2551 2565
2552/** 2566/**
2553 * pci_request_region_exclusive - Reserved PCI I/O and memory resource 2567 * pci_request_region_exclusive - Reserved PCI I/O and memory resource
@@ -2567,10 +2581,13 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
2567 * explicitly not allowed to map the resource via /dev/mem or 2581 * explicitly not allowed to map the resource via /dev/mem or
2568 * sysfs. 2582 * sysfs.
2569 */ 2583 */
2570int pci_request_region_exclusive(struct pci_dev *pdev, int bar, const char *res_name) 2584int pci_request_region_exclusive(struct pci_dev *pdev, int bar,
2585 const char *res_name)
2571{ 2586{
2572 return __pci_request_region(pdev, bar, res_name, IORESOURCE_EXCLUSIVE); 2587 return __pci_request_region(pdev, bar, res_name, IORESOURCE_EXCLUSIVE);
2573} 2588}
2589EXPORT_SYMBOL(pci_request_region_exclusive);
2590
2574/** 2591/**
2575 * pci_release_selected_regions - Release selected PCI I/O and memory resources 2592 * pci_release_selected_regions - Release selected PCI I/O and memory resources
2576 * @pdev: PCI device whose resources were previously reserved 2593 * @pdev: PCI device whose resources were previously reserved
@@ -2587,9 +2604,10 @@ void pci_release_selected_regions(struct pci_dev *pdev, int bars)
2587 if (bars & (1 << i)) 2604 if (bars & (1 << i))
2588 pci_release_region(pdev, i); 2605 pci_release_region(pdev, i);
2589} 2606}
2607EXPORT_SYMBOL(pci_release_selected_regions);
2590 2608
2591static int __pci_request_selected_regions(struct pci_dev *pdev, int bars, 2609static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
2592 const char *res_name, int excl) 2610 const char *res_name, int excl)
2593{ 2611{
2594 int i; 2612 int i;
2595 2613
@@ -2600,7 +2618,7 @@ static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
2600 return 0; 2618 return 0;
2601 2619
2602err_out: 2620err_out:
2603 while(--i >= 0) 2621 while (--i >= 0)
2604 if (bars & (1 << i)) 2622 if (bars & (1 << i))
2605 pci_release_region(pdev, i); 2623 pci_release_region(pdev, i);
2606 2624
@@ -2619,13 +2637,15 @@ int pci_request_selected_regions(struct pci_dev *pdev, int bars,
2619{ 2637{
2620 return __pci_request_selected_regions(pdev, bars, res_name, 0); 2638 return __pci_request_selected_regions(pdev, bars, res_name, 0);
2621} 2639}
2640EXPORT_SYMBOL(pci_request_selected_regions);
2622 2641
2623int pci_request_selected_regions_exclusive(struct pci_dev *pdev, 2642int pci_request_selected_regions_exclusive(struct pci_dev *pdev, int bars,
2624 int bars, const char *res_name) 2643 const char *res_name)
2625{ 2644{
2626 return __pci_request_selected_regions(pdev, bars, res_name, 2645 return __pci_request_selected_regions(pdev, bars, res_name,
2627 IORESOURCE_EXCLUSIVE); 2646 IORESOURCE_EXCLUSIVE);
2628} 2647}
2648EXPORT_SYMBOL(pci_request_selected_regions_exclusive);
2629 2649
2630/** 2650/**
2631 * pci_release_regions - Release reserved PCI I/O and memory resources 2651 * pci_release_regions - Release reserved PCI I/O and memory resources
@@ -2640,6 +2660,7 @@ void pci_release_regions(struct pci_dev *pdev)
2640{ 2660{
2641 pci_release_selected_regions(pdev, (1 << 6) - 1); 2661 pci_release_selected_regions(pdev, (1 << 6) - 1);
2642} 2662}
2663EXPORT_SYMBOL(pci_release_regions);
2643 2664
2644/** 2665/**
2645 * pci_request_regions - Reserved PCI I/O and memory resources 2666 * pci_request_regions - Reserved PCI I/O and memory resources
@@ -2658,6 +2679,7 @@ int pci_request_regions(struct pci_dev *pdev, const char *res_name)
2658{ 2679{
2659 return pci_request_selected_regions(pdev, ((1 << 6) - 1), res_name); 2680 return pci_request_selected_regions(pdev, ((1 << 6) - 1), res_name);
2660} 2681}
2682EXPORT_SYMBOL(pci_request_regions);
2661 2683
2662/** 2684/**
2663 * pci_request_regions_exclusive - Reserved PCI I/O and memory resources 2685 * pci_request_regions_exclusive - Reserved PCI I/O and memory resources
@@ -2680,6 +2702,7 @@ int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
2680 return pci_request_selected_regions_exclusive(pdev, 2702 return pci_request_selected_regions_exclusive(pdev,
2681 ((1 << 6) - 1), res_name); 2703 ((1 << 6) - 1), res_name);
2682} 2704}
2705EXPORT_SYMBOL(pci_request_regions_exclusive);
2683 2706
2684static void __pci_set_master(struct pci_dev *dev, bool enable) 2707static void __pci_set_master(struct pci_dev *dev, bool enable)
2685{ 2708{
@@ -2749,6 +2772,7 @@ void pci_set_master(struct pci_dev *dev)
2749 __pci_set_master(dev, true); 2772 __pci_set_master(dev, true);
2750 pcibios_set_master(dev); 2773 pcibios_set_master(dev);
2751} 2774}
2775EXPORT_SYMBOL(pci_set_master);
2752 2776
2753/** 2777/**
2754 * pci_clear_master - disables bus-mastering for device dev 2778 * pci_clear_master - disables bus-mastering for device dev
@@ -2758,6 +2782,7 @@ void pci_clear_master(struct pci_dev *dev)
2758{ 2782{
2759 __pci_set_master(dev, false); 2783 __pci_set_master(dev, false);
2760} 2784}
2785EXPORT_SYMBOL(pci_clear_master);
2761 2786
2762/** 2787/**
2763 * pci_set_cacheline_size - ensure the CACHE_LINE_SIZE register is programmed 2788 * pci_set_cacheline_size - ensure the CACHE_LINE_SIZE register is programmed
@@ -2790,30 +2815,13 @@ int pci_set_cacheline_size(struct pci_dev *dev)
2790 if (cacheline_size == pci_cache_line_size) 2815 if (cacheline_size == pci_cache_line_size)
2791 return 0; 2816 return 0;
2792 2817
2793 dev_printk(KERN_DEBUG, &dev->dev, "cache line size of %d is not " 2818 dev_printk(KERN_DEBUG, &dev->dev, "cache line size of %d is not supported\n",
2794 "supported\n", pci_cache_line_size << 2); 2819 pci_cache_line_size << 2);
2795 2820
2796 return -EINVAL; 2821 return -EINVAL;
2797} 2822}
2798EXPORT_SYMBOL_GPL(pci_set_cacheline_size); 2823EXPORT_SYMBOL_GPL(pci_set_cacheline_size);
2799 2824
2800#ifdef PCI_DISABLE_MWI
2801int pci_set_mwi(struct pci_dev *dev)
2802{
2803 return 0;
2804}
2805
2806int pci_try_set_mwi(struct pci_dev *dev)
2807{
2808 return 0;
2809}
2810
2811void pci_clear_mwi(struct pci_dev *dev)
2812{
2813}
2814
2815#else
2816
2817/** 2825/**
2818 * pci_set_mwi - enables memory-write-invalidate PCI transaction 2826 * pci_set_mwi - enables memory-write-invalidate PCI transaction
2819 * @dev: the PCI device for which MWI is enabled 2827 * @dev: the PCI device for which MWI is enabled
@@ -2822,9 +2830,11 @@ void pci_clear_mwi(struct pci_dev *dev)
2822 * 2830 *
2823 * RETURNS: An appropriate -ERRNO error value on error, or zero for success. 2831 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
2824 */ 2832 */
2825int 2833int pci_set_mwi(struct pci_dev *dev)
2826pci_set_mwi(struct pci_dev *dev)
2827{ 2834{
2835#ifdef PCI_DISABLE_MWI
2836 return 0;
2837#else
2828 int rc; 2838 int rc;
2829 u16 cmd; 2839 u16 cmd;
2830 2840
@@ -2833,14 +2843,15 @@ pci_set_mwi(struct pci_dev *dev)
2833 return rc; 2843 return rc;
2834 2844
2835 pci_read_config_word(dev, PCI_COMMAND, &cmd); 2845 pci_read_config_word(dev, PCI_COMMAND, &cmd);
2836 if (! (cmd & PCI_COMMAND_INVALIDATE)) { 2846 if (!(cmd & PCI_COMMAND_INVALIDATE)) {
2837 dev_dbg(&dev->dev, "enabling Mem-Wr-Inval\n"); 2847 dev_dbg(&dev->dev, "enabling Mem-Wr-Inval\n");
2838 cmd |= PCI_COMMAND_INVALIDATE; 2848 cmd |= PCI_COMMAND_INVALIDATE;
2839 pci_write_config_word(dev, PCI_COMMAND, cmd); 2849 pci_write_config_word(dev, PCI_COMMAND, cmd);
2840 } 2850 }
2841
2842 return 0; 2851 return 0;
2852#endif
2843} 2853}
2854EXPORT_SYMBOL(pci_set_mwi);
2844 2855
2845/** 2856/**
2846 * pci_try_set_mwi - enables memory-write-invalidate PCI transaction 2857 * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
@@ -2853,9 +2864,13 @@ pci_set_mwi(struct pci_dev *dev)
2853 */ 2864 */
2854int pci_try_set_mwi(struct pci_dev *dev) 2865int pci_try_set_mwi(struct pci_dev *dev)
2855{ 2866{
2856 int rc = pci_set_mwi(dev); 2867#ifdef PCI_DISABLE_MWI
2857 return rc; 2868 return 0;
2869#else
2870 return pci_set_mwi(dev);
2871#endif
2858} 2872}
2873EXPORT_SYMBOL(pci_try_set_mwi);
2859 2874
2860/** 2875/**
2861 * pci_clear_mwi - disables Memory-Write-Invalidate for device dev 2876 * pci_clear_mwi - disables Memory-Write-Invalidate for device dev
@@ -2863,9 +2878,9 @@ int pci_try_set_mwi(struct pci_dev *dev)
2863 * 2878 *
2864 * Disables PCI Memory-Write-Invalidate transaction on the device 2879 * Disables PCI Memory-Write-Invalidate transaction on the device
2865 */ 2880 */
2866void 2881void pci_clear_mwi(struct pci_dev *dev)
2867pci_clear_mwi(struct pci_dev *dev)
2868{ 2882{
2883#ifndef PCI_DISABLE_MWI
2869 u16 cmd; 2884 u16 cmd;
2870 2885
2871 pci_read_config_word(dev, PCI_COMMAND, &cmd); 2886 pci_read_config_word(dev, PCI_COMMAND, &cmd);
@@ -2873,8 +2888,9 @@ pci_clear_mwi(struct pci_dev *dev)
2873 cmd &= ~PCI_COMMAND_INVALIDATE; 2888 cmd &= ~PCI_COMMAND_INVALIDATE;
2874 pci_write_config_word(dev, PCI_COMMAND, cmd); 2889 pci_write_config_word(dev, PCI_COMMAND, cmd);
2875 } 2890 }
2891#endif
2876} 2892}
2877#endif /* ! PCI_DISABLE_MWI */ 2893EXPORT_SYMBOL(pci_clear_mwi);
2878 2894
2879/** 2895/**
2880 * pci_intx - enables/disables PCI INTx for device dev 2896 * pci_intx - enables/disables PCI INTx for device dev
@@ -2883,18 +2899,16 @@ pci_clear_mwi(struct pci_dev *dev)
2883 * 2899 *
2884 * Enables/disables PCI INTx for device dev 2900 * Enables/disables PCI INTx for device dev
2885 */ 2901 */
2886void 2902void pci_intx(struct pci_dev *pdev, int enable)
2887pci_intx(struct pci_dev *pdev, int enable)
2888{ 2903{
2889 u16 pci_command, new; 2904 u16 pci_command, new;
2890 2905
2891 pci_read_config_word(pdev, PCI_COMMAND, &pci_command); 2906 pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
2892 2907
2893 if (enable) { 2908 if (enable)
2894 new = pci_command & ~PCI_COMMAND_INTX_DISABLE; 2909 new = pci_command & ~PCI_COMMAND_INTX_DISABLE;
2895 } else { 2910 else
2896 new = pci_command | PCI_COMMAND_INTX_DISABLE; 2911 new = pci_command | PCI_COMMAND_INTX_DISABLE;
2897 }
2898 2912
2899 if (new != pci_command) { 2913 if (new != pci_command) {
2900 struct pci_devres *dr; 2914 struct pci_devres *dr;
@@ -2908,6 +2922,7 @@ pci_intx(struct pci_dev *pdev, int enable)
2908 } 2922 }
2909 } 2923 }
2910} 2924}
2925EXPORT_SYMBOL_GPL(pci_intx);
2911 2926
2912/** 2927/**
2913 * pci_intx_mask_supported - probe for INTx masking support 2928 * pci_intx_mask_supported - probe for INTx masking support
@@ -2937,8 +2952,8 @@ bool pci_intx_mask_supported(struct pci_dev *dev)
2937 * go ahead and check it. 2952 * go ahead and check it.
2938 */ 2953 */
2939 if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) { 2954 if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
2940 dev_err(&dev->dev, "Command register changed from " 2955 dev_err(&dev->dev, "Command register changed from 0x%x to 0x%x: driver or hardware bug?\n",
2941 "0x%x to 0x%x: driver or hardware bug?\n", orig, new); 2956 orig, new);
2942 } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) { 2957 } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
2943 mask_supported = true; 2958 mask_supported = true;
2944 pci_write_config_word(dev, PCI_COMMAND, orig); 2959 pci_write_config_word(dev, PCI_COMMAND, orig);
@@ -3124,8 +3139,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
3124 if (pci_wait_for_pending(dev, pos + PCI_AF_STATUS, PCI_AF_STATUS_TP)) 3139 if (pci_wait_for_pending(dev, pos + PCI_AF_STATUS, PCI_AF_STATUS_TP))
3125 goto clear; 3140 goto clear;
3126 3141
3127 dev_err(&dev->dev, "transaction is not cleared; " 3142 dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
3128 "proceeding with reset anyway\n");
3129 3143
3130clear: 3144clear:
3131 pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR); 3145 pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
@@ -4100,6 +4114,7 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
4100 bars |= (1 << i); 4114 bars |= (1 << i);
4101 return bars; 4115 return bars;
4102} 4116}
4117EXPORT_SYMBOL(pci_select_bars);
4103 4118
4104/** 4119/**
4105 * pci_resource_bar - get position of the BAR associated with a resource 4120 * pci_resource_bar - get position of the BAR associated with a resource
@@ -4139,7 +4154,7 @@ void __init pci_register_set_vga_state(arch_set_vga_state_t func)
4139} 4154}
4140 4155
4141static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode, 4156static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode,
4142 unsigned int command_bits, u32 flags) 4157 unsigned int command_bits, u32 flags)
4143{ 4158{
4144 if (arch_set_vga_state) 4159 if (arch_set_vga_state)
4145 return arch_set_vga_state(dev, decode, command_bits, 4160 return arch_set_vga_state(dev, decode, command_bits,
@@ -4251,11 +4266,10 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
4251 bus == dev->bus->number && 4266 bus == dev->bus->number &&
4252 slot == PCI_SLOT(dev->devfn) && 4267 slot == PCI_SLOT(dev->devfn) &&
4253 func == PCI_FUNC(dev->devfn)) { 4268 func == PCI_FUNC(dev->devfn)) {
4254 if (align_order == -1) { 4269 if (align_order == -1)
4255 align = PAGE_SIZE; 4270 align = PAGE_SIZE;
4256 } else { 4271 else
4257 align = 1 << align_order; 4272 align = 1 << align_order;
4258 }
4259 /* Found */ 4273 /* Found */
4260 break; 4274 break;
4261 } 4275 }
@@ -4373,7 +4387,6 @@ static int __init pci_resource_alignment_sysfs_init(void)
4373 return bus_create_file(&pci_bus_type, 4387 return bus_create_file(&pci_bus_type,
4374 &bus_attr_resource_alignment); 4388 &bus_attr_resource_alignment);
4375} 4389}
4376
4377late_initcall(pci_resource_alignment_sysfs_init); 4390late_initcall(pci_resource_alignment_sysfs_init);
4378 4391
4379static void pci_no_domains(void) 4392static void pci_no_domains(void)
@@ -4452,41 +4465,3 @@ static int __init pci_setup(char *str)
4452 return 0; 4465 return 0;
4453} 4466}
4454early_param("pci", pci_setup); 4467early_param("pci", pci_setup);
4455
4456EXPORT_SYMBOL(pci_reenable_device);
4457EXPORT_SYMBOL(pci_enable_device_io);
4458EXPORT_SYMBOL(pci_enable_device_mem);
4459EXPORT_SYMBOL(pci_enable_device);
4460EXPORT_SYMBOL(pcim_enable_device);
4461EXPORT_SYMBOL(pcim_pin_device);
4462EXPORT_SYMBOL(pci_disable_device);
4463EXPORT_SYMBOL(pci_find_capability);
4464EXPORT_SYMBOL(pci_bus_find_capability);
4465EXPORT_SYMBOL(pci_release_regions);
4466EXPORT_SYMBOL(pci_request_regions);
4467EXPORT_SYMBOL(pci_request_regions_exclusive);
4468EXPORT_SYMBOL(pci_release_region);
4469EXPORT_SYMBOL(pci_request_region);
4470EXPORT_SYMBOL(pci_request_region_exclusive);
4471EXPORT_SYMBOL(pci_release_selected_regions);
4472EXPORT_SYMBOL(pci_request_selected_regions);
4473EXPORT_SYMBOL(pci_request_selected_regions_exclusive);
4474EXPORT_SYMBOL(pci_set_master);
4475EXPORT_SYMBOL(pci_clear_master);
4476EXPORT_SYMBOL(pci_set_mwi);
4477EXPORT_SYMBOL(pci_try_set_mwi);
4478EXPORT_SYMBOL(pci_clear_mwi);
4479EXPORT_SYMBOL_GPL(pci_intx);
4480EXPORT_SYMBOL(pci_assign_resource);
4481EXPORT_SYMBOL(pci_find_parent_resource);
4482EXPORT_SYMBOL(pci_select_bars);
4483
4484EXPORT_SYMBOL(pci_set_power_state);
4485EXPORT_SYMBOL(pci_save_state);
4486EXPORT_SYMBOL(pci_restore_state);
4487EXPORT_SYMBOL(pci_pme_capable);
4488EXPORT_SYMBOL(pci_pme_active);
4489EXPORT_SYMBOL(pci_wake_from_d3);
4490EXPORT_SYMBOL(pci_prepare_to_sleep);
4491EXPORT_SYMBOL(pci_back_from_sleep);
4492EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);