From: Vinod Koul <vkoul@kernel.org>
To: Sheetal <sheetal@nvidia.com>
Cc: Jon Hunter <jonathanh@nvidia.com>,
Thierry Reding <thierry.reding@kernel.org>,
Laxman Dewangan <ldewangan@nvidia.com>,
Frank Li <Frank.Li@kernel.org>, Mohan Kumar <mkumard@nvidia.com>,
dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: tegra210-adma: Add error logging on failure paths
Date: Wed, 18 Mar 2026 15:15:18 +0530 [thread overview]
Message-ID: <abp0LhQf4gP0Vv0X@vaman> (raw)
In-Reply-To: <20260318073922.1760132-1-sheetal@nvidia.com>
On 18-03-26, 07:39, Sheetal wrote:
> Add dev_err/dev_err_probe logging across failure paths to improve
> debuggability of DMA errors during runtime and probe.
This fails to build. Please enable W=1 and send
drivers/dma/tegra210-adma.c: In function ‘tegra_adma_set_xfer_params’:
drivers/dma/tegra210-adma.c:677:39: error: format ‘%u’ expects argument of type ‘unsigned int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’} [-Werror=format=]
677 | dev_err(tdc2dev(tdc), "invalid DMA periods %u (max %u)\n",
>
> 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
--
~Vinod
next prev parent reply other threads:[~2026-03-18 9:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-18 7:39 [PATCH] dmaengine: tegra210-adma: Add error logging on failure paths Sheetal
2026-03-18 9:45 ` Vinod Koul [this message]
2026-03-18 23:42 ` kernel test robot
2026-03-18 23:42 ` kernel test robot
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=abp0LhQf4gP0Vv0X@vaman \
--to=vkoul@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=jonathanh@nvidia.com \
--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=thierry.reding@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