summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Medhurst2013-06-17 04:15:08 -0500
committerJon Medhurst2013-06-17 07:27:01 -0500
commitf15a1807ecf7af6dd0cac9e175ff00bf06d7c304 (patch)
tree747c381b968e6d044cdaefa4a64c5295566e2764
parent921c40f23d8b6deeee18e9dff097a06a9b643f3a (diff)
downloadarm-ds5-gator-f15a1807ecf7af6dd0cac9e175ff00bf06d7c304.tar.gz
arm-ds5-gator-f15a1807ecf7af6dd0cac9e175ff00bf06d7c304.tar.xz
arm-ds5-gator-f15a1807ecf7af6dd0cac9e175ff00bf06d7c304.zip
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 <tixy@linaro.org>
-rw-r--r--driver/gator_iks.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/driver/gator_iks.c b/driver/gator_iks.c
index 932be26..ed2c6dd 100644
--- a/driver/gator_iks.c
+++ b/driver/gator_iks.c
@@ -14,6 +14,7 @@
14#include <asm/smp_plat.h> 14#include <asm/smp_plat.h>
15#include <trace/events/power_cpu_migrate.h> 15#include <trace/events/power_cpu_migrate.h>
16 16
17static bool map_cpuids;
17static int mpidr_cpuids[NR_CPUS]; 18static int mpidr_cpuids[NR_CPUS];
18static int __lcpu_to_pcpu[NR_CPUS]; 19static int __lcpu_to_pcpu[NR_CPUS];
19 20
@@ -40,7 +41,7 @@ static void calc_first_cluster_size(void)
40 ++mpidr_cpuids_count; 41 ++mpidr_cpuids_count;
41 } 42 }
42 43
43 BUG_ON(mpidr_cpuids_count != nr_cpu_ids); 44 map_cpuids = (mpidr_cpuids_count == nr_cpu_ids);
44} 45}
45 46
46static int linearize_mpidr(int mpidr) 47static int linearize_mpidr(int mpidr)
@@ -58,6 +59,10 @@ static int linearize_mpidr(int mpidr)
58int lcpu_to_pcpu(const int lcpu) 59int lcpu_to_pcpu(const int lcpu)
59{ 60{
60 int pcpu; 61 int pcpu;
62
63 if (!map_cpuids)
64 return lcpu;
65
61 BUG_ON(lcpu >= nr_cpu_ids || lcpu < 0); 66 BUG_ON(lcpu >= nr_cpu_ids || lcpu < 0);
62 pcpu = __lcpu_to_pcpu[lcpu]; 67 pcpu = __lcpu_to_pcpu[lcpu];
63 BUG_ON(pcpu >= nr_cpu_ids || pcpu < 0); 68 BUG_ON(pcpu >= nr_cpu_ids || pcpu < 0);
@@ -67,6 +72,10 @@ int lcpu_to_pcpu(const int lcpu)
67int pcpu_to_lcpu(const int pcpu) 72int pcpu_to_lcpu(const int pcpu)
68{ 73{
69 int lcpu; 74 int lcpu;
75
76 if (!map_cpuids)
77 return pcpu;
78
70 BUG_ON(pcpu >= nr_cpu_ids || pcpu < 0); 79 BUG_ON(pcpu >= nr_cpu_ids || pcpu < 0);
71 for (lcpu = 0; lcpu < nr_cpu_ids; ++lcpu) { 80 for (lcpu = 0; lcpu < nr_cpu_ids; ++lcpu) {
72 if (__lcpu_to_pcpu[lcpu] == pcpu) { 81 if (__lcpu_to_pcpu[lcpu] == pcpu) {
@@ -114,6 +123,10 @@ GATOR_DEFINE_PROBE(cpu_migrate_current, TP_PROTO(u64 timestamp, u32 cpu_hwid))
114static int gator_migrate_start(void) 123static int gator_migrate_start(void)
115{ 124{
116 int retval = 0; 125 int retval = 0;
126
127 if (!map_cpuids)
128 return retval;
129
117 if (retval == 0) 130 if (retval == 0)
118 retval = GATOR_REGISTER_TRACE(cpu_migrate_begin); 131 retval = GATOR_REGISTER_TRACE(cpu_migrate_begin);
119 if (retval == 0) 132 if (retval == 0)
@@ -130,6 +143,9 @@ static int gator_migrate_start(void)
130 143
131static void gator_migrate_stop(void) 144static void gator_migrate_stop(void)
132{ 145{
146 if (!map_cpuids)
147 return;
148
133 GATOR_UNREGISTER_TRACE(cpu_migrate_current); 149 GATOR_UNREGISTER_TRACE(cpu_migrate_current);
134 GATOR_UNREGISTER_TRACE(cpu_migrate_finish); 150 GATOR_UNREGISTER_TRACE(cpu_migrate_finish);
135 GATOR_UNREGISTER_TRACE(cpu_migrate_begin); 151 GATOR_UNREGISTER_TRACE(cpu_migrate_begin);