[U-Boot] [PATCH v2 0/4] Fix default values for address and size cells

From: Matthias Brugger mbrugger@suse.com
The libftd implementation of U-Boot is outdated with the upstream project. Especially the default number of size-cells was wrong. This series fixes this by backporting the corresponding patches from the upstream project.
Changes since v1: - fix spelling of U-Boot (patch 1 + 2 /4) - add Reviewed-by tag (patch 1/4) - fix the case of size-cells == 0 (patch 3/4) - fix default address cells for livetree (patch 4/4)
v1 can be found here: https://patchwork.ozlabs.org/patch/1137331/ https://patchwork.ozlabs.org/patch/1137330/
Matthias Brugger (4): libfdt: fdt_address_cells() and fdt_size_cells() libfdt: return correct value if #size-cells property is not present libfdt: Allow #size-cells of 0 dm: Fix default address cells return value
include/dm/of.h | 2 +- scripts/dtc/libfdt/fdt_addresses.c | 45 ++++++++++++++++-------------- scripts/dtc/libfdt/libfdt.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-)

From: Matthias Brugger mbrugger@suse.com
Add internal fdt_cells() to avoid copy and paste. Fix typo in fdt_size_cells() documentation comment.
This is based in upstream commit: c12b2b0 ("libfdt: fdt_address_cells() and fdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com Reviewed-by: Simon Glass sjg@chromium.org ---
scripts/dtc/libfdt/fdt_addresses.c | 35 +++++++++++------------------- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c index eff4dbcc72..49537b578d 100644 --- a/scripts/dtc/libfdt/fdt_addresses.c +++ b/scripts/dtc/libfdt/fdt_addresses.c @@ -1,6 +1,7 @@ /* * libfdt - Flat Device Tree manipulation * Copyright (C) 2014 David Gibson david@gibson.dropbear.id.au + * Copyright (C) 2018 embedded brains GmbH * * libfdt is dual licensed: you can use it either under the terms of * the GPL, or the BSD license, at your option. @@ -55,42 +56,32 @@
#include "libfdt_internal.h"
-int fdt_address_cells(const void *fdt, int nodeoffset) +static int fdt_cells(const void *fdt, int nodeoffset, const char *name) { - const fdt32_t *ac; + const fdt32_t *c; int val; int len;
- ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len); - if (!ac) + c = fdt_getprop(fdt, nodeoffset, name, &len); + if (!c) return 2;
- if (len != sizeof(*ac)) + if (len != sizeof(*c)) return -FDT_ERR_BADNCELLS;
- val = fdt32_to_cpu(*ac); + val = fdt32_to_cpu(*c); if ((val <= 0) || (val > FDT_MAX_NCELLS)) return -FDT_ERR_BADNCELLS;
return val; }
-int fdt_size_cells(const void *fdt, int nodeoffset) +int fdt_address_cells(const void *fdt, int nodeoffset) { - const fdt32_t *sc; - int val; - int len; - - sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len); - if (!sc) - return 2; - - if (len != sizeof(*sc)) - return -FDT_ERR_BADNCELLS; - - val = fdt32_to_cpu(*sc); - if ((val < 0) || (val > FDT_MAX_NCELLS)) - return -FDT_ERR_BADNCELLS; + return fdt_cells(fdt, nodeoffset, "#address-cells"); +}
- return val; +int fdt_size_cells(const void *fdt, int nodeoffset) +{ + return fdt_cells(fdt, nodeoffset, "#size-cells"); } diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h index cf86ddba88..66f01fec53 100644 --- a/scripts/dtc/libfdt/libfdt.h +++ b/scripts/dtc/libfdt/libfdt.h @@ -1109,7 +1109,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset); * * returns: * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #address-cells property + * 2, if the node has no #size-cells property * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid * #size-cells property * -FDT_ERR_BADMAGIC,

From: Matthias Brugger mbrugger@suse.com
Add internal fdt_cells() to avoid copy and paste. Fix typo in fdt_size_cells() documentation comment.
This is based in upstream commit: c12b2b0 ("libfdt: fdt_address_cells() and fdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com Reviewed-by: Simon Glass sjg@chromium.org ---
scripts/dtc/libfdt/fdt_addresses.c | 35 +++++++++++------------------- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!

Hi Simon,
On 28/09/2019 01:28, sjg@google.com wrote:
From: Matthias Brugger mbrugger@suse.com
Add internal fdt_cells() to avoid copy and paste. Fix typo in fdt_size_cells() documentation comment.
This is based in upstream commit: c12b2b0 ("libfdt: fdt_address_cells() and fdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com Reviewed-by: Simon Glass sjg@chromium.org
scripts/dtc/libfdt/fdt_addresses.c | 35 +++++++++++------------------- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
I just looked through the upstream U-Boot commit log and don't see them queued for 2019.10-rc5 Do I understand correctly that you are planning to merge them after 2019.10 is released. Correct?
I'm asking because without these patches the grub boot path for RPi4 with RAM > 1GB is 'broken', in the sense that the kernel will only see RAM size of 1GB.
I can keep them as backports in openSUSE, that's no problem, just wanted to know what's your plan. And have a quick answer if someone asks on the mailinglist :)
Regards, Matthias

Hi Matthias,
On Mon, 7 Oct 2019 at 07:31, Matthias Brugger mbrugger@suse.com wrote:
Hi Simon,
On 28/09/2019 01:28, sjg@google.com wrote:
From: Matthias Brugger mbrugger@suse.com
Add internal fdt_cells() to avoid copy and paste. Fix typo in fdt_size_cells() documentation comment.
This is based in upstream commit: c12b2b0 ("libfdt: fdt_address_cells() and fdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com Reviewed-by: Simon Glass sjg@chromium.org
scripts/dtc/libfdt/fdt_addresses.c | 35 +++++++++++------------------- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
I just looked through the upstream U-Boot commit log and don't see them queued for 2019.10-rc5 Do I understand correctly that you are planning to merge them after 2019.10 is released. Correct?
I'm asking because without these patches the grub boot path for RPi4 with RAM > 1GB is 'broken', in the sense that the kernel will only see RAM size of 1GB.
I can keep them as backports in openSUSE, that's no problem, just wanted to know what's your plan. And have a quick answer if someone asks on the mailinglist :)
Yes that's right. Should get these applied next week.
Regards, Simon

On 11/10/2019 20:28, Simon Glass wrote:
Hi Matthias,
On Mon, 7 Oct 2019 at 07:31, Matthias Brugger mbrugger@suse.com wrote:
Hi Simon,
On 28/09/2019 01:28, sjg@google.com wrote:
From: Matthias Brugger mbrugger@suse.com
Add internal fdt_cells() to avoid copy and paste. Fix typo in fdt_size_cells() documentation comment.
This is based in upstream commit: c12b2b0 ("libfdt: fdt_address_cells() and fdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com Reviewed-by: Simon Glass sjg@chromium.org
scripts/dtc/libfdt/fdt_addresses.c | 35 +++++++++++------------------- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 23 deletions(-)
Applied to u-boot-dm/next, thanks!
I just looked through the upstream U-Boot commit log and don't see them queued for 2019.10-rc5 Do I understand correctly that you are planning to merge them after 2019.10 is released. Correct?
I'm asking because without these patches the grub boot path for RPi4 with RAM > 1GB is 'broken', in the sense that the kernel will only see RAM size of 1GB.
I can keep them as backports in openSUSE, that's no problem, just wanted to know what's your plan. And have a quick answer if someone asks on the mailinglist :)
Yes that's right. Should get these applied next week.
Ok, thanks for the info :)

From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com ---
scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c index 49537b578d..f13a87dfa0 100644 --- a/scripts/dtc/libfdt/fdt_addresses.c +++ b/scripts/dtc/libfdt/fdt_addresses.c @@ -64,7 +64,7 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
c = fdt_getprop(fdt, nodeoffset, name, &len); if (!c) - return 2; + return len;
if (len != sizeof(*c)) return -FDT_ERR_BADNCELLS; @@ -78,10 +78,20 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name)
int fdt_address_cells(const void *fdt, int nodeoffset) { - return fdt_cells(fdt, nodeoffset, "#address-cells"); + int val; + + val = fdt_cells(fdt, nodeoffset, "#address-cells"); + if (val == -FDT_ERR_NOTFOUND) + return 2; + return val; }
int fdt_size_cells(const void *fdt, int nodeoffset) { - return fdt_cells(fdt, nodeoffset, "#size-cells"); + int val; + + val = fdt_cells(fdt, nodeoffset, "#size-cells"); + if (val == -FDT_ERR_NOTFOUND) + return 1; + return val; } diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h index 66f01fec53..5c778b115b 100644 --- a/scripts/dtc/libfdt/libfdt.h +++ b/scripts/dtc/libfdt/libfdt.h @@ -1109,7 +1109,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset); * * returns: * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #size-cells property + * 1, if the node has no #size-cells property * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid * #size-cells property * -FDT_ERR_BADMAGIC,

Hi,
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
This is v2 but I don't see a change log?
scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-)
Regards, Simon

Hi Simon,
On 17/09/2019 07:48, Simon Glass wrote:
Hi,
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
This is v2 but I don't see a change log?
I put the changelog into the cover letter: https://patchwork.ozlabs.org/cover/1158304/
From your email I understand that you prefer a patch by patch changelog, correct?
Regards, Matthias
scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-)
Regards, Simon

Hi Matthias,
On Tue, 17 Sep 2019 at 00:29, Matthias Brugger mbrugger@suse.com wrote:
Hi Simon,
On 17/09/2019 07:48, Simon Glass wrote:
Hi,
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
This is v2 but I don't see a change log?
I put the changelog into the cover letter: https://patchwork.ozlabs.org/cover/1158304/
From your email I understand that you prefer a patch by patch changelog, correct?
Both is best. If you use patman it does this for you.
Regards, Simon

On Tue, 17 Sep 2019 at 09:52, Simon Glass sjg@chromium.org wrote:
Hi Matthias,
On Tue, 17 Sep 2019 at 00:29, Matthias Brugger mbrugger@suse.com wrote:
Hi Simon,
On 17/09/2019 07:48, Simon Glass wrote:
Hi,
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for
There seems to be something missing here/...
was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
This is v2 but I don't see a change log?
I put the changelog into the cover letter: https://patchwork.ozlabs.org/cover/1158304/
From your email I understand that you prefer a patch by patch changelog, correct?
Both is best. If you use patman it does this for you.
Reviewed-by: Simon Glass sjg@chromium.org
Regards, Simon

On 27/09/2019 03:48, Simon Glass wrote:
On Tue, 17 Sep 2019 at 09:52, Simon Glass sjg@chromium.org wrote:
Hi Matthias,
On Tue, 17 Sep 2019 at 00:29, Matthias Brugger mbrugger@suse.com wrote:
Hi Simon,
On 17/09/2019 07:48, Simon Glass wrote:
Hi,
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for
There seems to be something missing here/...
Argh, you are right, I accidentally deleted one line from the commit message. The correct paragraph should read like this:
<snip> According to the device tree specification, the default value for #size-cells is 1, but fdt_size_cells() was returning 2 if this property was not present. </snip>
BTW this series is a fix and I'd like to see it in v2019.10-rc5. I'm not sure who is to take it, you or Tom.
Regards, Matthias
was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
This is v2 but I don't see a change log?
I put the changelog into the cover letter: https://patchwork.ozlabs.org/cover/1158304/
From your email I understand that you prefer a patch by patch changelog, correct?
Both is best. If you use patman it does this for you.
Reviewed-by: Simon Glass sjg@chromium.org
Regards, Simon

On 27/09/2019 03:48, Simon Glass wrote:
On Tue, 17 Sep 2019 at 09:52, Simon Glass sjg@chromium.org wrote:
Hi Matthias,
On Tue, 17 Sep 2019 at 00:29, Matthias Brugger mbrugger@suse.com wrote:
Hi Simon,
On 17/09/2019 07:48, Simon Glass wrote:
Hi,
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
According to the device tree specification, the default value for
There seems to be something missing here/...
Argh, you are right, I accidentally deleted one line from the commit message. The correct paragraph should read like this:
<snip> According to the device tree specification, the default value for #size-cells is 1, but fdt_size_cells() was returning 2 if this property was not present. </snip>
BTW this series is a fix and I'd like to see it in v2019.10-rc5. I'm not sure who is to take it, you or Tom.
Regards, Matthias
was not present.
This patch also makes fdt_address_cells() and fdt_size_cells() conform to the behaviour documented in libfdt.h. The defaults are only returned if fdt_getprop() returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
This is based on upstream commit: aa7254d ("libfdt: return correct value if #size-cells property is not present") but misses the test case part, as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
This is v2 but I don't see a change log?
I put the changelog into the cover letter: https://patchwork.ozlabs.org/cover/1158304/
From your email I understand that you prefer a patch by patch changelog, correct?
Both is best. If you use patman it does this for you.
Reviewed-by: Simon Glass sjg@chromium.org
Regards, Simon
Applied to u-boot-dm/next, thanks!

From: Matthias Brugger mbrugger@suse.com
The commit "libfdt: fdt_address_cells() and fdt_size_cells()" introduced a bug as it consolidated code between the helpers for getting be 0, and is frequently found so in practice for /cpus. IEEE1275 only requires implementations to handle 1..4 for #address-cells, although one could make a case for #address-cells == #size-cells == 0 being used to represent a bridge with a single port.
While we're there, it's not totally obvious that the existing implicit cast of a u32 to int will give the correct results according to strict C, although it does work in practice. Straighten that up to cast only after we've made our range checks.
This is based on upstream commit: b8d6eca ("libfdt: Allow #size-cells of 0") but misses the test cases,as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com ---
scripts/dtc/libfdt/fdt_addresses.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/dtc/libfdt/fdt_addresses.c b/scripts/dtc/libfdt/fdt_addresses.c index f13a87dfa0..788c143113 100644 --- a/scripts/dtc/libfdt/fdt_addresses.c +++ b/scripts/dtc/libfdt/fdt_addresses.c @@ -59,7 +59,7 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name) { const fdt32_t *c; - int val; + uint32_t val; int len;
c = fdt_getprop(fdt, nodeoffset, name, &len); @@ -70,10 +70,10 @@ static int fdt_cells(const void *fdt, int nodeoffset, const char *name) return -FDT_ERR_BADNCELLS;
val = fdt32_to_cpu(*c); - if ((val <= 0) || (val > FDT_MAX_NCELLS)) + if (val > FDT_MAX_NCELLS) return -FDT_ERR_BADNCELLS;
- return val; + return (int)val; }
int fdt_address_cells(const void *fdt, int nodeoffset) @@ -81,6 +81,8 @@ int fdt_address_cells(const void *fdt, int nodeoffset) int val;
val = fdt_cells(fdt, nodeoffset, "#address-cells"); + if (val == 0) + return -FDT_ERR_BADNCELLS; if (val == -FDT_ERR_NOTFOUND) return 2; return val;

On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
The commit "libfdt: fdt_address_cells() and fdt_size_cells()" introduced a bug as it consolidated code between the helpers for getting be 0, and is frequently found so in practice for /cpus. IEEE1275 only requires implementations to handle 1..4 for #address-cells, although one could make a case for #address-cells == #size-cells == 0 being used to represent a bridge with a single port.
While we're there, it's not totally obvious that the existing implicit cast of a u32 to int will give the correct results according to strict C, although it does work in practice. Straighten that up to cast only after we've made our range checks.
This is based on upstream commit: b8d6eca ("libfdt: Allow #size-cells of 0") but misses the test cases,as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
scripts/dtc/libfdt/fdt_addresses.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
This is v2 but I don't see a change log?
- Simon

On Mon, 16 Sep 2019 at 22:48, Simon Glass sjg@chromium.org wrote:
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
The commit "libfdt: fdt_address_cells() and fdt_size_cells()" introduced a bug as it consolidated code between the helpers for getting be 0, and is frequently found so in practice for /cpus. IEEE1275 only requires implementations to handle 1..4 for #address-cells, although one could make a case for #address-cells == #size-cells == 0 being used to represent a bridge with a single port.
While we're there, it's not totally obvious that the existing implicit cast of a u32 to int will give the correct results according to strict C, although it does work in practice. Straighten that up to cast only after we've made our range checks.
This is based on upstream commit: b8d6eca ("libfdt: Allow #size-cells of 0") but misses the test cases,as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
scripts/dtc/libfdt/fdt_addresses.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
This is v2 but I don't see a change log?
Reviewed-by: Simon Glass sjg@chromium.org
(please use patman if you can next time)

On Mon, 16 Sep 2019 at 22:48, Simon Glass sjg@chromium.org wrote:
On Thu, 5 Sep 2019 at 02:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
The commit "libfdt: fdt_address_cells() and fdt_size_cells()" introduced a bug as it consolidated code between the helpers for getting be 0, and is frequently found so in practice for /cpus. IEEE1275 only requires implementations to handle 1..4 for #address-cells, although one could make a case for #address-cells == #size-cells == 0 being used to represent a bridge with a single port.
While we're there, it's not totally obvious that the existing implicit cast of a u32 to int will give the correct results according to strict C, although it does work in practice. Straighten that up to cast only after we've made our range checks.
This is based on upstream commit: b8d6eca ("libfdt: Allow #size-cells of 0") but misses the test cases,as we don't implement them in U-Boot.
Signed-off-by: Matthias Brugger mbrugger@suse.com
scripts/dtc/libfdt/fdt_addresses.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
This is v2 but I don't see a change log?
Reviewed-by: Simon Glass sjg@chromium.org
(please use patman if you can next time)
Applied to u-boot-dm/next, thanks!

From: Matthias Brugger mbrugger@suse.com
Default address cells value on the livetree access function returns the wrong value. Fix this so that the value returned corresponds to the device tree specification.
Signed-off-by: Matthias Brugger mbrugger@suse.com ---
include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/dm/of.h b/include/dm/of.h index 461e25aa19..6bef73b441 100644 --- a/include/dm/of.h +++ b/include/dm/of.h @@ -111,7 +111,7 @@ static inline const char *of_node_full_name(const struct device_node *np)
/* Default #address and #size cells */ #if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT) -#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1 +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1 #endif

On Thu, 5 Sep 2019 at 01:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
Default address cells value on the livetree access function returns the wrong value. Fix this so that the value returned corresponds to the device tree specification.
Signed-off-by: Matthias Brugger mbrugger@suse.com
include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Thu, 5 Sep 2019 at 01:49, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
Default address cells value on the livetree access function returns the wrong value. Fix this so that the value returned corresponds to the device tree specification.
Signed-off-by: Matthias Brugger mbrugger@suse.com
include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot-dm/next, thanks!

Hi Simon,
On 05/09/2019 10:48, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
The libftd implementation of U-Boot is outdated with the upstream project. Especially the default number of size-cells was wrong. This series fixes this by backporting the corresponding patches from the upstream project.
Changes since v1:
- fix spelling of U-Boot (patch 1 + 2 /4)
- add Reviewed-by tag (patch 1/4)
- fix the case of size-cells == 0 (patch 3/4)
- fix default address cells for livetree (patch 4/4)
v1 can be found here: https://patchwork.ozlabs.org/patch/1137331/ https://patchwork.ozlabs.org/patch/1137330/
Matthias Brugger (4): libfdt: fdt_address_cells() and fdt_size_cells() libfdt: return correct value if #size-cells property is not present libfdt: Allow #size-cells of 0 dm: Fix default address cells return value
include/dm/of.h | 2 +- scripts/dtc/libfdt/fdt_addresses.c | 45 ++++++++++++++++-------------- scripts/dtc/libfdt/libfdt.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-)
Any comments on this? I tried to find your custodian tree, but wasn't able to do so and check if you took it already.
Regards, Matthias

Hi Matthias,
On Wed, 25 Sep 2019 at 03:57, Matthias Brugger matthias.bgg@gmail.com wrote:
Hi Simon,
On 05/09/2019 10:48, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
The libftd implementation of U-Boot is outdated with the upstream project. Especially the default number of size-cells was wrong. This series fixes this by backporting the corresponding patches from the upstream project.
Changes since v1:
- fix spelling of U-Boot (patch 1 + 2 /4)
- add Reviewed-by tag (patch 1/4)
- fix the case of size-cells == 0 (patch 3/4)
- fix default address cells for livetree (patch 4/4)
v1 can be found here: https://patchwork.ozlabs.org/patch/1137331/ https://patchwork.ozlabs.org/patch/1137330/
Matthias Brugger (4): libfdt: fdt_address_cells() and fdt_size_cells() libfdt: return correct value if #size-cells property is not present libfdt: Allow #size-cells of 0 dm: Fix default address cells return value
include/dm/of.h | 2 +- scripts/dtc/libfdt/fdt_addresses.c | 45 ++++++++++++++++-------------- scripts/dtc/libfdt/libfdt.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-)
Any comments on this? I tried to find your custodian tree, but wasn't able to do so and check if you took it already.
This was applied. Did you not get the emails on each patch?
Regards, Simon

On 22/10/2019 01:47, Simon Glass wrote:
Hi Matthias,
On Wed, 25 Sep 2019 at 03:57, Matthias Brugger matthias.bgg@gmail.com wrote:
Hi Simon,
On 05/09/2019 10:48, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
The libftd implementation of U-Boot is outdated with the upstream project. Especially the default number of size-cells was wrong. This series fixes this by backporting the corresponding patches from the upstream project.
Changes since v1:
- fix spelling of U-Boot (patch 1 + 2 /4)
- add Reviewed-by tag (patch 1/4)
- fix the case of size-cells == 0 (patch 3/4)
- fix default address cells for livetree (patch 4/4)
v1 can be found here: https://patchwork.ozlabs.org/patch/1137331/ https://patchwork.ozlabs.org/patch/1137330/
Matthias Brugger (4): libfdt: fdt_address_cells() and fdt_size_cells() libfdt: return correct value if #size-cells property is not present libfdt: Allow #size-cells of 0 dm: Fix default address cells return value
include/dm/of.h | 2 +- scripts/dtc/libfdt/fdt_addresses.c | 45 ++++++++++++++++-------------- scripts/dtc/libfdt/libfdt.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-)
Any comments on this? I tried to find your custodian tree, but wasn't able to do so and check if you took it already.
This was applied. Did you not get the emails on each patch?
I got emails saying that they were applied to u-boot-dm/next, but wasn't able to find that branch.
Seeing it now, not sure if I didn't look correctly. Anyway thank for merging these fixes.
Regards, Matthias
participants (6)
-
Matthias Brugger
-
Matthias Brugger
-
matthias.bgg@kernel.org
-
Simon Glass
-
Simon Glass
-
sjg@google.com