aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2018-08-05 10:39:29 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-08-05 10:39:29 -0400
commitf2701b77bbd992f3df4631de8493f21db0830452 (patch)
treeb05b2bf8b47002ae81c79aaa9de2a311b8ee075e /drivers/pci
parent18b57ce2eb8c8b9a24174a89250cf5f57c76ecdc (diff)
parentacb1872577b346bd15ab3a3f8dff780d6cca4b70 (diff)
Merge 4.18-rc7 into master to pick up the KVM dependcy
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/Makefile6
-rw-r--r--drivers/pci/controller/Kconfig3
-rw-r--r--drivers/pci/controller/dwc/Kconfig1
-rw-r--r--drivers/pci/controller/dwc/pcie-designware-host.c3
-rw-r--r--drivers/pci/controller/pci-aardvark.c2
-rw-r--r--drivers/pci/controller/pci-ftpci100.c4
-rw-r--r--drivers/pci/controller/pci-hyperv.c8
-rw-r--r--drivers/pci/controller/pci-v3-semi.c2
-rw-r--r--drivers/pci/controller/pci-versatile.c2
-rw-r--r--drivers/pci/controller/pci-xgene.c2
-rw-r--r--drivers/pci/controller/pcie-mediatek.c2
-rw-r--r--drivers/pci/controller/pcie-rcar.c16
-rw-r--r--drivers/pci/controller/pcie-xilinx-nwl.c2
-rw-r--r--drivers/pci/controller/pcie-xilinx.c1
-rw-r--r--drivers/pci/endpoint/pci-epf-core.c62
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c10
-rw-r--r--drivers/pci/iov.c16
-rw-r--r--drivers/pci/of.c2
-rw-r--r--drivers/pci/pci-acpi.c12
-rw-r--r--drivers/pci/pci-driver.c1
-rw-r--r--drivers/pci/pci.c38
-rw-r--r--drivers/pci/pci.h4
-rw-r--r--drivers/pci/pcie/err.c2
23 files changed, 159 insertions, 42 deletions
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
28obj-$(CONFIG_PCI_ECAM) += ecam.o 28obj-$(CONFIG_PCI_ECAM) += ecam.o
29obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o 29obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
30 30
31obj-y += controller/
32obj-y += switch/
33
34# Endpoint library must be initialized before its users 31# Endpoint library must be initialized before its users
35obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ 32obj-$(CONFIG_PCI_ENDPOINT) += endpoint/
36 33
34obj-y += controller/
35obj-y += switch/
36
37ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG 37ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
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
139config PCIE_IPROC 138config 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
176config PCIE_ALTERA 174config 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 fadc305533d9..d4d4a55f09f8 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1074,6 +1074,7 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
1074 struct pci_bus *pbus; 1074 struct pci_bus *pbus;
1075 struct pci_dev *pdev; 1075 struct pci_dev *pdev;
1076 struct cpumask *dest; 1076 struct cpumask *dest;
1077 unsigned long flags;
1077 struct compose_comp_ctxt comp; 1078 struct compose_comp_ctxt comp;
1078 struct tran_int_desc *int_desc; 1079 struct tran_int_desc *int_desc;
1079 struct { 1080 struct {
@@ -1165,14 +1166,15 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
1165 * the channel callback directly when channel->target_cpu is 1166 * the channel callback directly when channel->target_cpu is
1166 * the current CPU. When the higher level interrupt code 1167 * the current CPU. When the higher level interrupt code
1167 * calls us with interrupt enabled, let's add the 1168 * calls us with interrupt enabled, let's add the
1168 * local_bh_disable()/enable() to avoid race. 1169 * local_irq_save()/restore() to avoid race:
1170 * hv_pci_onchannelcallback() can also run in tasklet.
1169 */ 1171 */
1170 local_bh_disable(); 1172 local_irq_save(flags);
1171 1173
1172 if (hbus->hdev->channel->target_cpu == smp_processor_id()) 1174 if (hbus->hdev->channel->target_cpu == smp_processor_id())
1173 hv_pci_onchannelcallback(hbus); 1175 hv_pci_onchannelcallback(hbus);
1174 1176
1175 local_bh_enable(); 1177 local_irq_restore(flags);
1176 1178
1177 if (hpdev->state == hv_pcichild_ejecting) { 1179 if (hpdev->state == hv_pcichild_ejecting) {
1178 dev_err_once(&hbus->hdev->device, 1180 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-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
686static int rcar_msi_alloc(struct rcar_msi *chip) 690static 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
1198err_phy_shutdown:
1199 if (pcie->phy) {
1200 phy_power_off(pcie->phy);
1201 phy_exit(pcie->phy);
1202 }
1203
1194err_clk_disable: 1204err_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}
138EXPORT_SYMBOL_GPL(pci_epf_alloc_space); 138EXPORT_SYMBOL_GPL(pci_epf_alloc_space);
139 139
140static 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 */
146void pci_epf_unregister_driver(struct pci_epf_driver *driver) 160void 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}
157EXPORT_SYMBOL_GPL(pci_epf_unregister_driver); 165EXPORT_SYMBOL_GPL(pci_epf_unregister_driver);
158 166
167static 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/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 */
581void 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-acpi.c b/drivers/pci/pci-acpi.c
index 65113b6eed14..89ee6a2b6eb8 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -629,6 +629,18 @@ static bool acpi_pci_need_resume(struct pci_dev *dev)
629{ 629{
630 struct acpi_device *adev = ACPI_COMPANION(&dev->dev); 630 struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
631 631
632 /*
633 * In some cases (eg. Samsung 305V4A) leaving a bridge in suspend over
634 * system-wide suspend/resume confuses the platform firmware, so avoid
635 * doing that, unless the bridge has a driver that should take care of
636 * the PM handling. According to Section 16.1.6 of ACPI 6.2, endpoint
637 * devices are expected to be in D3 before invoking the S3 entry path
638 * from the firmware, so they should not be affected by this issue.
639 */
640 if (pci_is_bridge(dev) && !dev->driver &&
641 acpi_target_system_state() != ACPI_STATE_S0)
642 return true;
643
632 if (!adev || !acpi_device_power_manageable(adev)) 644 if (!adev || !acpi_device_power_manageable(adev))
633 return false; 645 return false;
634 646
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}
3580EXPORT_SYMBOL(pci_unmap_iospace); 3580EXPORT_SYMBOL(pci_unmap_iospace);
3581 3581
3582static 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 */
3598int 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}
3618EXPORT_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..882f1f9596df 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -311,6 +311,7 @@ static inline void pci_restore_ats_state(struct pci_dev *dev)
311#ifdef CONFIG_PCI_IOV 311#ifdef CONFIG_PCI_IOV
312int pci_iov_init(struct pci_dev *dev); 312int pci_iov_init(struct pci_dev *dev);
313void pci_iov_release(struct pci_dev *dev); 313void pci_iov_release(struct pci_dev *dev);
314void pci_iov_remove(struct pci_dev *dev);
314void pci_iov_update_resource(struct pci_dev *dev, int resno); 315void pci_iov_update_resource(struct pci_dev *dev, int resno);
315resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno); 316resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno);
316void pci_restore_iov_state(struct pci_dev *dev); 317void pci_restore_iov_state(struct pci_dev *dev);
@@ -325,6 +326,9 @@ static inline void pci_iov_release(struct pci_dev *dev)
325 326
326{ 327{
327} 328}
329static inline void pci_iov_remove(struct pci_dev *dev)
330{
331}
328static inline void pci_restore_iov_state(struct pci_dev *dev) 332static inline void pci_restore_iov_state(struct pci_dev *dev)
329{ 333{
330} 334}
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