[ARM] fix VIPT/VIVT macro optimisations, add comments

cacheflush.h was doing:

... VIVT only stuff
... VIPT only stuff
... VIVT or VIPT stuff

which is clearly bogus - we would only ever use the "VIVT or VIPT" case
when both VIVT and VIPT are not selected. Fix this.

Add comments to each case, including noting the impossibility of
correctly detecting the cache type of ARM926 and ARMv6 cores from
the cache type register in the "VIVT or VIPT" case.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Russell King and committed by Russell King daf93dd5 6cab4860

+13 -4
+13 -4
include/asm-arm/cacheflush.h
··· 459 #define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0) 460 461 #if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT) 462 - 463 #define cache_is_vivt() 1 464 #define cache_is_vipt() 0 465 #define cache_is_vipt_nonaliasing() 0 466 #define cache_is_vipt_aliasing() 0 467 #define icache_is_vivt_asid_tagged() 0 468 469 - #elif defined(CONFIG_CPU_CACHE_VIPT) 470 - 471 #define cache_is_vivt() 0 472 #define cache_is_vipt() 1 473 #define cache_is_vipt_nonaliasing() \ ··· 493 }) 494 495 #else 496 - 497 #define cache_is_vivt() \ 498 ({ \ 499 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \
··· 459 #define __cacheid_vivt_asid_tagged_instr(val) (__cacheid_type_v7(val) ? ((val & (3 << 14)) == (1 << 14)) : 0) 460 461 #if defined(CONFIG_CPU_CACHE_VIVT) && !defined(CONFIG_CPU_CACHE_VIPT) 462 + /* 463 + * VIVT caches only 464 + */ 465 #define cache_is_vivt() 1 466 #define cache_is_vipt() 0 467 #define cache_is_vipt_nonaliasing() 0 468 #define cache_is_vipt_aliasing() 0 469 #define icache_is_vivt_asid_tagged() 0 470 471 + #elif !defined(CONFIG_CPU_CACHE_VIVT) && defined(CONFIG_CPU_CACHE_VIPT) 472 + /* 473 + * VIPT caches only 474 + */ 475 #define cache_is_vivt() 0 476 #define cache_is_vipt() 1 477 #define cache_is_vipt_nonaliasing() \ ··· 489 }) 490 491 #else 492 + /* 493 + * VIVT or VIPT caches. Note that this is unreliable since ARM926 494 + * and V6 CPUs satisfy the "(val & (15 << 25)) == (14 << 25)" test. 495 + * There's no way to tell from the CacheType register what type (!) 496 + * the cache is. 497 + */ 498 #define cache_is_vivt() \ 499 ({ \ 500 unsigned int __val = read_cpuid(CPUID_CACHETYPE); \