powerpc/pseries: Enable RAS hotplug events later

"Linux Kernel Mailing List" <[email protected]> Wed, 14 Feb 2018 18:19:52 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/c9dccf1d074a67d36c510845f663980d69e3409b
Commit:     c9dccf1d074a67d36c510845f663980d69e3409b
Parent:     4dd5f8a99e791a8c6500e3592f3ce81ae7edcde1
Refname:    refs/heads/master
Author:     Sam Bobroff <[email protected]>
AuthorDate: Mon Feb 12 11:19:29 2018 +1100
Committer:  Michael Ellerman <[email protected]>
CommitDate: Tue Feb 13 22:37:46 2018 +1100

    powerpc/pseries: Enable RAS hotplug events later
    
    Currently if the kernel receives a memory hot-unplug event early
    enough, it may get stuck in an infinite loop in
    dissolve_free_huge_pages(). This appears as a stall just after:
    
      pseries-hotplug-mem: Attempting to hot-remove XX LMB(s) at YYYYYYYY
    
    It appears to be caused by "minimum_order" being uninitialized, due to
    init_ras_IRQ() executing before hugetlb_init().
    
    To correct this, extract the part of init_ras_IRQ() that enables
    hotplug event processing and place it in the machine_late_initcall
    phase, which is guaranteed to be after hugetlb_init() is called.
    
    Signed-off-by: Sam Bobroff <[email protected]>
    Acked-by: Balbir Singh <[email protected]>
    [mpe: Reorder the functions to make the diff readable]
    Signed-off-by: Michael Ellerman <[email protected]>
---
 arch/powerpc/platforms/pseries/ras.c | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 81d8614e7379..5e1ef9150182 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -48,6 +48,28 @@ static irqreturn_t ras_epow_interrupt(int irq, void *dev_id);
 static irqreturn_t ras_error_interrupt(int irq, void *dev_id);
 
 
+/*
+ * Enable the hotplug interrupt late because processing them may touch other
+ * devices or systems (e.g. hugepages) that have not been initialized at the
+ * subsys stage.
+ */
+int __init init_ras_hotplug_IRQ(void)
+{
+	struct device_node *np;
+
+	/* Hotplug Events */
+	np = of_find_node_by_path("/event-sources/hot-plug-events");
+	if (np != NULL) {
+		if (dlpar_workqueue_init() == 0)
+			request_event_sources_irqs(np, ras_hotplug_interrupt,
+						   "RAS_HOTPLUG");
+		of_node_put(np);
+	}
+
+	return 0;
+}
+machine_late_initcall(pseries, init_ras_hotplug_IRQ);
+
 /*
  * Initialize handlers for the set of interrupts caused by hardware errors
  * and power system events.
@@ -66,15 +88,6 @@ static int __init init_ras_IRQ(void)
 		of_node_put(np);
 	}
 
-	/* Hotplug Events */
-	np = of_find_node_by_path("/event-sources/hot-plug-events");
-	if (np != NULL) {
-		if (dlpar_workqueue_init() == 0)
-			request_event_sources_irqs(np, ras_hotplug_interrupt,
-					   "RAS_HOTPLUG");
-		of_node_put(np);
-	}