* [PATCH] dmaengine: tegra210: avoid broken division
@ 2025-01-22 6:51 Arnd Bergmann
0 siblings, 0 replies; only message in thread
From: Arnd Bergmann @ 2025-01-22 6:51 UTC (permalink / raw)
To: Laxman Dewangan, Jon Hunter, Vinod Koul, Thierry Reding,
Mohan Kumar D
Cc: Arnd Bergmann, Uwe Kleine-König, dmaengine, linux-tegra,
linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
When build testing on 32-bit targets with 64-bit resource_size_t,
the new probe logic causes a link failure:
arm-linux-gnueabi-ld: drivers/dma/tegra210-adma.o: in function `tegra_adma_probe':
tegra210-adma.c:(.text+0x122c): undefined reference to `__aeabi_uldivmod'
In addition, it seems that the same division can trap when running
on tegra210, which sets .ch_base_offset=0.
Avoid both using the div_u64() helper and an added zero-check.
Fixes: 68811c928f88 ("dmaengine: tegra210-adma: Support channel page")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/dma/tegra210-adma.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index d80a60de0160..fd339f10151c 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -913,8 +913,9 @@ static int tegra_adma_probe(struct platform_device *pdev)
return PTR_ERR(tdma->ch_base_addr);
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 (res_base && cdata->ch_base_offset) {
+ page_no = div_u64(res_page->start - res_base->start,
+ cdata->ch_base_offset);
if (page_no <= 0)
return -EINVAL;
tdma->ch_page_no = page_no - 1;
--
2.39.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-22 6:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 6:51 [PATCH] dmaengine: tegra210: avoid broken division Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).