From: Jon Hunter <jonathanh@nvidia.com>
To: Sheetal <sheetal@nvidia.com>, Vinod Koul <vkoul@kernel.org>,
dmaengine@vger.kernel.org, Frank Li <Frank.Li@kernel.org>
Cc: Laxman Dewangan <ldewangan@nvidia.com>,
Thierry Reding <thierry.reding@kernel.org>,
Mohan Kumar <mkumard@nvidia.com>,
Sameer Pujar <spujar@nvidia.com>,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7] dmaengine: tegra210-adma: Add error logging on failure paths
Date: Fri, 5 Jun 2026 12:53:01 +0100 [thread overview]
Message-ID: <eaac1f6e-90d2-4d8e-8238-30e7ea01c1c2@nvidia.com> (raw)
In-Reply-To: <20260517163045.363444-1-sheetal@nvidia.com>
On 17/05/2026 17:30, Sheetal wrote:
> Add dev_err/dev_err_probe logging across failure paths to improve
> debuggability of DMA errors during runtime and probe.
>
> Use return dev_err_probe() pattern where no cleanup is required in the
> probe function. On error paths that need explicit unwind, store the
> dev_err_probe() return value in ret before jumping to the cleanup label.
> Also convert existing dev_err calls in probe to dev_err_probe for
> consistency, and use dev_err in non-probe functions.
>
> Keep explicit runtime PM and DMA registration unwind instead of managed or
> scoped cleanup. The scoped runtime PM guard releases the usage count with
> pm_runtime_put(), while this probe error path needs pm_runtime_put_sync()
> before pm_runtime_disable(). The OF DMA registration failure path also
> needs to unregister the DMA engine before dropping the runtime PM reference.
>
> Signed-off-by: Sheetal <sheetal@nvidia.com>
> ---
> Changes in v7:
> - Keep explicit runtime PM unwind instead of using a scoped runtime PM guard
> and devm_pm_runtime_enable(), because the guard releases with
> pm_runtime_put() while this path needs pm_runtime_put_sync() before
> pm_runtime_disable().
> - Keep manual DMA registration unwind instead of using
> dmaenginem_async_device_register() so DMA unregister happens before the
> runtime PM reference is dropped on OF DMA registration failure.
> - Restore the explicit IRQ cleanup path instead of using managed IRQ disposal.
>
> ---
> drivers/dma/tegra210-adma.c | 63 ++++++++++++++++++++++++++-----------
> 1 file changed, 44 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
> index 14e0c408ed1e..ceaee1e33e68 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 %zu (max %u)\n",
> + desc->num_periods, ADMA_CH_CONFIG_MAX_BUFS);
> return -EINVAL;
> + }
>
> switch (direction) {
> case DMA_MEM_TO_DEV:
> @@ -1029,8 +1040,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
>
> cdata = of_device_get_match_data(&pdev->dev);
> if (!cdata) {
> - dev_err(&pdev->dev, "device match data not found\n");
> - return -ENODEV;
> + return dev_err_probe(&pdev->dev, -ENODEV,
> + "device match data not found\n");
> }
>
> tdma = devm_kzalloc(&pdev->dev,
> @@ -1056,7 +1067,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
> unsigned int ch_base_offset;
>
> if (res_page->start < res_base->start)
> - return -EINVAL;
> + return dev_err_probe(&pdev->dev, -EINVAL,
> + "invalid page/global resource order\n");
> page_offset = res_page->start - res_base->start;
> ch_base_offset = cdata->ch_base_offset;
> if (!ch_base_offset)
> @@ -1064,7 +1076,9 @@ static int tegra_adma_probe(struct platform_device *pdev)
>
> page_no = div_u64(page_offset, ch_base_offset);
> if (!page_no || page_no > INT_MAX)
> - return -EINVAL;
> + return dev_err_probe(&pdev->dev, -EINVAL,
> + "invalid page number %llu\n",
> + (unsigned long long)page_no);
>
> tdma->ch_page_no = page_no - 1;
> tdma->base_addr = devm_ioremap_resource(&pdev->dev, res_base);
> @@ -1079,7 +1093,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
> if (IS_ERR(tdma->base_addr))
> return PTR_ERR(tdma->base_addr);
> } else {
> - return -ENODEV;
> + return dev_err_probe(&pdev->dev, -ENODEV,
> + "failed to get memory resource\n");
> }
>
> tdma->ch_base_addr = tdma->base_addr + cdata->ch_base_offset;
> @@ -1087,8 +1102,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
>
> tdma->ahub_clk = devm_clk_get(&pdev->dev, "d_audio");
> if (IS_ERR(tdma->ahub_clk)) {
> - dev_err(&pdev->dev, "Error: Missing ahub controller clock\n");
> - return PTR_ERR(tdma->ahub_clk);
> + return dev_err_probe(&pdev->dev, PTR_ERR(tdma->ahub_clk),
> + "failed to get ahub clock\n");
> }
>
> tdma->dma_chan_mask = devm_kzalloc(&pdev->dev,
> @@ -1104,8 +1119,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
> (u32 *)tdma->dma_chan_mask,
> BITS_TO_U32(tdma->nr_channels));
> if (ret < 0 && (ret != -EINVAL)) {
> - dev_err(&pdev->dev, "dma-channel-mask is not complete.\n");
> - return ret;
> + return dev_err_probe(&pdev->dev, ret,
> + "dma-channel-mask is not complete.\n");
> }
>
> INIT_LIST_HEAD(&tdma->dma_dev.channels);
> @@ -1127,11 +1142,13 @@ static int tegra_adma_probe(struct platform_device *pdev)
> cdata->global_ch_config_base + (4 * i);
> }
>
> - tdc->irq = of_irq_get(pdev->dev.of_node, i);
> - if (tdc->irq <= 0) {
> - ret = tdc->irq ?: -ENXIO;
> + ret = of_irq_get(pdev->dev.of_node, i);
> + if (ret <= 0) {
> + ret = dev_err_probe(&pdev->dev, ret ?: -ENXIO,
> + "failed to get IRQ for channel %d\n", i);
> goto irq_dispose;
> }
> + tdc->irq = ret;
>
> vchan_init(&tdc->vc, &tdma->dma_dev);
> tdc->vc.desc_free = tegra_adma_desc_free;
> @@ -1141,12 +1158,18 @@ 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) {
> + ret = dev_err_probe(&pdev->dev, ret,
> + "runtime PM resume failed\n");
> goto rpm_disable;
> + }
>
> ret = tegra_adma_init(tdma);
> - if (ret)
> + if (ret) {
> + ret = dev_err_probe(&pdev->dev, ret,
> + "failed to initialize ADMA\n");
> goto rpm_put;
> + }
>
> dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
> dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
> @@ -1172,14 +1195,16 @@ static int tegra_adma_probe(struct platform_device *pdev)
>
> ret = dma_async_device_register(&tdma->dma_dev);
> if (ret < 0) {
> - dev_err(&pdev->dev, "ADMA registration failed: %d\n", ret);
> + ret = dev_err_probe(&pdev->dev, ret,
> + "ADMA registration failed\n");
> goto rpm_put;
> }
>
> ret = of_dma_controller_register(pdev->dev.of_node,
> tegra_dma_of_xlate, tdma);
> if (ret < 0) {
> - dev_err(&pdev->dev, "ADMA OF registration failed %d\n", ret);
> + ret = dev_err_probe(&pdev->dev, ret,
> + "ADMA OF registration failed\n");
> goto dma_remove;
> }
>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Thanks!
Jon
--
nvpublic
next prev parent reply other threads:[~2026-06-05 11:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-17 16:30 Sheetal
2026-06-05 11:53 ` Jon Hunter [this message]
2026-06-08 12:12 ` Vinod Koul
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=eaac1f6e-90d2-4d8e-8238-30e7ea01c1c2@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=ldewangan@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mkumard@nvidia.com \
--cc=sheetal@nvidia.com \
--cc=spujar@nvidia.com \
--cc=thierry.reding@kernel.org \
--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
all inboxes | Powered by JetHome®