Patchwork [U-Boot,v2] common/image.c: align usage of fdt_high with initrd_high

login
register
mail settings
Submitter Shawn Guo
Date Jan. 7, 2012, 2:39 p.m.
Message ID <1325947193-18168-1-git-send-email-shawn.guo@linaro.org>
Download mbox | patch
Permalink /patch/134855/
State Changes Requested
Headers show

Comments

Shawn Guo - Jan. 7, 2012, 2:39 p.m.
The commit message of a28afca (Add uboot "fdt_high" enviroment variable)
states that fdt_high behaves similarly to the existing initrd_high.
But fdt_high actually has an outstanding difference from initrd_high.
The former specifies the start address, while the later specifies the
end address.

As fdt_high and initrd_high will likely be used together, it'd be nice
to have them behave same.  The patch changes the behavior of fdt_high
to have it aligned with initrd_high.

The document of fdt_high in README is updated with an example to
demonstrate the usage of this environment variable.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
Changes since v1:
 * Update document of fdt_high with an example to demonstrate the usage

 README         |    8 ++++++++
 common/image.c |    6 ++----
 2 files changed, 10 insertions(+), 4 deletions(-)
Shawn Guo - Jan. 10, 2012, 6:52 a.m.
Please hold on this patch.  I found some problem with it.

Regards,
Shawn

On Sat, Jan 07, 2012 at 10:39:53PM +0800, Shawn Guo wrote:
> The commit message of a28afca (Add uboot "fdt_high" enviroment variable)
> states that fdt_high behaves similarly to the existing initrd_high.
> But fdt_high actually has an outstanding difference from initrd_high.
> The former specifies the start address, while the later specifies the
> end address.
> 
> As fdt_high and initrd_high will likely be used together, it'd be nice
> to have them behave same.  The patch changes the behavior of fdt_high
> to have it aligned with initrd_high.
> 
> The document of fdt_high in README is updated with an example to
> demonstrate the usage of this environment variable.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> Changes since v1:
>  * Update document of fdt_high with an example to demonstrate the usage
> 
>  README         |    8 ++++++++
>  common/image.c |    6 ++----
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/README b/README
> index ff72e47..1c3713c 100644
> --- a/README
> +++ b/README
> @@ -3619,6 +3619,14 @@ List of environment variables (most likely not complete):
>  
>    fdt_high	- if set this restricts the maximum address that the
>  		  flattened device tree will be copied into upon boot.
> +		  For example, if you have a system with 1 GB memory
> +		  at physical address 0x10000000, while Linux kernel
> +		  only recognizes the first 704 MB as low memory, you
> +		  may need to set fdt_high as 0x3C000000 to have the
> +		  device tree blob be copied to the maximum address
> +		  of the 704 MB low memory, so that Linux kernel can
> +		  access it during the boot procedure.
> +
>  		  If this is set to the special value 0xFFFFFFFF then
>  		  the fdt will not be copied at all on boot.  For this
>  		  to work it must reside in writable memory, have
> diff --git a/common/image.c b/common/image.c
> index 77ca6e4..12ceacf 100644
> --- a/common/image.c
> +++ b/common/image.c
> @@ -1294,10 +1294,8 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
>  		if (desired_addr) {
>  			of_start =
>  			    (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
> -							   ((ulong)
> -							    desired_addr)
> -							   + of_len);
> -			if (desired_addr && of_start != desired_addr) {
> +							   (ulong)desired_addr);
> +			if (of_start == 0) {
>  				puts("Failed using fdt_high value for Device Tree");
>  				goto error;
>  			}
> -- 
> 1.7.4.1
>

Patch

diff --git a/README b/README
index ff72e47..1c3713c 100644
--- a/README
+++ b/README
@@ -3619,6 +3619,14 @@  List of environment variables (most likely not complete):
 
   fdt_high	- if set this restricts the maximum address that the
 		  flattened device tree will be copied into upon boot.
+		  For example, if you have a system with 1 GB memory
+		  at physical address 0x10000000, while Linux kernel
+		  only recognizes the first 704 MB as low memory, you
+		  may need to set fdt_high as 0x3C000000 to have the
+		  device tree blob be copied to the maximum address
+		  of the 704 MB low memory, so that Linux kernel can
+		  access it during the boot procedure.
+
 		  If this is set to the special value 0xFFFFFFFF then
 		  the fdt will not be copied at all on boot.  For this
 		  to work it must reside in writable memory, have
diff --git a/common/image.c b/common/image.c
index 77ca6e4..12ceacf 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1294,10 +1294,8 @@  int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 		if (desired_addr) {
 			of_start =
 			    (void *)(ulong) lmb_alloc_base(lmb, of_len, 0x1000,
-							   ((ulong)
-							    desired_addr)
-							   + of_len);
-			if (desired_addr && of_start != desired_addr) {
+							   (ulong)desired_addr);
+			if (of_start == 0) {
 				puts("Failed using fdt_high value for Device Tree");
 				goto error;
 			}