[U-Boot-Users] [PATCH v4] ppc: Add CFG_MEM_TOP_HIDE option to hide memory area that doesn't get "touched"

If CFG_MEM_TOP_HIDE is defined in the board config header, this specified memory area will get subtracted from the top (end) of ram and won't get "touched" at all by U-Boot. By fixing up gd->ram_size the Linux kernel should gets passed the now "corrected" memory size and won't touch it either. This should work for arch/ppc and arch/powerpc. Only Linux board ports in arch/powerpc with bootwrapper support, that recalculate the memory size from the SDRAM controller setup will have to get fixed.
This patch enables this config option on some PPC440EPx boards as a workaround for the CHIP 11 errata. Here the description from the AMCC documentation:
CHIP_11: End of memory range area restricted access. Category: 3
Overview: The 440EPx DDR controller does not acknowledge any transaction which is determined to be crossing over the end-of-memory-range boundary, even if the starting address is within valid memory space. Any such transaction from any PLB4 master will result in a PLB time-out on PLB4 bus.
Impact: In case of such misaligned bursts, PLB4 masters will not retrieve any data at all, just the available data up to the end of memory, especially the 440 CPU. For example, if a CPU instruction required an operand located in memory within the last 7 words of memory, the DCU master would burst read 8 words to update the data cache and cross over the end-of-memory-range boundary. Such a DCU read would not be answered by the DDR controller, resulting in a PLB4 time-out and ultimately in a Machine Check interrupt. The data would be inaccessible to the CPU.
Workaround: Forbid any application to access the last 256 bytes of DDR memory. For example, make your operating system believe that the last 256 bytes of DDR memory are absent. AMCC has a patch that does this, available for Linux.
This patch sets CFG_MEM_TOP_HIDE for the following 440EPx boards: lwmon5, korat, sequoia
The other remaining 440EPx board were intentionally not included since it is not clear to me, if they use the end of ram for some other purpose. This is unclear, since these boards have CONFIG_PRAM defined and even comments like this:
PMC440.h: /* esd expects pram at end of physical memory. * So no logbuffer at the moment. */
It is strongly recommendet to not use the last 256 bytes on those boards too. Patches from the board maintainers are welcome.
Signed-off-by: Stefan Roese sr@denx.de --- Changes in this version v4: - Add CFG_MEM_TOP_HIDE decription to README
Changes in this version v3: - Changed value of CFG_MEM_TOP_HIDE from 256 to 4k so that memory end location is on a page boundary - Rebased on current git version
Changes in this version v2: - Changed name of define to CFG_MEM_TOP_HIDE
README | 21 +++++++++++++++++++++ include/configs/korat.h | 2 ++ include/configs/lwmon5.h | 2 ++ include/configs/sequoia.h | 4 +++- lib_ppc/board.c | 13 +++++++++++++ 5 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/README b/README index 0e37b8b..4c7bf95 100644 --- a/README +++ b/README @@ -1854,6 +1854,27 @@ Configuration Settings: Scratch address used by the alternate memory test You only need to set this if address zero isn't writeable
+- CFG_MEM_TOP_HIDE (PPC only): + If CFG_MEM_TOP_HIDE is defined in the board config header, + this specified memory area will get subtracted from the top + (end) of ram and won't get "touched" at all by U-Boot. By + fixing up gd->ram_size the Linux kernel should gets passed + the now "corrected" memory size and won't touch it either. + This should work for arch/ppc and arch/powerpc. Only Linux + board ports in arch/powerpc with bootwrapper support, that + recalculate the memory size from the SDRAM controller setup + will have to get fixed. + + This option can be used as a workaround for the 440EPx/GRx + CHIP 11 errata where the last 256 bytes in SDRAM shouldn't + be touched. + + WARNING: Please make sure that this value is a multiple of + the Linux page size (normally 4k). If this is not the case, + then the end address of the Linux memory will be located at a + non page size aligned address and this could cause mayor + problems. + - CFG_TFTP_LOADADDR: Default load address for network file downloads
diff --git a/include/configs/korat.h b/include/configs/korat.h index dcec9b0..de672ea 100644 --- a/include/configs/korat.h +++ b/include/configs/korat.h @@ -144,6 +144,8 @@ #define SPD_EEPROM_ADDRESS {0x50} #define CONFIG_PROG_SDRAM_TLB #define CFG_DRAM_TEST +#define CFG_MEM_TOP_HIDE (4 << 10) /* don't use last 4kbytes */ + /* 440EPx errata CHIP 11 */
/* * I2C diff --git a/include/configs/lwmon5.h b/include/configs/lwmon5.h index ced7ba6..3056cb0 100644 --- a/include/configs/lwmon5.h +++ b/include/configs/lwmon5.h @@ -86,6 +86,8 @@ #define CFG_INIT_SP_OFFSET CFG_GBL_DATA_OFFSET #define CFG_POST_ALT_WORD_ADDR (CFG_PERIPHERAL_BASE + GPT0_COMP6) /* unused GPT0 COMP reg */ +#define CFG_MEM_TOP_HIDE (4 << 10) /* don't use last 4kbytes */ + /* 440EPx errata CHIP 11 */
/* Additional registers for watchdog timer post test */
diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h index dfa8779..555316f 100644 --- a/include/configs/sequoia.h +++ b/include/configs/sequoia.h @@ -221,6 +221,8 @@ #if !defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL) #define CONFIG_DDR_DATA_EYE /* use DDR2 optimization */ #endif +#define CFG_MEM_TOP_HIDE (4 << 10) /* don't use last 4kbytes */ + /* 440EPx errata CHIP 11 */
/* * I2C @@ -275,7 +277,7 @@ "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ ":${hostname}:${netdev}:off panic=1\0" \ "addtty=setenv bootargs ${bootargs} console=ttyS0,${baudrate}\0"\ - "addmisc=setenv bootargs ${bootargs} mem=${mem}\0" \ + "addmisc=setenv bootargs ${bootargs}\0" \ "flash_nfs=run nfsargs addip addtty addmisc;" \ "bootm ${kernel_addr}\0" \ "flash_self=run ramargs addip addtty addmisc;" \ diff --git a/lib_ppc/board.c b/lib_ppc/board.c index 3ab22f8..f0a2c87 100644 --- a/lib_ppc/board.c +++ b/lib_ppc/board.c @@ -425,6 +425,7 @@ void board_init_f (ulong bootflag) * relocate the code and continue running from DRAM. * * Reserve memory at end of RAM for (top down in that order): + * - area that won't get touched by U-Boot and Linux (optional) * - kernel log buffer * - protected RAM * - LCD framebuffer @@ -433,6 +434,18 @@ void board_init_f (ulong bootflag) */ len = (ulong)&_end - CFG_MONITOR_BASE;
+ /* + * Subtract specified amount of memory to hide so that it won't + * get "touched" at all by U-Boot. By fixing up gd->ram_size + * the Linux kernel should now get passed the now "corrected" + * memory size and won't touch it either. This should work + * for arch/ppc and arch/powerpc. Only Linux board ports in + * arch/powerpc with bootwrapper support, that recalculate the + * memory size from the SDRAM controller setup will have to + * get fixed. + */ + gd->ram_size -= CFG_MEM_TOP_HIDE; + #ifndef CONFIG_MAX_MEM_MAPPED #define CONFIG_MAX_MEM_MAPPED (256 << 20) #endif

Dear Stefan,
in message 1206523009-18011-1-git-send-email-sr@denx.de you wrote:
It is strongly recommendet to not use the last 256 bytes on those
<nitpick> recommended </nitpick>
--- a/README +++ b/README @@ -1854,6 +1854,27 @@ Configuration Settings: Scratch address used by the alternate memory test You only need to set this if address zero isn't writeable
+- CFG_MEM_TOP_HIDE (PPC only):
If CFG_MEM_TOP_HIDE is defined in the board config header,
this specified memory area will get subtracted from the top
(end) of ram and won't get "touched" at all by U-Boot. By
fixing up gd->ram_size the Linux kernel should gets passed
the now "corrected" memory size and won't touch it either.
This should work for arch/ppc and arch/powerpc. Only Linux
board ports in arch/powerpc with bootwrapper support, that
recalculate the memory size from the SDRAM controller setup
will have to get fixed.
This option can be used as a workaround for the 440EPx/GRx
CHIP 11 errata where the last 256 bytes in SDRAM shouldn't
be touched.
WARNING: Please make sure that this value is a multiple of
the Linux page size (normally 4k). If this is not the case,
then the end address of the Linux memory will be located at a
non page size aligned address and this could cause mayor
<nitpick> major </nitpick>
Will you send a pull request for the ppc4xx repo, or should I apply this directly?
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Wednesday 26 March 2008, Wolfgang Denk wrote: <snip>
WARNING: Please make sure that this value is a multiple of
the Linux page size (normally 4k). If this is not the case,
then the end address of the Linux memory will be located at a
non page size aligned address and this could cause mayor
<nitpick> major </nitpick>
Changed in current version. Thanks.
Will you send a pull request for the ppc4xx repo, or should I apply this directly?
I was going to ask you this too. Since I was going to send a pull request today anyways, I'll integrate this patch too if you have no objections.
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@denx.de =====================================================================

Stefan Roese wrote:
[...] +- CFG_MEM_TOP_HIDE (PPC only):
If CFG_MEM_TOP_HIDE is defined in the board config header,
this specified memory area will get subtracted from the top
(end) of ram and won't get "touched" at all by U-Boot. By
fixing up gd->ram_size the Linux kernel should gets passed
the now "corrected" memory size and won't touch it either.
This should work for arch/ppc and arch/powerpc. Only Linux
board ports in arch/powerpc with bootwrapper support, that
recalculate the memory size from the SDRAM controller setup
will have to get fixed.
[...]
Hi Stefan,
I also have a nit to pick :-) . It's not clear to me whether the clause in the last sentence is meant to be restrictive or non-restrictive. If restrictive, I recommend removing the comma before the word "that". If non-restrictive, I recommend replacing the word "that" with the word "which".
Best regards, Larry

I wrote:
Stefan Roese wrote:
[...] +- CFG_MEM_TOP_HIDE (PPC only):
If CFG_MEM_TOP_HIDE is defined in the board config header,
this specified memory area will get subtracted from the top
(end) of ram and won't get "touched" at all by U-Boot. By
fixing up gd->ram_size the Linux kernel should gets passed
the now "corrected" memory size and won't touch it either.
This should work for arch/ppc and arch/powerpc. Only Linux
board ports in arch/powerpc with bootwrapper support, that
recalculate the memory size from the SDRAM controller setup
will have to get fixed.
[...]
Hi Stefan,
I also have a nit to pick :-) . It's not clear to me whether the clause in the last sentence is meant to be restrictive or non-restrictive. If restrictive, I recommend removing the comma before the word "that". If non-restrictive, I recommend replacing the word "that" with the word "which".
Oops, I forgot to write that, for the non-restrictive clause, there should also be a comma after the word "setup".
Best regards, Larry

On Thursday 27 March 2008, Larry Johnson wrote:
+- CFG_MEM_TOP_HIDE (PPC only):
If CFG_MEM_TOP_HIDE is defined in the board config header,
this specified memory area will get subtracted from the top
(end) of ram and won't get "touched" at all by U-Boot. By
fixing up gd->ram_size the Linux kernel should gets passed
the now "corrected" memory size and won't touch it either.
This should work for arch/ppc and arch/powerpc. Only Linux
board ports in arch/powerpc with bootwrapper support, that
recalculate the memory size from the SDRAM controller setup
will have to get fixed.
[...]
Hi Stefan,
I also have a nit to pick :-) . It's not clear to me whether the clause in the last sentence is meant to be restrictive or non-restrictive. If restrictive, I recommend removing the comma before the word "that". If non-restrictive, I recommend replacing the word "that" with the word "which".
Thanks. Its sometimes helpful if native English speakers helps out here. I have to admit that I don't really get the difference of both versions you mention above. In this sentense I refer to Linux board ports which need *additional* fixes in Linux. I'll send the changed patch in a few minutes with this sentence:
" Only Linux board ports in arch/powerpc with bootwrapper support, which recalculate the memory size from the SDRAM controller setup, will have to get fixed in Linux additionally. "
I hope its clear now.
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@denx.de =====================================================================

Stefan Roese wrote:
On Thursday 27 March 2008, Larry Johnson wrote:
+- CFG_MEM_TOP_HIDE (PPC only):
If CFG_MEM_TOP_HIDE is defined in the board config header,
this specified memory area will get subtracted from the top
(end) of ram and won't get "touched" at all by U-Boot. By
fixing up gd->ram_size the Linux kernel should gets passed
the now "corrected" memory size and won't touch it either.
This should work for arch/ppc and arch/powerpc. Only Linux
board ports in arch/powerpc with bootwrapper support, that
recalculate the memory size from the SDRAM controller setup
will have to get fixed.
[...]
Hi Stefan,
I also have a nit to pick :-) . It's not clear to me whether the clause in the last sentence is meant to be restrictive or non-restrictive. If restrictive, I recommend removing the comma before the word "that". If non-restrictive, I recommend replacing the word "that" with the word "which".
Thanks. Its sometimes helpful if native English speakers helps out here. I have to admit that I don't really get the difference of both versions you mention above. In this sentense I refer to Linux board ports which need *additional* fixes in Linux. I'll send the changed patch in a few minutes with this sentence:
" Only Linux board ports in arch/powerpc with bootwrapper support, which recalculate the memory size from the SDRAM controller setup, will have to get fixed in Linux additionally. "
I hope its clear now.
It's clear now, but unfortunately I don't know enough to tell whether it is also correct :-( . The statement as now written implies that the statement without the clause, i.e., "Only Linux board ports in arch/powerpc with bootwrapper support will have to get fixed in Linux additionally", is also true. If this is not correct (because boards that do not recalculate their memory size do not need to be fixed in Linux), then you would write: "Only Linux board ports in arch/powerpc with bootwrapper support that recalculate the memory size from the SDRAM controller setup will have to get fixed in Linux additionally."
BTW, there is no general agreement on whether the word "that" in the preceding sentence is correct. While I prefer it, some believe the word "which" should be used instead. English is such a complicated language, even for native speakers, that I am always amazed at the quality of the postings from contributors who did not learn it as their first language.
Best regards, Larry

Larry Johnson wrote:
[snip]
BTW, there is no general agreement on whether the word "that" in the preceding sentence is correct. While I prefer it, some believe the word "which" should be used instead. English is such a complicated language, even for native speakers, that I am always amazed at the quality of the postings from contributors who did not learn it as their first language.
Best regards, Larry
Yeah, Wolfgang has corrected my English more than once. :-D
Best regards, gvb

In message 47EBEA01.8000403@ge.com you wrote:
Yeah, Wolfgang has corrected my English more than once. :-D
Really? That must have been by accident, then.
Best regards,
Wolfgang Denk

On Thursday 27 March 2008, Larry Johnson wrote:
It's clear now, but unfortunately I don't know enough to tell whether it is also correct :-( . The statement as now written implies that the statement without the clause, i.e., "Only Linux board ports in arch/powerpc with bootwrapper support will have to get fixed in Linux additionally", is also true. If this is not correct (because boards that do not recalculate their memory size do not need to be fixed in Linux), then you would write: "Only Linux board ports in arch/powerpc with bootwrapper support that recalculate the memory size from the SDRAM controller setup will have to get fixed in Linux additionally."
Now I'm confused. :)
Here is the current version I now have in my "master" branch (with your last sentense):
- CFG_MEM_TOP_HIDE (PPC only): If CFG_MEM_TOP_HIDE is defined in the board config header, this specified memory area will get subtracted from the top (end) of ram and won't get "touched" at all by U-Boot. By fixing up gd->ram_size the Linux kernel should gets passed the now "corrected" memory size and won't touch it either. This should work for arch/ppc and arch/powerpc. Only Linux board ports in arch/powerpc with bootwrapper support that recalculate the memory size from the SDRAM controller setup will have to get fixed in Linux additionally.
This option can be used as a workaround for the 440EPx/GRx CHIP 11 errata where the last 256 bytes in SDRAM shouldn't be touched.
WARNING: Please make sure that this value is a multiple of the Linux page size (normally 4k). If this is not the case, then the end address of the Linux memory will be located at a non page size aligned address and this could cause major problems.
Please send a patch to change this description if necessary.
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@denx.de =====================================================================

Stefan Roese wrote:
On Thursday 27 March 2008, Larry Johnson wrote:
It's clear now, but unfortunately I don't know enough to tell whether it is also correct :-( . The statement as now written implies that the statement without the clause, i.e., "Only Linux board ports in arch/powerpc with bootwrapper support will have to get fixed in Linux additionally", is also true. If this is not correct (because boards that do not recalculate their memory size do not need to be fixed in Linux), then you would write: "Only Linux board ports in arch/powerpc with bootwrapper support that recalculate the memory size from the SDRAM controller setup will have to get fixed in Linux additionally."
Now I'm confused. :)
Here is the current version I now have in my "master" branch (with your last sentense):
CFG_MEM_TOP_HIDE (PPC only): If CFG_MEM_TOP_HIDE is defined in the board config header, this specified memory area will get subtracted from the top (end) of ram and won't get "touched" at all by U-Boot. By fixing up gd->ram_size the Linux kernel should gets passed the now "corrected" memory size and won't touch it either. This should work for arch/ppc and arch/powerpc. Only Linux board ports in arch/powerpc with bootwrapper support that recalculate the memory size from the SDRAM controller setup will have to get fixed in Linux additionally.
This option can be used as a workaround for the 440EPx/GRx CHIP 11 errata where the last 256 bytes in SDRAM shouldn't be touched.
WARNING: Please make sure that this value is a multiple of the Linux page size (normally 4k). If this is not the case, then the end address of the Linux memory will be located at a non page size aligned address and this could cause major problems.
Please send a patch to change this description if necessary.
Thanks.
I'm not explaining it well, you can look at "http://en.wikipedia.org/wiki/English_relative_clauses" for a better explanation. What you have above should be technically correct, at worse it would be redundant.
Best regards, Larry

On Mar 26, 2008, at 4:16 AM, Stefan Roese wrote:
If CFG_MEM_TOP_HIDE is defined in the board config header, this specified memory area will get subtracted from the top (end) of ram and won't get "touched" at all by U-Boot. By fixing up gd->ram_size the Linux kernel should gets passed the now "corrected" memory size and won't touch it either. This should work for arch/ppc and arch/powerpc. Only Linux board ports in arch/powerpc with bootwrapper support, that recalculate the memory size from the SDRAM controller setup will have to get fixed.
This patch enables this config option on some PPC440EPx boards as a workaround for the CHIP 11 errata. Here the description from the AMCC documentation:
If you reduce the memory size this way does the 44x kernel have issues with the TLBs that are used to mapped pin kernel lowmem?
I know on 85xx this would be a bad thing and rather than changing gd-
ram_size, i'd add a memreserve in the device tree that the kernel
got passed.
- k

On Friday 28 March 2008, Kumar Gala wrote:
This patch enables this config option on some PPC440EPx boards as a workaround for the CHIP 11 errata. Here the description from the AMCC documentation:
If you reduce the memory size this way does the 44x kernel have issues with the TLBs that are used to mapped pin kernel lowmem?
Not that I am aware of. I tested arch/ppc and arch/powerpc kernel version without problems.
I know on 85xx this would be a bad thing and rather than changing gd-> ram_size, i'd add a memreserve in the device tree that the kernel got passed.
This way I have no chance to "fix" arch/ppc kernels too. I know, arch/ppc is dead. :) But we need to support it a little while longer.
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@denx.de =====================================================================
participants (5)
-
Jerry Van Baren
-
Kumar Gala
-
Larry Johnson
-
Stefan Roese
-
Wolfgang Denk