Skip to contentSkip to conversation

dmaengine: tegra210: avoid broken division

PATCH New Arnd Bergmann 1 participant 1 message Jan 22, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: tegra210: avoid broken division

From: Arnd Bergmann <[email protected]>

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")
---
 drivers/dma/tegra210-adma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dma/tegra210-adma.c +3 -2
index d80a60de0160..fd339f10151c 100644
@@ -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;
Signature · 1 line
2.39.5