Skip to content

Commit 395ee2a

Browse files
oohalmpe
authored andcommitted
powerpc/eeh: Move EEH initialisation to an arch initcall
The initialisation of EEH mostly happens in a core_initcall_sync initcall, followed by registering a bus notifier later on in an arch_initcall. Anything involving initcall dependecies is mostly incomprehensible unless you've spent a while staring at code so here's the full sequence: ppc_md.setup_arch <-- pci_controllers are created here ...time passes... core_initcall <-- pci_dns are created from DT nodes core_initcall_sync <-- platforms call eeh_init() postcore_initcall <-- PCI bus type is registered postcore_initcall_sync arch_initcall <-- EEH pci_bus notifier registered subsys_initcall <-- PHBs are scanned here There's no real requirement to do the EEH setup at the core_initcall_sync level. It just needs to be done after pci_dn's are created and before we start scanning PHBs. Simplify the flow a bit by moving the platform EEH inititalisation to an arch_initcall so we can fold the bus notifier registration into eeh_init(). Signed-off-by: Oliver O'Halloran <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5d69e46 commit 395ee2a

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

arch/powerpc/kernel/eeh.c

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,30 @@ static struct notifier_block eeh_reboot_nb = {
940940
.notifier_call = eeh_reboot_notifier,
941941
};
942942

943+
static int eeh_device_notifier(struct notifier_block *nb,
944+
unsigned long action, void *data)
945+
{
946+
struct device *dev = data;
947+
948+
switch (action) {
949+
/*
950+
* Note: It's not possible to perform EEH device addition (i.e.
951+
* {pseries,pnv}_pcibios_bus_add_device()) here because it depends on
952+
* the device's resources, which have not yet been set up.
953+
*/
954+
case BUS_NOTIFY_DEL_DEVICE:
955+
eeh_remove_device(to_pci_dev(dev));
956+
break;
957+
default:
958+
break;
959+
}
960+
return NOTIFY_DONE;
961+
}
962+
963+
static struct notifier_block eeh_device_nb = {
964+
.notifier_call = eeh_device_notifier,
965+
};
966+
943967
/**
944968
* eeh_init - System wide EEH initialization
945969
*
@@ -960,7 +984,14 @@ int eeh_init(struct eeh_ops *ops)
960984
/* Register reboot notifier */
961985
ret = register_reboot_notifier(&eeh_reboot_nb);
962986
if (ret) {
963-
pr_warn("%s: Failed to register notifier (%d)\n",
987+
pr_warn("%s: Failed to register reboot notifier (%d)\n",
988+
__func__, ret);
989+
return ret;
990+
}
991+
992+
ret = bus_register_notifier(&pci_bus_type, &eeh_device_nb);
993+
if (ret) {
994+
pr_warn("%s: Failed to register bus notifier (%d)\n",
964995
__func__, ret);
965996
return ret;
966997
}
@@ -975,37 +1006,6 @@ int eeh_init(struct eeh_ops *ops)
9751006
return eeh_event_init();
9761007
}
9771008

978-
static int eeh_device_notifier(struct notifier_block *nb,
979-
unsigned long action, void *data)
980-
{
981-
struct device *dev = data;
982-
983-
switch (action) {
984-
/*
985-
* Note: It's not possible to perform EEH device addition (i.e.
986-
* {pseries,pnv}_pcibios_bus_add_device()) here because it depends on
987-
* the device's resources, which have not yet been set up.
988-
*/
989-
case BUS_NOTIFY_DEL_DEVICE:
990-
eeh_remove_device(to_pci_dev(dev));
991-
break;
992-
default:
993-
break;
994-
}
995-
return NOTIFY_DONE;
996-
}
997-
998-
static struct notifier_block eeh_device_nb = {
999-
.notifier_call = eeh_device_notifier,
1000-
};
1001-
1002-
static __init int eeh_set_bus_notifier(void)
1003-
{
1004-
bus_register_notifier(&pci_bus_type, &eeh_device_nb);
1005-
return 0;
1006-
}
1007-
arch_initcall(eeh_set_bus_notifier);
1008-
10091009
/**
10101010
* eeh_probe_device() - Perform EEH initialization for the indicated pci device
10111011
* @dev: pci device for which to set up EEH

arch/powerpc/platforms/powernv/eeh-powernv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,4 +1721,4 @@ static int __init eeh_powernv_init(void)
17211721

17221722
return ret;
17231723
}
1724-
machine_core_initcall_sync(powernv, eeh_powernv_init);
1724+
machine_arch_initcall(powernv, eeh_powernv_init);

arch/powerpc/platforms/pseries/eeh_pseries.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,4 +985,4 @@ static int __init eeh_pseries_init(void)
985985
ret);
986986
return ret;
987987
}
988-
machine_core_initcall_sync(pseries, eeh_pseries_init);
988+
machine_arch_initcall(pseries, eeh_pseries_init);

0 commit comments

Comments
 (0)