Skip to contentSkip to conversation

ppc: Cleanup get_effective_memsize() use

PATCH New Marian Balakowicz 3 participants 7 messages May 7, 2008 – May 12, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ppc: Cleanup get_effective_memsize() use

Removed duplicated effective memory size calculation code.

---

 lib_ppc/board.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)
lib_ppc/board.c +0 -11
index 1b8a872..4956403 100644
@@ -453,18 +453,7 @@ void board_init_f (ulong bootflag)
 	 */
 	gd->ram_size -= CFG_MEM_TOP_HIDE;
 
-#ifndef CONFIG_MAX_MEM_MAPPED
-#define CONFIG_MAX_MEM_MAPPED (256 << 20)
-#endif
-
-#ifndef	CONFIG_VERY_BIG_RAM
 	addr = CFG_SDRAM_BASE + get_effective_memsize();
-#else
-	/* only allow stack below 256M */
-	addr = CFG_SDRAM_BASE +
-		(gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
-		CONFIG_MAX_MEM_MAPPED : get_effective_memsize();
-#endif
 
 #ifdef CONFIG_LOGBUFFER
 #ifndef CONFIG_ALT_LB_ADDR
#1 lore raw

RFC PATCH 2/2 Avoid initrd and logbuffer area overlaps

Add logbuffer to reserved LMB areas to prevent initrd allocation from overlaping with it.

Make sure to use correct logbuffer base address.

---

This patch attempts to assure that initrd allocation made during OS booting will not destroy logbuffer area.

Please review and comment.

Cheers,
m.

 common/cmd_log.c  |    8 +++++++-
 common/image.c    |    7 +++++++
 include/logbuff.h |    1 +
 lib_ppc/board.c   |    5 +++++
 4 files changed, 20 insertions(+), 1 deletions(-)
common/cmd_log.c +7 -1
index b9f9ba0..8e04941 100644
@@ -66,6 +66,12 @@ static logbuff_t *log;
 #endif
 static char *lbuf;
 
+unsigned long __logbuffer_base(void)
+{
+	return CFG_SDRAM_BASE + gd->bd->bi_memsize - LOGBUFF_LEN;
+}
+unsigned long logbuffer_base (void) __attribute__((weak, alias("__logbuffer_base")));
+
 void logbuff_init_ptrs (void)
 {
 	unsigned long tag, post_word;
@@ -75,7 +81,7 @@ void logbuff_init_ptrs (void)
 	log = (logbuff_t *)CONFIG_ALT_LH_ADDR;
 	lbuf = (char *)CONFIG_ALT_LB_ADDR;
 #else
-	log = (logbuff_t *)(gd->bd->bi_memsize-LOGBUFF_LEN) - 1;
+	log = (logbuff_t *)(logbuffer_base ()) - 1;
 	lbuf = (char *)log->buf;
 #endif
 
common/image.c +7 -0
index 0a78385..8afaccd 100644
@@ -36,6 +36,10 @@
 #include <dataflash.h>
 #endif
 
+#ifdef CONFIG_LOGBUFFER
+#include <logbuff.h>
+#endif
+
 #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE)
 #include <rtc.h>
 #endif
@@ -1017,6 +1021,9 @@ int boot_ramdisk_high (struct lmb *lmb, ulong rd_data, ulong rd_len,
 		initrd_high = ~0;
 	}
 
+	/* Prevent initrd from overwriting logbuffer */
+	lmb_reserve(lmb, logbuffer_base() - LOGBUFF_OVERHEAD, LOGBUFF_RESERVE);
+
 	debug ("## initrd_high = 0x%08lx, copy_to_ram = %d\n",
 			initrd_high, initrd_copy_to_ram);
 
include/logbuff.h +1 -0
index d415729..f117c66 100644
@@ -60,6 +60,7 @@ int drv_logbuff_init (void);
 void logbuff_init_ptrs (void);
 void logbuff_log(char *msg);
 void logbuff_reset (void);
+unsigned long logbuffer_base (void);
 
 #endif /* CONFIG_LOGBUFFER */
 
lib_ppc/board.c +5 -0
index 4956403..bc49ea1 100644
@@ -398,6 +398,11 @@ ulong get_effective_memsize(void)
  ************************************************************************
  */
 
+unsigned long logbuffer_base(void)
+{
+	return CFG_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
+}
+
 void board_init_f (ulong bootflag)
 {
 	bd_t *bd;
#2 lore raw

RFC PATCH 2/2 Avoid initrd and logbuffer area overlaps

Quoted 6 lines · In message <[email protected]> you wrote:

Add logbuffer to reserved LMB areas to prevent initrd allocation from overlaping with it.

Make sure to use correct logbuffer base address.

---

Quoted 6 lines

This patch attempts to assure that initrd allocation made during OS booting will not destroy logbuffer area.

Please review and comment.

Quoted 8 lines

Cheers,
m.

 common/cmd_log.c  |    8 +++++++-
 common/image.c    |    7 +++++++
 include/logbuff.h |    1 +
 lib_ppc/board.c   |    5 +++++
 4 files changed, 20 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Any sufficiently advanced  technology  is  indistinguishable  from  a
rigged demo.                              - Andy Finkel, computer guy
#3 lore raw

RFC PATCH 2/2 Avoid initrd and logbuffer area overlaps

In reply to Marian Balakowicz
Quoted 6 lines · Marian Balakowicz

Add logbuffer to reserved LMB areas to prevent initrd allocation from overlaping with it.

Make sure to use correct logbuffer base address.

Hmmm, this patch breaks all PPC boards without logbuffer support. Take a look at "acadia" for example:

[stefan at kubuntu u-boot (master)]$ ./MAKEALL acadia Configuring for acadia board...
board.c: In function 'logbuffer_base':
board.c:403: error: 'LOGBUFF_LEN' undeclared (first use in this function) board.c:403: error: (Each undeclared identifier is reported only once board.c:403: error: for each function it appears in.) make[1]: *** [board.o] Error 1
make: *** [lib_ppc/libppc.a] Error 2

I tried to quickly (#ifdef around the logbuffer_base() function in lib_ppc/board.c) fix it but it didn't work. So it would be great if you could come up with a fix for this.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#4 lore raw

RFC PATCH 2/2 Avoid initrd and logbuffer area overlaps

Dear Marian,

Quoted 10 lines · in message <[email protected]> Stefan Roese wrote:
Quoted 7 lines

Add logbuffer to reserved LMB areas to prevent initrd allocation from overlaping with it.

Make sure to use correct logbuffer base address.

Hmmm, this patch breaks all PPC boards without logbuffer support. Take a look at "acadia" for example:

Indeed. It is obvious that this patch was not even minimally tested. Please see "Note 2" at http://www.denx.de/wiki/UBoot/Patches

I reverted the patch. Please resubmit after fixing the problems.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
1 1 was a race-horse, 2 2 was 1 2. When 1 1 1 1 race, 2 2 1 1 2.
#5 lore raw

RFC PATCH 2/2 Avoid initrd and logbuffer area overlaps

Dear Wolfgang,

Quoted 5 lines · Wolfgang Denk
Quoted 3 lines · in message <[email protected]> Stefan Roese wrote:
Quoted 3 lines

Add logbuffer to reserved LMB areas to prevent initrd allocation from overlaping with it.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Make sure to use correct logbuffer base address.

Hmmm, this patch breaks all PPC boards without logbuffer support. Take a look at "acadia" for example:

Indeed. It is obvious that this patch was not even minimally tested. Please see "Note 2" at http://www.denx.de/wiki/UBoot/Patches

That is true, but the patch was explicitly marked RFC, as I was hoping to hear possible comments on the approach first.

Quoted 1 line

I reverted the patch. Please resubmit after fixing the problems.

Will do.

Cheers,
Marian

#6 lore raw

PATCH 1/2 ppc: Cleanup get_effective_memsize() use

In reply to Marian Balakowicz
Quoted 7 lines · In message <[email protected]> you wrote:

Removed duplicated effective memory size calculation code.

---

 lib_ppc/board.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Every program has at least one bug and can be shortened by  at  least
one instruction - from which, by induction, one can deduce that every
program can be reduced to one instruction which doesn't work.