linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] can: rockchip_canfd: avoids 64-bit division
  2024-09-09 11:21 [PATCH] can: rockchip_canfd: avoids 64-bit division Arnd Bergmann
@ 2024-09-09  9:44 ` Marc Kleine-Budde
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2024-09-09  9:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Vincent Mailhol, Arnd Bergmann, kernel, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
	linux-can, netdev, linux-arm-kernel, linux-rockchip, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

On 09.09.2024 11:21:04, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The new driver fails to build on some 32-bit configurations:
> 
> arm-linux-gnueabi-ld: drivers/net/can/rockchip/rockchip_canfd-timestamp.o: in function `rkcanfd_timestamp_init':
> rockchip_canfd-timestamp.c:(.text+0x14a): undefined reference to `__aeabi_ldivmod'
> 
> Rework the delay calculation to only require a single 64-bit
> division.
> 
> Fixes: 4e1a18bab124 ("can: rockchip_canfd: add hardware timestamping support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

I've already send a PR which replaces the division by div_u64(), so not
as elaborate as yours:

| https://lore.kernel.org/all/20240909-can-rockchip_canfd-fix-64-bit-division-v1-1-2748d9422b00@pengutronix.de/

I'll port your patch on top of mine and include it in my next PR.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] can: rockchip_canfd: avoids 64-bit division
@ 2024-09-09 11:21 Arnd Bergmann
  2024-09-09  9:44 ` Marc Kleine-Budde
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2024-09-09 11:21 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol
  Cc: Arnd Bergmann, kernel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Heiko Stuebner, linux-can, netdev,
	linux-arm-kernel, linux-rockchip, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The new driver fails to build on some 32-bit configurations:

arm-linux-gnueabi-ld: drivers/net/can/rockchip/rockchip_canfd-timestamp.o: in function `rkcanfd_timestamp_init':
rockchip_canfd-timestamp.c:(.text+0x14a): undefined reference to `__aeabi_ldivmod'

Rework the delay calculation to only require a single 64-bit
division.

Fixes: 4e1a18bab124 ("can: rockchip_canfd: add hardware timestamping support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/can/rockchip/rockchip_canfd-timestamp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/rockchip/rockchip_canfd-timestamp.c b/drivers/net/can/rockchip/rockchip_canfd-timestamp.c
index 81cccc5fd838..43d4b5721812 100644
--- a/drivers/net/can/rockchip/rockchip_canfd-timestamp.c
+++ b/drivers/net/can/rockchip/rockchip_canfd-timestamp.c
@@ -71,8 +71,8 @@ void rkcanfd_timestamp_init(struct rkcanfd_priv *priv)
 
 	max_cycles = div_u64(ULLONG_MAX, cc->mult);
 	max_cycles = min(max_cycles, cc->mask);
-	work_delay_ns = clocksource_cyc2ns(max_cycles, cc->mult, cc->shift) / 3;
-	priv->work_delay_jiffies = nsecs_to_jiffies(work_delay_ns);
+	work_delay_ns = clocksource_cyc2ns(max_cycles, cc->mult, cc->shift);
+	priv->work_delay_jiffies = div_u64(work_delay_ns, 3u * NSEC_PER_SEC / HZ);
 	INIT_DELAYED_WORK(&priv->timestamp, rkcanfd_timestamp_work);
 
 	netdev_dbg(priv->ndev, "clock=%lu.%02luMHz bitrate=%lu.%02luMBit/s div=%u rate=%lu.%02luMHz mult=%u shift=%u delay=%lus\n",
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-09 11:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 11:21 [PATCH] can: rockchip_canfd: avoids 64-bit division Arnd Bergmann
2024-09-09  9:44 ` Marc Kleine-Budde

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).