Message ID | 20190807000508.9477-1-palmer@sifive.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | RISC-V: Remove udivdi3 | expand |
On Tue, Aug 06, 2019 at 05:05:08PM -0700, Palmer Dabbelt wrote: > 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 <tesheng@andestech.com>" here. > Signed-off-by: Palmer Dabbelt <palmer@sifive.com> > Acked-by: Nicolas Pitre <nico@fluxnic.net> > --- > arch/riscv/lib/Makefile | 2 -- > arch/riscv/lib/udivdi3.S | 32 -------------------------------- > 2 files changed, 34 deletions(-) > delete mode 100644 arch/riscv/lib/udivdi3.S > > diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile > index 8e364ebf37de..267feaa10f6a 100644 > --- a/arch/riscv/lib/Makefile > +++ b/arch/riscv/lib/Makefile > @@ -5,5 +5,3 @@ lib-y += memset.o > lib-y += uaccess.o > > lib-$(CONFIG_64BIT) += tishift.o > - > -lib-$(CONFIG_32BIT) += udivdi3.o > diff --git a/arch/riscv/lib/udivdi3.S b/arch/riscv/lib/udivdi3.S > deleted file mode 100644 > index 3f07476a91a9..000000000000 > --- a/arch/riscv/lib/udivdi3.S > +++ /dev/null > @@ -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) > -- > 2.21.0 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
On Wed, 7 Aug 2019, Alan Kao wrote: > On Tue, Aug 06, 2019 at 05:05:08PM -0700, Palmer Dabbelt wrote: > > 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 <tesheng@andestech.com>" here. > > > Signed-off-by: Palmer Dabbelt <palmer@sifive.com> > > Acked-by: Nicolas Pitre <nico@fluxnic.net> Thanks, queued for v5.3-rc with Eric's Reported-by. - Paul
On Tue, 6 Aug 2019, Paul Walmsley wrote: > On Wed, 7 Aug 2019, Alan Kao wrote: > > > On Tue, Aug 06, 2019 at 05:05:08PM -0700, Palmer Dabbelt wrote: > > > 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 <tesheng@andestech.com>" here. > > > > > Signed-off-by: Palmer Dabbelt <palmer@sifive.com> > > > Acked-by: Nicolas Pitre <nico@fluxnic.net> > > 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/alpine.DEB.2.21.9999.1908061906240.25231@viisi.sifive.com/T/#u - Paul
On Tue, 6 Aug 2019, Paul Walmsley wrote: > 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/alpine.DEB.2.21.9999.1908061906240.25231@viisi.sifive.com/T/#u > + 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
On Tue, 6 Aug 2019, Nicolas Pitre wrote: > On Tue, 6 Aug 2019, Paul Walmsley wrote: > > > 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/alpine.DEB.2.21.9999.1908061906240.25231@viisi.sifive.com/T/#u > > > + 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. Thanks Nico. Updated patch below - Paul From: Paul Walmsley <paul.walmsley@sifive.com> 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 <nico@fluxnic.net> for the suggestion. Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com> Cc: Nicolas Pitre <nico@fluxnic.net> --- arch/riscv/lib/delay.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/riscv/lib/delay.c b/arch/riscv/lib/delay.c index 87ff89e88f2c..f51c9a03bca1 100644 --- a/arch/riscv/lib/delay.c +++ b/arch/riscv/lib/delay.c @@ -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; }
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index 8e364ebf37de..267feaa10f6a 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -5,5 +5,3 @@ lib-y += memset.o lib-y += uaccess.o lib-$(CONFIG_64BIT) += tishift.o - -lib-$(CONFIG_32BIT) += udivdi3.o diff --git a/arch/riscv/lib/udivdi3.S b/arch/riscv/lib/udivdi3.S deleted file mode 100644 index 3f07476a91a9..000000000000 --- a/arch/riscv/lib/udivdi3.S +++ /dev/null @@ -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)