diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2018-08-15 15:58:43 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2018-08-15 15:58:43 -0400 |
commit | af863d18a1fbedd164366d0f3d4946d9cc3edc46 (patch) | |
tree | 46ed284871234e825bc3211dd5bf0d960b7c3cda | |
parent | ce397d215ccd07b8ae3f71db689aedb85d56ab40 (diff) | |
parent | 44bda4b7d26e9fffed6d7152d98a2e9edaeb2a76 (diff) |
Merge branch 'for-linus'
* for-linus:
PCI: Fix is_added/is_busmaster race condition
PCI: mobiveil: Avoid integer overflow in IB_WIN_SIZE
PCI/AER: Work around use-after-free in pcie_do_fatal_recovery()
PCI: v3-semi: Fix I/O space page leak
PCI: mediatek: Fix I/O space page leak
PCI: faraday: Fix I/O space page leak
PCI: aardvark: Fix I/O space page leak
PCI: designware: Fix I/O space page leak
PCI: versatile: Fix I/O space page leak
PCI: xgene: Fix I/O space page leak
PCI: OF: Fix I/O space page leak
PCI: endpoint: Fix NULL pointer dereference error when CONFIGFS is disabled
PCI: hv: Disable/enable IRQs rather than BH in hv_compose_msi_msg()
nfp: stop limiting VFs to 0
PCI/IOV: Reset total_VFs limit after detaching PF driver
PCI: faraday: Add missing of_node_put()
PCI: xilinx-nwl: Add missing of_node_put()
PCI: xilinx: Add missing of_node_put()
PCI: endpoint: Use after free in pci_epf_unregister_driver()
PCI: controller: dwc: Do not let PCIE_DW_PLAT_HOST default to yes
PCI: rcar: Clean up PHY init on failure
PCI: rcar: Shut the PHY down in failpath
PCI: controller: Move PCI_DOMAINS selection to arch Kconfig
PCI: Initialize endpoint library before controllers
PCI: shpchp: Manage SHPC unconditionally on non-ACPI systems
35 files changed, 187 insertions, 61 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 54eeb8d00bc6..843edfd000be 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -1245,8 +1245,14 @@ config PCI | |||
1245 | VESA. If you have PCI, say Y, otherwise N. | 1245 | VESA. If you have PCI, say Y, otherwise N. |
1246 | 1246 | ||
1247 | config PCI_DOMAINS | 1247 | config PCI_DOMAINS |
1248 | bool | 1248 | bool "Support for multiple PCI domains" |
1249 | depends on PCI | 1249 | depends on PCI |
1250 | help | ||
1251 | Enable PCI domains kernel management. Say Y if your machine | ||
1252 | has a PCI bus hierarchy that requires more than one PCI | ||
1253 | domain (aka segment) to be correctly managed. Say N otherwise. | ||
1254 | |||
1255 | If you don't know what to do here, say N. | ||
1250 | 1256 | ||
1251 | config PCI_DOMAINS_GENERIC | 1257 | config PCI_DOMAINS_GENERIC |
1252 | def_bool PCI_DOMAINS | 1258 | def_bool PCI_DOMAINS |
diff --git a/arch/arm/mach-bcm/Kconfig b/arch/arm/mach-bcm/Kconfig index c46a728df44e..25aac6ee2ab1 100644 --- a/arch/arm/mach-bcm/Kconfig +++ b/arch/arm/mach-bcm/Kconfig | |||
@@ -20,6 +20,7 @@ config ARCH_BCM_IPROC | |||
20 | select GPIOLIB | 20 | select GPIOLIB |
21 | select ARM_AMBA | 21 | select ARM_AMBA |
22 | select PINCTRL | 22 | select PINCTRL |
23 | select PCI_DOMAINS if PCI | ||
23 | help | 24 | help |
24 | This enables support for systems based on Broadcom IPROC architected SoCs. | 25 | This enables support for systems based on Broadcom IPROC architected SoCs. |
25 | The IPROC complex contains one or more ARM CPUs along with common | 26 | The IPROC complex contains one or more ARM CPUs along with common |
diff --git a/arch/arm/mach-socfpga/Kconfig b/arch/arm/mach-socfpga/Kconfig index d0f62eacf59d..4adb901dd5eb 100644 --- a/arch/arm/mach-socfpga/Kconfig +++ b/arch/arm/mach-socfpga/Kconfig | |||
@@ -10,6 +10,7 @@ menuconfig ARCH_SOCFPGA | |||
10 | select HAVE_ARM_SCU | 10 | select HAVE_ARM_SCU |
11 | select HAVE_ARM_TWD if SMP | 11 | select HAVE_ARM_TWD if SMP |
12 | select MFD_SYSCON | 12 | select MFD_SYSCON |
13 | select PCI_DOMAINS if PCI | ||
13 | 14 | ||
14 | if ARCH_SOCFPGA | 15 | if ARCH_SOCFPGA |
15 | config SOCFPGA_SUSPEND | 16 | config SOCFPGA_SUSPEND |
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index fe9733ffffaa..471aac313b89 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c | |||
@@ -42,6 +42,8 @@ | |||
42 | #include <asm/ppc-pci.h> | 42 | #include <asm/ppc-pci.h> |
43 | #include <asm/eeh.h> | 43 | #include <asm/eeh.h> |
44 | 44 | ||
45 | #include "../../../drivers/pci/pci.h" | ||
46 | |||
45 | /* hose_spinlock protects accesses to the the phb_bitmap. */ | 47 | /* hose_spinlock protects accesses to the the phb_bitmap. */ |
46 | static DEFINE_SPINLOCK(hose_spinlock); | 48 | static DEFINE_SPINLOCK(hose_spinlock); |
47 | LIST_HEAD(hose_list); | 49 | LIST_HEAD(hose_list); |
@@ -1014,7 +1016,7 @@ void pcibios_setup_bus_devices(struct pci_bus *bus) | |||
1014 | /* Cardbus can call us to add new devices to a bus, so ignore | 1016 | /* Cardbus can call us to add new devices to a bus, so ignore |
1015 | * those who are already fully discovered | 1017 | * those who are already fully discovered |
1016 | */ | 1018 | */ |
1017 | if (dev->is_added) | 1019 | if (pci_dev_is_added(dev)) |
1018 | continue; | 1020 | continue; |
1019 | 1021 | ||
1020 | pcibios_setup_device(dev); | 1022 | pcibios_setup_device(dev); |
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 5bd0eb6681bc..70b2e1e0f23c 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c | |||
@@ -46,6 +46,7 @@ | |||
46 | 46 | ||
47 | #include "powernv.h" | 47 | #include "powernv.h" |
48 | #include "pci.h" | 48 | #include "pci.h" |
49 | #include "../../../../drivers/pci/pci.h" | ||
49 | 50 | ||
50 | #define PNV_IODA1_M64_NUM 16 /* Number of M64 BARs */ | 51 | #define PNV_IODA1_M64_NUM 16 /* Number of M64 BARs */ |
51 | #define PNV_IODA1_M64_SEGS 8 /* Segments per M64 BAR */ | 52 | #define PNV_IODA1_M64_SEGS 8 /* Segments per M64 BAR */ |
@@ -3138,7 +3139,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev) | |||
3138 | struct pci_dn *pdn; | 3139 | struct pci_dn *pdn; |
3139 | int mul, total_vfs; | 3140 | int mul, total_vfs; |
3140 | 3141 | ||
3141 | if (!pdev->is_physfn || pdev->is_added) | 3142 | if (!pdev->is_physfn || pci_dev_is_added(pdev)) |
3142 | return; | 3143 | return; |
3143 | 3144 | ||
3144 | pdn = pci_get_pdn(pdev); | 3145 | pdn = pci_get_pdn(pdev); |
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index 139f0af6c3d9..8a4868a3964b 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c | |||
@@ -71,6 +71,7 @@ | |||
71 | #include <asm/security_features.h> | 71 | #include <asm/security_features.h> |
72 | 72 | ||
73 | #include "pseries.h" | 73 | #include "pseries.h" |
74 | #include "../../../../drivers/pci/pci.h" | ||
74 | 75 | ||
75 | int CMO_PrPSP = -1; | 76 | int CMO_PrPSP = -1; |
76 | int CMO_SecPSP = -1; | 77 | int CMO_SecPSP = -1; |
@@ -664,7 +665,7 @@ static void pseries_pci_fixup_iov_resources(struct pci_dev *pdev) | |||
664 | const int *indexes; | 665 | const int *indexes; |
665 | struct device_node *dn = pci_device_to_OF_node(pdev); | 666 | struct device_node *dn = pci_device_to_OF_node(pdev); |
666 | 667 | ||
667 | if (!pdev->is_physfn || pdev->is_added) | 668 | if (!pdev->is_physfn || pci_dev_is_added(pdev)) |
668 | return; | 669 | return; |
669 | /*Firmware must support open sriov otherwise dont configure*/ | 670 | /*Firmware must support open sriov otherwise dont configure*/ |
670 | indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL); | 671 | indexes = of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL); |
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index 46b76d5a726c..152283d7e59c 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c | |||
@@ -240,7 +240,6 @@ static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) | |||
240 | return pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs); | 240 | return pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs); |
241 | 241 | ||
242 | pf->limit_vfs = ~0; | 242 | pf->limit_vfs = ~0; |
243 | pci_sriov_set_totalvfs(pf->pdev, 0); /* 0 is unset */ | ||
244 | /* Allow any setting for backwards compatibility if symbol not found */ | 243 | /* Allow any setting for backwards compatibility if symbol not found */ |
245 | if (err == -ENOENT) | 244 | if (err == -ENOENT) |
246 | return 0; | 245 | return 0; |
@@ -668,7 +667,7 @@ static int nfp_pci_probe(struct pci_dev *pdev, | |||
668 | 667 | ||
669 | err = nfp_net_pci_probe(pf); | 668 | err = nfp_net_pci_probe(pf); |
670 | if (err) | 669 | if (err) |
671 | goto err_sriov_unlimit; | 670 | goto err_fw_unload; |
672 | 671 | ||
673 | err = nfp_hwmon_register(pf); | 672 | err = nfp_hwmon_register(pf); |
674 | if (err) { | 673 | if (err) { |
@@ -680,8 +679,6 @@ static int nfp_pci_probe(struct pci_dev *pdev, | |||
680 | 679 | ||
681 | err_net_remove: | 680 | err_net_remove: |
682 | nfp_net_pci_remove(pf); | 681 | nfp_net_pci_remove(pf); |
683 | err_sriov_unlimit: | ||
684 | pci_sriov_set_totalvfs(pf->pdev, 0); | ||
685 | err_fw_unload: | 682 | err_fw_unload: |
686 | kfree(pf->rtbl); | 683 | kfree(pf->rtbl); |
687 | nfp_mip_close(pf->mip); | 684 | nfp_mip_close(pf->mip); |
@@ -715,7 +712,6 @@ static void nfp_pci_remove(struct pci_dev *pdev) | |||
715 | nfp_hwmon_unregister(pf); | 712 | nfp_hwmon_unregister(pf); |
716 | 713 | ||
717 | nfp_pcie_sriov_disable(pdev); | 714 | nfp_pcie_sriov_disable(pdev); |
718 | pci_sriov_set_totalvfs(pf->pdev, 0); | ||
719 | 715 | ||
720 | nfp_net_pci_remove(pf); | 716 | nfp_net_pci_remove(pf); |
721 | 717 | ||
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 535201984b8b..1b2cfe51e8d7 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile | |||
@@ -28,10 +28,10 @@ obj-$(CONFIG_PCI_PF_STUB) += pci-pf-stub.o | |||
28 | obj-$(CONFIG_PCI_ECAM) += ecam.o | 28 | obj-$(CONFIG_PCI_ECAM) += ecam.o |
29 | obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o | 29 | obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o |
30 | 30 | ||
31 | obj-y += controller/ | ||
32 | obj-y += switch/ | ||
33 | |||
34 | # Endpoint library must be initialized before its users | 31 | # Endpoint library must be initialized before its users |
35 | obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ | 32 | obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ |
36 | 33 | ||
34 | obj-y += controller/ | ||
35 | obj-y += switch/ | ||
36 | |||
37 | ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG | 37 | ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG |
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 35b7fc87eac5..5cb40b2518f9 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c | |||
@@ -330,7 +330,7 @@ void pci_bus_add_device(struct pci_dev *dev) | |||
330 | return; | 330 | return; |
331 | } | 331 | } |
332 | 332 | ||
333 | dev->is_added = 1; | 333 | pci_dev_assign_added(dev, true); |
334 | } | 334 | } |
335 | EXPORT_SYMBOL_GPL(pci_bus_add_device); | 335 | EXPORT_SYMBOL_GPL(pci_bus_add_device); |
336 | 336 | ||
@@ -347,14 +347,14 @@ void pci_bus_add_devices(const struct pci_bus *bus) | |||
347 | 347 | ||
348 | list_for_each_entry(dev, &bus->devices, bus_list) { | 348 | list_for_each_entry(dev, &bus->devices, bus_list) { |
349 | /* Skip already-added devices */ | 349 | /* Skip already-added devices */ |
350 | if (dev->is_added) | 350 | if (pci_dev_is_added(dev)) |
351 | continue; | 351 | continue; |
352 | pci_bus_add_device(dev); | 352 | pci_bus_add_device(dev); |
353 | } | 353 | } |
354 | 354 | ||
355 | list_for_each_entry(dev, &bus->devices, bus_list) { | 355 | list_for_each_entry(dev, &bus->devices, bus_list) { |
356 | /* Skip if device attach failed */ | 356 | /* Skip if device attach failed */ |
357 | if (!dev->is_added) | 357 | if (!pci_dev_is_added(dev)) |
358 | continue; | 358 | continue; |
359 | child = dev->subordinate; | 359 | child = dev->subordinate; |
360 | if (child) | 360 | if (child) |
diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index 18fa09b3ac8f..cc9fa02d32a0 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig | |||
@@ -96,7 +96,6 @@ config PCI_HOST_GENERIC | |||
96 | depends on OF | 96 | depends on OF |
97 | select PCI_HOST_COMMON | 97 | select PCI_HOST_COMMON |
98 | select IRQ_DOMAIN | 98 | select IRQ_DOMAIN |
99 | select PCI_DOMAINS | ||
100 | help | 99 | help |
101 | Say Y here if you want to support a simple generic PCI host | 100 | Say Y here if you want to support a simple generic PCI host |
102 | controller, such as the one emulated by kvmtool. | 101 | controller, such as the one emulated by kvmtool. |
@@ -138,7 +137,6 @@ config PCI_VERSATILE | |||
138 | 137 | ||
139 | config PCIE_IPROC | 138 | config PCIE_IPROC |
140 | tristate | 139 | tristate |
141 | select PCI_DOMAINS | ||
142 | help | 140 | help |
143 | This enables the iProc PCIe core controller support for Broadcom's | 141 | This enables the iProc PCIe core controller support for Broadcom's |
144 | iProc family of SoCs. An appropriate bus interface driver needs | 142 | iProc family of SoCs. An appropriate bus interface driver needs |
@@ -176,7 +174,6 @@ config PCIE_IPROC_MSI | |||
176 | config PCIE_ALTERA | 174 | config PCIE_ALTERA |
177 | bool "Altera PCIe controller" | 175 | bool "Altera PCIe controller" |
178 | depends on ARM || NIOS2 || COMPILE_TEST | 176 | depends on ARM || NIOS2 || COMPILE_TEST |
179 | select PCI_DOMAINS | ||
180 | help | 177 | help |
181 | Say Y here if you want to enable PCIe controller support on Altera | 178 | Say Y here if you want to enable PCIe controller support on Altera |
182 | FPGA. | 179 | FPGA. |
diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index 16f52c626b4b..91b0194240a5 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig | |||
@@ -58,7 +58,6 @@ config PCIE_DW_PLAT_HOST | |||
58 | depends on PCI && PCI_MSI_IRQ_DOMAIN | 58 | depends on PCI && PCI_MSI_IRQ_DOMAIN |
59 | select PCIE_DW_HOST | 59 | select PCIE_DW_HOST |
60 | select PCIE_DW_PLAT | 60 | select PCIE_DW_PLAT |
61 | default y | ||
62 | help | 61 | help |
63 | Enables support for the PCIe controller in the Designware IP to | 62 | Enables support for the PCIe controller in the Designware IP to |
64 | work in host mode. There are two instances of PCIe controller in | 63 | work in host mode. There are two instances of PCIe controller in |
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 781aa03aeede..29a05759a294 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c | |||
@@ -363,7 +363,8 @@ int dw_pcie_host_init(struct pcie_port *pp) | |||
363 | resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { | 363 | resource_list_for_each_entry_safe(win, tmp, &bridge->windows) { |
364 | switch (resource_type(win->res)) { | 364 | switch (resource_type(win->res)) { |
365 | case IORESOURCE_IO: | 365 | case IORESOURCE_IO: |
366 | ret = pci_remap_iospace(win->res, pp->io_base); | 366 | ret = devm_pci_remap_iospace(dev, win->res, |
367 | pp->io_base); | ||
367 | if (ret) { | 368 | if (ret) { |
368 | dev_warn(dev, "Error %d: failed to map resource %pR\n", | 369 | dev_warn(dev, "Error %d: failed to map resource %pR\n", |
369 | ret, win->res); | 370 | ret, win->res); |
diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index d3172d5d3d35..0fae816fba39 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c | |||
@@ -849,7 +849,7 @@ static int advk_pcie_parse_request_of_pci_ranges(struct advk_pcie *pcie) | |||
849 | 0, 0xF8000000, 0, | 849 | 0, 0xF8000000, 0, |
850 | lower_32_bits(res->start), | 850 | lower_32_bits(res->start), |
851 | OB_PCIE_IO); | 851 | OB_PCIE_IO); |
852 | err = pci_remap_iospace(res, iobase); | 852 | err = devm_pci_remap_iospace(dev, res, iobase); |
853 | if (err) { | 853 | if (err) { |
854 | dev_warn(dev, "error %d: failed to map resource %pR\n", | 854 | dev_warn(dev, "error %d: failed to map resource %pR\n", |
855 | err, res); | 855 | err, res); |
diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index a1ebe9ed441f..bf5ece5d9291 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c | |||
@@ -355,11 +355,13 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) | |||
355 | irq = of_irq_get(intc, 0); | 355 | irq = of_irq_get(intc, 0); |
356 | if (irq <= 0) { | 356 | if (irq <= 0) { |
357 | dev_err(p->dev, "failed to get parent IRQ\n"); | 357 | dev_err(p->dev, "failed to get parent IRQ\n"); |
358 | of_node_put(intc); | ||
358 | return irq ?: -EINVAL; | 359 | return irq ?: -EINVAL; |
359 | } | 360 | } |
360 | 361 | ||
361 | p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX, | 362 | p->irqdomain = irq_domain_add_linear(intc, PCI_NUM_INTX, |
362 | &faraday_pci_irqdomain_ops, p); | 363 | &faraday_pci_irqdomain_ops, p); |
364 | of_node_put(intc); | ||
363 | if (!p->irqdomain) { | 365 | if (!p->irqdomain) { |
364 | dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n"); | 366 | dev_err(p->dev, "failed to create Gemini PCI IRQ domain\n"); |
365 | return -EINVAL; | 367 | return -EINVAL; |
@@ -501,7 +503,7 @@ static int faraday_pci_probe(struct platform_device *pdev) | |||
501 | dev_err(dev, "illegal IO mem size\n"); | 503 | dev_err(dev, "illegal IO mem size\n"); |
502 | return -EINVAL; | 504 | return -EINVAL; |
503 | } | 505 | } |
504 | ret = pci_remap_iospace(io, io_base); | 506 | ret = devm_pci_remap_iospace(dev, io, io_base); |
505 | if (ret) { | 507 | if (ret) { |
506 | dev_warn(dev, "error %d: failed to map resource %pR\n", | 508 | dev_warn(dev, "error %d: failed to map resource %pR\n", |
507 | ret, io); | 509 | ret, io); |
diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c index 6cc5036ac83c..f6325f1a89e8 100644 --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c | |||
@@ -1073,6 +1073,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) | |||
1073 | struct pci_bus *pbus; | 1073 | struct pci_bus *pbus; |
1074 | struct pci_dev *pdev; | 1074 | struct pci_dev *pdev; |
1075 | struct cpumask *dest; | 1075 | struct cpumask *dest; |
1076 | unsigned long flags; | ||
1076 | struct compose_comp_ctxt comp; | 1077 | struct compose_comp_ctxt comp; |
1077 | struct tran_int_desc *int_desc; | 1078 | struct tran_int_desc *int_desc; |
1078 | struct { | 1079 | struct { |
@@ -1164,14 +1165,15 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) | |||
1164 | * the channel callback directly when channel->target_cpu is | 1165 | * the channel callback directly when channel->target_cpu is |
1165 | * the current CPU. When the higher level interrupt code | 1166 | * the current CPU. When the higher level interrupt code |
1166 | * calls us with interrupt enabled, let's add the | 1167 | * calls us with interrupt enabled, let's add the |
1167 | * local_bh_disable()/enable() to avoid race. | 1168 | * local_irq_save()/restore() to avoid race: |
1169 | * hv_pci_onchannelcallback() can also run in tasklet. | ||
1168 | */ | 1170 | */ |
1169 | local_bh_disable(); | 1171 | local_irq_save(flags); |
1170 | 1172 | ||
1171 | if (hbus->hdev->channel->target_cpu == smp_processor_id()) | 1173 | if (hbus->hdev->channel->target_cpu == smp_processor_id()) |
1172 | hv_pci_onchannelcallback(hbus); | 1174 | hv_pci_onchannelcallback(hbus); |
1173 | 1175 | ||
1174 | local_bh_enable(); | 1176 | local_irq_restore(flags); |
1175 | 1177 | ||
1176 | if (hpdev->state == hv_pcichild_ejecting) { | 1178 | if (hpdev->state == hv_pcichild_ejecting) { |
1177 | dev_err_once(&hbus->hdev->device, | 1179 | dev_err_once(&hbus->hdev->device, |
diff --git a/drivers/pci/controller/pci-v3-semi.c b/drivers/pci/controller/pci-v3-semi.c index 68b8bfbdb867..d219404bad92 100644 --- a/drivers/pci/controller/pci-v3-semi.c +++ b/drivers/pci/controller/pci-v3-semi.c | |||
@@ -537,7 +537,7 @@ static int v3_pci_setup_resource(struct v3_pci *v3, | |||
537 | v3->io_bus_addr = io->start - win->offset; | 537 | v3->io_bus_addr = io->start - win->offset; |
538 | dev_dbg(dev, "I/O window %pR, bus addr %pap\n", | 538 | dev_dbg(dev, "I/O window %pR, bus addr %pap\n", |
539 | io, &v3->io_bus_addr); | 539 | io, &v3->io_bus_addr); |
540 | ret = pci_remap_iospace(io, io_base); | 540 | ret = devm_pci_remap_iospace(dev, io, io_base); |
541 | if (ret) { | 541 | if (ret) { |
542 | dev_warn(dev, | 542 | dev_warn(dev, |
543 | "error %d: failed to map resource %pR\n", | 543 | "error %d: failed to map resource %pR\n", |
diff --git a/drivers/pci/controller/pci-versatile.c b/drivers/pci/controller/pci-versatile.c index 994f32061b32..f59ad2728c0b 100644 --- a/drivers/pci/controller/pci-versatile.c +++ b/drivers/pci/controller/pci-versatile.c | |||
@@ -82,7 +82,7 @@ static int versatile_pci_parse_request_of_pci_ranges(struct device *dev, | |||
82 | 82 | ||
83 | switch (resource_type(res)) { | 83 | switch (resource_type(res)) { |
84 | case IORESOURCE_IO: | 84 | case IORESOURCE_IO: |
85 | err = pci_remap_iospace(res, iobase); | 85 | err = devm_pci_remap_iospace(dev, res, iobase); |
86 | if (err) { | 86 | if (err) { |
87 | dev_warn(dev, "error %d: failed to map resource %pR\n", | 87 | dev_warn(dev, "error %d: failed to map resource %pR\n", |
88 | err, res); | 88 | err, res); |
diff --git a/drivers/pci/controller/pci-xgene.c b/drivers/pci/controller/pci-xgene.c index d854d67e873c..ffda3e8b4742 100644 --- a/drivers/pci/controller/pci-xgene.c +++ b/drivers/pci/controller/pci-xgene.c | |||
@@ -423,7 +423,7 @@ static int xgene_pcie_map_ranges(struct xgene_pcie_port *port, | |||
423 | case IORESOURCE_IO: | 423 | case IORESOURCE_IO: |
424 | xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base, | 424 | xgene_pcie_setup_ob_reg(port, res, OMR3BARL, io_base, |
425 | res->start - window->offset); | 425 | res->start - window->offset); |
426 | ret = pci_remap_iospace(res, io_base); | 426 | ret = devm_pci_remap_iospace(dev, res, io_base); |
427 | if (ret < 0) | 427 | if (ret < 0) |
428 | return ret; | 428 | return ret; |
429 | break; | 429 | break; |
diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 0baabe30858f..861dda69f366 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c | |||
@@ -1109,7 +1109,7 @@ static int mtk_pcie_request_resources(struct mtk_pcie *pcie) | |||
1109 | if (err < 0) | 1109 | if (err < 0) |
1110 | return err; | 1110 | return err; |
1111 | 1111 | ||
1112 | pci_remap_iospace(&pcie->pio, pcie->io.start); | 1112 | devm_pci_remap_iospace(dev, &pcie->pio, pcie->io.start); |
1113 | 1113 | ||
1114 | return 0; | 1114 | return 0; |
1115 | } | 1115 | } |
diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c index 4d6c20e47bed..cf0aa7cee5b0 100644 --- a/drivers/pci/controller/pcie-mobiveil.c +++ b/drivers/pci/controller/pcie-mobiveil.c | |||
@@ -107,7 +107,7 @@ | |||
107 | #define CFG_WINDOW_TYPE 0 | 107 | #define CFG_WINDOW_TYPE 0 |
108 | #define IO_WINDOW_TYPE 1 | 108 | #define IO_WINDOW_TYPE 1 |
109 | #define MEM_WINDOW_TYPE 2 | 109 | #define MEM_WINDOW_TYPE 2 |
110 | #define IB_WIN_SIZE (256 * 1024 * 1024 * 1024) | 110 | #define IB_WIN_SIZE ((u64)256 * 1024 * 1024 * 1024) |
111 | #define MAX_PIO_WINDOWS 8 | 111 | #define MAX_PIO_WINDOWS 8 |
112 | 112 | ||
113 | /* Parameters for the waiting for link up routine */ | 113 | /* Parameters for the waiting for link up routine */ |
diff --git a/drivers/pci/controller/pcie-rcar.c b/drivers/pci/controller/pcie-rcar.c index 874d75c9ee4a..c8febb009454 100644 --- a/drivers/pci/controller/pcie-rcar.c +++ b/drivers/pci/controller/pcie-rcar.c | |||
@@ -680,7 +680,11 @@ static int rcar_pcie_phy_init_gen3(struct rcar_pcie *pcie) | |||
680 | if (err) | 680 | if (err) |
681 | return err; | 681 | return err; |
682 | 682 | ||
683 | return phy_power_on(pcie->phy); | 683 | err = phy_power_on(pcie->phy); |
684 | if (err) | ||
685 | phy_exit(pcie->phy); | ||
686 | |||
687 | return err; | ||
684 | } | 688 | } |
685 | 689 | ||
686 | static int rcar_msi_alloc(struct rcar_msi *chip) | 690 | static int rcar_msi_alloc(struct rcar_msi *chip) |
@@ -1165,7 +1169,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
1165 | if (rcar_pcie_hw_init(pcie)) { | 1169 | if (rcar_pcie_hw_init(pcie)) { |
1166 | dev_info(dev, "PCIe link down\n"); | 1170 | dev_info(dev, "PCIe link down\n"); |
1167 | err = -ENODEV; | 1171 | err = -ENODEV; |
1168 | goto err_clk_disable; | 1172 | goto err_phy_shutdown; |
1169 | } | 1173 | } |
1170 | 1174 | ||
1171 | data = rcar_pci_read_reg(pcie, MACSR); | 1175 | data = rcar_pci_read_reg(pcie, MACSR); |
@@ -1177,7 +1181,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) | |||
1177 | dev_err(dev, | 1181 | dev_err(dev, |
1178 | "failed to enable MSI support: %d\n", | 1182 | "failed to enable MSI support: %d\n", |
1179 | err); | 1183 | err); |
1180 | goto err_clk_disable; | 1184 | goto err_phy_shutdown; |
1181 | } | 1185 | } |
1182 | } | 1186 | } |
1183 | 1187 | ||
@@ -1191,6 +1195,12 @@ err_msi_teardown: | |||
1191 | if (IS_ENABLED(CONFIG_PCI_MSI)) | 1195 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
1192 | rcar_pcie_teardown_msi(pcie); | 1196 | rcar_pcie_teardown_msi(pcie); |
1193 | 1197 | ||
1198 | err_phy_shutdown: | ||
1199 | if (pcie->phy) { | ||
1200 | phy_power_off(pcie->phy); | ||
1201 | phy_exit(pcie->phy); | ||
1202 | } | ||
1203 | |||
1194 | err_clk_disable: | 1204 | err_clk_disable: |
1195 | clk_disable_unprepare(pcie->bus_clk); | 1205 | clk_disable_unprepare(pcie->bus_clk); |
1196 | 1206 | ||
diff --git a/drivers/pci/controller/pcie-xilinx-nwl.c b/drivers/pci/controller/pcie-xilinx-nwl.c index 6a4bbb5b3de0..fb32840ce8e6 100644 --- a/drivers/pci/controller/pcie-xilinx-nwl.c +++ b/drivers/pci/controller/pcie-xilinx-nwl.c | |||
@@ -559,7 +559,7 @@ static int nwl_pcie_init_irq_domain(struct nwl_pcie *pcie) | |||
559 | PCI_NUM_INTX, | 559 | PCI_NUM_INTX, |
560 | &legacy_domain_ops, | 560 | &legacy_domain_ops, |
561 | pcie); | 561 | pcie); |
562 | 562 | of_node_put(legacy_intc_node); | |
563 | if (!pcie->legacy_irq_domain) { | 563 | if (!pcie->legacy_irq_domain) { |
564 | dev_err(dev, "failed to create IRQ domain\n"); | 564 | dev_err(dev, "failed to create IRQ domain\n"); |
565 | return -ENOMEM; | 565 | return -ENOMEM; |
diff --git a/drivers/pci/controller/pcie-xilinx.c b/drivers/pci/controller/pcie-xilinx.c index b110a3a814e3..7b1389d8e2a5 100644 --- a/drivers/pci/controller/pcie-xilinx.c +++ b/drivers/pci/controller/pcie-xilinx.c | |||
@@ -509,6 +509,7 @@ static int xilinx_pcie_init_irq_domain(struct xilinx_pcie_port *port) | |||
509 | port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, | 509 | port->leg_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, |
510 | &intx_domain_ops, | 510 | &intx_domain_ops, |
511 | port); | 511 | port); |
512 | of_node_put(pcie_intc_node); | ||
512 | if (!port->leg_domain) { | 513 | if (!port->leg_domain) { |
513 | dev_err(dev, "Failed to get a INTx IRQ domain\n"); | 514 | dev_err(dev, "Failed to get a INTx IRQ domain\n"); |
514 | return -ENODEV; | 515 | return -ENODEV; |
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 523a8cab3bfb..825fa24427a3 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c | |||
@@ -137,6 +137,20 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar) | |||
137 | } | 137 | } |
138 | EXPORT_SYMBOL_GPL(pci_epf_alloc_space); | 138 | EXPORT_SYMBOL_GPL(pci_epf_alloc_space); |
139 | 139 | ||
140 | static void pci_epf_remove_cfs(struct pci_epf_driver *driver) | ||
141 | { | ||
142 | struct config_group *group, *tmp; | ||
143 | |||
144 | if (!IS_ENABLED(CONFIG_PCI_ENDPOINT_CONFIGFS)) | ||
145 | return; | ||
146 | |||
147 | mutex_lock(&pci_epf_mutex); | ||
148 | list_for_each_entry_safe(group, tmp, &driver->epf_group, group_entry) | ||
149 | pci_ep_cfs_remove_epf_group(group); | ||
150 | list_del(&driver->epf_group); | ||
151 | mutex_unlock(&pci_epf_mutex); | ||
152 | } | ||
153 | |||
140 | /** | 154 | /** |
141 | * pci_epf_unregister_driver() - unregister the PCI EPF driver | 155 | * pci_epf_unregister_driver() - unregister the PCI EPF driver |
142 | * @driver: the PCI EPF driver that has to be unregistered | 156 | * @driver: the PCI EPF driver that has to be unregistered |
@@ -145,17 +159,38 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space); | |||
145 | */ | 159 | */ |
146 | void pci_epf_unregister_driver(struct pci_epf_driver *driver) | 160 | void pci_epf_unregister_driver(struct pci_epf_driver *driver) |
147 | { | 161 | { |
148 | struct config_group *group; | 162 | pci_epf_remove_cfs(driver); |
149 | |||
150 | mutex_lock(&pci_epf_mutex); | ||
151 | list_for_each_entry(group, &driver->epf_group, group_entry) | ||
152 | pci_ep_cfs_remove_epf_group(group); | ||
153 | list_del(&driver->epf_group); | ||
154 | mutex_unlock(&pci_epf_mutex); | ||
155 | driver_unregister(&driver->driver); | 163 | driver_unregister(&driver->driver); |
156 | } | 164 | } |
157 | EXPORT_SYMBOL_GPL(pci_epf_unregister_driver); | 165 | EXPORT_SYMBOL_GPL(pci_epf_unregister_driver); |
158 | 166 | ||
167 | static int pci_epf_add_cfs(struct pci_epf_driver *driver) | ||
168 | { | ||
169 | struct config_group *group; | ||
170 | const struct pci_epf_device_id *id; | ||
171 | |||
172 | if (!IS_ENABLED(CONFIG_PCI_ENDPOINT_CONFIGFS)) | ||
173 | return 0; | ||
174 | |||
175 | INIT_LIST_HEAD(&driver->epf_group); | ||
176 | |||
177 | id = driver->id_table; | ||
178 | while (id->name[0]) { | ||
179 | group = pci_ep_cfs_add_epf_group(id->name); | ||
180 | if (IS_ERR(group)) { | ||
181 | pci_epf_remove_cfs(driver); | ||
182 | return PTR_ERR(group); | ||
183 | } | ||
184 | |||
185 | mutex_lock(&pci_epf_mutex); | ||
186 | list_add_tail(&group->group_entry, &driver->epf_group); | ||
187 | mutex_unlock(&pci_epf_mutex); | ||
188 | id++; | ||
189 | } | ||
190 | |||
191 | return 0; | ||
192 | } | ||
193 | |||
159 | /** | 194 | /** |
160 | * __pci_epf_register_driver() - register a new PCI EPF driver | 195 | * __pci_epf_register_driver() - register a new PCI EPF driver |
161 | * @driver: structure representing PCI EPF driver | 196 | * @driver: structure representing PCI EPF driver |
@@ -167,8 +202,6 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, | |||
167 | struct module *owner) | 202 | struct module *owner) |
168 | { | 203 | { |
169 | int ret; | 204 | int ret; |
170 | struct config_group *group; | ||
171 | const struct pci_epf_device_id *id; | ||
172 | 205 | ||
173 | if (!driver->ops) | 206 | if (!driver->ops) |
174 | return -EINVAL; | 207 | return -EINVAL; |
@@ -183,16 +216,7 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver, | |||
183 | if (ret) | 216 | if (ret) |
184 | return ret; | 217 | return ret; |
185 | 218 | ||
186 | INIT_LIST_HEAD(&driver->epf_group); | 219 | pci_epf_add_cfs(driver); |
187 | |||
188 | id = driver->id_table; | ||
189 | while (id->name[0]) { | ||
190 | group = pci_ep_cfs_add_epf_group(id->name); | ||
191 | mutex_lock(&pci_epf_mutex); | ||
192 | list_add_tail(&group->group_entry, &driver->epf_group); | ||
193 | mutex_unlock(&pci_epf_mutex); | ||
194 | id++; | ||
195 | } | ||
196 | 220 | ||
197 | return 0; | 221 | return 0; |
198 | } | 222 | } |
diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index 3979f89b250a..5bd6c1573295 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * All rights reserved. | 7 | * All rights reserved. |
8 | * | 8 | * |
9 | * Send feedback to <kristen.c.accardi@intel.com> | 9 | * Send feedback to <kristen.c.accardi@intel.com> |
10 | * | ||
11 | */ | 10 | */ |
12 | 11 | ||
13 | #include <linux/module.h> | 12 | #include <linux/module.h> |
@@ -87,8 +86,17 @@ int acpi_get_hp_hw_control_from_firmware(struct pci_dev *pdev) | |||
87 | return 0; | 86 | return 0; |
88 | 87 | ||
89 | /* If _OSC exists, we should not evaluate OSHP */ | 88 | /* If _OSC exists, we should not evaluate OSHP */ |
89 | |||
90 | /* | ||
91 | * If there's no ACPI host bridge (i.e., ACPI support is compiled | ||
92 | * into the kernel but the hardware platform doesn't support ACPI), | ||
93 | * there's nothing to do here. | ||
94 | */ | ||
90 | host = pci_find_host_bridge(pdev->bus); | 95 | host = pci_find_host_bridge(pdev->bus); |
91 | root = acpi_pci_find_root(ACPI_HANDLE(&host->dev)); | 96 | root = acpi_pci_find_root(ACPI_HANDLE(&host->dev)); |
97 | if (!root) | ||
98 | return 0; | ||
99 | |||
92 | if (root->osc_support_set) | 100 | if (root->osc_support_set) |
93 | goto no_control; | 101 | goto no_control; |
94 | 102 | ||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 3a17b290df5d..ef0b1b6ba86f 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -509,7 +509,7 @@ static void enable_slot(struct acpiphp_slot *slot) | |||
509 | 509 | ||
510 | list_for_each_entry(dev, &bus->devices, bus_list) { | 510 | list_for_each_entry(dev, &bus->devices, bus_list) { |
511 | /* Assume that newly added devices are powered on already. */ | 511 | /* Assume that newly added devices are powered on already. */ |
512 | if (!dev->is_added) | 512 | if (!pci_dev_is_added(dev)) |
513 | dev->current_state = PCI_D0; | 513 | dev->current_state = PCI_D0; |
514 | } | 514 | } |
515 | 515 | ||
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index d0d73dbbd5ca..0f04ae648cf1 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c | |||
@@ -575,6 +575,22 @@ void pci_iov_release(struct pci_dev *dev) | |||
575 | } | 575 | } |
576 | 576 | ||
577 | /** | 577 | /** |
578 | * pci_iov_remove - clean up SR-IOV state after PF driver is detached | ||
579 | * @dev: the PCI device | ||
580 | */ | ||
581 | void pci_iov_remove(struct pci_dev *dev) | ||
582 | { | ||
583 | struct pci_sriov *iov = dev->sriov; | ||
584 | |||
585 | if (!dev->is_physfn) | ||
586 | return; | ||
587 | |||
588 | iov->driver_max_VFs = iov->total_VFs; | ||
589 | if (iov->num_VFs) | ||
590 | pci_warn(dev, "driver left SR-IOV enabled after remove\n"); | ||
591 | } | ||
592 | |||
593 | /** | ||
578 | * pci_iov_update_resource - update a VF BAR | 594 | * pci_iov_update_resource - update a VF BAR |
579 | * @dev: the PCI device | 595 | * @dev: the PCI device |
580 | * @resno: the resource number | 596 | * @resno: the resource number |
diff --git a/drivers/pci/of.c b/drivers/pci/of.c index d088c9147f10..69a60d6ebd73 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c | |||
@@ -612,7 +612,7 @@ int pci_parse_request_of_pci_ranges(struct device *dev, | |||
612 | 612 | ||
613 | switch (resource_type(res)) { | 613 | switch (resource_type(res)) { |
614 | case IORESOURCE_IO: | 614 | case IORESOURCE_IO: |
615 | err = pci_remap_iospace(res, iobase); | 615 | err = devm_pci_remap_iospace(dev, res, iobase); |
616 | if (err) { | 616 | if (err) { |
617 | dev_warn(dev, "error %d: failed to map resource %pR\n", | 617 | dev_warn(dev, "error %d: failed to map resource %pR\n", |
618 | err, res); | 618 | err, res); |
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index c125d53033c6..6792292b5fc7 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c | |||
@@ -445,6 +445,7 @@ static int pci_device_remove(struct device *dev) | |||
445 | } | 445 | } |
446 | pcibios_free_irq(pci_dev); | 446 | pcibios_free_irq(pci_dev); |
447 | pci_dev->driver = NULL; | 447 | pci_dev->driver = NULL; |
448 | pci_iov_remove(pci_dev); | ||
448 | } | 449 | } |
449 | 450 | ||
450 | /* Undo the runtime PM settings in local_pci_probe() */ | 451 | /* Undo the runtime PM settings in local_pci_probe() */ |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 97acba712e4e..316496e99da9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -3579,6 +3579,44 @@ void pci_unmap_iospace(struct resource *res) | |||
3579 | } | 3579 | } |
3580 | EXPORT_SYMBOL(pci_unmap_iospace); | 3580 | EXPORT_SYMBOL(pci_unmap_iospace); |
3581 | 3581 | ||
3582 | static void devm_pci_unmap_iospace(struct device *dev, void *ptr) | ||
3583 | { | ||
3584 | struct resource **res = ptr; | ||
3585 | |||
3586 | pci_unmap_iospace(*res); | ||
3587 | } | ||
3588 | |||
3589 | /** | ||
3590 | * devm_pci_remap_iospace - Managed pci_remap_iospace() | ||
3591 | * @dev: Generic device to remap IO address for | ||
3592 | * @res: Resource describing the I/O space | ||
3593 | * @phys_addr: physical address of range to be mapped | ||
3594 | * | ||
3595 | * Managed pci_remap_iospace(). Map is automatically unmapped on driver | ||
3596 | * detach. | ||
3597 | */ | ||
3598 | int devm_pci_remap_iospace(struct device *dev, const struct resource *res, | ||
3599 | phys_addr_t phys_addr) | ||
3600 | { | ||
3601 | const struct resource **ptr; | ||
3602 | int error; | ||
3603 | |||
3604 | ptr = devres_alloc(devm_pci_unmap_iospace, sizeof(*ptr), GFP_KERNEL); | ||
3605 | if (!ptr) | ||
3606 | return -ENOMEM; | ||
3607 | |||
3608 | error = pci_remap_iospace(res, phys_addr); | ||
3609 | if (error) { | ||
3610 | devres_free(ptr); | ||
3611 | } else { | ||
3612 | *ptr = res; | ||
3613 | devres_add(dev, ptr); | ||
3614 | } | ||
3615 | |||
3616 | return error; | ||
3617 | } | ||
3618 | EXPORT_SYMBOL(devm_pci_remap_iospace); | ||
3619 | |||
3582 | /** | 3620 | /** |
3583 | * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace() | 3621 | * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace() |
3584 | * @dev: Generic device to remap IO address for | 3622 | * @dev: Generic device to remap IO address for |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index c358e7a07f3f..08817253c8a2 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -288,6 +288,7 @@ struct pci_sriov { | |||
288 | 288 | ||
289 | /* pci_dev priv_flags */ | 289 | /* pci_dev priv_flags */ |
290 | #define PCI_DEV_DISCONNECTED 0 | 290 | #define PCI_DEV_DISCONNECTED 0 |
291 | #define PCI_DEV_ADDED 1 | ||
291 | 292 | ||
292 | static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused) | 293 | static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused) |
293 | { | 294 | { |
@@ -300,6 +301,16 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev) | |||
300 | return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags); | 301 | return test_bit(PCI_DEV_DISCONNECTED, &dev->priv_flags); |
301 | } | 302 | } |
302 | 303 | ||
304 | static inline void pci_dev_assign_added(struct pci_dev *dev, bool added) | ||
305 | { | ||
306 | assign_bit(PCI_DEV_ADDED, &dev->priv_flags, added); | ||
307 | } | ||
308 | |||
309 | static inline bool pci_dev_is_added(const struct pci_dev *dev) | ||
310 | { | ||
311 | return test_bit(PCI_DEV_ADDED, &dev->priv_flags); | ||
312 | } | ||
313 | |||
303 | #ifdef CONFIG_PCI_ATS | 314 | #ifdef CONFIG_PCI_ATS |
304 | void pci_restore_ats_state(struct pci_dev *dev); | 315 | void pci_restore_ats_state(struct pci_dev *dev); |
305 | #else | 316 | #else |
@@ -311,6 +322,7 @@ static inline void pci_restore_ats_state(struct pci_dev *dev) | |||
311 | #ifdef CONFIG_PCI_IOV | 322 | #ifdef CONFIG_PCI_IOV |
312 | int pci_iov_init(struct pci_dev *dev); | 323 | int pci_iov_init(struct pci_dev *dev); |
313 | void pci_iov_release(struct pci_dev *dev); | 324 | void pci_iov_release(struct pci_dev *dev); |
325 | void pci_iov_remove(struct pci_dev *dev); | ||
314 | void pci_iov_update_resource(struct pci_dev *dev, int resno); | 326 | void pci_iov_update_resource(struct pci_dev *dev, int resno); |
315 | resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); | 327 | resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); |
316 | void pci_restore_iov_state(struct pci_dev *dev); | 328 | void pci_restore_iov_state(struct pci_dev *dev); |
@@ -325,6 +337,9 @@ static inline void pci_iov_release(struct pci_dev *dev) | |||
325 | 337 | ||
326 | { | 338 | { |
327 | } | 339 | } |
340 | static inline void pci_iov_remove(struct pci_dev *dev) | ||
341 | { | ||
342 | } | ||
328 | static inline void pci_restore_iov_state(struct pci_dev *dev) | 343 | static inline void pci_restore_iov_state(struct pci_dev *dev) |
329 | { | 344 | { |
330 | } | 345 | } |
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c index f7ce0cb0b0b7..f02e334beb45 100644 --- a/drivers/pci/pcie/err.c +++ b/drivers/pci/pcie/err.c | |||
@@ -295,6 +295,7 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service) | |||
295 | 295 | ||
296 | parent = udev->subordinate; | 296 | parent = udev->subordinate; |
297 | pci_lock_rescan_remove(); | 297 | pci_lock_rescan_remove(); |
298 | pci_dev_get(dev); | ||
298 | list_for_each_entry_safe_reverse(pdev, temp, &parent->devices, | 299 | list_for_each_entry_safe_reverse(pdev, temp, &parent->devices, |
299 | bus_list) { | 300 | bus_list) { |
300 | pci_dev_get(pdev); | 301 | pci_dev_get(pdev); |
@@ -328,6 +329,7 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service) | |||
328 | pci_info(dev, "Device recovery from fatal error failed\n"); | 329 | pci_info(dev, "Device recovery from fatal error failed\n"); |
329 | } | 330 | } |
330 | 331 | ||
332 | pci_dev_put(dev); | ||
331 | pci_unlock_rescan_remove(); | 333 | pci_unlock_rescan_remove(); |
332 | } | 334 | } |
333 | 335 | ||
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index ac876e32de4b..611adcd9c169 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -2433,13 +2433,13 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) | |||
2433 | dev = pci_scan_single_device(bus, devfn); | 2433 | dev = pci_scan_single_device(bus, devfn); |
2434 | if (!dev) | 2434 | if (!dev) |
2435 | return 0; | 2435 | return 0; |
2436 | if (!dev->is_added) | 2436 | if (!pci_dev_is_added(dev)) |
2437 | nr++; | 2437 | nr++; |
2438 | 2438 | ||
2439 | for (fn = next_fn(bus, dev, 0); fn > 0; fn = next_fn(bus, dev, fn)) { | 2439 | for (fn = next_fn(bus, dev, 0); fn > 0; fn = next_fn(bus, dev, fn)) { |
2440 | dev = pci_scan_single_device(bus, devfn + fn); | 2440 | dev = pci_scan_single_device(bus, devfn + fn); |
2441 | if (dev) { | 2441 | if (dev) { |
2442 | if (!dev->is_added) | 2442 | if (!pci_dev_is_added(dev)) |
2443 | nr++; | 2443 | nr++; |
2444 | dev->multifunction = 1; | 2444 | dev->multifunction = 1; |
2445 | } | 2445 | } |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 6f072eae4f7a..5e3d0dced2b8 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -19,11 +19,12 @@ static void pci_stop_dev(struct pci_dev *dev) | |||
19 | { | 19 | { |
20 | pci_pme_active(dev, false); | 20 | pci_pme_active(dev, false); |
21 | 21 | ||
22 | if (dev->is_added) { | 22 | if (pci_dev_is_added(dev)) { |
23 | device_release_driver(&dev->dev); | 23 | device_release_driver(&dev->dev); |
24 | pci_proc_detach_device(dev); | 24 | pci_proc_detach_device(dev); |
25 | pci_remove_sysfs_dev_files(dev); | 25 | pci_remove_sysfs_dev_files(dev); |
26 | dev->is_added = 0; | 26 | |
27 | pci_dev_assign_added(dev, false); | ||
27 | } | 28 | } |
28 | 29 | ||
29 | if (dev->bus->self) | 30 | if (dev->bus->self) |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 340029b2fb38..c133ccfa002e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -368,7 +368,6 @@ struct pci_dev { | |||
368 | unsigned int transparent:1; /* Subtractive decode bridge */ | 368 | unsigned int transparent:1; /* Subtractive decode bridge */ |
369 | unsigned int multifunction:1; /* Multi-function device */ | 369 | unsigned int multifunction:1; /* Multi-function device */ |
370 | 370 | ||
371 | unsigned int is_added:1; | ||
372 | unsigned int is_busmaster:1; /* Is busmaster */ | 371 | unsigned int is_busmaster:1; /* Is busmaster */ |
373 | unsigned int no_msi:1; /* May not use MSI */ | 372 | unsigned int no_msi:1; /* May not use MSI */ |
374 | unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */ | 373 | unsigned int no_64bit_msi:1; /* May only use 32-bit MSIs */ |
@@ -1240,6 +1239,8 @@ int pci_register_io_range(struct fwnode_handle *fwnode, phys_addr_t addr, | |||
1240 | unsigned long pci_address_to_pio(phys_addr_t addr); | 1239 | unsigned long pci_address_to_pio(phys_addr_t addr); |
1241 | phys_addr_t pci_pio_to_address(unsigned long pio); | 1240 | phys_addr_t pci_pio_to_address(unsigned long pio); |
1242 | int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr); | 1241 | int pci_remap_iospace(const struct resource *res, phys_addr_t phys_addr); |
1242 | int devm_pci_remap_iospace(struct device *dev, const struct resource *res, | ||
1243 | phys_addr_t phys_addr); | ||
1243 | void pci_unmap_iospace(struct resource *res); | 1244 | void pci_unmap_iospace(struct resource *res); |
1244 | void __iomem *devm_pci_remap_cfgspace(struct device *dev, | 1245 | void __iomem *devm_pci_remap_cfgspace(struct device *dev, |
1245 | resource_size_t offset, | 1246 | resource_size_t offset, |