]> git.kernelconcepts.de Git - karo-tx-uboot.git/commit
fdt: Fix bug in size calculation in fdt_resize() with initrd use
authorFeng Wang <fwang02@harris.com>
Tue, 3 Aug 2010 14:22:43 +0000 (16:22 +0200)
committerWolfgang Denk <wd@denx.de>
Sun, 8 Aug 2010 23:10:30 +0000 (01:10 +0200)
commit3840ebfaf8f3af46d1046ce63dbebc22f2b39349
tree013b1d4df18ec000a018484d8a8aea0aadfb784b
parent75b5bbdef67678560a12efa8e135b40b77dcde48
fdt: Fix bug in size calculation in fdt_resize() with initrd use

Original bug description from Feng (fdt_resize() bug caused "WARNING:
could not set linux, initrd-start FDT_ERR_NOSPACE."):

What I got is an error: "WARNING: could not set linux,initrd-start
FDT_ERR_NOSPACE." after loading Device Tree blob. This in turn caused
linux to miss init part.

After some digging, I found out the reason for this error, it is caused
by fdt_resize().

FDT blob got resized after filling in all board specific information of
PowerPC. (in boot_body_linux()). It reduced blob size with only extra
space for two fdt_reserve_entry, one for fdt itself, and one for initrd.
Then it's aligned to a 0x1000 page boundary. However, later in
fdt_initrd(), it could add two more properties, initrd-start AND
initrd-end, each one needs at least two fdt_reserve_entry sizes done by
_fdt_add_property() (name and value). Thus, the two fdt_reserve_entry
extra space is not sufficient.

So for some specific fdt size which is just under the page boundary
after resizing, this will cause an error of FDT_ERR_NOSPACE in
fdt_initrd() when setting those two properties, and failed to pass
initrd information to linux.

My fix is in fdt_resize(), leave at least 4 fdt_reserve_entry for
initrd. So instead of 2*sizeof(struct fdt_reserve_entry) for
actual_totalsize, use 5*sizeof(struc fdt_reserve_entry).

Stefan: I got this same error on katmai, when trying to boot with
initrd (run flash_self). This patch fixes this issue.

Signed-off-by: Feng Wang <fwang02@harris.com>
Tested-by: Stefan Roese <sr@denx.de>
Cc: Jerry Van Baren <gvb.uboot@gmail.com>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
common/fdt_support.c