aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-08 18:47:43 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-08 18:47:43 -0400
commit0d519f2d1ed1f11e49abc88cfcf6cf13b83ba14c (patch)
treefe2bfed7c6e8448f9661216610ec81f1e0c28515 /drivers/pci/pci.c
parent0756b7fbb696d2cb18785da9cab13ec164017f64 (diff)
parentcf2d804110d3c20dc6865ade514c44179de34855 (diff)
Merge tag 'pci-v4.14-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
Pull PCI updates from Bjorn Helgaas: - add enhanced Downstream Port Containment support, which prints more details about Root Port Programmed I/O errors (Dongdong Liu) - add Layerscape ls1088a and ls2088a support (Hou Zhiqiang) - add MediaTek MT2712 and MT7622 support (Ryder Lee) - add MediaTek MT2712 and MT7622 MSI support (Honghui Zhang) - add Qualcom IPQ8074 support (Varadarajan Narayanan) - add R-Car r8a7743/5 device tree support (Biju Das) - add Rockchip per-lane PHY support for better power management (Shawn Lin) - fix IRQ mapping for hot-added devices by replacing the pci_fixup_irqs() boot-time design with a host bridge hook called at probe-time (Lorenzo Pieralisi, Matthew Minter) - fix race when enabling two devices that results in upstream bridge not being enabled correctly (Srinath Mannam) - fix pciehp power fault infinite loop (Keith Busch) - fix SHPC bridge MSI hotplug events by enabling bus mastering (Aleksandr Bezzubikov) - fix a VFIO issue by correcting PCIe capability sizes (Alex Williamson) - fix an INTD issue on Xilinx and possibly other drivers by unifying INTx IRQ domain support (Paul Burton) - avoid IOMMU stalls by marking AMD Stoney GPU ATS as broken (Joerg Roedel) - allow APM X-Gene device assignment to guests by adding an ACS quirk (Feng Kan) - fix driver crashes by disabling Extended Tags on Broadcom HT2100 (Extended Tags support is required for PCIe Receivers but not Requesters, and we now enable them by default when Requesters support them) (Sinan Kaya) - fix MSIs for devices that use phantom RIDs for DMA by assuming MSIs use the real Requester ID (not a phantom RID) (Robin Murphy) - prevent assignment of Intel VMD children to guests (which may be supported eventually, but isn't yet) by not associating an IOMMU with them (Jon Derrick) - fix Intel VMD suspend/resume by releasing IRQs on suspend (Scott Bauer) - fix a Function-Level Reset issue with Intel 750 NVMe by waiting longer (up to 60sec instead of 1sec) for device to become ready (Sinan Kaya) - fix a Function-Level Reset issue on iProc Stingray by working around hardware defects in the CRS implementation (Oza Pawandeep) - fix an issue with Intel NVMe P3700 after an iProc reset by adding a delay during shutdown (Oza Pawandeep) - fix a Microsoft Hyper-V lockdep issue by polling instead of blocking in compose_msi_msg() (Stephen Hemminger) - fix a wireless LAN driver timeout by clearing DesignWare MSI interrupt status after it is handled, not before (Faiz Abbas) - fix DesignWare ATU enable checking (Jisheng Zhang) - reduce Layerscape dependencies on the bootloader by doing more initialization in the driver (Hou Zhiqiang) - improve Intel VMD performance allowing allocation of more IRQ vectors than present CPUs (Keith Busch) - improve endpoint framework support for initial DMA mask, different BAR sizes, configurable page sizes, MSI, test driver, etc (Kishon Vijay Abraham I, Stan Drozd) - rework CRS support to add periodic messages while we poll during enumeration and after Function-Level Reset and prepare for possible other uses of CRS (Sinan Kaya) - clean up Root Port AER handling by removing unnecessary code and moving error handler methods to struct pcie_port_service_driver (Christoph Hellwig) - clean up error handling paths in various drivers (Bjorn Andersson, Fabio Estevam, Gustavo A. R. Silva, Harunobu Kurokawa, Jeffy Chen, Lorenzo Pieralisi, Sergei Shtylyov) - clean up SR-IOV resource handling by disabling VF decoding before updating the corresponding resource structs (Gavin Shan) - clean up DesignWare-based drivers by unifying quirks to update Class Code and Interrupt Pin and related handling of write-protected registers (Hou Zhiqiang) - clean up by adding empty generic pcibios_align_resource() and pcibios_fixup_bus() and removing empty arch-specific implementations (Palmer Dabbelt) - request exclusive reset control for several drivers to allow cleanup elsewhere (Philipp Zabel) - constify various structures (Arvind Yadav, Bhumika Goyal) - convert from full_name() to %pOF (Rob Herring) - remove unused variables from iProc, HiSi, Altera, Keystone (Shawn Lin) * tag 'pci-v4.14-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (170 commits) PCI: xgene: Clean up whitespace PCI: xgene: Define XGENE_PCI_EXP_CAP and use generic PCI_EXP_RTCTL offset PCI: xgene: Fix platform_get_irq() error handling PCI: xilinx-nwl: Fix platform_get_irq() error handling PCI: rockchip: Fix platform_get_irq() error handling PCI: altera: Fix platform_get_irq() error handling PCI: spear13xx: Fix platform_get_irq() error handling PCI: artpec6: Fix platform_get_irq() error handling PCI: armada8k: Fix platform_get_irq() error handling PCI: dra7xx: Fix platform_get_irq() error handling PCI: exynos: Fix platform_get_irq() error handling PCI: iproc: Clean up whitespace PCI: iproc: Rename PCI_EXP_CAP to IPROC_PCI_EXP_CAP PCI: iproc: Add 500ms delay during device shutdown PCI: Fix typos and whitespace errors PCI: Remove unused "res" variable from pci_resource_io() PCI: Correct kernel-doc of pci_vpd_srdt_size(), pci_vpd_srdt_tag() PCI/AER: Reformat AER register definitions iommu/vt-d: Prevent VMD child devices from being remapping targets x86/PCI: Use is_vmd() rather than relying on the domain number ...
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c71
1 files changed, 52 insertions, 19 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 68e3b2b0da93..b0002daa50f3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -52,6 +52,7 @@ static void pci_pme_list_scan(struct work_struct *work);
52static LIST_HEAD(pci_pme_list); 52static LIST_HEAD(pci_pme_list);
53static DEFINE_MUTEX(pci_pme_list_mutex); 53static DEFINE_MUTEX(pci_pme_list_mutex);
54static DECLARE_DELAYED_WORK(pci_pme_work, pci_pme_list_scan); 54static DECLARE_DELAYED_WORK(pci_pme_work, pci_pme_list_scan);
55static DEFINE_MUTEX(pci_bridge_mutex);
55 56
56struct pci_pme_device { 57struct pci_pme_device {
57 struct list_head list; 58 struct list_head list;
@@ -892,7 +893,9 @@ EXPORT_SYMBOL_GPL(__pci_complete_power_transition);
892 * -EINVAL if the requested state is invalid. 893 * -EINVAL if the requested state is invalid.
893 * -EIO if device does not support PCI PM or its PM capabilities register has a 894 * -EIO if device does not support PCI PM or its PM capabilities register has a
894 * wrong version, or device doesn't support the requested state. 895 * wrong version, or device doesn't support the requested state.
896 * 0 if the transition is to D1 or D2 but D1 and D2 are not supported.
895 * 0 if device already is in the requested state. 897 * 0 if device already is in the requested state.
898 * 0 if the transition is to D3 but D3 is not supported.
896 * 0 if device's power state has been successfully changed. 899 * 0 if device's power state has been successfully changed.
897 */ 900 */
898int pci_set_power_state(struct pci_dev *dev, pci_power_t state) 901int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
@@ -1348,10 +1351,16 @@ static void pci_enable_bridge(struct pci_dev *dev)
1348 if (bridge) 1351 if (bridge)
1349 pci_enable_bridge(bridge); 1352 pci_enable_bridge(bridge);
1350 1353
1354 /*
1355 * Hold pci_bridge_mutex to prevent a race when enabling two
1356 * devices below the bridge simultaneously. The race may cause a
1357 * PCI_COMMAND_MEMORY update to be lost (see changelog).
1358 */
1359 mutex_lock(&pci_bridge_mutex);
1351 if (pci_is_enabled(dev)) { 1360 if (pci_is_enabled(dev)) {
1352 if (!dev->is_busmaster) 1361 if (!dev->is_busmaster)
1353 pci_set_master(dev); 1362 pci_set_master(dev);
1354 return; 1363 goto end;
1355 } 1364 }
1356 1365
1357 retval = pci_enable_device(dev); 1366 retval = pci_enable_device(dev);
@@ -1359,6 +1368,8 @@ static void pci_enable_bridge(struct pci_dev *dev)
1359 dev_err(&dev->dev, "Error enabling bridge (%d), continuing\n", 1368 dev_err(&dev->dev, "Error enabling bridge (%d), continuing\n",
1360 retval); 1369 retval);
1361 pci_set_master(dev); 1370 pci_set_master(dev);
1371end:
1372 mutex_unlock(&pci_bridge_mutex);
1362} 1373}
1363 1374
1364static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags) 1375static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
@@ -1383,7 +1394,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
1383 return 0; /* already enabled */ 1394 return 0; /* already enabled */
1384 1395
1385 bridge = pci_upstream_bridge(dev); 1396 bridge = pci_upstream_bridge(dev);
1386 if (bridge) 1397 if (bridge && !pci_is_enabled(bridge))
1387 pci_enable_bridge(bridge); 1398 pci_enable_bridge(bridge);
1388 1399
1389 /* only skip sriov related */ 1400 /* only skip sriov related */
@@ -3818,27 +3829,49 @@ int pci_wait_for_pending_transaction(struct pci_dev *dev)
3818} 3829}
3819EXPORT_SYMBOL(pci_wait_for_pending_transaction); 3830EXPORT_SYMBOL(pci_wait_for_pending_transaction);
3820 3831
3821/*
3822 * We should only need to wait 100ms after FLR, but some devices take longer.
3823 * Wait for up to 1000ms for config space to return something other than -1.
3824 * Intel IGD requires this when an LCD panel is attached. We read the 2nd
3825 * dword because VFs don't implement the 1st dword.
3826 */
3827static void pci_flr_wait(struct pci_dev *dev) 3832static void pci_flr_wait(struct pci_dev *dev)
3828{ 3833{
3829 int i = 0; 3834 int delay = 1, timeout = 60000;
3830 u32 id; 3835 u32 id;
3831 3836
3832 do { 3837 /*
3833 msleep(100); 3838 * Per PCIe r3.1, sec 6.6.2, a device must complete an FLR within
3839 * 100ms, but may silently discard requests while the FLR is in
3840 * progress. Wait 100ms before trying to access the device.
3841 */
3842 msleep(100);
3843
3844 /*
3845 * After 100ms, the device should not silently discard config
3846 * requests, but it may still indicate that it needs more time by
3847 * responding to them with CRS completions. The Root Port will
3848 * generally synthesize ~0 data to complete the read (except when
3849 * CRS SV is enabled and the read was for the Vendor ID; in that
3850 * case it synthesizes 0x0001 data).
3851 *
3852 * Wait for the device to return a non-CRS completion. Read the
3853 * Command register instead of Vendor ID so we don't have to
3854 * contend with the CRS SV value.
3855 */
3856 pci_read_config_dword(dev, PCI_COMMAND, &id);
3857 while (id == ~0) {
3858 if (delay > timeout) {
3859 dev_warn(&dev->dev, "not ready %dms after FLR; giving up\n",
3860 100 + delay - 1);
3861 return;
3862 }
3863
3864 if (delay > 1000)
3865 dev_info(&dev->dev, "not ready %dms after FLR; waiting\n",
3866 100 + delay - 1);
3867
3868 msleep(delay);
3869 delay *= 2;
3834 pci_read_config_dword(dev, PCI_COMMAND, &id); 3870 pci_read_config_dword(dev, PCI_COMMAND, &id);
3835 } while (i++ < 10 && id == ~0); 3871 }
3836 3872
3837 if (id == ~0) 3873 if (delay > 1000)
3838 dev_warn(&dev->dev, "Failed to return from FLR\n"); 3874 dev_info(&dev->dev, "ready %dms after FLR\n", 100 + delay - 1);
3839 else if (i > 1)
3840 dev_info(&dev->dev, "Required additional %dms to return from FLR\n",
3841 (i - 1) * 100);
3842} 3875}
3843 3876
3844/** 3877/**
@@ -5405,8 +5438,8 @@ static int of_pci_bus_find_domain_nr(struct device *parent)
5405 use_dt_domains = 0; 5438 use_dt_domains = 0;
5406 domain = pci_get_new_domain_nr(); 5439 domain = pci_get_new_domain_nr();
5407 } else { 5440 } else {
5408 dev_err(parent, "Node %s has inconsistent \"linux,pci-domain\" property in DT\n", 5441 dev_err(parent, "Node %pOF has inconsistent \"linux,pci-domain\" property in DT\n",
5409 parent->of_node->full_name); 5442 parent->of_node);
5410 domain = -1; 5443 domain = -1;
5411 } 5444 }
5412 5445