@@ -314,8 +314,18 @@ static void __init create_pte_mapping(pte_t *ptep,
phys_addr_t sz, pgprot_t prot)
{
uintptr_t pte_idx = pte_index(va);
-
- BUG_ON(sz != PAGE_SIZE);
+ pte_t pte;
+
+ WARN_ON(sz != NAPOT_CONT64KB_SIZE && sz != PAGE_SIZE);
+ if (sz == NAPOT_CONT64KB_SIZE) {
+ do {
+ pte = pfn_pte(PFN_DOWN(pa), prot);
+ ptep[pte_idx] = pte_mknapot(pte, NAPOT_CONT64KB_ORDER);
+ pte_idx++;
+ sz -= PAGE_SIZE;
+ } while (sz > 0);
+ return;
+ }
if (pte_none(ptep[pte_idx]))
ptep[pte_idx] = pfn_pte(PFN_DOWN(pa), prot);
@@ -444,10 +454,13 @@ void __init create_pgd_mapping(pgd_t *pgdp,
static uintptr_t __init best_map_size(phys_addr_t base, phys_addr_t size)
{
/* Upgrade to PMD_SIZE mappings whenever possible */
- if ((base & (PMD_SIZE - 1)) || (size & (PMD_SIZE - 1)))
- return PAGE_SIZE;
+ if (!((base | size) & (PMD_SIZE - 1)))
+ return PMD_SIZE;
+
+ if (!((base | size) & (NAPOT_CONT64KB_SIZE - 1)))
+ return NAPOT_CONT64KB_SIZE;
- return PMD_SIZE;
+ return PAGE_SIZE;
}
#ifdef CONFIG_XIP_KERNEL