[Cbe-oss-dev] [PATCH] fix cbe_thermal for legacy SLOF tree.

Christian Krafft krafft at de.ibm.com
Thu Jun 28 01:26:43 EST 2007


On Tue, 26 Jun 2007 14:59:06 +0200
Jean-Christophe Dubois <jdubois at mc.com> wrote:

> On some legacy 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_thermal.c
> ===================================================================
> --- linux-2.6.22-rc4.orig/arch/powerpc/platforms/cell/cbe_thermal.c
> +++ linux-2.6.22-rc4/arch/powerpc/platforms/cell/cbe_thermal.c
> @@ -108,6 +108,11 @@ static ssize_t spu_show_temp(struct sys_
> 
>  	pmd_regs = get_pmd_regs(sysdev);
> 
> +	if (!pmd_regs) {
> +		WARN_ON_ONCE(!pmd_regs);
> +		return 0;
> +	}
> +
>  	value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1);
> 
>  	return sprintf(buf, "%d\n", reg_to_temp(value));
> @@ -117,6 +122,11 @@ static ssize_t show_throttle(struct cbe_
>  {
>  	u64 value;
> 
> +	if (!pmd_regs) {
> +		WARN_ON_ONCE(!pmd_regs);
> +		return 0;
> +	}
> +
>  	value = in_be64(&pmd_regs->tm_tpr.val);
>  	/* access the corresponding byte */
>  	value >>= pos;
> @@ -186,6 +196,12 @@ static ssize_t ppe_show_temp(struct sys_
>  	u64 value;
> 
>  	pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
> +
> +	if (!pmd_regs) {
> +		WARN_ON_ONCE(!pmd_regs);
> +		return 0;
> +	}
> +
>  	value = in_be64(&pmd_regs->ts_ctsr2);
> 
>  	value = (value >> pos) & 0x3f;
> @@ -339,8 +355,19 @@ static void __init init_default_values(v
>  	for_each_possible_cpu (cpu) {
>  		pr_debug("processing cpu %d\n", cpu);
>  		sysdev = get_cpu_sysdev(cpu);
> +
> +		if (!sysdev) {
> +			WARN_ON_ONCE(!sysdev);
> +			continue;
> +		}
> +
>  		pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
> 
> +		if (!pmd_regs) {
> +			WARN_ON_ONCE(!pmd_regs);
> +			continue;
> +		}
> +
>  		out_be64(&pmd_regs->tm_str2, str2);
>  		out_be64(&pmd_regs->tm_str1.val, str1.val);
>  		out_be64(&pmd_regs->tm_tpr.val, tpr.val);
> _______________________________________________
> cbe-oss-dev mailing list
> cbe-oss-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/cbe-oss-dev

Same comment as for your cbe_cpufreq_pervasive fix:
I would include the check in thermal_init.
So the module would not load, if the device tree is not correct.
This way we need only one check per module, no need for a WARN_ON_ONCE then.

-- 
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
IBM Systems & Technology Group,
Linux Kernel Development
IT Specialist


Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaeftsfuehrung:		Herbert Kircher
Sitz der Gesellschaft:		Boeblingen
Registriergericht:		Amtsgericht Stuttgart, HRB 243294

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20070627/b534d7a6/attachment.pgp>


More information about the cbe-oss-dev mailing list