aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2018-09-20 12:27:06 -0400
committerBjorn Helgaas <bhelgaas@google.com>2018-09-20 13:05:54 -0400
commitc29de84149aba5f74e87b6491c13ac7203c12f55 (patch)
treebe2916b0d37a15aca8580440aae8cabc4b03aa6f
parenta0d58937404f5fe095120687c8914175587e6c51 (diff)
PCI: portdrv: Initialize service drivers directly
The PCI port driver saves the PCI state after initializing the device with the applicable service devices. This was, however, before the service drivers were even registered because PCI probe happens before the device_initcall initialized those service drivers. The config space state that the services set up were not being saved. The end result would cause PCI devices to not react to events that the drivers think they did if the PCI state ever needed to be restored. Fix this by changing the service drivers from using the init calls to having the portdrv driver calling the services directly. This will get the state saved as desired, while making the relationship between the port driver and the services under it more explicit in the code. Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Sinan Kaya <okaya@kernel.org>
-rw-r--r--drivers/pci/hotplug/pciehp_core.c3
-rw-r--r--drivers/pci/pcie/aer.c3
-rw-r--r--drivers/pci/pcie/dpc.c3
-rw-r--r--drivers/pci/pcie/pme.c3
-rw-r--r--drivers/pci/pcie/portdrv.h24
-rw-r--r--drivers/pci/pcie/portdrv_pci.c9
6 files changed, 37 insertions, 8 deletions
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 68b20e667764..944047976569 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -287,7 +287,7 @@ static struct pcie_port_service_driver hpdriver_portdrv = {
287#endif /* PM */ 287#endif /* PM */
288}; 288};
289 289
290static int __init pcied_init(void) 290int __init pcie_hp_init(void)
291{ 291{
292 int retval = 0; 292 int retval = 0;
293 293
@@ -298,4 +298,3 @@ static int __init pcied_init(void)
298 298
299 return retval; 299 return retval;
300} 300}
301device_initcall(pcied_init);
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 83180edd6ed4..637d638f73da 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1569,10 +1569,9 @@ static struct pcie_port_service_driver aerdriver = {
1569 * 1569 *
1570 * Invoked when AER root service driver is loaded. 1570 * Invoked when AER root service driver is loaded.
1571 */ 1571 */
1572static int __init aer_service_init(void) 1572int __init pcie_aer_init(void)
1573{ 1573{
1574 if (!pci_aer_available() || aer_acpi_firmware_first()) 1574 if (!pci_aer_available() || aer_acpi_firmware_first())
1575 return -ENXIO; 1575 return -ENXIO;
1576 return pcie_port_service_register(&aerdriver); 1576 return pcie_port_service_register(&aerdriver);
1577} 1577}
1578device_initcall(aer_service_init);
diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
index f03279fc87cd..a1fd16bf1cab 100644
--- a/drivers/pci/pcie/dpc.c
+++ b/drivers/pci/pcie/dpc.c
@@ -282,8 +282,7 @@ static struct pcie_port_service_driver dpcdriver = {
282 .reset_link = dpc_reset_link, 282 .reset_link = dpc_reset_link,
283}; 283};
284 284
285static int __init dpc_service_init(void) 285int __init pcie_dpc_init(void)
286{ 286{
287 return pcie_port_service_register(&dpcdriver); 287 return pcie_port_service_register(&dpcdriver);
288} 288}
289device_initcall(dpc_service_init);
diff --git a/drivers/pci/pcie/pme.c b/drivers/pci/pcie/pme.c
index 3ed67676ea2a..1a8b85051b1b 100644
--- a/drivers/pci/pcie/pme.c
+++ b/drivers/pci/pcie/pme.c
@@ -446,8 +446,7 @@ static struct pcie_port_service_driver pcie_pme_driver = {
446/** 446/**
447 * pcie_pme_service_init - Register the PCIe PME service driver. 447 * pcie_pme_service_init - Register the PCIe PME service driver.
448 */ 448 */
449static int __init pcie_pme_service_init(void) 449int __init pcie_pme_init(void)
450{ 450{
451 return pcie_port_service_register(&pcie_pme_driver); 451 return pcie_port_service_register(&pcie_pme_driver);
452} 452}
453device_initcall(pcie_pme_service_init);
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index d59afa42fc14..2498b2d34009 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -23,6 +23,30 @@
23 23
24#define PCIE_PORT_DEVICE_MAXSERVICES 4 24#define PCIE_PORT_DEVICE_MAXSERVICES 4
25 25
26#ifdef CONFIG_PCIEAER
27int pcie_aer_init(void);
28#else
29static inline int pcie_aer_init(void) { return 0; }
30#endif
31
32#ifdef CONFIG_HOTPLUG_PCI_PCIE
33int pcie_hp_init(void);
34#else
35static inline int pcie_hp_init(void) { return 0; }
36#endif
37
38#ifdef CONFIG_PCIE_PME
39int pcie_pme_init(void);
40#else
41static inline int pcie_pme_init(void) { return 0; }
42#endif
43
44#ifdef CONFIG_PCIE_DPC
45int pcie_dpc_init(void);
46#else
47static inline int pcie_dpc_init(void) { return 0; }
48#endif
49
26/* Port Type */ 50/* Port Type */
27#define PCIE_ANY_PORT (~0) 51#define PCIE_ANY_PORT (~0)
28 52
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index eef22dc29140..23a5a0c2c3fe 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -226,11 +226,20 @@ static const struct dmi_system_id pcie_portdrv_dmi_table[] __initconst = {
226 {} 226 {}
227}; 227};
228 228
229static void __init pcie_init_services(void)
230{
231 pcie_aer_init();
232 pcie_pme_init();
233 pcie_dpc_init();
234 pcie_hp_init();
235}
236
229static int __init pcie_portdrv_init(void) 237static int __init pcie_portdrv_init(void)
230{ 238{
231 if (pcie_ports_disabled) 239 if (pcie_ports_disabled)
232 return -EACCES; 240 return -EACCES;
233 241
242 pcie_init_services();
234 dmi_check_system(pcie_portdrv_dmi_table); 243 dmi_check_system(pcie_portdrv_dmi_table);
235 244
236 return pci_register_driver(&pcie_portdriver); 245 return pci_register_driver(&pcie_portdriver);