
Hi,
On 3/30/21 3:29 PM, Patrick Delaunay wrote:
Call the translation function on the ofnode_read_resource result only when the livetree is not activated.
Today of_address_to_resource() calls ofnode_read_resource() for livetree support and fdt_get_resource() when livetree is not supported.
The fdt_get_resource() doesn't do the address translation so when it is required when livetree is activated but this address translation is already done by ofnode_read_resource().
Fixes: 240720e9052f ("firmware: scmi: mailbox/smt agent device") Signed-off-by: Patrick Delaunay patrick.delaunay@foss.st.com
Hi,
This patch is a short-term workaround for ofnode_read_resource translation issue on stm32mp15 boards when scmi is used and OF_LIVE is activated.
A full solution is a patch in core to have the same behavior of the API ofnode_read_resource() when livretree is activated or not:
fdt_get_resource() ... while (ptr + na + ns <= end) { if (i == index) {
res->start = fdtdec_get_number(ptr, na);
if (CONFIG_IS_ENABLED(OF_TRANSLATE))
res->start = fdt_translate_address(fdt, node, ptr);
else
res->start = fdtdec_get_number(ptr, na);
I will propose it soon but it is more aggressive and impacts all the user of fdt_get_resource() or fdt_get_named_resource() function; this correct patch need more tests.
For information the proposed patch with a full correction in dm core is now available:
"dm: core: Add address translation in fdt_get_resource"
http://patchwork.ozlabs.org/project/uboot/list/?series=237557&state=*
So I think it will take many time to be integrated so I prefer to propose the current patch for a short term integration on v2021.07.
Patrick
drivers/firmware/scmi/smt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/scmi/smt.c b/drivers/firmware/scmi/smt.c index 4954355c1a..f1915c0074 100644 --- a/drivers/firmware/scmi/smt.c +++ b/drivers/firmware/scmi/smt.c @@ -41,8 +41,13 @@ int scmi_dt_get_smt_buffer(struct udevice *dev, struct scmi_smt *smt) if (ret) return ret;
- faddr = cpu_to_fdt32(resource.start);
- paddr = ofnode_translate_address(args.node, &faddr);
/* TEMP workaround for ofnode_read_resource translation issue */
if (of_live_active()) {
paddr = resource.start;
} else {
faddr = cpu_to_fdt32(resource.start);
paddr = ofnode_translate_address(args.node, &faddr);
}
smt->size = resource_size(&resource); if (smt->size < sizeof(struct scmi_smt_header)) {
Regards
Patrick