[Cbe-oss-dev] [PATCH] fix cbe_cpufreq for "old" SLOF tree.
Jean-Christophe Dubois
jcd at tribudubois.net
Fri Jun 22 00:59:32 EST 2007
On some "old" SLOF tree the generic code is unable to ioremap some Cell BE
registers. Therefore the "generic"" functions are returning a NULL pointer,
triggering a crash on such platforms.
Let's handle this more gracefully.
Signed-off-by: Jean-Christophe DUBOIS <jcd at tribudubois.net>
Index: linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_cpufreq_pervasive.c
===================================================================
--- linux-2.6.22-rc4.orig/arch/powerpc/platforms/cell/cbe_cpufreq_pervasive.c
+++ linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_cpufreq_pervasive.c
@@ -68,6 +68,12 @@ int cbe_cpufreq_set_pmode(int cpu, unsig
mic_tm_regs = cbe_get_cpu_mic_tm_regs(cpu);
pmd_regs = cbe_get_cpu_pmd_regs(cpu);
+
+ if (!mic_tm_regs || !pmd_regs) {
+ local_irq_restore(flags);
+ return -1;
+ }
+
pr_debug("pm register is mapped at %p\n", &pmd_regs->pmcr);
pr_debug("mic register is mapped at %p\n", &mic_tm_regs->slow_fast_timer_0);
@@ -114,6 +120,10 @@ int cbe_cpufreq_get_pmode(int cpu)
struct cbe_pmd_regs __iomem *pmd_regs;
pmd_regs = cbe_get_cpu_pmd_regs(cpu);
+
+ if (!pmd_regs)
+ return -1;
+
ret = in_be64(&pmd_regs->pmsr) & 0x07;
return ret;
Index: linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_cpufreq.c
===================================================================
--- linux-2.6.22-rc4.orig/arch/powerpc/platforms/cell/cbe_cpufreq.c
+++ linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -96,6 +96,9 @@ static int cbe_cpufreq_cpu_init(struct c
cur_pmode = cbe_cpufreq_get_pmode(policy->cpu);
pr_debug("current pmode is at %d\n",cur_pmode);
+ if (cur_pmode == -1)
+ return -EINVAL;
+
policy->cur = cbe_freqs[cur_pmode].frequency;
#ifdef CONFIG_SMP
@@ -155,7 +158,9 @@ static int cbe_cpufreq_target(struct cpu
rc = set_pmode(policy->cpu, cbe_pmode_new);
- cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+ if (rc != -1)
+ cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
+
mutex_unlock(&cbe_switch_mutex);
return rc;
More information about the cbe-oss-dev
mailing list