Skip to contentSkip to conversation

arm64/mm: Drop use_1G_block()

PATCH Applied Anshuman Khandual 3 participants 4 messages Feb 16, 2022 – Mar 7, 2022 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64/mm: Drop use_1G_block()

pud_sect_supported() already checks for PUD level block mapping support i.e on ARM64_4K_PAGES config. Hence pud_sect_supported(), along with some other required alignment checks can help completely drop use_1G_block().

---
This applies on v5.17-rc4

 arch/arm64/mm/mmu.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
arch/arm64/mm/mmu.c +2 -13
index acfae9b41cc8..5a7954c9e6ec 100644
@@ -294,18 +294,6 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
 	} while (addr = next, addr != end);
 }
 
-static inline bool use_1G_block(unsigned long addr, unsigned long next,
-			unsigned long phys)
-{
-	if (PAGE_SHIFT != 12)
-		return false;
-
-	if (((addr | next | phys) & ~PUD_MASK) != 0)
-		return false;
-
-	return true;
-}
-
 static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end,
 			   phys_addr_t phys, pgprot_t prot,
 			   phys_addr_t (*pgtable_alloc)(int),
@@ -338,7 +326,8 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end,
 		/*
 		 * For 4K granule only, attempt to put down a 1GB block
 		 */
-		if (use_1G_block(addr, next, phys) &&
+		if (pud_sect_supported() &&
+		   ((addr | next | phys) & ~PUD_MASK) == 0 &&
 		    (flags & NO_BLOCK_MAPPINGS) == 0) {
 			pud_set_huge(pudp, phys, prot);
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 39 lines · Anshuman Khandual

pud_sect_supported() already checks for PUD level block mapping support i.e on ARM64_4K_PAGES config. Hence pud_sect_supported(), along with some other required alignment checks can help completely drop use_1G_block().

---
This applies on v5.17-rc4

 arch/arm64/mm/mmu.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)
arch/arm64/mm/mmu.c +0 -12
index acfae9b41cc8..5a7954c9e6ec 100644
@@ -294,18 +294,6 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr,
 	} while (addr = next, addr != end);
 }
 
-static inline bool use_1G_block(unsigned long addr, unsigned long next,
-			unsigned long phys)
-{
-	if (PAGE_SHIFT != 12)
-		return false;
-
-	if (((addr | next | phys) & ~PUD_MASK) != 0)
-		return false;
-
-	return true;
-}
-
 static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end,
 			   phys_addr_t phys, pgprot_t prot,
 			   phys_addr_t (*pgtable_alloc)(int),

arch/arm64/mm/mmu.c static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, · line 331

Quoted 7 lines
arch/arm64/mm/mmu.c +2 -1
@@ -338,7 +326,8 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end,
 		/*
 		 * For 4K granule only, attempt to put down a 1GB block
 		 */
-		if (use_1G_block(addr, next, phys) &&
+		if (pud_sect_supported() &&
+		   ((addr | next | phys) & ~PUD_MASK) == 0 &&
 		    (flags & NO_BLOCK_MAPPINGS) == 0) {

This is now very similar to init_pmd() block mapping check.

Quoted 3 lines
arch/arm64/mm/mmu.c +0 -0
 			pud_set_huge(pudp, phys, prot);
 
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Anshuman Khandual
Quoted 9 lines · Anshuman Khandual

pud_sect_supported() already checks for PUD level block mapping support i.e on ARM64_4K_PAGES config. Hence pud_sect_supported(), along with some other required alignment checks can help completely drop use_1G_block().

(in case Will still picks stuff for 5.18)

maintainer Applied
#3 lore raw
In reply to Anshuman Khandual
Quoted 5 lines · Anshuman Khandual

pud_sect_supported() already checks for PUD level block mapping support i.e on ARM64_4K_PAGES config. Hence pud_sect_supported(), along with some other required alignment checks can help completely drop use_1G_block().

Applied to arm64 (for-next/mm), thanks!

[1/1] arm64/mm: Drop use_1G_block()

      https://git.kernel.org/arm64/c/1310222c276b

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev