From: r.sricharan@ti.com (R Sricharan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/1] ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses.
Date: Mon, 6 Aug 2012 13:11:25 +0530 [thread overview]
Message-ID: <1344238885-13683-1-git-send-email-r.sricharan@ti.com> (raw)
With LPAE, When either the start address or end address
or physical address to be mapped is unaligned,
alloc_init_section creates page granularity mappings.
alloc_init_section calls alloc_init_pte which populates
one pmd entry and sets up the ptes. But if the size is
greater than what can be mapped by one pmd entry,
then the rest remains unmapped.
The issue becomes visible when LPAE is enabled, where we have
the 3 levels with seperate pgd and pmd's.
When a static mapping for 3MB is requested, only 2MB is mapped
and the remaining 1MB is unmapped. Fixing this here, by looping
in to map the entire unaligned address range.
Boot tested on OMAP5 evm with both LPAE enabled/disabled
and verified that static mappings with unaligned addresses
are properly mapped.
Signed-off-by: R Sricharan <r.sricharan@ti.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
---
[V2] Moved the loop to alloc_init_pte as per Russell's
feedback and changed the subject accordingly.
Using PMD_XXX instead of SECTION_XXX to avoid
different loop increments with/without LPAE.
arch/arm/mm/mmu.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index cf4528d..0ed8808 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -585,11 +585,25 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
unsigned long end, unsigned long pfn,
const struct mem_type *type)
{
- pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+ unsigned long next;
+ pte_t *pte;
+ phys_addr_t phys;
+
do {
- set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
- pfn++;
- } while (pte++, addr += PAGE_SIZE, addr != end);
+ if ((end-addr) & PMD_MASK)
+ next = (addr + PMD_SIZE) & PMD_MASK;
+ else
+ next = end;
+
+ pte = early_pte_alloc(pmd, addr, type->prot_l1);
+ do {
+ set_pte_ext(pte, pfn_pte(pfn,
+ __pgprot(type->prot_pte)), 0);
+ pfn++;
+ } while (pte++, addr += PAGE_SIZE, addr != next);
+
+ phys += next - addr;
+ } while (pmd++, addr = next, addr != end);
}
static void __init alloc_init_section(pud_t *pud, unsigned long addr,
--
1.7.9.5
next reply other threads:[~2012-08-06 7:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 7:41 R Sricharan [this message]
2012-08-17 11:02 ` [PATCH v2 1/1] ARM: LPAE: Fix mapping in alloc_init_pte for unaligned addresses R, Sricharan
2012-09-18 11:52 ` R, Sricharan
2013-03-14 5:14 ` Catalin Marinas
2013-03-14 20:19 ` Laura Abbott
2013-03-15 6:58 ` Sricharan R
2013-03-15 14:50 ` Laura Abbott
2013-03-15 15:00 ` Sricharan R
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1344238885-13683-1-git-send-email-r.sricharan@ti.com \
--to=r.sricharan@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).