public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: tegra210-adma: Add error logging on failure paths
@ 2026-03-18  7:39 Sheetal
  2026-03-18  9:45 ` Vinod Koul
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sheetal @ 2026-03-18  7:39 UTC (permalink / raw)
  To: Jon Hunter, Vinod Koul, Thierry Reding
  Cc: Laxman Dewangan, Frank Li, Mohan Kumar, dmaengine, linux-tegra,
	linux-kernel, Sheetal

Add dev_err/dev_err_probe logging across failure paths to improve
debuggability of DMA errors during runtime and probe.

Signed-off-by: Sheetal <sheetal@nvidia.com>
---
 drivers/dma/tegra210-adma.c | 48 +++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index 14e0c408ed1e..a50cd52fec18 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -335,8 +335,16 @@ static int tegra_adma_request_alloc(struct tegra_adma_chan *tdc,
 	struct tegra_adma *tdma = tdc->tdma;
 	unsigned int sreq_index = tdc->sreq_index;
 
-	if (tdc->sreq_reserved)
-		return tdc->sreq_dir == direction ? 0 : -EINVAL;
+	if (tdc->sreq_reserved) {
+		if (tdc->sreq_dir != direction) {
+			dev_err(tdma->dev,
+				"DMA request direction mismatch: reserved=%s, requested=%s\n",
+				dmaengine_get_direction_text(tdc->sreq_dir),
+				dmaengine_get_direction_text(direction));
+			return -EINVAL;
+		}
+		return 0;
+	}
 
 	if (sreq_index > tdma->cdata->ch_req_max) {
 		dev_err(tdma->dev, "invalid DMA request\n");
@@ -665,8 +673,11 @@ static int tegra_adma_set_xfer_params(struct tegra_adma_chan *tdc,
 	const struct tegra_adma_chip_data *cdata = tdc->tdma->cdata;
 	unsigned int burst_size, adma_dir, fifo_size_shift;
 
-	if (desc->num_periods > ADMA_CH_CONFIG_MAX_BUFS)
+	if (desc->num_periods > ADMA_CH_CONFIG_MAX_BUFS) {
+		dev_err(tdc2dev(tdc), "invalid DMA periods %u (max %u)\n",
+			desc->num_periods, ADMA_CH_CONFIG_MAX_BUFS);
 		return -EINVAL;
+	}
 
 	switch (direction) {
 	case DMA_MEM_TO_DEV:
@@ -1047,38 +1058,50 @@ static int tegra_adma_probe(struct platform_device *pdev)
 	res_page = platform_get_resource_byname(pdev, IORESOURCE_MEM, "page");
 	if (res_page) {
 		tdma->ch_base_addr = devm_ioremap_resource(&pdev->dev, res_page);
-		if (IS_ERR(tdma->ch_base_addr))
+		if (IS_ERR(tdma->ch_base_addr)) {
+			dev_err(&pdev->dev, "failed to map page resource\n");
 			return PTR_ERR(tdma->ch_base_addr);
+		}
 
 		res_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "global");
 		if (res_base) {
 			resource_size_t page_offset, page_no;
 			unsigned int ch_base_offset;
 
-			if (res_page->start < res_base->start)
+			if (res_page->start < res_base->start) {
+				dev_err(&pdev->dev, "invalid page/global resource order\n");
 				return -EINVAL;
+			}
+
 			page_offset = res_page->start - res_base->start;
 			ch_base_offset = cdata->ch_base_offset;
 			if (!ch_base_offset)
 				return -EINVAL;
 
 			page_no = div_u64(page_offset, ch_base_offset);
-			if (!page_no || page_no > INT_MAX)
+			if (!page_no || page_no > INT_MAX) {
+				dev_err(&pdev->dev, "invalid page number %llu\n", page_no);
 				return -EINVAL;
+			}
 
 			tdma->ch_page_no = page_no - 1;
 			tdma->base_addr = devm_ioremap_resource(&pdev->dev, res_base);
-			if (IS_ERR(tdma->base_addr))
+			if (IS_ERR(tdma->base_addr)) {
+				dev_err(&pdev->dev, "failed to map global resource\n");
 				return PTR_ERR(tdma->base_addr);
+			}
 		}
 	} else {
 		/* If no 'page' property found, then reg DT binding would be legacy */
 		res_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 		if (res_base) {
 			tdma->base_addr = devm_ioremap_resource(&pdev->dev, res_base);
-			if (IS_ERR(tdma->base_addr))
+			if (IS_ERR(tdma->base_addr)) {
+				dev_err(&pdev->dev, "failed to map base resource\n");
 				return PTR_ERR(tdma->base_addr);
+			}
 		} else {
+			dev_err(&pdev->dev, "failed to map mem resource\n");
 			return -ENODEV;
 		}
 
@@ -1130,6 +1153,7 @@ static int tegra_adma_probe(struct platform_device *pdev)
 		tdc->irq = of_irq_get(pdev->dev.of_node, i);
 		if (tdc->irq <= 0) {
 			ret = tdc->irq ?: -ENXIO;
+			dev_err_probe(&pdev->dev, ret, "failed to get IRQ for channel %d\n", i);
 			goto irq_dispose;
 		}
 
@@ -1141,12 +1165,16 @@ static int tegra_adma_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	ret = pm_runtime_resume_and_get(&pdev->dev);
-	if (ret < 0)
+	if (ret < 0) {
+		dev_err(&pdev->dev, "runtime PM resume failed: %d\n", ret);
 		goto rpm_disable;
+	}
 
 	ret = tegra_adma_init(tdma);
-	if (ret)
+	if (ret) {
+		dev_err(&pdev->dev, "failed to initialize ADMA: %d\n", ret);
 		goto rpm_put;
+	}
 
 	dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
 	dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
-- 
2.17.1


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

end of thread, other threads:[~2026-03-18 23:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-18  7:39 [PATCH] dmaengine: tegra210-adma: Add error logging on failure paths Sheetal
2026-03-18  9:45 ` Vinod Koul
2026-03-18 23:42 ` kernel test robot
2026-03-18 23:42 ` kernel test robot

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