Fix default values for address and size cells
v2 cover Fix default values for address and size cells
From: Matthias Brugger <[email protected]>
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(-)
Signature · 1 line
2.22.0
PATCH v2 1/4 libfdt: fdt_address_cells() and fdt_size_cells()
From: Matthias Brugger <[email protected]>
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.
---
scripts/dtc/libfdt/fdt_addresses.c | 35 +++++++++++------------------- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 23 deletions(-)
scripts/dtc/libfdt/fdt_addresses.c +13 -22
@@ -1,6 +1,7 @@/* * libfdt - Flat Device Tree manipulation * Copyright (C) 2014 David Gibson <[email protected]> +* 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" ); }
scripts/dtc/libfdt/libfdt.h +1 -1
@@ -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,
Signature · 1 line
2.22.0
PATCH v2 1/4 libfdt: fdt_address_cells() and fdt_size_cells()
From: Matthias Brugger <[email protected]>
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.
---
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!
PATCH v2 1/4 libfdt: fdt_address_cells() and fdt_size_cells()
Hi Simon,
Quoted 11 lines · sjg at google.com
From: Matthias Brugger <[email protected]>
Add internal
fdt_cells()to avoid copy and paste. Fix typo infdt_size_cells()documentation comment.This is based in upstream commit:
c12b2b0 ("libfdt:fdt_address_cells()andfdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.Signed-off-by Matthias Brugger <[email protected]>Reviewed-by Simon Glass <[email protected]>
Quoted 7 lines
---
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
PATCH v2 1/4 libfdt: fdt_address_cells() and fdt_size_cells()
Hi Matthias,
Quoted 28 lines · Matthias Brugger
Hi Simon,
Quoted 11 lines · sjg at google.com
From: Matthias Brugger <[email protected]>
Add internal
fdt_cells()to avoid copy and paste. Fix typo infdt_size_cells()documentation comment.This is based in upstream commit:
c12b2b0 ("libfdt:fdt_address_cells()andfdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.Signed-off-by Matthias Brugger <[email protected]>Reviewed-by Simon Glass <[email protected]>Quoted 7 lines
---
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?
Quoted 6 lines
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
PATCH v2 1/4 libfdt: fdt_address_cells() and fdt_size_cells()
Quoted 31 lines · Simon Glass
Hi Matthias,
Quoted 28 lines · Matthias Brugger
Hi Simon,
Quoted 11 lines · sjg at google.com
From: Matthias Brugger <[email protected]>
Add internal
fdt_cells()to avoid copy and paste. Fix typo infdt_size_cells()documentation comment.This is based in upstream commit:
c12b2b0 ("libfdt:fdt_address_cells()andfdt_size_cells()") but misses the test cases, as we don't implement them in U-Boot.Signed-off-by Matthias Brugger <[email protected]>Reviewed-by Simon Glass <[email protected]>Quoted 7 lines
---
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?
Quoted 9 lines
Quoted 6 lines
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 :)
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
In reply to matthias.bgg at kernel.orgFrom: Matthias Brugger <[email protected]>
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.
---
scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-)
scripts/dtc/libfdt/fdt_addresses.c +13 -3
@@ -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; }
scripts/dtc/libfdt/libfdt.h +1 -1
@@ -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,
Signature · 1 line
2.22.0
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
Hi,
Quoted 11 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
According to the device tree specification, the default value for was not present.
This patch also makes
fdt_address_cells()andfdt_size_cells()conform to the behaviour documented inlibfdt.h. The defaults are only returned iffdt_getprop()returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
Quoted 5 lines
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 <[email protected]>
This is v2 but I don't see a change log?
Quoted 5 lines
---
scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-)
Regards,
Simon
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
Hi Simon,
Quoted 14 lines · Simon Glass
Hi,
Quoted 11 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
According to the device tree specification, the default value for was not present.
This patch also makes
fdt_address_cells()andfdt_size_cells()conform to the behaviour documented inlibfdt.h. The defaults are only returned iffdt_getprop()returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.
Quoted 8 lines
Quoted 5 lines
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 <[email protected]>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
Quoted 9 lines
Quoted 5 lines
---
scripts/dtc/libfdt/fdt_addresses.c | 16 +++++++++++++--- scripts/dtc/libfdt/libfdt.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-)Regards,
Simon
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
Hi Matthias,
Quoted 24 lines · Matthias Brugger
Hi Simon,
Quoted 20 lines · Simon Glass
Hi,
Quoted 16 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
According to the device tree specification, the default value for was not present.
This patch also makes
fdt_address_cells()andfdt_size_cells()conform to the behaviour documented inlibfdt.h. The defaults are only returned iffdt_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 <[email protected]>
Quoted 7 lines
Quoted 2 lines
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
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
Quoted 15 lines · Simon Glass
Hi Matthias,
Quoted 11 lines · Matthias Brugger
Hi Simon,
Quoted 7 lines · Simon Glass
Hi,
Quoted 4 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
According to the device tree specification, the default value for
There seems to be something missing here/...
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines
was not present.
This patch also makes
fdt_address_cells()andfdt_size_cells()conform to the behaviour documented inlibfdt.h. The defaults are only returned iffdt_getprop()returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.Quoted 5 lines
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 <[email protected]>This is v2 but I don't see a change log?
Quoted 6 lines
Quoted 4 lines
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
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
Quoted 11 lines · Simon Glass
Quoted 10 lines · Simon Glass
Hi Matthias,
Quoted 6 lines · Matthias Brugger
Hi Simon,
Quoted 2 lines · Simon Glass
Hi,
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
Quoted 4 lines
From: Matthias Brugger <[email protected]>
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
Quoted 28 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines
was not present.
This patch also makes
fdt_address_cells()andfdt_size_cells()conform to the behaviour documented inlibfdt.h. The defaults are only returned iffdt_getprop()returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.Quoted 5 lines
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 <[email protected]>This is v2 but I don't see a change log?
Quoted 6 lines
Quoted 4 lines
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 <[email protected]>Regards,
Simon
PATCH v2 2/4 libfdt: return correct value if #size-cells property is not present
Quoted 11 lines · Simon Glass
Quoted 10 lines · Simon Glass
Hi Matthias,
Quoted 6 lines · Matthias Brugger
Hi Simon,
Quoted 2 lines · Simon Glass
Hi,
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
Quoted 4 lines
From: Matthias Brugger <[email protected]>
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
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
was not present.
This patch also makes
fdt_address_cells()andfdt_size_cells()conform to the behaviour documented inlibfdt.h. The defaults are only returned iffdt_getprop()returns -FDT_ERR_NOTFOUND, otherwise the actual error is returned.Quoted 8 lines
Quoted 5 lines
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 <[email protected]>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/
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
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 <[email protected]>Regards,
Simon
Applied to u-boot-dm/next, thanks!
PATCH v2 3/4 libfdt: Allow #size-cells of 0
In reply to matthias.bgg at kernel.orgFrom: Matthias Brugger <[email protected]>
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.
---
scripts/dtc/libfdt/fdt_addresses.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
scripts/dtc/libfdt/fdt_addresses.c +5 -3
@@ -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;
Signature · 1 line
2.22.0
PATCH v2 3/4 libfdt: Allow #size-cells of 0
Quoted 19 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
The commit "libfdt:
fdt_address_cells()andfdt_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.
Quoted 5 lines
Signed-off-by Matthias Brugger <[email protected]>---
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
PATCH v2 3/4 libfdt: Allow #size-cells of 0
Quoted 21 lines · Simon Glass
Quoted 19 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
The commit "libfdt:
fdt_address_cells()andfdt_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.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Matthias Brugger <[email protected]>---
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?
(please use patman if you can next time)
PATCH v2 3/4 libfdt: Allow #size-cells of 0
Quoted 21 lines · Simon Glass
Quoted 19 lines · On Thu, 5 Sep 2019 at 02:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
The commit "libfdt:
fdt_address_cells()andfdt_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.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Matthias Brugger <[email protected]>---
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?
(please use patman if you can next time)
Applied to u-boot-dm/next, thanks!
PATCH v2 4/4 dm: Fix default address cells return value
In reply to matthias.bgg at kernel.orgFrom: Matthias Brugger <[email protected]>
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.
---
include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/dm/of.h +1 -1
@@ -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
Signature · 1 line
2.22.0
PATCH v2 4/4 dm: Fix default address cells return value
Quoted 7 lines · On Thu, 5 Sep 2019 at 01:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
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.
Quoted 5 lines
Signed-off-by Matthias Brugger <[email protected]>---
include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v2 4/4 dm: Fix default address cells return value
Quoted 7 lines · On Thu, 5 Sep 2019 at 01:49, <[email protected]> wrote:
From: Matthias Brugger <[email protected]>
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.
Quoted 5 lines
Signed-off-by Matthias Brugger <[email protected]>---
include/dm/of.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
v2 cover Fix default values for address and size cells
In reply to matthias.bgg at kernel.orgHi Simon,
Quoted 24 lines · matthias.bgg at kernel.org
From: Matthias Brugger <[email protected]>
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()andfdt_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
Quoted 5 lines
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
v2 cover Fix default values for address and size cells
Hi Matthias,
Quoted 28 lines · Matthias Brugger
Hi Simon,
Quoted 24 lines · matthias.bgg at kernel.org
From: Matthias Brugger <[email protected]>
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()andfdt_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
Quoted 8 lines
Quoted 5 lines
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
v2 cover Fix default values for address and size cells
Quoted 37 lines · Simon Glass
Hi Matthias,
Quoted 34 lines · Matthias Brugger
Hi Simon,
Quoted 29 lines · matthias.bgg at kernel.org
From: Matthias Brugger <[email protected]>
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()andfdt_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 valueinclude/dm/of.h | 2 +- scripts/dtc/libfdt/fdt_addresses.c | 45 ++++++++++++++++-------------- scripts/dtc/libfdt/libfdt.h | 2 +- 3 files changed, 26 insertions(+), 23 deletions(-)
Quoted 5 lines
Quoted 2 lines
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