From 9c68b19be568a84c9bbd88e6a7a9627d6a81a0c4 Mon Sep 17 00:00:00 2001 From: Jon Medhurst Date: Mon, 17 Jun 2013 10:15:08 +0100 Subject: [PATCH] gator: Prevent BUG() when no device-tree cpu nodes present. When IKS support is enabled in gator but we are running on boards without a device-tree or where there are no cpu nodes in the device-tree, then calc_first_cluster_size will call BUG_ON() because mpidr_cpuids_count == 0. To work around this, we will instead set a flag to indicate we haven't managed to create an mpidr table and fallback to the behaviour we would have if IKS wasn't enabled. This means that IKS support will only function as expected if there are device-tree nodes for CPUs but we expect that to always be the case anyway. Signed-off-by: Jon Medhurst --- drivers/gator/gator_iks.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gator/gator_iks.c b/drivers/gator/gator_iks.c index 932be26bfcf7..ed2c6dd8d4c7 100644 --- a/drivers/gator/gator_iks.c +++ b/drivers/gator/gator_iks.c @@ -14,6 +14,7 @@ #include #include +static bool map_cpuids; static int mpidr_cpuids[NR_CPUS]; static int __lcpu_to_pcpu[NR_CPUS]; @@ -40,7 +41,7 @@ static void calc_first_cluster_size(void) ++mpidr_cpuids_count; } - BUG_ON(mpidr_cpuids_count != nr_cpu_ids); + map_cpuids = (mpidr_cpuids_count == nr_cpu_ids); } static int linearize_mpidr(int mpidr) @@ -58,6 +59,10 @@ static int linearize_mpidr(int mpidr) int lcpu_to_pcpu(const int lcpu) { int pcpu; + + if (!map_cpuids) + return lcpu; + BUG_ON(lcpu >= nr_cpu_ids || lcpu < 0); pcpu = __lcpu_to_pcpu[lcpu]; BUG_ON(pcpu >= nr_cpu_ids || pcpu < 0); @@ -67,6 +72,10 @@ int lcpu_to_pcpu(const int lcpu) int pcpu_to_lcpu(const int pcpu) { int lcpu; + + if (!map_cpuids) + return pcpu; + BUG_ON(pcpu >= nr_cpu_ids || pcpu < 0); for (lcpu = 0; lcpu < nr_cpu_ids; ++lcpu) { if (__lcpu_to_pcpu[lcpu] == pcpu) { @@ -114,6 +123,10 @@ GATOR_DEFINE_PROBE(cpu_migrate_current, TP_PROTO(u64 timestamp, u32 cpu_hwid)) static int gator_migrate_start(void) { int retval = 0; + + if (!map_cpuids) + return retval; + if (retval == 0) retval = GATOR_REGISTER_TRACE(cpu_migrate_begin); if (retval == 0) @@ -130,6 +143,9 @@ static int gator_migrate_start(void) static void gator_migrate_stop(void) { + if (!map_cpuids) + return; + GATOR_UNREGISTER_TRACE(cpu_migrate_current); GATOR_UNREGISTER_TRACE(cpu_migrate_finish); GATOR_UNREGISTER_TRACE(cpu_migrate_begin); -- 2.34.1