mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Sean Cross <xobs@kosagi.com>
Cc: barebox@lists.infradead.org
Subject: Re: Porting barebox to Novena: misc questions
Date: Tue, 18 Mar 2014 09:58:12 +0100	[thread overview]
Message-ID: <20140318085811.GU17250@pengutronix.de> (raw)
In-Reply-To: <53280734.6000802@kosagi.com>

On Tue, Mar 18, 2014 at 04:43:32PM +0800, Sean Cross wrote:
> > arm_add_mem_device("ram0", 0x10000000, SZ_2G + SZ_1G + SZ_512M + SZ_128M + SZ_1M);
> > 
> > and this works on a board I have here (although that board doesn't even
> > have that amount of memory)
> 
> Oh, I didn't realize there was a requirement to align to the nearest
> megabyte.
> 
> In that case, you're right.  I tried this, and it works:
> 
> arm_add_mem_device("ram0", 0x10000000, SZ_2G + SZ_1G + SZ_512M + SZ_256M
> - SZ_1M);
> 
> However, this fails:
> 
> arm_add_mem_device("ram0", 0x10000000, SZ_2G + SZ_1G + SZ_512M + SZ_256M);

You are really exploring corner cases here ;)

Try this:

--------------------------8<--------------------

From 4a84905c61d4a4a895c83f4f156f60a7258e6413 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Tue, 18 Mar 2014 09:53:18 +0100
Subject: [PATCH] ARM: MMU: Fix memory reaching to the end of address space

For memory reaching the end of the address space
phys + bank->size overflows to 0. Fix this by right shifting
phys and bank->size before adding them.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 84daa3d..bf0141b 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -200,7 +200,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
 {
 	unsigned long phys = (unsigned long)bank->start;
 	unsigned long ttb_start = phys >> 20;
-	unsigned long ttb_end = (phys + bank->size) >> 20;
+	unsigned long ttb_end = (phys >> 20) + (bank->size >> 20);
 	unsigned long num_ptes = bank->size >> 10;
 	int i, pte;
 	u32 *ptes;
-- 
1.9.0

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-03-18  8:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-13  2:04 Sean Cross
2014-03-13  7:38 ` Sascha Hauer
2014-03-13 10:18   ` Sean Cross
2014-03-13 20:27     ` Sascha Hauer
2014-03-14  3:35       ` Sean Cross
2014-03-14  8:22         ` Sascha Hauer
2014-03-17  4:28           ` Sean Cross
2014-03-17  7:18             ` Sascha Hauer
2014-03-17  7:31               ` Alexander Aring
2014-03-17  7:44               ` Sean Cross
2014-03-17 10:53                 ` Sascha Hauer
2014-03-18  3:35                   ` Sean Cross
2014-03-18  8:36                     ` Sascha Hauer
2014-03-18  8:43                       ` Sean Cross
2014-03-18  8:58                         ` Sascha Hauer [this message]
2014-03-18  9:04                           ` Sean Cross
2014-03-13 19:42   ` Jean-Christophe PLAGNIOL-VILLARD
2014-03-13 20:30     ` Sascha Hauer
2014-03-14  3:03       ` Jean-Christophe PLAGNIOL-VILLARD
2014-03-13 20:43 ` Eric Bénard
2014-03-13 21:26   ` Sascha Hauer
2014-03-14  3:13     ` Jean-Christophe PLAGNIOL-VILLARD

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=20140318085811.GU17250@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=xobs@kosagi.com \
    /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