[PATCH v3] dm: core: Add address translation in fdt_get_resource
Simon Glass
sjg at chromium.org
Tue May 4 18:58:25 CEST 2021
On Tue, 4 May 2021 at 04:02, Patrick Delaunay
<patrick.delaunay at foss.st.com> wrote:
>
> Today of_address_to_resource() is called only in
> ofnode_read_resource() for livetree support and
> fdt_get_resource() is called when livetree is not supported.
>
> The fdt_get_resource() doesn't do the address translation
> so when it is required, but the address translation is done
> by ofnode_read_resource() caller, for example in
> drivers/firmware/scmi/smt.c::scmi_dt_get_smt_buffer() {
> ...
> ret = ofnode_read_resource(args.node, 0, &resource);
> if (ret)
> return ret;
>
> faddr = cpu_to_fdt32(resource.start);
> paddr = ofnode_translate_address(args.node, &faddr);
> ...
>
> The both behavior should be aligned and the address translation
> must be called in fdt_get_resource() and removed for each caller.
>
> Fixes: a44810123f9e ("dm: core: Add dev_read_resource() to read device resources")
> Signed-off-by: Patrick Delaunay <patrick.delaunay at foss.st.com>
> ---
>
> This patch allows to remove the workaround in smci/smt.c
> introduced by [1].
>
> But it impact with all user of
> - ofnode_read_resource
> - ofnode_read_resource_byname
> - dev_read_resource
> - dev_read_resource_byname
>
> After my first check, the only impacts are in drivers/net/mscc_eswitch
> => I remove the unnecessary translate after code review,
> this patch need to be verify on real hardware
>
> I proposed to merge the workaround [1] as soon as possible to avoid issue
> on stm32mp1 platform and this patch can be merged when it will be acked
> by mscc_eswitch maintainers and other API users.
>
> [1] "scmi: translate the resource only when livetree is not activated"
> http://patchwork.ozlabs.org/project/uboot/list/?series=236526&state=*
>
>
> Changes in v3:
> - add test dm_test_read_resource
>
> Changes in v2:
> - remove translate in luton_switch.c:luton_probe()
>
> drivers/firmware/scmi/smt.c | 12 +--------
> drivers/net/mscc_eswitch/jr2_switch.c | 4 +--
> drivers/net/mscc_eswitch/luton_switch.c | 5 +---
> drivers/net/mscc_eswitch/ocelot_switch.c | 4 +--
> drivers/net/mscc_eswitch/serval_switch.c | 4 +--
> drivers/net/mscc_eswitch/servalt_switch.c | 4 +--
> lib/fdtdec.c | 6 ++++-
> test/dm/test-fdt.c | 33 +++++++++++++++++++++++
> 8 files changed, 44 insertions(+), 28 deletions(-)
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list