1 From 8ca9590c39b69b55a8de63d2b21b0d44f523b43a Mon Sep 17 00:00:00 2001
2 From: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
3 Date: Thu, 17 Apr 2025 13:25:21 +0530
4 Subject: dmaengine: ti: k3-udma: Use cap_mask directly from dma_device structure instead of a local copy
6 From: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
8 commit 8ca9590c39b69b55a8de63d2b21b0d44f523b43a upstream.
10 Currently, a local dma_cap_mask_t variable is used to store device
11 cap_mask within udma_of_xlate(). However, the DMA_PRIVATE flag in
12 the device cap_mask can get cleared when the last channel is released.
13 This can happen right after storing the cap_mask locally in
14 udma_of_xlate(), and subsequent dma_request_channel() can fail due to
15 mismatch in the cap_mask. Fix this by removing the local dma_cap_mask_t
16 variable and directly using the one from the dma_device structure.
18 Fixes: 25dcb5dd7b7c ("dmaengine: ti: New driver for K3 UDMA")
19 Cc: stable@vger.kernel.org
20 Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
21 Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
22 Reviewed-by: Udit Kumar <u-kumar1@ti.com>
23 Signed-off-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
24 Link: https://lore.kernel.org/r/20250417075521.623651-1-y-abhilashchandra@ti.com
25 Signed-off-by: Vinod Koul <vkoul@kernel.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28 drivers/dma/ti/k3-udma.c | 3 +--
29 1 file changed, 1 insertion(+), 2 deletions(-)
31 --- a/drivers/dma/ti/k3-udma.c
32 +++ b/drivers/dma/ti/k3-udma.c
33 @@ -3082,7 +3082,6 @@ static struct dma_chan *udma_of_xlate(st
36 struct udma_dev *ud = ofdma->of_dma_data;
37 - dma_cap_mask_t mask = ud->ddev.cap_mask;
38 struct udma_filter_param filter_param;
39 struct dma_chan *chan;
41 @@ -3095,7 +3094,7 @@ static struct dma_chan *udma_of_xlate(st
43 filter_param.atype = 0;
45 - chan = __dma_request_channel(&mask, udma_dma_filter_fn, &filter_param,
46 + chan = __dma_request_channel(&ud->ddev.cap_mask, udma_dma_filter_fn, &filter_param,
49 dev_err(ud->dev, "get channel fail in %s.\n", __func__);