[PATCH] sparse fixes for cpu feature constants

David Gibson david at gibson.dropbear.id.au
Sun Jan 2 09:33:45 EST 2005


On Wed, Dec 29, 2004 at 10:33:26PM -0600, Nathan Lynch wrote:
> Hi-
> 
> I've been playing around with sparse a little and saw that it gives a
> lot of warnings like this:
> 
> arch/ppc64/mm/init.c:755:35: warning: constant 0x0000020000000000 is so
> big it is long
> 
> It looks like we get such a warning for every expression of the form
> "(cur_cpu_spec->cpu_features & CPU_FTR_COHERENT_ICACHE)" -- basically,
> every time the code checks for a cpu feature.
> 
> Following is an attempt to clean these up by defining the cpu feature
> constants using the ASM_CONST macro from ppc64's page.h.  I believe this
> is consistent with the intentions for ASM_CONST's use.
> 
> There's some fallout:
> 
> flush_icache_range() was already using ASM_CONST on one of the
> constants, so that is fixed up.
> 
> switch_mm() uses a BEGIN_FTR_SECTION ...
> END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) which gets broken by the change
> since 0x0000000000000008UL winds up in the generated assembly.  I
> couldn't find the BEGIN/END_FTR_SECTION construct used in any other C
> code, so I replaced this with the usual bitwise 'and' conditional (I
> hope someone else will verify that this is equivalent :).
> 
> So, does this look like the right thing to do?  It eliminates 129 sparse
> warnings from a defconfig 2.6.10 build.

Hurrah!  You beat me to it...

> Index: 2.6.10/include/asm-ppc64/cputable.h
> ===================================================================
> +++ 2.6.10/include/asm-ppc64/cputable.h	2004-12-30 04:04:09.463979408 +0000
> @@ -16,6 +16,7 @@
>  #define __ASM_PPC_CPUTABLE_H
>  
>  #include <linux/config.h>
> +#include <asm/page.h> /* for ASM_CONST */

Have you double checked that this won't cause a nasty #include loop?
The CPU constants are used in quite a few places, as is page.h

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist.  NOT _the_ _other_ _way_
				| _around_!
http://www.ozlabs.org/people/dgibson



More information about the Linuxppc64-dev mailing list