of: addr: Abort address translation for parent nodes missing 'ranges'
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
The implementation of of_translate_one() was taken from the one in Linux kernel drivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.
---
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
drivers/core/of_addr.c +6 -18
@@ -173,25 +173,13 @@ static int of_translate_one(const struct device_node *parent,int rone;u64 offset =OF_BAD_ADDR ; -/* -* Normally, an absence of a "ranges" property means we are -* crossing a non-translatable boundary, and thus the addresses -* below the current cannot be converted to CPU physical ones. -* Unfortunately, while this is very clear in the spec, it's not -* what Apple understood, and they do have things like /uni-n or -* /ht nodes with no "ranges" property and a lot of perfectly -* useable mapped devices below them. Thus we treat the absence of -* "ranges" as equivalent to an empty "ranges" property which means -* a 1:1 translation at that level. It's up to the caller not to try -* to translate addresses that aren't supposed to be translated in -* the first place. --BenH. -* -* As far as we know, this damage only exists on Apple machines, so -* This code is only enabled on powerpc. --gcl -*/ - ranges =of_get_property (parent, rprop, &rlen); -if (ranges ==NULL || rlen ==0 ) { +if (ranges ==NULL ) { +debug ("no ranges; cannot translate\n" ); +return 1 ; + } + +if (rlen ==0 ) { offset =of_read_number (addr, na);memset (addr,0 , pna *4 );debug ("empty ranges; 1:1 translation\n" );
Signature · 1 line
2.7.4
PATCH 2/2 of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.
This keeps in sync with Linux kernel commit:
81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
---
drivers/core/of_addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/core/of_addr.c +2 -2
@@ -174,12 +174,12 @@ static int of_translate_one(const struct device_node *parent,u64 offset =OF_BAD_ADDR ; ranges =of_get_property (parent, rprop, &rlen); -if (ranges ==NULL ) { +if (ranges ==NULL &&strcmp (rprop,"dma-ranges" )) {debug ("no ranges; cannot translate\n" );return 1 ; } -if (rlen ==0 ) { +if (ranges ==NULL || rlen ==0 ) { offset =of_read_number (addr, na);memset (addr,0 , pna *4 );debug ("empty ranges; 1:1 translation\n" );
Signature · 1 line
2.7.4
PATCH 2/2 of: addr: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'
Quoted 10 lines · Bin Meng
'dma-ranges' frequently exists without parent nodes having 'dma-ranges'. While this is an error for 'ranges', this is fine because DMA capable devices always have a translatable DMA address. Also, with no 'dma-ranges' at all, the assumption is that DMA addresses are 1:1 with no restrictions unless perhaps the device itself has implicit restrictions.
This keeps in sync with Linux kernel commit:
Quoted 7 lines
81db12ee15cb: of/address: Translate 'dma-ranges' for parent nodes missing 'dma-ranges'Signed-off-by Bin Meng <[email protected]>---
drivers/core/of_addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
In reply to Bin MengQuoted 7 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.
Quoted 5 lines
Signed-off-by Bin Meng <[email protected]>---
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Bin,
Quoted 9 lines · Simon Glass
Quoted 7 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Bin Meng <[email protected]>---
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>
Unfortunately this seems to cause a test failure for ut_dm_fdt_translation. Can you please take a look?
Regards,
Simon
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?
It seems the no "ranges" property was intentionally removed by the following commit:
commit d64b9cdcd475eb7f07b49741ded87e24dae4a5fc
Author: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100
fdt: translate address if #size-cells = <0>
The __of_translate_address routine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in the am33xx-clocks.dtsi nodes would not be possible. They all have a parent with #size-cells = <0>.
It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
+Tom Rini too
Quoted 54 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Quoted 60 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added the CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS symbol to fix the issue, not enabled by default, thus making the change backwards compatible.
Thanks and regards,
Dario
Quoted 2 lines
Quoted 2 lines
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Best regards,
Dario
Quoted 3 lines
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.
Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Bin,
Quoted 90 lines
Il 17/03/2021 02:26 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Quoted 6 lines
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
I'll do some checking, although I think the Linux device binding / probing flow is more complex than u-boot.
Thanks and regards,
Dario
Quoted 3 lines
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Quoted 94 lines · Dario Binacchi
Hi Bin,
Quoted 92 lines
Il 17/03/2021 02:26 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
Quoted 7 lines
Quoted 4 lines
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
I'll do some checking, although I think the Linux device binding / probing flow is more complex than u-boot.
I guess at the high level, we need to understand what's going on here and why. With the whole "dt describes hardware", it shouldn't matter so much how Linux does its probing, both cases should work with the same DT, so someones (our?) logic needs to be corrected somewhere along the line.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210318/1e391f9a/attachment.sig>
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Tom,
Quoted 103 lines
Il 18/03/2021 20:51 Tom Rini <[email protected]> ha scritto:
Quoted 99 lines · Dario Binacchi
Hi Bin,
Quoted 96 lines
Il 17/03/2021 02:26 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
Quoted 8 lines
Quoted 2 lines
I'll do some checking, although I think the Linux device binding / probing flow is more complex than u-boot.
I guess at the high level, we need to understand what's going on here and why. With the whole "dt describes hardware", it shouldn't matter so much how Linux does its probing, both cases should work with the same DT, so someones (our?) logic needs to be corrected somewhere along the line.
My commit d64b9cdcd4 (fdt: translate address if #size-cells = <0>) previously reported by Bin is partial. In the missing lines it is explained why I removed the of_empty_ranges_quirk().
It itself also differed from the Linux kernel version before my commit.
Author: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100
fdt: translate address if #size-cells = <0>
The __of_translate_address routine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in the am33xx-clocks.dtsi nodes would not be possible. They all have a parent with #size-cells = <0>.
The CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLS symbol makes translation possible even in the case of crossing levels with #size-cells = <0>.
The patch acts conservatively on address translation, except for removing a check within the of_translate_one function in the drivers/core/of_addr.c file:
+
ranges = of_get_property(parent, rprop, &rlen);
- if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
- debug("no ranges; cannot translate\n");
- return 1;
- }
if (ranges == NULL || rlen == 0) {
offset = of_read_number(addr, na); memset(addr, 0, pna * 4); debug("empty ranges; 1:1 translation\n");
There are two reasons:
1 The function of_empty_ranges_quirk always returns false, invalidating
the following if statement in case of null ranges. Therefore one of the two checks is useless.
2 The implementation of the of_translate_one function found in the
common/fdt_support.c file has removed this check while keeping the one about the 1:1 translation.
The patch adds a test and modifies a check for the correctness of an address in the case of enabling translation also for zero size cells. The added test checks translations of addresses generated by nodes of a device tree similar to those you can find in the files am33xx.dtsi and am33xx-clocks.dtsi for which the patch was created.
The patch was also tested on a beaglebone black board. The addresses generated for the registers of the loaded drivers are those specified by the AM335x reference manual.
I didn't want to wire any peripheral base addresses but just retrieve them from the device tree. To achieve this, this patch was crucial.
I think this does not happen in the kernel, where such structures contain base addresses without querying the device tree.
https://elixir.bootlin.com/linux/latest/source/drivers/clk/ti/clk-33xx.c#L230
Thanks and regards,
Dario
Quoted 3 lines
Signature · 2 lines
-- Tom
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Dario,
Quoted 171 lines · Dario Binacchi
Hi Tom,
Quoted 103 lines
Il 18/03/2021 20:51 Tom Rini <[email protected]> ha scritto:
Quoted 99 lines · Dario Binacchi
Hi Bin,
Quoted 96 lines
Il 17/03/2021 02:26 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
Quoted 8 lines
Quoted 2 lines
I'll do some checking, although I think the Linux device binding / probing flow is more complex than u-boot.
I guess at the high level, we need to understand what's going on here and why. With the whole "dt describes hardware", it shouldn't matter so much how Linux does its probing, both cases should work with the same DT, so someones (our?) logic needs to be corrected somewhere along the line.
My commit
d64b9cdcd4(fdt: translate address if #size-cells = <0>) previously reported by Bin is partial. In the missing lines it is explained why I removed theof_empty_ranges_quirk().
It itself also differed from the Linux kernel version before my commit.Author: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.The
CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol makes translation possible even in the case of crossing levels with #size-cells = <0>.The patch acts conservatively on address translation, except for removing a check within the
of_translate_onefunction in thedrivers/core/of_addr.cfile:+
ranges =of_get_property(parent, rprop, &rlen);
- if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
-debug("no ranges; cannot translate\n");
- return 1;
- }
if (ranges == NULL || rlen == 0) {
offset =of_read_number(addr, na);memset(addr, 0, pna * 4);debug("empty ranges; 1:1 translation\n");There are two reasons:
1 The functionof_empty_ranges_quirkalways returns false, invalidating
the following if statement in case of null ranges. Therefore one of the two checks is useless.2 The implementation of the
of_translate_onefunction found in the
common/fdt_support.cfile has removed this check while keeping the one about the 1:1 translation.The patch adds a test and modifies a check for the correctness of an address in the case of enabling translation also for zero size cells. The added test checks translations of addresses generated by nodes of a device tree similar to those you can find in the files
am33xx.dtsiandam33xx-clocks.dtsifor which the patch was created.The patch was also tested on a beaglebone black board. The addresses generated for the registers of the loaded drivers are those specified by the AM335x reference manual.
Quoted 5 lines
I didn't want to wire any peripheral base addresses but just retrieve them from the device tree. To achieve this, this patch was crucial.
I think this does not happen in the kernel, where such structures contain base addresses without querying the device tree.
https://elixir.bootlin.com/linux/latest/source/drivers/clk/ti/clk-33xx.c#L230
Thanks for the details. So Linux kernel is using hardcoded address from the driver file, instead of getting it from device tree, which masks the issue in the kernel.
Could you please send a patch (the one that currently U-Boot does) to the Linux kernel then?
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Bin,
Quoted 183 lines
Il 22/03/2021 02:25 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 171 lines · Dario Binacchi
Hi Tom,
Quoted 103 lines
Il 18/03/2021 20:51 Tom Rini <[email protected]> ha scritto:
Quoted 99 lines · Dario Binacchi
Hi Bin,
Quoted 96 lines
Il 17/03/2021 02:26 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of of_translate_one() was taken from the one in
Linux kernel drivers/of/address.c, and the Linux one added a quirk
for Apple Macs that don't have the <ranges> property in the parent
node. Since U-Boot does not support Apple Macs, remove the comment
block and adhere to the spec to abort the translation.Signed-off-by: Bin Meng <[email protected]>
---Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
Quoted 8 lines
Quoted 2 lines
I'll do some checking, although I think the Linux device binding / probing flow is more complex than u-boot.
I guess at the high level, we need to understand what's going on here and why. With the whole "dt describes hardware", it shouldn't matter so much how Linux does its probing, both cases should work with the same DT, so someones (our?) logic needs to be corrected somewhere along the line.
My commit
d64b9cdcd4(fdt: translate address if #size-cells = <0>) previously reported by Bin is partial. In the missing lines it is explained why I removed theof_empty_ranges_quirk().
It itself also differed from the Linux kernel version before my commit.Author: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.The
CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol makes translation possible even in the case of crossing levels with #size-cells = <0>.The patch acts conservatively on address translation, except for removing a check within the
of_translate_onefunction in thedrivers/core/of_addr.cfile:+
ranges =of_get_property(parent, rprop, &rlen);
- if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
-debug("no ranges; cannot translate\n");
- return 1;
- }
if (ranges == NULL || rlen == 0) {
offset =of_read_number(addr, na);memset(addr, 0, pna * 4);debug("empty ranges; 1:1 translation\n");There are two reasons:
1 The functionof_empty_ranges_quirkalways returns false, invalidating
the following if statement in case of null ranges. Therefore one of the two checks is useless.2 The implementation of the
of_translate_onefunction found in the
common/fdt_support.cfile has removed this check while keeping the one about the 1:1 translation.The patch adds a test and modifies a check for the correctness of an address in the case of enabling translation also for zero size cells. The added test checks translations of addresses generated by nodes of a device tree similar to those you can find in the files
am33xx.dtsiandam33xx-clocks.dtsifor which the patch was created.The patch was also tested on a beaglebone black board. The addresses generated for the registers of the loaded drivers are those specified by the AM335x reference manual.
Quoted 5 lines
I didn't want to wire any peripheral base addresses but just retrieve them from the device tree. To achieve this, this patch was crucial.
I think this does not happen in the kernel, where such structures contain base addresses without querying the device tree.
https://elixir.bootlin.com/linux/latest/source/drivers/clk/ti/clk-33xx.c#L230
Quoted 6 lines
Thanks for the details. So Linux kernel is using hardcoded address from the driver file, instead of getting it from device tree, which masks the issue in the kernel.
Could you please send a patch (the one that currently U-Boot does) to the Linux kernel then?
I'll do it as soon as possible.
Can I CC your email address?
Thanks and regards,
Dario
Quoted 3 lines
Regards,
Bin
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi Dario,
Quoted 186 lines · Dario Binacchi
Hi Bin,
Quoted 183 lines
Il 22/03/2021 02:25 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 176 lines · Dario Binacchi
Hi Tom,
Quoted 103 lines
Il 18/03/2021 20:51 Tom Rini <[email protected]> ha scritto:
Quoted 99 lines · Dario Binacchi
Hi Bin,
Quoted 96 lines
Il 17/03/2021 02:26 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 78 lines · Dario Binacchi
Hi Bin,
Quoted 75 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 68 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
On Fri, 26 Feb 2021 at 00:36, Bin Meng <[email protected]> wrote:
The implementation of of_translate_one() was taken from the one in
Linux kernel drivers/of/address.c, and the Linux one added a quirk
for Apple Macs that don't have the <ranges> property in the parent
node. Since U-Boot does not support Apple Macs, remove the comment
block and adhere to the spec to abort the translation.Signed-off-by: Bin Meng <[email protected]>
---Quoted 7 lines
Quoted 4 lines
drivers/core/of_addr.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by: Simon Glass <[email protected]>
Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Quoted 5 lines
Quoted 2 lines
Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
Quoted 8 lines
Quoted 2 lines
I'll do some checking, although I think the Linux device binding / probing flow is more complex than u-boot.
I guess at the high level, we need to understand what's going on here and why. With the whole "dt describes hardware", it shouldn't matter so much how Linux does its probing, both cases should work with the same DT, so someones (our?) logic needs to be corrected somewhere along the line.
My commit
d64b9cdcd4(fdt: translate address if #size-cells = <0>) previously reported by Bin is partial. In the missing lines it is explained why I removed theof_empty_ranges_quirk().
It itself also differed from the Linux kernel version before my commit.Author: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.The
CONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol makes translation possible even in the case of crossing levels with #size-cells = <0>.The patch acts conservatively on address translation, except for removing a check within the
of_translate_onefunction in thedrivers/core/of_addr.cfile:+
ranges =of_get_property(parent, rprop, &rlen);
- if (ranges == NULL && !of_empty_ranges_quirk(parent)) {
-debug("no ranges; cannot translate\n");
- return 1;
- }
if (ranges == NULL || rlen == 0) {
offset =of_read_number(addr, na);memset(addr, 0, pna * 4);debug("empty ranges; 1:1 translation\n");There are two reasons:
1 The functionof_empty_ranges_quirkalways returns false, invalidating
the following if statement in case of null ranges. Therefore one of the two checks is useless.2 The implementation of the
of_translate_onefunction found in the
common/fdt_support.cfile has removed this check while keeping the one about the 1:1 translation.The patch adds a test and modifies a check for the correctness of an address in the case of enabling translation also for zero size cells. The added test checks translations of addresses generated by nodes of a device tree similar to those you can find in the files
am33xx.dtsiandam33xx-clocks.dtsifor which the patch was created.The patch was also tested on a beaglebone black board. The addresses generated for the registers of the loaded drivers are those specified by the AM335x reference manual.
I didn't want to wire any peripheral base addresses but just retrieve them from the device tree. To achieve this, this patch was crucial.
I think this does not happen in the kernel, where such structures contain base addresses without querying the device tree.
https://elixir.bootlin.com/linux/latest/source/drivers/clk/ti/clk-33xx.c#L230
Quoted 8 lines
Quoted 6 lines
Thanks for the details. So Linux kernel is using hardcoded address from the driver file, instead of getting it from device tree, which masks the issue in the kernel.
Could you please send a patch (the one that currently U-Boot does) to the Linux kernel then?
I'll do it as soon as possible.
Thanks!
Quoted 2 lines
Can I CC your email address?
Sure.
Regards,
Bin
Rob Herring
maintainerPATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
In reply to Bin MengQuoted 84 lines · Bin Meng
Hi Dario,
Quoted 80 lines · Dario Binacchi
Hi Bin,
Quoted 77 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
I've replied on that patch...
Quoted 7 lines
Quoted 3 lines
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
IMO, yes it is. Simply put, 'ranges' must be present to be translatable. Using '#size-cells == 0' is at least questionable, but could maybe be supported (depends what happens with non-empty 'ranges').
The 'fix' makes every 'reg' translatable. Give the function an I2C address 'reg' and you'll get back 'I2C controller address + I2C address'.
Quoted 2 lines
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
The quirk for the platform should live in the code for the platform.
Rob
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Quoted 100 lines
Il 06/04/2021 16:26 Rob Herring <[email protected]> ha scritto:
Quoted 84 lines · Bin Meng
Hi Dario,
Quoted 80 lines · Dario Binacchi
Hi Bin,
Quoted 77 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
I've replied on that patch...
Quoted 7 lines
Quoted 3 lines
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
Quoted 8 lines
IMO, yes it is. Simply put, 'ranges' must be present to be translatable. Using '#size-cells == 0' is at least questionable, but could maybe be supported (depends what happens with non-empty 'ranges').
The 'fix' makes every 'reg' translatable. Give the function an I2C address 'reg' and you'll get back 'I2C controller address + I2C address'.
IMHO this could mean that using size-cells = <0> in the prcm_clocks and scm_clocks nodes is perhaps not quite correct. We need an address translation and if possible, better without having to develop code to handle this special case.
With the following changes in the am33xx-l4.dtsi and am33xx-clocks.dtsi files we get an address translation that does not require special case handling code and the device tree would not be an exception to what we usually see. I have tested these changes in the kernel and they seem to work.
arch/arm/boot/dts/am33xx-l4.dtsi +4 -2
@@ -110,7 +110,8 @@ prcm_clocks: clocks { #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges = <0 0 0x2000>; }; prcm_clockdomains: clockdomains {
@@ -320,7 +321,8 @@ scm_clocks: clocks { #address-cells = <1>; - #size-cells = <0>; + #size-cells = <1>; + ranges = <0 0 0x800>; }; };
arch/arm/boot/dts/am33xx-clocks.dtsi +35 -35
280 lines not on this page · raw message
Thanks and regards,
Dario
Quoted 7 lines
Quoted 3 lines
Maybe the beagleboard needs to use another API to decode the address? What API is used in Linux?
The quirk for the platform should live in the code for the platform.
Rob
Rob Herring
maintainerPATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Quoted 106 lines · Dario Binacchi
Quoted 106 lines
Il 06/04/2021 16:26 Rob Herring <[email protected]> ha scritto:
Quoted 84 lines · Bin Meng
Hi Dario,
Quoted 80 lines · Dario Binacchi
Hi Bin,
Quoted 77 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
I've replied on that patch...
Quoted 7 lines
Quoted 3 lines
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
IMO, yes it is. Simply put, 'ranges' must be present to be translatable. Using '#size-cells == 0' is at least questionable, but could maybe be supported (depends what happens with non-empty 'ranges').
Quoted 8 lines
Quoted 3 lines
The 'fix' makes every 'reg' translatable. Give the function an I2C address 'reg' and you'll get back 'I2C controller address + I2C address'.
IMHO this could mean that using size-cells = <0> in the
prcm_clocksandscm_clocksnodes is perhaps not quite correct. We need an address translation and if possible, better without having to develop code to handle this special case.
I agree as with a size of 0 there's an implicit assumption as to what the size of the registers are. It's 4 bytes in your case, but what if I have 2 byte registers?
Quoted 5 lines
With the following changes in the
am33xx-l4.dtsiandam33xx-clocks.dtsifiles we get an address translation that does not require special case handling code and the device tree would not be an exception to what we usually see. I have tested these changes in the kernel and they seem to work.
That is the correct change, but compatibility is the issue here.
Rob
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Hi,
Quoted 122 lines · Rob Herring
Quoted 106 lines · Dario Binacchi
Quoted 106 lines
Il 06/04/2021 16:26 Rob Herring <[email protected]> ha scritto:
Quoted 84 lines · Bin Meng
Hi Dario,
Quoted 80 lines · Dario Binacchi
Hi Bin,
Quoted 77 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of
of_translate_one()was taken from the one in Linux kerneldrivers/of/address.c, and the Linux one added a quirk for Apple Macs that don't have the <ranges> property in the parent node. Since U-Boot does not support Apple Macs, remove the comment block and adhere to the spec to abort the translation.Signed-off-by Bin Meng <[email protected]>---
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
I've replied on that patch...
Quoted 7 lines
Quoted 3 lines
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
IMO, yes it is. Simply put, 'ranges' must be present to be translatable. Using '#size-cells == 0' is at least questionable, but could maybe be supported (depends what happens with non-empty 'ranges').
Quoted 8 lines
Quoted 3 lines
The 'fix' makes every 'reg' translatable. Give the function an I2C address 'reg' and you'll get back 'I2C controller address + I2C address'.
IMHO this could mean that using size-cells = <0> in the
prcm_clocksandscm_clocksnodes is perhaps not quite correct. We need an address translation and if possible, better without having to develop code to handle this special case.I agree as with a size of 0 there's an implicit assumption as to what the size of the registers are. It's 4 bytes in your case, but what if I have 2 byte registers?
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
With the following changes in the
am33xx-l4.dtsiandam33xx-clocks.dtsifiles we get an address translation that does not require special case handling code and the device tree would not be an exception to what we usually see. I have tested these changes in the kernel and they seem to work.That is the correct change, but compatibility is the issue here.
Just to dig into this a bit, at least within U-Boot the DT is captive, so we should be able to make this change. If there is a quirk needed, then perhaps it can be added with a property to enable it.
Can you give a few more details about the compatibility problem?
Regards,
Simon
PATCH 1/2 of: addr: Abort address translation for parent nodes missing 'ranges'
Quoted 130 lines · Simon Glass
Hi,
Quoted 127 lines · Rob Herring
Quoted 106 lines · Dario Binacchi
Quoted 106 lines
Il 06/04/2021 16:26 Rob Herring <[email protected]> ha scritto:
Quoted 84 lines · Bin Meng
Hi Dario,
Quoted 80 lines · Dario Binacchi
Hi Bin,
Quoted 77 lines
Il 16/03/2021 02:28 Bin Meng <[email protected]> ha scritto:
Hi Dario,
Quoted 62 lines · Dario Binacchi
Quoted 61 lines
Il 15/03/2021 19:23 Simon Glass <[email protected]> ha scritto:
+Tom Rini too
Quoted 52 lines · Bin Meng
+Dario Binacchi
Quoted 16 lines · Simon Glass
Hi Bin,
Quoted 12 lines · Simon Glass
Quoted 10 lines · Bin Meng
The implementation of of_translate_one() was taken from the one in
Linux kernel drivers/of/address.c, and the Linux one added a quirk
for Apple Macs that don't have the <ranges> property in the parent
node. Since U-Boot does not support Apple Macs, remove the comment
block and adhere to the spec to abort the translation.Signed-off-by: Bin Meng <[email protected]>
---Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
drivers/core/of_addr.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)Reviewed-by Simon Glass <[email protected]>Unfortunately this seems to cause a test failure for
ut_dm_fdt_translation. Can you please take a look?It seems the no "ranges" property was intentionally removed by the following commit:
commit
d64b9cdcd475eb7f07b49741ded87e24dae4a5fcAuthor: Dario Binacchi <[email protected]> Date: Wed Dec 30 00:16:21 2020 +0100fdt: translate address if #size-cells = <0>
The
__of_translate_addressroutine translates an address from the device tree into a CPU physical address. A note in the description of the routine explains that the crossing of any level with since inherited from IBM. This does not happen for Texas Instruments, or at least for the beaglebone device tree. Without this patch, in fact, the translation into physical addresses of the registers contained in theam33xx-clocks.dtsinodes would not be possible. They all have a parent with #size-cells = <0>.It looks the commit was needed for beaglebone board.
Dario, could you please comment on why U-Boot needs to done like this, while Linux kernel has this check? Is the beaglebone board not working in Linux?
Quoted 6 lines
Beaglebone is working in Linux, but I think Linux walks the device tree less fully than u-boot.
I was surprised by the address translation error when traversing nodes with size cells 0. And for this reason I added theCONFIG_OF_TRANSLATE_ZERO_SIZE_CELLSsymbol to fix the issue, not enabled by default, thus making the change backwards compatible.Could you please prepare a patch against upstream Linux kernel, so that U-Boot can be in sync with it?
I've replied on that patch...
Quoted 7 lines
Quoted 3 lines
With pleasure. But how do I justify the patch since it doesn't fix any bugs? Can I refer to the patches developed for U-boot?
Good question :)
If Linux does not have any issue, maybe U-Boot's fix is questionable?
IMO, yes it is. Simply put, 'ranges' must be present to be translatable. Using '#size-cells == 0' is at least questionable, but could maybe be supported (depends what happens with non-empty 'ranges').
Quoted 8 lines
Quoted 3 lines
The 'fix' makes every 'reg' translatable. Give the function an I2C address 'reg' and you'll get back 'I2C controller address + I2C address'.
IMHO this could mean that using size-cells = <0> in the
prcm_clocksandscm_clocksnodes is perhaps not quite correct. We need an address translation and if possible, better without having to develop code to handle this special case.I agree as with a size of 0 there's an implicit assumption as to what the size of the registers are. It's 4 bytes in your case, but what if I have 2 byte registers?
Quoted 5 lines
With the following changes in the
am33xx-l4.dtsiandam33xx-clocks.dtsifiles we get an address translation that does not require special case handling code and the device tree would not be an exception to what we usually see. I have tested these changes in the kernel and they seem to work.
Quoted 7 lines
Quoted 1 line
That is the correct change, but compatibility is the issue here.
Just to dig into this a bit, at least within U-Boot the DT is captive, so we should be able to make this change. If there is a quirk needed, then perhaps it can be added with a property to enable it.
Can you give a few more details about the compatibility problem?
These are files that in U-Boot we keep untouched and in-sync with the kernel. We might be able to whack something in to -u-boot.dtsi but that's not ideal when there's an actual problem being exposed that needs fixing.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 659 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210407/67f14b94/attachment.sig>