From: Nishanth Aravamudan <nacc@us.ibm.com>
Subject: dlpar: invoke notifier chains before removing /proc nodes
Patch-Mainline: no
References: bnc#793678

This change reflects the DLPAR flow upstream, but in the 3.0- series of
kernels, there is an unnecessary dichotomy between the /proc DT and OF nodes
being removed and when the notifier gets invoked. Thus, upstream, we are safe
to remove the custom DDW property; but in the 3.0- kernel, we get a warning
from fs/proc/generic.c that the parent's directory entry of the property we are
removing is NULL (not found). The fix is to call the notifiers before doing any
removals, which avoids the issue, and seems like a safe change to me.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Acked-by: Torsten Duwe <duwe@suse.de>

diff -urpN linux-3.0/arch/powerpc/platforms/pseries/dlpar.c linux-3.0-ddw5/arch/powerpc/platforms/pseries/dlpar.c
--- linux-3.0/arch/powerpc/platforms/pseries/dlpar.c	2013-01-23 19:01:35.000000000 -0500
+++ linux-3.0-ddw5/arch/powerpc/platforms/pseries/dlpar.c	2013-01-23 20:57:17.000000000 -0500
@@ -291,7 +291,12 @@ int dlpar_detach_node(struct device_node
 #ifdef CONFIG_PROC_DEVICETREE
 	struct device_node *parent = dn->parent;
 	struct property *prop = dn->properties;
+#endif
+
+	blocking_notifier_call_chain(&pSeries_reconfig_chain,
+			    PSERIES_RECONFIG_REMOVE, dn);
 
+#ifdef CONFIG_PROC_DEVICETREE
 	while (prop) {
 		remove_proc_entry(prop->name, dn->pde);
 		prop = prop->next;
@@ -301,8 +306,6 @@ int dlpar_detach_node(struct device_node
 		remove_proc_entry(dn->pde->name, parent->pde);
 #endif
 
-	blocking_notifier_call_chain(&pSeries_reconfig_chain,
-			    PSERIES_RECONFIG_REMOVE, dn);
 	of_detach_node(dn);
 	of_node_put(dn); /* Must decrement the refcount */
 
diff -urpN linux-3.0/arch/powerpc/platforms/pseries/reconfig.c linux-3.0-ddw/arch/powerpc/platforms/pseries/reconfig.c
--- linux-3.0/arch/powerpc/platforms/pseries/reconfig.c	2011-07-21 22:17:23.000000000 -0400
+++ linux-3.0-ddw/arch/powerpc/platforms/pseries/reconfig.c	2013-01-24 14:02:13.000000000 -0500
@@ -171,10 +171,11 @@ static int pSeries_reconfig_remove_node(
 		return -EBUSY;
 	}
 
-	remove_node_proc_entries(np);
-
 	blocking_notifier_call_chain(&pSeries_reconfig_chain,
 			    PSERIES_RECONFIG_REMOVE, np);
+
+	remove_node_proc_entries(np);
+
 	of_detach_node(np);
 
 	of_node_put(parent);
