From: sashiko-bot@kernel.org
To: "Sai Sree Kartheek Adivi" <s-adivi@ti.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org,
devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
dmaengine@vger.kernel.org
Subject: Re: [PATCH v11 16/19] dmaengine: ti: k3-udma-v2: New driver for K3 BCDMA_V2
Date: Thu, 01 Oct 2026 09:18:36 +0000 [thread overview]
Message-ID: <20261001091836.C10A51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261001084105.1692228-17-s-adivi@ti.com>
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [High] dmaengine: ti: missing of_dma_controller_free() in udma_v2_remove()
- [High] dmaengine: ti: use-after-free due to missing cancel_work_sync() for purge_work
- [High] dmaengine: ti: sleep in atomic context via udma_reset_rings() in udma_v2_start()
- [High] dmaengine: ti: invalid pointer assignment for BCDMA rflow->reg_rt
- [Medium] dmaengine: ti: missing dma_unmap_single() for rx_flush buffers
- [Medium] dmaengine: ti: missing k3_configure_chan_coherency() cleanup on error
- [Low] dmaengine: ti: unnecessary Kconfig dependency on TI_SCI_INTA_IRQCHIP
--
commit e8e40f1e4b5f21e6fd35ecdd799e94a5c516bcb6
Author: Sai Sree Kartheek Adivi <s-adivi@ti.com>
dmaengine: ti: k3-udma-v2: New driver for K3 BCDMA_V2
This commit introduces support for the K3 BCDMA_V2 driver. It handles
architectural changes like static channel mapping, autopairing without PSIL
pair, and directly connected GIC interrupts. It also unifies Tx and Rx channel
configurations and modifies the match_data structure.
> diff --git a/drivers/dma/ti/Kconfig b/drivers/dma/ti/Kconfig
> index a389ae04ec930..e6a2cf37062e7 100644
> --- a/drivers/dma/ti/Kconfig
> +++ b/drivers/dma/ti/Kconfig
> @@ -49,6 +49,19 @@ config TI_K3_UDMA
> Enable support for the TI UDMA (Unified DMA) controller. This
> DMA engine is used in AM65x and j721e.
>
> +config TI_K3_UDMA_V2
> + tristate "Texas Instruments K3 UDMA v2 support"
> + depends on ARCH_K3 || COMPILE_TEST
> + depends on TI_SCI_INTA_IRQCHIP
[Severity: Low]
Is the dependency on TI_SCI_INTA_IRQCHIP required here? The driver appears
to rely exclusively on directly connected GIC interrupts accessed via
platform_get_irq_byname() without using the INT-A router, so keeping this
might prevent the driver from being enabled on K3 architectures that lack the
INT-A interrupt router.
> + select DMA_ENGINE
> + select DMA_VIRTUAL_CHANNELS
> + select TI_K3_UDMA_COMMON
> + select TI_K3_RINGACC
> + select TI_K3_PSIL
[ ... ]
> diff --git a/drivers/dma/ti/k3-udma-v2.c b/drivers/dma/ti/k3-udma-v2.c
> new file mode 100644
> index 0000000000000..8465517e8d21a
> --- /dev/null
> +++ b/drivers/dma/ti/k3-udma-v2.c
[ ... ]
> +static int udma_v2_start(struct udma_chan *uc)
> +{
[ ... ]
> + udma_chanrt_write(uc, UDMA_CHAN_RT_CTL_REG,
> + UDMA_CHAN_RT_CTL_EN | UDMA_CHAN_RT_CTL_AUTOPAIR);
> +
> + /* Poll for autopair completion */
> + read_poll_timeout_atomic(udma_v2_check_chan_autopair_completion,
> + status, status != 0, 100, 500, false, uc);
> +
> + if (status <= 0) {
> + udma_chanrt_write(uc, UDMA_CHAN_RT_CTL_REG, 0);
> + /*
> + * udma_start_desc() above already pushed uc->desc to
> + * the hardware ring. Since the channel never actually
> + * started, no completion interrupt will ever arrive
> + * to free it - drain the ring and free it here to
> + * avoid leaking it.
> + */
> + udma_reset_rings(uc);
[Severity: High]
Can this code sleep in atomic context? udma_v2_start() is called while
holding the uc->vc.lock raw spinlock (e.g. from udma_issue_pending()), but if
the autopair times out, it invokes udma_reset_rings(). This eventually calls
k3_ringacc_ring_reset_sci(), which uses the readl_poll_timeout macro that
attempts to sleep via usleep_range.
[ ... ]
> +static int udma_v2_alloc_tx_resources(struct udma_chan *uc)
> +{
[ ... ]
> + k3_configure_chan_coherency(&uc->vc.chan, uc->config.asel);
> + ring_cfg.asel = uc->config.asel;
> + ring_cfg.dma_dev = dmaengine_get_dma_device(&uc->vc.chan);
> +
> + ret = k3_ringacc_ring_cfg(tchan->t_ring, &ring_cfg);
> + ret |= k3_ringacc_ring_cfg(tchan->tc_ring, &ring_cfg);
> +
> + if (ret)
> + goto err_ringcfg;
> +
> + return 0;
> +
> +err_ringcfg:
> + k3_ringacc_ring_free(uc->tchan->tc_ring);
> + uc->tchan->tc_ring = NULL;
> + k3_ringacc_ring_free(uc->tchan->t_ring);
> + uc->tchan->t_ring = NULL;
[Severity: Medium]
Should k3_configure_chan_coherency(&uc->vc.chan, 0) be called here in the
error path? It appears the coherency state is configured earlier in the
function but isn't reverted on failure, potentially leaving the underlying
dma_parms structure incorrectly assigned for subsequent allocation attempts.
> +err_ring:
> + udma_put_tchan(uc);
> +
> + return ret;
> +}
[ ... ]
> +static int udma_v2_alloc_rx_resources(struct udma_chan *uc)
> +{
[ ... ]
> + k3_configure_chan_coherency(&uc->vc.chan, uc->config.asel);
> + ring_cfg.asel = uc->config.asel;
> + ring_cfg.dma_dev = dmaengine_get_dma_device(&uc->vc.chan);
> +
> + ret = k3_ringacc_ring_cfg(rflow->fd_ring, &ring_cfg);
> +
> + ring_cfg.size = K3_UDMA_DEFAULT_RING_SIZE;
> + ret |= k3_ringacc_ring_cfg(rflow->r_ring, &ring_cfg);
> +
> + if (ret)
> + goto err_ringcfg;
> +
> + return 0;
> +
> +err_ringcfg:
> + k3_ringacc_ring_free(rflow->r_ring);
> + rflow->r_ring = NULL;
> + k3_ringacc_ring_free(rflow->fd_ring);
> + rflow->fd_ring = NULL;
[Severity: Medium]
Similarly, should k3_configure_chan_coherency(&uc->vc.chan, 0) be added to
this error path to revert the coherency configuration if k3_ringacc_ring_cfg()
fails?
> +err_ring:
> + udma_put_rflow(uc);
> +err_rflow:
> + udma_put_rchan(uc);
> +
> + return ret;
> +}
[ ... ]
> +static int udma_v2_probe(struct platform_device *pdev)
> +{
[ ... ]
> + for (i = 0; i < ud->rflow_cnt; i++) {
> + struct udma_rflow *rflow = &ud->rflows[i];
> +
> + rflow->id = i;
> + rflow->reg_rt = ud->rflow_rt + i * 0x2000;
> + }
[Severity: High]
Can this result in an invalid pointer assignment? For the DMA_TYPE_BCDMA
device type, the base address ud->rflow_rt is never mapped or initialized,
remaining NULL due to the devm_kzalloc allocation. When the K3 UDMA glue
interface configures the RX flow (e.g. via xudma_rflowrt_write()), wouldn't
this dereference an invalid memory-mapped I/O address and cause a kernel panic?
[ ... ]
> +static void udma_v2_remove(struct platform_device *pdev)
> +{
> + struct udma_dev *ud = platform_get_drvdata(pdev);
> +
> + dma_async_device_unregister(&ud->ddev);
> +}
[Severity: High]
Does this fail to deregister the OF DMA controller?
of_dma_controller_register() dynamically allocates memory for the of_dma
structure and adds it to the global of_dma_list during probe. Since
of_dma_controller_free() is not called here, could this leak the allocation
and leave a dangling pointer in the global list, risking a use-after-free
if another device requests a DMA channel via the Device Tree after the driver
is unloaded?
[Severity: High]
Is it necessary to call cancel_work_sync(&ud->purge_work) here? The driver
uses an asynchronous workqueue (ud->purge_work) to free descriptors, and the
udma_dev structure is managed by devres (devm_kzalloc) and freed
automatically upon return. Any pending work item could continue to execute
after module unload and dereference the freed ud structure.
[Severity: Medium]
Should dma_unmap_single() be called for the rx_flush buffers?
udma_setup_rx_flush() maps memory buffers and descriptors during probe, but
this remove function does not release those mappings. This leaks IOMMU mapping
space and, because the memory itself is allocated via devm_kzalloc, it is
freed upon unload, leaving the DMA mapping active and pointing to freed memory.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261001084105.1692228-1-s-adivi@ti.com?part=16
next prev parent reply other threads:[~2026-10-01 9:18 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 8:40 [PATCH v11 00/19] dmaengine: ti: Add support for BCDMA v2 and PKTDMA v2 Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 01/19] dmaengine: ti: k3-udma: Fix sporadic crash on AM62x Sai Sree Kartheek Adivi
2026-10-01 8:57 ` sashiko-bot
2026-10-01 8:40 ` [PATCH v11 02/19] dmaengine: ti: k3-udma: move macros to header file Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 03/19] dmaengine: ti: k3-udma: move structs and enums " Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 04/19] dmaengine: ti: k3-udma: move static inline helper functions " Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 05/19] dmaengine: ti: k3-udma: move descriptor management to k3-udma-common.c Sai Sree Kartheek Adivi
2026-10-01 9:03 ` sashiko-bot
2026-10-01 8:40 ` [PATCH v11 06/19] dmaengine: ti: k3-udma: move ring management functions " Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 07/19] dmaengine: ti: k3-udma: Add variant-specific function pointers to udma_dev Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 08/19] dmaengine: ti: k3-udma: move udma utility functions to k3-udma-common.c Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 09/19] dmaengine: ti: k3-udma: move resource management " Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 10/19] dmaengine: ti: k3-udma: refactor resource setup functions Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 11/19] dmaengine: ti: k3-udma: move inclusion of k3-udma-private.c to k3-udma-common.c Sai Sree Kartheek Adivi
2026-10-01 9:06 ` sashiko-bot
2026-10-01 8:40 ` [PATCH v11 12/19] drivers: soc: ti: k3-ringacc: handle absence of tisci Sai Sree Kartheek Adivi
2026-10-05 16:05 ` Vinod Koul
2026-10-01 8:40 ` [PATCH v11 13/19] dt-bindings: dma: ti: Add K3 BCDMA V2 Sai Sree Kartheek Adivi
2026-10-01 9:08 ` sashiko-bot
2026-10-01 8:40 ` [PATCH v11 14/19] dt-bindings: dma: ti: Add K3 PKTDMA V2 Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 15/19] dmaengine: ti: k3-psil-am62l: Add AM62Lx PSIL and PDMA data Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 16/19] dmaengine: ti: k3-udma-v2: New driver for K3 BCDMA_V2 Sai Sree Kartheek Adivi
2026-10-01 9:18 ` sashiko-bot [this message]
2026-10-01 8:40 ` [PATCH v11 17/19] dmaengine: ti: k3-udma-v2: Add support for PKTDMA V2 Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 18/19] dmaengine: ti: k3-udma-v2: Update glue layer to support " Sai Sree Kartheek Adivi
2026-10-01 8:40 ` [PATCH v11 19/19] dmaengine: ti: k3-udma: Validate resource ID and fix logging in reservation Sai Sree Kartheek Adivi
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=20261001091836.C10A51F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=robh@kernel.org \
--cc=s-adivi@ti.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox