From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Revert "common/memsize.c: Simplify RAM size detection"
Date: Tue, 9 Feb 2016 22:38:31 +0100 [thread overview]
Message-ID: <1455053911-7530-1-git-send-email-hdegoede@redhat.com> (raw)
This commit breaks bootup on sunxi boards, the get stuck
when running the main u-boot binary at:
CPU: Allwinner H3 (SUN8I)
I2C: ready
DRAM:
This reverts commit 8e7cba048baae68ee0916a8f52b4304277328d5e.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
common/memsize.c | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/common/memsize.c b/common/memsize.c
index 5c0d279..0fb9ba5 100644
--- a/common/memsize.c
+++ b/common/memsize.c
@@ -33,28 +33,38 @@ long get_ram_size(long *base, long maxsize)
long size;
int i = 0;
- for (cnt = (maxsize / sizeof(long)) >> 1; cnt >= 0; cnt >>= 1) {
+ for (cnt = (maxsize / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
addr = base + cnt; /* pointer arith! */
sync();
- save[i] = *addr;
+ save[i++] = *addr;
sync();
- if (cnt) {
- i++;
- *addr = ~cnt;
- } else {
- *addr = 0;
- }
+ *addr = ~cnt;
}
+ addr = base;
+ sync();
+ save[i] = *addr;
+ sync();
+ *addr = 0;
+
sync();
- cnt = 0;
- do {
+ if ((val = *addr) != 0) {
+ /* Restore the original data before leaving the function. */
+ sync();
+ *addr = save[i];
+ for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
+ addr = base + cnt;
+ sync();
+ *addr = save[--i];
+ }
+ return (0);
+ }
+
+ for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
addr = base + cnt; /* pointer arith! */
val = *addr;
- *addr = save[i--];
- sync();
- if (((cnt == 0) && (val != 0)) ||
- ((cnt != 0) && (val != ~cnt))) {
+ *addr = save[--i];
+ if (val != ~cnt) {
size = cnt * sizeof(long);
/*
* Restore the original data
@@ -64,16 +74,11 @@ long get_ram_size(long *base, long maxsize)
cnt < maxsize / sizeof(long);
cnt <<= 1) {
addr = base + cnt;
- *addr = save[i--];
+ *addr = save[--i];
}
return (size);
}
-
- if (cnt)
- cnt = cnt << 1;
- else
- cnt = 1;
- } while (cnt < maxsize / sizeof(long));
+ }
return (maxsize);
}
--
2.5.0
next reply other threads:[~2016-02-09 21:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-09 21:38 Hans de Goede [this message]
2016-02-10 6:11 ` [U-Boot] [PATCH] Revert "common/memsize.c: Simplify RAM size detection" Eddy Petrișor
2016-02-10 8:20 ` Hans de Goede
2016-02-10 9:00 ` Eddy Petrișor
2016-02-10 9:36 ` Wolfgang Denk
2016-02-10 13:35 ` Tom Rini
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=1455053911-7530-1-git-send-email-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--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.