Skip to content

Commit 727ac9e

Browse files
linuswRussell King (Oracle)
authored andcommitted
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 <[email protected]> Signed-off-by: Russell King (Oracle) <[email protected]>
1 parent de9c2c6 commit 727ac9e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

arch/arm/include/asm/pgtable-3level-hwdef.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106

107107
/*
108108
* 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"
109114
*/
110115
#define TTBCR_EAE (1 << 31)
111116
#define TTBCR_IMP (1 << 30)

arch/arm/mm/mmu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ static void __init early_paging_init(const struct machine_desc *mdesc)
16381638
{
16391639
pgtables_remap *lpae_pgtables_remap;
16401640
unsigned long pa_pgd;
1641-
unsigned int cr, ttbcr;
1641+
u32 cr, ttbcr, tmp;
16421642
long long offset;
16431643

16441644
if (!mdesc->pv_fixup)
@@ -1688,7 +1688,9 @@ static void __init early_paging_init(const struct machine_desc *mdesc)
16881688
cr = get_cr();
16891689
set_cr(cr & ~(CR_I | CR_C));
16901690
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);
16921694
flush_cache_all();
16931695

16941696
/*

0 commit comments

Comments
 (0)