Michal Suchanek 817e7c
From 7d35bef96a46f7e9e167bb25258c0bd389aeab1b Mon Sep 17 00:00:00 2001
Michal Suchanek 817e7c
From: Nathan Lynch <nathanl@linux.ibm.com>
Michal Suchanek 817e7c
Date: Fri, 12 Jun 2020 00:12:24 -0500
Michal Suchanek 817e7c
Subject: [PATCH] powerpc/numa: remove unreachable topology update code
Michal Suchanek 817e7c
Michal Suchanek 817e7c
References: bsc#1181674 ltc#189159
Michal Suchanek 817e7c
Patch-mainline: v5.9-rc1
Michal Suchanek 817e7c
Git-commit: 7d35bef96a46f7e9e167bb25258c0bd389aeab1b
Michal Suchanek 817e7c
Michal Suchanek 817e7c
Since the topology_updates_enabled flag is now always false, remove it
Michal Suchanek 817e7c
and the code which has become unreachable. This is the minimum change
Michal Suchanek 817e7c
that prevents 'defined but unused' warnings emitted by the compiler
Michal Suchanek 817e7c
after stubbing out the start/stop_topology_updates() functions.
Michal Suchanek 817e7c
Michal Suchanek 817e7c
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Michal Suchanek 817e7c
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Michal Suchanek 817e7c
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Michal Suchanek 817e7c
Link: https://lore.kernel.org/r/20200612051238.1007764-5-nathanl@linux.ibm.com
Michal Suchanek 817e7c
Acked-by: Michal Suchanek <msuchanek@suse.de>
Michal Suchanek 817e7c
---
Michal Suchanek 817e7c
 arch/powerpc/mm/numa.c | 149 +----------------------------------------
Michal Suchanek 817e7c
 1 file changed, 2 insertions(+), 147 deletions(-)
Michal Suchanek 817e7c
Michal Suchanek 817e7c
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
Michal Suchanek 817e7c
--- a/arch/powerpc/mm/numa.c
Michal Suchanek 817e7c
+++ b/arch/powerpc/mm/numa.c
Michal Suchanek 817e7c
@@ -984,8 +984,6 @@ static int __init early_numa(char *p)
Michal Suchanek 817e7c
 }
Michal Suchanek 817e7c
 early_param("numa", early_numa);
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
-static const bool topology_updates_enabled;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
 #ifdef CONFIG_MEMORY_HOTPLUG
Michal Suchanek 817e7c
 /*
Michal Suchanek 817e7c
  * Find the node associated with a hot added memory section for
Michal Suchanek 817e7c
@@ -1133,7 +1131,6 @@ struct topology_update_data {
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
 #define TOPOLOGY_DEF_TIMER_SECS	60
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
-static u8 vphn_cpu_change_counts[NR_CPUS][MAX_DISTANCE_REF_POINTS];
Michal Suchanek 817e7c
 static cpumask_t cpu_associativity_changes_mask;
Michal Suchanek 817e7c
 static int vphn_enabled;
Michal Suchanek 817e7c
 static int prrn_enabled;
Michal Suchanek 817e7c
@@ -1158,63 +1155,6 @@ int timed_topology_update(int nsecs)
Michal Suchanek 817e7c
 	return 0;
Michal Suchanek 817e7c
 }
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
-/*
Michal Suchanek 817e7c
- * Store the current values of the associativity change counters in the
Michal Suchanek 817e7c
- * hypervisor.
Michal Suchanek 817e7c
- */
Michal Suchanek 817e7c
-static void setup_cpu_associativity_change_counters(void)
Michal Suchanek 817e7c
-{
Michal Suchanek 817e7c
-	int cpu;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	/* The VPHN feature supports a maximum of 8 reference points */
Michal Suchanek 817e7c
-	BUILD_BUG_ON(MAX_DISTANCE_REF_POINTS > 8);
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	for_each_possible_cpu(cpu) {
Michal Suchanek 817e7c
-		int i;
Michal Suchanek 817e7c
-		u8 *counts = vphn_cpu_change_counts[cpu];
Michal Suchanek 817e7c
-		volatile u8 *hypervisor_counts = lppaca[cpu].vphn_assoc_counts;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-		for (i = 0; i < distance_ref_points_depth; i++)
Michal Suchanek 817e7c
-			counts[i] = hypervisor_counts[i];
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-/*
Michal Suchanek 817e7c
- * The hypervisor maintains a set of 8 associativity change counters in
Michal Suchanek 817e7c
- * the VPA of each cpu that correspond to the associativity levels in the
Michal Suchanek 817e7c
- * ibm,associativity-reference-points property. When an associativity
Michal Suchanek 817e7c
- * level changes, the corresponding counter is incremented.
Michal Suchanek 817e7c
- *
Michal Suchanek 817e7c
- * Set a bit in cpu_associativity_changes_mask for each cpu whose home
Michal Suchanek 817e7c
- * node associativity levels have changed.
Michal Suchanek 817e7c
- *
Michal Suchanek 817e7c
- * Returns the number of cpus with unhandled associativity changes.
Michal Suchanek 817e7c
- */
Michal Suchanek 817e7c
-static int update_cpu_associativity_changes_mask(void)
Michal Suchanek 817e7c
-{
Michal Suchanek 817e7c
-	int cpu;
Michal Suchanek 817e7c
-	cpumask_t *changes = &cpu_associativity_changes_mask;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	for_each_possible_cpu(cpu) {
Michal Suchanek 817e7c
-		int i, changed = 0;
Michal Suchanek 817e7c
-		u8 *counts = vphn_cpu_change_counts[cpu];
Michal Suchanek 817e7c
-		volatile u8 *hypervisor_counts = lppaca[cpu].vphn_assoc_counts;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-		for (i = 0; i < distance_ref_points_depth; i++) {
Michal Suchanek 817e7c
-			if (hypervisor_counts[i] != counts[i]) {
Michal Suchanek 817e7c
-				counts[i] = hypervisor_counts[i];
Michal Suchanek 817e7c
-				changed = 1;
Michal Suchanek 817e7c
-			}
Michal Suchanek 817e7c
-		}
Michal Suchanek 817e7c
-		if (changed) {
Michal Suchanek 817e7c
-			cpumask_or(changes, changes, cpu_sibling_mask(cpu));
Michal Suchanek 817e7c
-			cpu = cpu_last_thread_sibling(cpu);
Michal Suchanek 817e7c
-		}
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	return cpumask_weight(changes);
Michal Suchanek 817e7c
-}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
 /*
Michal Suchanek 817e7c
  * Retrieve the new associativity information for a virtual processor's
Michal Suchanek 817e7c
  * home node.
Michal Suchanek 817e7c
@@ -1498,16 +1438,6 @@ static void topology_schedule_update(void)
Michal Suchanek 817e7c
 	schedule_work(&topology_work);
Michal Suchanek 817e7c
 }
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
-static void topology_timer_fn(unsigned long ignored)
Michal Suchanek 817e7c
-{
Michal Suchanek 817e7c
-	if (prrn_enabled && cpumask_weight(&cpu_associativity_changes_mask))
Michal Suchanek 817e7c
-		topology_schedule_update();
Michal Suchanek 817e7c
-	else if (vphn_enabled) {
Michal Suchanek 817e7c
-		if (update_cpu_associativity_changes_mask() > 0)
Michal Suchanek 817e7c
-			topology_schedule_update();
Michal Suchanek 817e7c
-		reset_topology_timer();
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-}
Michal Suchanek 817e7c
 static struct timer_list topology_timer =
Michal Suchanek 817e7c
 	TIMER_INITIALIZER(topology_timer_fn, 0, 0);
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
@@ -1516,68 +1446,12 @@ static void reset_topology_timer(void)
Michal Suchanek 817e7c
 	mod_timer(&topology_timer, topology_timer.expires);
Michal Suchanek 817e7c
 }
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
-#ifdef CONFIG_SMP
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-static int dt_update_callback(struct notifier_block *nb,
Michal Suchanek 817e7c
-				unsigned long action, void *data)
Michal Suchanek 817e7c
-{
Michal Suchanek 817e7c
-	struct of_reconfig_data *update = data;
Michal Suchanek 817e7c
-	int rc = NOTIFY_DONE;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	switch (action) {
Michal Suchanek 817e7c
-	case OF_RECONFIG_UPDATE_PROPERTY:
Michal Suchanek 817e7c
-		if (!of_prop_cmp(update->dn->type, "cpu") &&
Michal Suchanek 817e7c
-		    !of_prop_cmp(update->prop->name, "ibm,associativity")) {
Michal Suchanek 817e7c
-			u32 core_id;
Michal Suchanek 817e7c
-			of_property_read_u32(update->dn, "reg", &core_id);
Michal Suchanek 817e7c
-			rc = dlpar_cpu_readd(core_id);
Michal Suchanek 817e7c
-			rc = NOTIFY_OK;
Michal Suchanek 817e7c
-		}
Michal Suchanek 817e7c
-		break;
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	return rc;
Michal Suchanek 817e7c
-}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-static struct notifier_block dt_update_nb = {
Michal Suchanek 817e7c
-	.notifier_call = dt_update_callback,
Michal Suchanek 817e7c
-};
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-#endif
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
 /*
Michal Suchanek 817e7c
  * Start polling for associativity changes.
Michal Suchanek 817e7c
  */
Michal Suchanek 817e7c
 int start_topology_update(void)
Michal Suchanek 817e7c
 {
Michal Suchanek 817e7c
-	int rc = 0;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	if (!topology_updates_enabled)
Michal Suchanek 817e7c
-		return 0;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	if (firmware_has_feature(FW_FEATURE_PRRN)) {
Michal Suchanek 817e7c
-		if (!prrn_enabled) {
Michal Suchanek 817e7c
-			prrn_enabled = 1;
Michal Suchanek 817e7c
-#ifdef CONFIG_SMP
Michal Suchanek 817e7c
-			rc = of_reconfig_notifier_register(&dt_update_nb);
Michal Suchanek 817e7c
-#endif
Michal Suchanek 817e7c
-		}
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-	if (firmware_has_feature(FW_FEATURE_VPHN) &&
Michal Suchanek 817e7c
-		   lppaca_shared_proc(get_lppaca())) {
Michal Suchanek 817e7c
-		if (!vphn_enabled) {
Michal Suchanek 817e7c
-			vphn_enabled = 1;
Michal Suchanek 817e7c
-			setup_cpu_associativity_change_counters();
Michal Suchanek 817e7c
-			init_timer_deferrable(&topology_timer);
Michal Suchanek 817e7c
-			reset_topology_timer();
Michal Suchanek 817e7c
-		}
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	pr_info("Starting topology update%s%s\n",
Michal Suchanek 817e7c
-		(prrn_enabled ? " prrn_enabled" : ""),
Michal Suchanek 817e7c
-		(vphn_enabled ? " vphn_enabled" : ""));
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	return rc;
Michal Suchanek 817e7c
+	return 0;
Michal Suchanek 817e7c
 }
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
 /*
Michal Suchanek 817e7c
@@ -1586,25 +1459,7 @@ int start_topology_update(void)
Michal Suchanek 817e7c
  */
Michal Suchanek 817e7c
 int stop_topology_update(void)
Michal Suchanek 817e7c
 {
Michal Suchanek 817e7c
-	int rc = 0;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	if (!topology_updates_enabled)
Michal Suchanek 817e7c
-		return 0;
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	if (prrn_enabled) {
Michal Suchanek 817e7c
-		prrn_enabled = 0;
Michal Suchanek 817e7c
-#ifdef CONFIG_SMP
Michal Suchanek 817e7c
-		rc = of_reconfig_notifier_unregister(&dt_update_nb);
Michal Suchanek 817e7c
-#endif
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-	if (vphn_enabled) {
Michal Suchanek 817e7c
-		vphn_enabled = 0;
Michal Suchanek 817e7c
-		rc = del_timer_sync(&topology_timer);
Michal Suchanek 817e7c
-	}
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	pr_info("Stopping topology update\n");
Michal Suchanek 817e7c
-
Michal Suchanek 817e7c
-	return rc;
Michal Suchanek 817e7c
+	return 0;
Michal Suchanek 817e7c
 }
Michal Suchanek 817e7c
 
Michal Suchanek 817e7c
 int prrn_is_enabled(void)
Michal Suchanek 817e7c
-- 
Michal Suchanek 817e7c
2.26.2
Michal Suchanek 817e7c