Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 9409/1: mmu: Do not use magic number for TTBCR settings

The code in early_paging_init is directly masking off bits
8, 9, 10 and 11 to temporarily disable caching of the translation
tables. There is some exlanations in the comment, but use some
defines instead of magic numbers so ut becomes more evident
what is going on.

Change the type of the register to u32 since these are indeed
unsigned 32bit registers, and use a temporary variable instead
of baking too much into the inline assembly call to increase
readability.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

authored by

Linus Walleij and committed by
Russell King (Oracle)
727ac9ec de9c2c66

+9 -2
+5
arch/arm/include/asm/pgtable-3level-hwdef.h
··· 106 106 107 107 /* 108 108 * TTBCR register bits. 109 + * 110 + * The ORGN0 and IRGN0 bits enables different forms of caching when 111 + * walking the translation table. Clearing these bits (which is claimed 112 + * to be the reset default) means "normal memory, [outer|inner] 113 + * non-cacheable" 109 114 */ 110 115 #define TTBCR_EAE (1 << 31) 111 116 #define TTBCR_IMP (1 << 30)
+4 -2
arch/arm/mm/mmu.c
··· 1638 1638 { 1639 1639 pgtables_remap *lpae_pgtables_remap; 1640 1640 unsigned long pa_pgd; 1641 - unsigned int cr, ttbcr; 1641 + u32 cr, ttbcr, tmp; 1642 1642 long long offset; 1643 1643 1644 1644 if (!mdesc->pv_fixup) ··· 1688 1688 cr = get_cr(); 1689 1689 set_cr(cr & ~(CR_I | CR_C)); 1690 1690 ttbcr = cpu_get_ttbcr(); 1691 - cpu_set_ttbcr(ttbcr & ~(3 << 8 | 3 << 10)); 1691 + /* Disable all kind of caching of the translation table */ 1692 + tmp = ttbcr & ~(TTBCR_ORGN0_MASK | TTBCR_IRGN0_MASK); 1693 + cpu_set_ttbcr(tmp); 1692 1694 flush_cache_all(); 1693 1695 1694 1696 /*