From: Mohan Kumar D <mkumard@nvidia.com>
To: <vkoul@kernel.org>, <thierry.reding@gmail.com>, <jonathanh@nvidia.com>
Cc: <dmaengine@vger.kernel.org>, <linux-tegra@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
Mohan Kumar D <mkumard@nvidia.com>,
kernel test robot <lkp@intel.com>,
Thierry Reding <treding@nvidia.com>
Subject: [PATCH v5 1/2] dmaengine: tegra210-adma: Use div_u64 for 64 bit division
Date: Mon, 10 Feb 2025 19:24:12 +0530 [thread overview]
Message-ID: <20250210135413.2504272-2-mkumard@nvidia.com> (raw)
In-Reply-To: <20250210135413.2504272-1-mkumard@nvidia.com>
The ADMA base and page address are represented using a 64-bit variable.
To accurately derive the exact ADMA page number provided from the DT
properties, use the div_u64() to divide the address difference between
adma page and base address by the page offset.
This change fixes the below error
"ERROR: modpost: "__udivdi3" [drivers/dma/tegra210-adma.ko] undefined!
ld: drivers/dma/tegra210-adma.o: in function `tegra_adma_probe':
tegra210-adma.c:(.text+0x12cf): undefined reference to `__udivdi3'"
Fixes: 68811c928f88 ("dmaengine: tegra210-adma: Support channel page")
Cc: stable@vger.kernel.org
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202412250204.GCQhdKe3-lkp@intel.com/
Signed-off-by: Mohan Kumar D <mkumard@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
---
drivers/dma/tegra210-adma.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index 6896da8ac7ef..a0bd4822ed80 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -887,7 +887,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
const struct tegra_adma_chip_data *cdata;
struct tegra_adma *tdma;
struct resource *res_page, *res_base;
- int ret, i, page_no;
+ u64 page_no, page_offset;
+ int ret, i;
cdata = of_device_get_match_data(&pdev->dev);
if (!cdata) {
@@ -914,10 +915,16 @@ static int tegra_adma_probe(struct platform_device *pdev)
res_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "global");
if (res_base) {
- page_no = (res_page->start - res_base->start) / cdata->ch_base_offset;
- if (page_no <= 0)
+ if (WARN_ON(res_page->start <= res_base->start))
return -EINVAL;
- tdma->ch_page_no = page_no - 1;
+
+ page_offset = res_page->start - res_base->start;
+ page_no = div_u64(page_offset, cdata->ch_base_offset);
+
+ if (WARN_ON(page_no == 0))
+ return -EINVAL;
+
+ tdma->ch_page_no = lower_32_bits(page_no) - 1;
tdma->base_addr = devm_ioremap_resource(&pdev->dev, res_base);
if (IS_ERR(tdma->base_addr))
return PTR_ERR(tdma->base_addr);
--
2.25.1
next prev parent reply other threads:[~2025-02-10 13:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 13:54 [PATCH v5 0/2] Tegra ADMA fixes Mohan Kumar D
2025-02-10 13:54 ` Mohan Kumar D [this message]
2025-02-10 13:54 ` [PATCH v5 2/2] dmaengine: tegra210-adma: check for adma max page Mohan Kumar D
2025-02-10 14:34 ` [PATCH v5 0/2] Tegra ADMA fixes 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=20250210135413.2504272-2-mkumard@nvidia.com \
--to=mkumard@nvidia.com \
--cc=dmaengine@vger.kernel.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lkp@intel.com \
--cc=stable@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=treding@nvidia.com \
--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®