All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] ARM: mx6: Prevent overflow in DRAM size detection
Date: Mon,  4 Aug 2014 01:47:09 +0200	[thread overview]
Message-ID: <1407109631-5470-2-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1407109631-5470-1-git-send-email-marex@denx.de>

The MX6 DRAM controller can be configured to handle 4GiB of DRAM, but
only 3840 MiB of that can be really used. In case the controller is
configured to operate a 4GiB module, the imx_ddr_size() function will
correctly compute that there is 4GiB of DRAM in the system. Firstly,
the return value is 32-bit, so the function will effectively return
zero. Secondly, the MX6 cannot address the full 4GiB, but only 3840MiB
of all that. Thus, clamp the returned size to 3840MiB in such case.

Signed-off-by: Marek Vasut <marex@denx.de>
---
 arch/arm/imx-common/cpu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/imx-common/cpu.c b/arch/arm/imx-common/cpu.c
index 5a09107..0ec8b18 100644
--- a/arch/arm/imx-common/cpu.c
+++ b/arch/arm/imx-common/cpu.c
@@ -93,6 +93,11 @@ unsigned imx_ddr_size(void)
 	bits += bank_lookup[ESD_MMDC_MISC_GET_BANK(misc)];
 	bits += ESD_MMDC_CTL_GET_WIDTH(ctl);
 	bits += ESD_MMDC_CTL_GET_CS1(ctl);
+
+	/* The MX6 can do only 3840 MiB of DRAM */
+	if (bits == 32)
+		return 0xf0000000;
+
 	return 1 << bits;
 }
 #endif
-- 
2.0.1

  reply	other threads:[~2014-08-03 23:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-03 23:47 [U-Boot] [PATCH 1/4] ARM: mx5: Fix CHSCCDR name Marek Vasut
2014-08-03 23:47 ` Marek Vasut [this message]
2014-08-04  4:50   ` [U-Boot] [PATCH 2/4] ARM: mx6: Prevent overflow in DRAM size detection Tim Harvey
2014-08-20 10:22   ` Stefano Babic
2014-08-03 23:47 ` [U-Boot] [PATCH 3/4] ARM: mx6: Handle the MMDCx_MDCTL COL field caprices Marek Vasut
2014-08-20 10:27   ` Stefano Babic
2014-08-03 23:47 ` [U-Boot] [PATCH 4/4] ARM: mx6: Enable Thumb build for SPL Marek Vasut
2014-08-06  9:23   ` Tim Harvey
2014-08-20 10:28   ` Stefano Babic
2014-08-20 10:21 ` [U-Boot] [PATCH 1/4] ARM: mx5: Fix CHSCCDR name Stefano Babic

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=1407109631-5470-2-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.