diff mbox series

[RFC] dmaengine: ti: k3-udma: Use cap_mask directly from dma_device structure instead of a local copy

Message ID 20250117121728.203452-1-y-abhilashchandra@ti.com (mailing list archive)
State Superseded
Headers show
Series [RFC] dmaengine: ti: k3-udma: Use cap_mask directly from dma_device structure instead of a local copy | expand

Commit Message

Yemike Abhilash Chandra Jan. 17, 2025, 12:17 p.m. UTC
Currently, a local dma_cap_mask_t variable is used to store device
cap_mask within udma_of_xlate(). However, the DMA_PRIVATE flag in
the device cap_mask can get cleared when the last channel is released.
This can happen right after storing the cap_mask locally in
udma_of_xlate() and subsequent dma_request_channel() can fail due to
mismatch in the cap_mask. Fix this by removing the local dma_cap_mask_t
variable and directly using the one from the dma_device structure.

Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
Signed-off-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
---
 drivers/dma/ti/k3-udma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Péter Ujfalusi Jan. 22, 2025, 3:24 p.m. UTC | #1
On 17/01/2025 14:17, Yemike Abhilash Chandra wrote:
> Currently, a local dma_cap_mask_t variable is used to store device
> cap_mask within udma_of_xlate(). However, the DMA_PRIVATE flag in
> the device cap_mask can get cleared when the last channel is released.
> This can happen right after storing the cap_mask locally in
> udma_of_xlate() and subsequent dma_request_channel() can fail due to
> mismatch in the cap_mask. Fix this by removing the local dma_cap_mask_t
> variable and directly using the one from the dma_device structure.

Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>

> 
> Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
> ---
>  drivers/dma/ti/k3-udma.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 7ed1956b4642..c775a2284e86 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -4246,7 +4246,6 @@ static struct dma_chan *udma_of_xlate(struct of_phandle_args *dma_spec,
>  				      struct of_dma *ofdma)
>  {
>  	struct udma_dev *ud = ofdma->of_dma_data;
> -	dma_cap_mask_t mask = ud->ddev.cap_mask;
>  	struct udma_filter_param filter_param;
>  	struct dma_chan *chan;
>  
> @@ -4278,7 +4277,7 @@ static struct dma_chan *udma_of_xlate(struct of_phandle_args *dma_spec,
>  		}
>  	}
>  
> -	chan = __dma_request_channel(&mask, udma_dma_filter_fn, &filter_param,
> +	chan = __dma_request_channel(&ud->ddev.cap_mask, udma_dma_filter_fn, &filter_param,
>  				     ofdma->of_node);
>  	if (!chan) {
>  		dev_err(ud->dev, "get channel fail in %s.\n", __func__);
Kumar, Udit Jan. 27, 2025, 10:57 a.m. UTC | #2
Hi Abhilash,

On 1/17/2025 5:47 PM, Yemike Abhilash Chandra wrote:
> Currently, a local dma_cap_mask_t variable is used to store device
> cap_mask within udma_of_xlate(). However, the DMA_PRIVATE flag in
> the device cap_mask can get cleared when the last channel is released.
> This can happen right after storing the cap_mask locally in
> udma_of_xlate() and subsequent dma_request_channel() can fail due to
> mismatch in the cap_mask. Fix this by removing the local dma_cap_mask_t

This should carry fixes tag


> variable and directly using the one from the dma_device structure.
>
> Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com>
> ---
>   drivers/dma/ti/k3-udma.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
> index 7ed1956b4642..c775a2284e86 100644
> --- a/drivers/dma/ti/k3-udma.c
> +++ b/drivers/dma/ti/k3-udma.c
> @@ -4246,7 +4246,6 @@ static struct dma_chan *udma_of_xlate(struct of_phandle_args *dma_spec,
>   				      struct of_dma *ofdma)
>   {
>   	struct udma_dev *ud = ofdma->of_dma_data;
> -	dma_cap_mask_t mask = ud->ddev.cap_mask;
>   	struct udma_filter_param filter_param;
>   	struct dma_chan *chan;
>   
> @@ -4278,7 +4277,7 @@ static struct dma_chan *udma_of_xlate(struct of_phandle_args *dma_spec,
>   		}
>   	}
>   
> -	chan = __dma_request_channel(&mask, udma_dma_filter_fn, &filter_param,
> +	chan = __dma_request_channel(&ud->ddev.cap_mask, udma_dma_filter_fn, &filter_param,
>   				     ofdma->of_node);

With addition of fixes tag in subject,

Reviewed-by: Udit Kumar <u-kumar1@ti.com>


>   	if (!chan) {
>   		dev_err(ud->dev, "get channel fail in %s.\n", __func__);
diff mbox series

Patch

diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index 7ed1956b4642..c775a2284e86 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -4246,7 +4246,6 @@  static struct dma_chan *udma_of_xlate(struct of_phandle_args *dma_spec,
 				      struct of_dma *ofdma)
 {
 	struct udma_dev *ud = ofdma->of_dma_data;
-	dma_cap_mask_t mask = ud->ddev.cap_mask;
 	struct udma_filter_param filter_param;
 	struct dma_chan *chan;
 
@@ -4278,7 +4277,7 @@  static struct dma_chan *udma_of_xlate(struct of_phandle_args *dma_spec,
 		}
 	}
 
-	chan = __dma_request_channel(&mask, udma_dma_filter_fn, &filter_param,
+	chan = __dma_request_channel(&ud->ddev.cap_mask, udma_dma_filter_fn, &filter_param,
 				     ofdma->of_node);
 	if (!chan) {
 		dev_err(ud->dev, "get channel fail in %s.\n", __func__);