mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] of: Fix memory block alignment in early_init_dt_add_memory_arch()
@ 2014-08-20 15:10 Geert Uytterhoeven
  2014-08-27 10:30 ` Grant Likely
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2014-08-20 15:10 UTC (permalink / raw)
  To: Grant Likely, Rob Herring; +Cc: devicetree, linux-kernel, Geert Uytterhoeven

If a memory block is not aligned to PAGE_SIZE, its base address must be
rounded up, not down, and its size must be reduced.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/of/fdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index f46a24ffa3fe..95fa81b8ca19 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -928,7 +928,11 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
 void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
 {
 	const u64 phys_offset = __pa(PAGE_OFFSET);
-	base &= PAGE_MASK;
+
+	if (!PAGE_ALIGNED(base)) {
+		size -= PAGE_SIZE - (base & ~PAGE_MASK);
+		base = PAGE_ALIGN(base);
+	}
 	size &= PAGE_MASK;
 
 	if (base > MAX_PHYS_ADDR) {
-- 
1.9.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-08 13:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-20 15:10 [PATCH] of: Fix memory block alignment in early_init_dt_add_memory_arch() Geert Uytterhoeven
2014-08-27 10:30 ` Grant Likely
2014-08-27 11:08   ` Geert Uytterhoeven
2014-09-08 13:55     ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®