linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Laxman Dewangan <ldewangan@nvidia.com>,
	Jon Hunter <jonathanh@nvidia.com>, Vinod Koul <vkoul@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Mohan Kumar D <mkumard@nvidia.com>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	dmaengine@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] dmaengine: tegra210: avoid broken division
Date: Wed, 22 Jan 2025 07:51:36 +0100	[thread overview]
Message-ID: <20250122065150.1352906-1-arnd@kernel.org> (raw)

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


                 reply	other threads:[~2025-01-22  6:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250122065150.1352906-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --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=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@baylibre.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;
as well as URLs for NNTP newsgroup(s).