From: sashiko-bot@kernel.org
To: "Linus Walleij" <linusw@kernel.org>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: ste_dma40: Use power domain for LCLA SRAM
Date: Sun, 15 Nov 2026 21:41:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-215867@kernel.org> (raw)
In-Reply-To: <20261115-ux500-dma40-powerdomain-v1-1-da8b6e1a0376@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dmaengine: ste_dma40: chained dev_err_probe() in d40_probe()
clobbers reason
It also noticed 2 related pre-existing issues this patch does not
introduce:
- [Critical] dmaengine: ste_dma40: use-after-free in d40_free_dma() [1]
- [Critical] dmaengine: ste_dma40: DMA API bypass in d40_lcla_allocate()
[2]
--
commit 1b5cce170c6b1253e8f796cc9973f76ac7915f4f
Author: Linus Walleij <linusw@kernel.org>
dmaengine: ste_dma40: Use power domain for LCLA SRAM
This commit replaces the LCLA ESRAM regulator and obsolete named memory
resource with LCLA SRAM phandle lookup and runtime PM of the SRAM device
owning the ESRAM34 power domain.
> diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
> index f1cbc719c4f09..eca1ae95fe1c9 100644
> --- a/drivers/dma/ste_dma40.c
> +++ b/drivers/dma/ste_dma40.c
[ ... ]
> @@ -2270,7 +2291,7 @@ static int d40_free_dma(struct d40_chan *d40c)
> d40c->base->lookup_phy_chans[phy->num] = NULL;
>
> if (d40c->busy)
> - pm_runtime_put_autosuspend(d40c->base->dev);
> + d40_transfer_runtime_put(d40c->base);
>
> d40c->busy = false;
> d40c->phy_chan = NULL;
[Severity: Critical]
This problem wasn't introduced by this patch, but can calling d40_term_all()
before d40_channel_execute_command(d40c, D40_DMA_STOP) in d40_free_dma() cause
a hardware use-after-free [1]?
drivers/dma/ste_dma40.c:d40_free_dma() {
...
d40_term_all(d40c);
...
res = pm_runtime_resume_and_get(d40c->base->dev);
if (res >= 0) {
res = d40_channel_execute_command(d40c, D40_DMA_STOP);
...
}
When tearing down an active channel, d40_term_all() unmaps and frees the
active descriptors while the DMA controller is still running and accessing
that memory until D40_DMA_STOP is issued.
[ ... ]
> @@ -3640,13 +3655,9 @@ static void __init d40_hw_init(struct d40_base *base)
>
> /* Write which interrupt to clear */
> writel(pcicr, base->virtbase + base->gen_dmac.interrupt_clear);
> -
> - /* These are __initdata and cannot be accessed after init */
> - base->gen_dmac.init_reg = NULL;
> - base->gen_dmac.init_reg_size = 0;
> }
>
> -static int __init d40_lcla_allocate(struct d40_base *base)
> +static int d40_lcla_allocate(struct d40_base *base)
> {
> struct d40_lcla_pool *pool = &base->lcla_pool;
> size_t lcla_size = SZ_1K * base->num_phy_chans;
[Severity: Critical]
This problem wasn't introduced by this patch, but shouldn't
d40_lcla_allocate() write pool->dma_addr instead of
virt_to_phys(base->lcla_pool.base) to D40_DREG_LCLA [2]?
drivers/dma/ste_dma40.c:d40_lcla_allocate() {
...
pool->dma_addr = dma_map_single(base->dev, pool->base, lcla_size,
DMA_TO_DEVICE);
if (dma_mapping_error(base->dev, pool->dma_addr)) {
pool->dma_addr = 0;
ret = -ENOMEM;
goto free_page_list;
}
writel(virt_to_phys(base->lcla_pool.base),
base->virtbase + D40_DREG_LCLA);
...
}
Programming raw CPU physical addresses instead of the mapped DMA address
bypasses IOMMU translations and bus offsets, which also happens in
d40_prep_sg_phy() where virt_to_phys(desc->lli_phy.src) and
virt_to_phys(desc->lli_phy.dst) are passed to d40_phy_sg_to_lli().
[ ... ]
> @@ -3781,13 +3791,70 @@ static int __init d40_of_probe(struct device *dev,
> return 0;
> }
>
> -static int __init d40_probe(struct platform_device *pdev)
> +static int d40_lcla_sram_setup(struct d40_base *base)
> +{
[ ... ]
> + if (!IS_ALIGNED(res.start, LCLA_ALIGNMENT) ||
> + resource_size(&res) < SZ_1K * base->num_phy_chans ||
> + res.end > U32_MAX) {
> + of_node_put(parent);
> + return dev_err_probe(dev, -EINVAL, "Invalid LCLA SRAM region\n");
> + }
[ ... ]
> @@ -3844,26 +3911,12 @@ static int __init d40_probe(struct platform_device *pdev)
> d40_err(dev, "Failed to ioremap LCPA region\n");
> goto report_failure;
> }
> - /* If lcla has to be located in ESRAM we don't need to allocate */
> - if (base->plat_data->use_esram_lcla) {
[ ... ]
> - } else {
> + ret = d40_lcla_sram_setup(base);
> + if (ret) {
> + dev_err_probe(dev, ret, "Failed to set up LCLA SRAM\n");
> + goto destroy_cache;
> + }
> + if (!base->lcla_pool.esram) {
> ret = d40_lcla_allocate(base);
> if (ret) {
> d40_err(dev, "Failed to allocate LCLA area\n");
[ ... ]
> @@ -3954,22 +3987,18 @@ static int __init d40_probe(struct platform_device *pdev)
> dma_unmap_single(base->dev, base->lcla_pool.dma_addr,
> SZ_1K * base->num_phy_chans,
> DMA_TO_DEVICE);
> -
> - if (!base->plat_data->use_esram_lcla &&
> - !base->lcla_pool.base_unaligned && base->lcla_pool.base)
> + if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)
> free_pages((unsigned long)base->lcla_pool.base,
> base->lcla_pool.alloc_order);
>
> kfree(base->lcla_pool.base_unaligned);
> -
> - if (base->lcpa_regulator) {
> - regulator_disable(base->lcpa_regulator);
> - regulator_put(base->lcpa_regulator);
> - }
> + if (base->lcla_link)
> + device_link_del(base->lcla_link);
> + if (base->lcla_dev)
> + put_device(base->lcla_dev);
>
> report_failure:
> - d40_err(dev, "probe failed\n");
> - return ret;
> + return dev_err_probe(dev, ret, "probe failed\n");
> }
[Severity: Low]
Does calling dev_err_probe(dev, ret, "probe failed\n") at report_failure
overwrite the deferred probe reason recorded earlier by d40_lcla_sram_setup()
or platform_get_irq()?
When d40_lcla_sram_setup() returns -EPROBE_DEFER, d40_probe() records "Failed
to set up LCLA SRAM" via dev_err_probe() and jumps to destroy_cache, which
falls through to report_failure and replaces that reason in debugfs
devices_deferred with "probe failed". On non-deferral errors such as an
invalid LCLA SRAM region, chaining dev_err_probe() across
d40_lcla_sram_setup(), its caller, and report_failure also logs up to three
error messages for a single failure.
[1] https://sashiko.dev/#/bug/linux-36e6bab6-2c91-434c-83be-1363c42736bc
[2] https://sashiko.dev/#/bug/linux-ca33b515-31eb-4b66-afe9-8493aaf2e04a
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-ux500-dma40-powerdomain-v1-1-da8b6e1a0376@kernel.org?part=1
next prev parent reply other threads:[~2026-11-15 21:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 21:26 [PATCH] dmaengine: ste_dma40: Use power domain for LCLA SRAM Linus Walleij
2026-11-15 21:41 ` sashiko-bot [this message]
2026-11-15 22:42 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-215867@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=linusw@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.