Re: [PATCH] remoteproc: elf_loader: fix loading segment when is_iomem true

From: Bjorn Andersson
Date: Mon Jun 28 2021 - 12:16:59 EST


On Mon 28 Jun 02:06 CDT 2021, Peng Fan (OSS) wrote:

> From: Peng Fan <peng.fan@xxxxxxx>
>
> It seems luckliy work on i.MX platform, but it is wrong.
> Need use memcpy_toio, not memcpy_fromio.
>
> Fixes: 40df0a91b2a52 ("remoteproc: add is_iomem to da_to_va")
> Tested-by: Dong Aisheng <aisheng.dong@xxxxxxx> (i.MX8MQ)
> Reported-by: Dong Aisheng <aisheng.dong@xxxxxxx>
> Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> ---
> 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 469c52e62faf..e8078efb3dec 100644
> --- a/drivers/remoteproc/remoteproc_elf_loader.c
> +++ b/drivers/remoteproc/remoteproc_elf_loader.c
> @@ -220,7 +220,7 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
> /* put the segment where the remote processor expects it */
> if (filesz) {
> if (is_iomem)
> - memcpy_fromio(ptr, (void __iomem *)(elf_data + offset), filesz);
> + memcpy_toio(ptr, (void __iomem *)(elf_data + offset), filesz);

Ouch, we should have caught that during the review, thanks for spotting
and fixing this.

That said, it's the ptr that's __iomem, so the cast should be on the
first parameter, not the second.

Regards,
Bjorn

> else
> memcpy(ptr, elf_data + offset, filesz);
> }
> --
> 2.30.0
>