Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] soc: qcom: mdt_loader: undocumented mapping change in qcom_mdt_load_no_init() --
commit eab28e4077f6ee900ea4fd6648711acdb8ef064c Author: Mukesh Ojha <[email protected]> soc: qcom: mdt_loader: remove qcom_mdt_load() This commit removes the unused qcom_mdt_load() wrapper and moves memory mapping from qcom_mdt_pas_load() into qcom_mdt_load_no_init() when mem_region is NULL. > diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c > index aafa83466b92b..436d8bc4847a3 100644 > --- a/drivers/soc/qcom/mdt_loader.c > +++ b/drivers/soc/qcom/mdt_loader.c > @@ -326,7 +326,8 @@ static bool qcom_mdt_bins_are_split(const struct firmware > *fw) > * @dev: device handle to associate resources with > * @fw: firmware object for the mdt file > * @fw_name: name of the firmware, for construction of segment file names > - * @mem_region: allocated memory region to load firmware into > + * @mem_region: virtual address of the memory region to load firmware > into, > + * or NULL to have the region mapped internally with ioremap_wc() > * @mem_phys: physical address of allocated memory region > * @mem_size: size of the allocated memory region > * @reloc_base: adjusted physical address after relocation > @@ -341,6 +342,7 @@ int qcom_mdt_load_no_init(struct device *dev, const > struct firmware *fw, > const struct elf32_phdr *phdrs; > const struct elf32_phdr *phdr; > const struct elf32_hdr *ehdr; > + void __iomem *mapped = NULL; > phys_addr_t mem_reloc; > phys_addr_t min_addr = PHYS_ADDR_MAX; > ssize_t offset; > @@ -350,12 +352,22 @@ int qcom_mdt_load_no_init(struct device *dev, const > struct firmware *fw, > int ret = 0; > int i; > > - if (!fw || !mem_region || !mem_phys || !mem_size) > + if (!fw || !mem_phys || !mem_size) > return -EINVAL; > > if (!mdt_header_valid(fw)) > return -EINVAL; > > + if (!mem_region) { > + mapped = ioremap_wc(mem_phys, mem_size); > + if (!mapped) { > + dev_err(dev, "unable to map memory region: %pa+%zx\n", > + &mem_phys, mem_size); > + return -ENOMEM; > + } > + mem_region = (__force void *)mapped; > + } > + > is_split = qcom_mdt_bins_are_split(fw); > ehdr = (struct elf32_hdr *)fw->data; > phdrs = (struct elf32_phdr *)(fw->data + ehdr->e_phoff); > @@ -434,39 +446,13 @@ int qcom_mdt_load_no_init(struct device *dev, const > struct firmware *fw, > if (reloc_base) > *reloc_base = mem_reloc; > > + if (mapped) > + iounmap(mapped); > + > return ret; > } > EXPORT_SYMBOL_GPL(qcom_mdt_load_no_init); [ ... ] > @@ -486,21 +472,14 @@ EXPORT_SYMBOL_GPL(qcom_mdt_load); > int qcom_mdt_pas_load(struct qcom_pas_context *ctx, const struct firmware > *fw, > const char *firmware, phys_addr_t *reloc_base) > { > - void __iomem *mem_region; > int ret; > > ret = __qcom_mdt_pas_init(ctx->dev, fw, firmware, ctx->pas_id, > ctx->mem_phys, ctx); > if (ret) > return ret; > > - mem_region = qcom_pas_ctx_map(ctx); > - if (!mem_region) > - return -ENOMEM; > - > - ret = qcom_mdt_load_no_init(ctx->dev, fw, firmware, (__force void > *)mem_region, > - ctx->mem_phys, ctx->mem_size, reloc_base); > - iounmap(mem_region); > - return ret; > + return qcom_mdt_load_no_init(ctx->dev, fw, firmware, NULL, > + ctx->mem_phys, ctx->mem_size, reloc_base); > } [Severity: Medium] Why does this patch move the memory mapping from qcom_mdt_pas_load() into qcom_mdt_load_no_init()? The changelog only describes removing qcom_mdt_load(), which was already a simple wrapper around __qcom_mdt_pas_init() and qcom_mdt_load_no_init(). Moving the mapping into qcom_mdt_load_no_init() duplicates the ioremap_wc() and error logging already provided by qcom_pas_ctx_map(): include/linux/firmware/qcom/qcom_pas.h:qcom_pas_ctx_map() { void __iomem *ptr = ioremap_wc(ctx->mem_phys, ctx->mem_size); if (!ptr) dev_err(ctx->dev, "unable to map memory region: %pa+%zx\n", &ctx->mem_phys, ctx->mem_size); return ptr; } All direct callers of qcom_mdt_load_no_init() manage their own mem_region mapping. Dropping the !mem_region check means a non-PAS caller that inadvertently passes a NULL mem_region after a mapping failure will silently trigger an internal ioremap_wc() instead of failing with -EINVAL. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=8
