mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dmaengine: altera-msgdma: fail probe when reset times out
@ 2026-06-23  6:05 Pengpeng Hou
  2026-10-16 15:31 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-06-23  6:05 UTC (permalink / raw)
  To: Olivier Dautricourt, Stefan Roese, Vinod Koul, Frank Li,
	dmaengine, linux-kernel
  Cc: Pengpeng Hou

msgdma_probe() resets the controller before publishing the DMA device
and OF DMA provider, but msgdma_reset() only logs a timeout and then
continues to enable the controller and mark it idle.

If the reset bit never clears, the driver can still register a DMA
engine backed by a controller that did not leave reset. Return the
readl_poll_timeout() error from msgdma_reset() and abort probe on reset
failure.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/dma/altera-msgdma.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index b46999c81df0..f60a4e86a246 100644
--- a/drivers/dma/altera-msgdma.c
+++ b/drivers/dma/altera-msgdma.c
@@ -466,7 +466,7 @@ static int msgdma_dma_config(struct dma_chan *dchan,
 	return 0;
 }
 
-static void msgdma_reset(struct msgdma_device *mdev)
+static int msgdma_reset(struct msgdma_device *mdev)
 {
 	u32 val;
 	int ret;
@@ -478,8 +478,10 @@ static void msgdma_reset(struct msgdma_device *mdev)
 	ret = readl_poll_timeout(mdev->csr + MSGDMA_CSR_STATUS, val,
 				 (val & MSGDMA_CSR_STAT_RESETTING) == 0,
 				 1, 10000);
-	if (ret)
+	if (ret) {
 		dev_err(mdev->dev, "DMA channel did not reset\n");
+		return ret;
+	}
 
 	/* Clear all status bits */
 	iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS);
@@ -489,6 +491,7 @@ static void msgdma_reset(struct msgdma_device *mdev)
 		  MSGDMA_CSR_CTL_GLOBAL_INTR, mdev->csr + MSGDMA_CSR_CONTROL);
 
 	mdev->idle = true;
+	return 0;
 };
 
 static void msgdma_copy_one(struct msgdma_device *mdev,
@@ -896,7 +899,9 @@ static int msgdma_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
-	msgdma_reset(mdev);
+	ret = msgdma_reset(mdev);
+	if (ret)
+		goto fail;
 
 	ret = dma_async_device_register(dma_dev);
 	if (ret)
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dmaengine: altera-msgdma: fail probe when reset times out
  2026-06-23  6:05 [PATCH] dmaengine: altera-msgdma: fail probe when reset times out Pengpeng Hou
@ 2026-10-16 15:31 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-10-16 15:31 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Olivier Dautricourt, Stefan Roese, Vinod Koul, Frank Li,
	dmaengine, linux-kernel

On Tue, Jun 23, 2026 at 02:05:54PM +0800, Pengpeng Hou wrote:
> msgdma_probe() resets the controller before publishing the DMA device
> and OF DMA provider, but msgdma_reset() only logs a timeout and then
> continues to enable the controller and mark it idle.
>
> If the reset bit never clears, the driver can still register a DMA
> engine backed by a controller that did not leave reset. Return the
> readl_poll_timeout() error from msgdma_reset() and abort probe on reset
> failure.
>
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/altera-msgdma.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
> index b46999c81df0..f60a4e86a246 100644
> --- a/drivers/dma/altera-msgdma.c
> +++ b/drivers/dma/altera-msgdma.c
> @@ -466,7 +466,7 @@ static int msgdma_dma_config(struct dma_chan *dchan,
>  	return 0;
>  }
>
> -static void msgdma_reset(struct msgdma_device *mdev)
> +static int msgdma_reset(struct msgdma_device *mdev)
>  {
>  	u32 val;
>  	int ret;
> @@ -478,8 +478,10 @@ static void msgdma_reset(struct msgdma_device *mdev)
>  	ret = readl_poll_timeout(mdev->csr + MSGDMA_CSR_STATUS, val,
>  				 (val & MSGDMA_CSR_STAT_RESETTING) == 0,
>  				 1, 10000);
> -	if (ret)
> +	if (ret) {
>  		dev_err(mdev->dev, "DMA channel did not reset\n");
> +		return ret;
> +	}
>
>  	/* Clear all status bits */
>  	iowrite32(MSGDMA_CSR_STAT_MASK, mdev->csr + MSGDMA_CSR_STATUS);
> @@ -489,6 +491,7 @@ static void msgdma_reset(struct msgdma_device *mdev)
>  		  MSGDMA_CSR_CTL_GLOBAL_INTR, mdev->csr + MSGDMA_CSR_CONTROL);
>
>  	mdev->idle = true;
> +	return 0;
>  };
>
>  static void msgdma_copy_one(struct msgdma_device *mdev,
> @@ -896,7 +899,9 @@ static int msgdma_probe(struct platform_device *pdev)
>  		goto fail;
>  	}
>
> -	msgdma_reset(mdev);
> +	ret = msgdma_reset(mdev);
> +	if (ret)
> +		goto fail;
>
>  	ret = dma_async_device_register(dma_dev);
>  	if (ret)
> --
> 2.50.1 (Apple Git-155)
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-16 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-23  6:05 [PATCH] dmaengine: altera-msgdma: fail probe when reset times out Pengpeng Hou
2026-10-16 15:31 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®