Skip to content

Commit

Permalink
dmaengine: tegra210-adma: Use div_u64 for 64 bit division
Browse files Browse the repository at this point in the history
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: 68811c9 ("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>
Link: https://lore.kernel.org/r/20250210135413.2504272-2-mkumard@nvidia.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
  • Loading branch information
Mohan Kumar D authored and Vinod Koul committed Feb 10, 2025
1 parent 2014c95 commit 1798745
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions drivers/dma/tegra210-adma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit 1798745

Please sign in to comment.