* [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero @ 2024-11-19 8:56 Ahmad Fatoum 2024-11-19 8:56 ` [PATCH 2/2] remoteproc: imx: add support for loading ELF data sections into DRAM Ahmad Fatoum 2024-11-25 8:42 ` [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Sascha Hauer 0 siblings, 2 replies; 3+ messages in thread From: Ahmad Fatoum @ 2024-11-19 8:56 UTC (permalink / raw) To: barebox; +Cc: Stefano Manni, Ahmad Fatoum From: Peng Fan <peng.fan@nxp.com> Per elf specification, p_filesz: This member gives the number of bytes in the file image of the segment; it may be zero. p_memsz: This member gives the number of bytes in the memory image of the segment; it may be zero. There is a case that i.MX DSP firmware has segment with PT_LOAD and p_memsz/p_filesz set to zero. Such segment needs to be ignored, otherwize rproc_da_to_va would report error. Signed-off-by: Peng Fan <peng.fan@nxp.com> Link: https://lore.kernel.org/r/20220413033038.1715945-2-peng.fan@oss.nxp.com Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> [ahmad: ported from Linux commit f340d5a19dc76c6b29eeb23537fd7345611e9117] Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/remoteproc/remoteproc_elf_loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_elf_loader.c b/drivers/remoteproc/remoteproc_elf_loader.c index 740ce8765165..8f6f6d0bfa8d 100644 --- a/drivers/remoteproc/remoteproc_elf_loader.c +++ b/drivers/remoteproc/remoteproc_elf_loader.c @@ -40,7 +40,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw) u32 offset = phdr->p_offset; void *ptr; - if (phdr->p_type != PT_LOAD) + if (phdr->p_type != PT_LOAD || !memsz) continue; dev_dbg(dev, "phdr: type %d da 0x%x memsz 0x%x filesz 0x%x\n", -- 2.39.5 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] remoteproc: imx: add support for loading ELF data sections into DRAM 2024-11-19 8:56 [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Ahmad Fatoum @ 2024-11-19 8:56 ` Ahmad Fatoum 2024-11-25 8:42 ` [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Sascha Hauer 1 sibling, 0 replies; 3+ messages in thread From: Ahmad Fatoum @ 2024-11-19 8:56 UTC (permalink / raw) To: barebox; +Cc: Stefano Manni, Ahmad Fatoum The Cortex-A MPU and the Cortex-M co-processor on the i.MX have different address space layouts. The driver thus keeps struct imx_rproc_att[] tables for the different SoCs to translate device addresses in the ELF headers to the virtual addresses used by the Cortex-A, which loads the ELF image. The maximum size of this mapping was so far 8, which may not be large enough for some ELF images. Enlarge it to 32 like Linux does. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> --- drivers/remoteproc/imx_rproc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c index 6ae8ef3966ae..d50b164bed93 100644 --- a/drivers/remoteproc/imx_rproc.c +++ b/drivers/remoteproc/imx_rproc.c @@ -44,7 +44,7 @@ | IMX6SX_SW_M4C_NON_SCLR_RST \ | IMX6SX_SW_M4C_RST) -#define IMX7D_RPROC_MEM_MAX 8 +#define IMX_RPROC_MEM_MAX 32 /** * struct imx_rproc_mem - slim internal memory structure @@ -84,7 +84,7 @@ struct imx_rproc { struct regmap *gpr; struct rproc *rproc; const struct imx_rproc_dcfg *dcfg; - struct imx_rproc_mem mem[IMX7D_RPROC_MEM_MAX]; + struct imx_rproc_mem mem[IMX_RPROC_MEM_MAX]; struct clk *clk; }; @@ -362,7 +362,7 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, int len) if (imx_rproc_da_to_sys(priv, da, len, &sys)) return NULL; - for (i = 0; i < IMX7D_RPROC_MEM_MAX; i++) { + for (i = 0; i < IMX_RPROC_MEM_MAX; i++) { if (sys >= priv->mem[i].sys_addr && sys + len < priv->mem[i].sys_addr + priv->mem[i].size) { unsigned int offset = sys - priv->mem[i].sys_addr; @@ -398,7 +398,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, if (!(att->flags & ATT_OWN)) continue; - if (b >= IMX7D_RPROC_MEM_MAX) + if (b >= IMX_RPROC_MEM_MAX) break; res_cpu = request_iomem_region(dev_name(dev), @@ -431,7 +431,7 @@ static int imx_rproc_addr_init(struct imx_rproc *priv, return err; } - if (b >= IMX7D_RPROC_MEM_MAX) + if (b >= IMX_RPROC_MEM_MAX) break; /* -- 2.39.5 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero 2024-11-19 8:56 [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Ahmad Fatoum 2024-11-19 8:56 ` [PATCH 2/2] remoteproc: imx: add support for loading ELF data sections into DRAM Ahmad Fatoum @ 2024-11-25 8:42 ` Sascha Hauer 1 sibling, 0 replies; 3+ messages in thread From: Sascha Hauer @ 2024-11-25 8:42 UTC (permalink / raw) To: barebox, Ahmad Fatoum; +Cc: Stefano Manni On Tue, 19 Nov 2024 09:56:40 +0100, Ahmad Fatoum wrote: > Per elf specification, > p_filesz: This member gives the number of bytes in the file image of > the segment; it may be zero. > p_memsz: This member gives the number of bytes in the memory image > of the segment; it may be zero. > > There is a case that i.MX DSP firmware has segment with PT_LOAD and > p_memsz/p_filesz set to zero. Such segment needs to be ignored, > otherwize rproc_da_to_va would report error. > > [...] Applied, thanks! [1/2] remoteproc: elf_loader: skip segment with memsz as zero https://git.pengutronix.de/cgit/barebox/commit/?id=f069a33703b9 (link may not be stable) [2/2] remoteproc: imx: add support for loading ELF data sections into DRAM https://git.pengutronix.de/cgit/barebox/commit/?id=31bd2c9b57a0 (link may not be stable) Best regards, -- Sascha Hauer <s.hauer@pengutronix.de> ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-25 8:43 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-11-19 8:56 [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Ahmad Fatoum 2024-11-19 8:56 ` [PATCH 2/2] remoteproc: imx: add support for loading ELF data sections into DRAM Ahmad Fatoum 2024-11-25 8:42 ` [PATCH 1/2] remoteproc: elf_loader: skip segment with memsz as zero Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox