* [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM
@ 2014-05-07 5:16 Bjorn Andersson
2014-05-07 5:32 ` Bjorn Andersson
2014-05-07 8:06 ` Uwe Kleine-König
0 siblings, 2 replies; 6+ messages in thread
From: Bjorn Andersson @ 2014-05-07 5:16 UTC (permalink / raw)
To: linux-arm-kernel
Support overriding ATAG_MEM, by specifying non-zero content of the /memory/reg
property in the appended DTB. This is needed to work around bootloaders passing
broken tags.
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---
arch/arm/boot/compressed/atags_to_fdt.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
index d1153c8..b534cd6 100644
--- a/arch/arm/boot/compressed/atags_to_fdt.c
+++ b/arch/arm/boot/compressed/atags_to_fdt.c
@@ -95,6 +95,22 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
setprop_string(fdt, "/chosen", "bootargs", cmdline);
}
+static int fdt_overrides_atag_mem(void *fdt)
+{
+ const char *memory;
+ int len = 0;
+
+ memory = getprop(fdt, "/memory", "reg", &len);
+ if (memory) {
+ while (len--) {
+ if (*memory != '\0')
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/*
* Convert and fold provided ATAGs into the provided FDT.
*
@@ -180,7 +196,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
}
}
- if (memcount) {
+ if (memcount && !fdt_overrides_atag_mem(fdt)) {
setprop(fdt, "/memory", "reg", mem_reg_property,
4 * memcount * memsize);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM
2014-05-07 5:16 [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM Bjorn Andersson
@ 2014-05-07 5:32 ` Bjorn Andersson
2014-05-07 8:06 ` Uwe Kleine-König
1 sibling, 0 replies; 6+ messages in thread
From: Bjorn Andersson @ 2014-05-07 5:32 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, May 6, 2014 at 10:16 PM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> wrote:
[...]
> +static int fdt_overrides_atag_mem(void *fdt)
> +{
> + const char *memory;
> + int len = 0;
> +
> + memory = getprop(fdt, "/memory", "reg", &len);
> + if (memory) {
> + while (len--) {
> + if (*memory != '\0')
Sorry, this is of course supposed to be:
if (*memory++ != '\0')
> + return 1;
> + }
> + }
> +
> + return 0;
> +}
Regards,
Bjorn
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM
2014-05-07 5:16 [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM Bjorn Andersson
2014-05-07 5:32 ` Bjorn Andersson
@ 2014-05-07 8:06 ` Uwe Kleine-König
2014-05-07 15:29 ` Bjorn Andersson
1 sibling, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2014-05-07 8:06 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, May 06, 2014 at 10:16:16PM -0700, Bjorn Andersson wrote:
> Support overriding ATAG_MEM, by specifying non-zero content of the /memory/reg
> property in the appended DTB. This is needed to work around bootloaders passing
> broken tags.
This feels wrong. I think it's quite usual that the device tree
specifies a non-0 /memory/reg property. I checked four more or less
random dts files[1], and three of them have this property set with
actual values.
So I wouldn't be surprised if this patch results in more damage than
it's worth. The optimal fix would be to make the bootloader do the right
thing. And if you trust your dtb more than your bootloader, disable
ARM_ATAG_DTB_COMPAT.
Best regards
Uwe
[1]
arch/arm/boot/dts/am335x-bone-common.dtsi
arch/arm/boot/dts/exynos5440-sd5v1.dts
arch/arm/boot/dts/imx6q-wandboard.dts
arch/arm/boot/dts/tegra30-cardhu.dtsi
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> ---
> arch/arm/boot/compressed/atags_to_fdt.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c
> index d1153c8..b534cd6 100644
> --- a/arch/arm/boot/compressed/atags_to_fdt.c
> +++ b/arch/arm/boot/compressed/atags_to_fdt.c
> @@ -95,6 +95,22 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline)
> setprop_string(fdt, "/chosen", "bootargs", cmdline);
> }
>
> +static int fdt_overrides_atag_mem(void *fdt)
> +{
> + const char *memory;
> + int len = 0;
> +
> + memory = getprop(fdt, "/memory", "reg", &len);
> + if (memory) {
> + while (len--) {
> + if (*memory++ != '\0')
[added fixup noted in follow-up-mail]
> + return 1;
> + }
> + }
> +
> + return 0;
> +}
> +
> /*
> * Convert and fold provided ATAGs into the provided FDT.
> *
> @@ -180,7 +196,7 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space)
> }
> }
>
> - if (memcount) {
> + if (memcount && !fdt_overrides_atag_mem(fdt)) {
> setprop(fdt, "/memory", "reg", mem_reg_property,
> 4 * memcount * memsize);
> }
> --
> 1.7.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM
2014-05-07 8:06 ` Uwe Kleine-König
@ 2014-05-07 15:29 ` Bjorn Andersson
2014-05-07 21:24 ` Andreas Färber
0 siblings, 1 reply; 6+ messages in thread
From: Bjorn Andersson @ 2014-05-07 15:29 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, May 7, 2014 at 1:06 AM, Uwe Kleine-K?nig
<u.kleine-koenig@pengutronix.de> wrote:
> On Tue, May 06, 2014 at 10:16:16PM -0700, Bjorn Andersson wrote:
>> Support overriding ATAG_MEM, by specifying non-zero content of the /memory/reg
>> property in the appended DTB. This is needed to work around bootloaders passing
>> broken tags.
> This feels wrong. I think it's quite usual that the device tree
> specifies a non-0 /memory/reg property. I checked four more or less
> random dts files[1], and three of them have this property set with
> actual values.
I thought u-boot did something like this, but after checking the code
it seems that I
was wrong.
But if that's not the case then you're right; we have to continue to
be bug-compatible
with all those dtbs out there.
>
> So I wouldn't be surprised if this patch results in more damage than
> it's worth. The optimal fix would be to make the bootloader do the right
> thing. And if you trust your dtb more than your bootloader, disable
> ARM_ATAG_DTB_COMPAT.
I unfortunately have a boot loader passing information in ATAG_CMDLINE that I
need, so I can't disable ARM_ATAG_DTB_COMPAT.
My problem is that the boot loader on every shipped Qualcomm MSM8x60, MSM8960
and APQ8064 based device passes ATAG_MEM with the incorrect start address. There
is no way to update the boot loader for these.
For development I have a .init_meminfo in my board file patching the
meminfo; this looks
really bad so I'm hoping we can find some alternative solution.
The proposed solution from some of the people working on this is to
(post build) patch the
zImage to inject code that corrects the ATAG_MEM before jumping to the
kernel; but I am
hoping we can find some sane way instead...
Regards,
Bjorn
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM
2014-05-07 15:29 ` Bjorn Andersson
@ 2014-05-07 21:24 ` Andreas Färber
2014-06-14 20:33 ` Pavel Machek
0 siblings, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2014-05-07 21:24 UTC (permalink / raw)
To: linux-arm-kernel
Am 07.05.2014 17:29, schrieb Bjorn Andersson:
> My problem is that the boot loader on every shipped Qualcomm MSM8x60, MSM8960
> and APQ8064 based device passes ATAG_MEM with the incorrect start address. There
> is no way to update the boot loader for these.
Chaining bootloaders comes to mind. This is being done on the Exynos5
based Chromebooks, for instance.
Regards,
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend?rffer; HRB 16746 AG N?rnberg
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-06-14 20:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 5:16 [PATCH] ARM: zImage: Allow DTB to override broken ATAG_MEM Bjorn Andersson
2014-05-07 5:32 ` Bjorn Andersson
2014-05-07 8:06 ` Uwe Kleine-König
2014-05-07 15:29 ` Bjorn Andersson
2014-05-07 21:24 ` Andreas Färber
2014-06-14 20:33 ` Pavel Machek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).