RISC-V: Remove udivdi3
PATCH 1/1 RISC-V: Remove udivdi3
This should never have landed in the first place: it was added as part of 64-bit divide support for 32-bit systems, but the kernel doesn't allow this sort of division. I must have forgotten to remove it.
This patch removes the support. Since this routine only worked on 64-bit platforms but was only built on 32-bit platforms, it's essentially just nonsense anyway.
--- arch/riscv/lib/Makefile | 2 -- arch/riscv/lib/udivdi3.S | 32 -------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 arch/riscv/lib/udivdi3.S
arch/riscv/lib/Makefile +0 -2
@@ -5,5 +5,3 @@ lib-y += memset.o lib-y += uaccess.o lib-$(CONFIG_64BIT) += tishift.o - -lib-$(CONFIG_32BIT) += udivdi3.o
arch/riscv/lib/udivdi3.S deleted +0 -32
@@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) 2016-2017 Free Software Foundation, Inc. - */ - -#include <linux/linkage.h> - -ENTRY(__udivdi3) - mv a2, a1 - mv a1, a0 - li a0, -1 - beqz a2, .L5 - li a3, 1 - bgeu a2, a1, .L2 -.L1: - blez a2, .L2 - slli a2, a2, 1 - slli a3, a3, 1 - bgtu a1, a2, .L1 -.L2: - li a0, 0 -.L3: - bltu a1, a2, .L4 - sub a1, a1, a2 - or a0, a0, a3 -.L4: - srli a3, a3, 1 - srli a2, a2, 1 - bnez a3, .L3 -.L5: - ret -ENDPROC(__udivdi3)
Signature · 7 lines
2.21.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 8 lines · Palmer Dabbelt
This should never have landed in the first place: it was added as part of 64-bit divide support for 32-bit systems, but the kernel doesn't allow this sort of division. I must have forgotten to remove it.
This patch removes the support. Since this routine only worked on 64-bit platforms but was only built on 32-bit platforms, it's essentially just nonsense anyway.
It would be more complete if we add "Reported-by: Eric Lin <[email protected]>" here.
Quoted 64 lines
Signed-off-by Palmer Dabbelt <[email protected]>Acked-by Nicolas Pitre <[email protected]>--- arch/riscv/lib/Makefile | 2 -- arch/riscv/lib/udivdi3.S | 32 -------------------------------- 2 files changed, 34 deletions(-) delete mode 100644 arch/riscv/lib/udivdi3.Sarch/riscv/lib/Makefile +0
-2@@ -5,5 +5,3 @@ lib-y += memset.o lib-y += uaccess.o lib-$(CONFIG_64BIT) += tishift.o - -lib-$(CONFIG_32BIT) += udivdi3.oarch/riscv/lib/udivdi3.S deleted +0
-32@@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (C) 2016-2017 Free Software Foundation, Inc. - */ - -#include <linux/linkage.h> - -ENTRY(__udivdi3) - mv a2, a1 - mv a1, a0 - li a0, -1 - beqz a2, .L5 - li a3, 1 - bgeu a2, a1, .L2 -.L1: - blez a2, .L2 - slli a2, a2, 1 - slli a3, a3, 1 - bgtu a1, a2, .L1 -.L2: - li a0, 0 -.L3: - bltu a1, a2, .L4 - sub a1, a1, a2 - or a0, a0, a3 -.L4: - srli a3, a3, 1 - srli a2, a2, 1 - bnez a3, .L3 -.L5: - ret -ENDPROC(__udivdi3)Signature · 7 lines
2.21.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 5 lines · Alan Kao
Quoted 4 lines · Palmer Dabbelt
This should never have landed in the first place: it was added as part of 64-bit divide support for 32-bit systems, but the kernel doesn't allow this sort of division. I must have forgotten to remove it.
Quoted 10 lines
Quoted 4 lines
This patch removes the support. Since this routine only worked on 64-bit platforms but was only built on 32-bit platforms, it's essentially just nonsense anyway.
It would be more complete if we add "Reported-by: Eric Lin <[email protected]>" here.
Quoted 2 lines
Signed-off-by Palmer Dabbelt <[email protected]>Acked-by Nicolas Pitre <[email protected]>
Thanks, queued for v5.3-rc with Eric's Reported-by.
- Paul
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 12 lines · Paul Walmsley
Quoted 10 lines · Alan Kao
Quoted 8 lines · Palmer Dabbelt
This should never have landed in the first place: it was added as part of 64-bit divide support for 32-bit systems, but the kernel doesn't allow this sort of division. I must have forgotten to remove it.
This patch removes the support. Since this routine only worked on 64-bit platforms but was only built on 32-bit platforms, it's essentially just nonsense anyway.
Quoted 7 lines
Quoted 5 lines
It would be more complete if we add "Reported-by: Eric Lin <[email protected]>" here.
Quoted 2 lines
Signed-off-by Palmer Dabbelt <[email protected]>Acked-by Nicolas Pitre <[email protected]>Thanks, queued for v5.3-rc with Eric's Reported-by.
This patch breaks the rv32_defconfig build, since udelay() still relies on __udivdi3(). I'll queue "riscv: delay: use do_div() instead of __udivdi3()" along with it:
https://lore.kernel.org/linux-riscv/[email protected]/T/#u
- Paul
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Review
Quoted 13 lines · Paul Walmsley
This patch breaks the
rv32_defconfigbuild, sinceudelay()still relies on__udivdi3(). I'll queue "riscv: delay: usedo_div()instead of__udivdi3()" along with it:https://lore.kernel.org/linux-riscv/[email protected]/T/#u
(quoted diff) +4
-1+ u64 n; + u32 rem; if (unlikely(usecs > MAX_UDELAY_US)) { - __delay((u64)usecs * riscv_timebase / 1000000ULL); + n = (u64)usecs * riscv_timebase; + rem = do_div(n, 1000000);
You may omit rem and ignore the return value here.
Nicolas
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 11 lines · Nicolas Pitre
Quoted 9 lines · Paul Walmsley
This patch breaks the
rv32_defconfigbuild, sinceudelay()still relies on__udivdi3(). I'll queue "riscv: delay: usedo_div()instead of__udivdi3()" along with it:https://lore.kernel.org/linux-riscv/[email protected]/T/#u
(quoted diff) +2
-0+ u64 n; + u32 rem;
Quoted 6 lines
Review
Quoted 4 lines
if (unlikely(usecs > MAX_UDELAY_US)) {(quoted diff) +2
-1- __delay((u64)usecs * riscv_timebase / 1000000ULL); + n = (u64)usecs * riscv_timebase; + rem = do_div(n, 1000000);You may omit rem and ignore the return value here.
Thanks Nico. Updated patch below
- Paul
From: Paul Walmsley <[email protected]>
Date: Tue, 6 Aug 2019 18:28:33 -0700
Subject: [PATCH] riscv: delay: use do_div() instead of __udivdi3()
In preparation for removing __udivdi3() from the RISC-V architecture-specific files, convert its one user to use do_div(). This avoids breaking the RV32 build after __udivdi3() is removed.
This second version removes the assignment of the remainder to an unused temporary variable. Thanks to Nicolas Pitre <[email protected]> for the suggestion.
--- arch/riscv/lib/delay.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/lib/delay.c +5 -1
@@ -81,9 +81,13 @@ EXPORT_SYMBOL(__delay);void udelay (unsigned long usecs) {u64 ucycles = (u64 )usecs * lpj_fine *UDELAY_MULT ; +u64 n;if (unlikely (usecs >MAX_UDELAY_US )) { -__delay ((u64 )usecs * riscv_timebase /1000000ULL ); + n = (u64 )usecs * riscv_timebase; +do_div (n,1000000 ); + +__delay (n);return ; }
Signature · 7 lines
2.22.0 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv