android_kernel_xiaomi_sm7250/arch
Maciej W. Rozycki a5e67c081d MIPS: Avoid handcoded DIVU in `__div64_32' altogether
commit 25ab14cbe9d1b66fda44c71a2db7582a31b6f5cd upstream.

Remove the inline asm with a DIVU instruction from `__div64_32' and use
plain C code for the intended DIVMOD calculation instead.  GCC is smart
enough to know that both the quotient and the remainder are calculated
with single DIVU, so with ISAs up to R5 the same instruction is actually
produced with overall similar code.

For R6 compiled code will work, but separate DIVU and MODU instructions
will be produced, which are also interlocked, so scalar implementations
will likely not perform as well as older ISAs with their asynchronous MD
unit.  Likely still faster then the generic algorithm though.

This removes a compilation error for R6 however where the original DIVU
instruction is not supported anymore and the MDU accumulator registers
have been removed and consequently GCC complains as to a constraint it
cannot find a register for:

In file included from ./include/linux/math.h:5,
                 from ./include/linux/kernel.h:13,
                 from mm/page-writeback.c:15:
./include/linux/math64.h: In function 'div_u64_rem':
./arch/mips/include/asm/div64.h:76:17: error: inconsistent operand constraints in an 'asm'
   76 |                 __asm__("divu   $0, %z1, %z2"                           \
      |                 ^~~~~~~
./include/asm-generic/div64.h:245:25: note: in expansion of macro '__div64_32'
  245 |                 __rem = __div64_32(&(n), __base);       \
      |                         ^~~~~~~~~~
./include/linux/math64.h:91:22: note: in expansion of macro 'do_div'
   91 |         *remainder = do_div(dividend, divisor);
      |                      ^~~~~~

This has passed correctness verification with test_div64 and reduced the
module's average execution time down to 1.0404s from 1.0445s with R3400
@40MHz.  The module's MIPS I machine code has also shrunk by 12 bytes or
3 instructions.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-05-22 10:59:47 +02:00
..
alpha alpha: fix annotation of io{read,write}{16,32}be() 2020-08-26 10:31:02 +02:00
arc ARC: entry: fix off-by-one error in syscall number validation 2021-05-22 10:59:45 +02:00
arm ARM: 9064/1: hw_breakpoint: Do not directly check the event's overflow_handler hook 2021-05-22 10:59:42 +02:00
arm64 arm64: dts: uniphier: Change phy-mode to RGMII-ID to enable delay pins for RTL8211E 2021-05-22 10:59:38 +02:00
c6x
h8300 h8300: fix PREEMPTION build, TI_PRE_COUNT undefined 2021-02-23 15:00:58 +01:00
hexagon hexagon: define ioremap_uc 2020-05-10 10:30:11 +02:00
ia64 ia64: module: fix symbolizer crash on fdescr 2021-05-22 10:59:42 +02:00
m68k m68k: q40: Fix info-leak in rtc_ioctl 2020-10-01 13:14:24 +02:00
microblaze
mips MIPS: Avoid handcoded DIVU in `__div64_32' altogether 2021-05-22 10:59:47 +02:00
nds32 nds32: flush_dcache_page: use page_mapping_file to avoid races with swapoff 2021-04-14 08:22:32 +02:00
nios2
openrisc openrisc: Fix cache API compile issue when not inlining 2020-09-23 12:10:58 +02:00
parisc parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers 2021-04-14 08:22:33 +02:00
powerpc powerpc/64s: Fix crashes when toggling entry flush barrier 2021-05-22 10:59:45 +02:00
riscv riscv,entry: fix misaligned base for excp_vect_table 2021-04-16 11:49:30 +02:00
s390 KVM: s390: split kvm_s390_real_to_abs 2021-05-22 10:59:26 +02:00
sh sh: dma: fix kconfig dependency for G2_DMA 2021-01-27 11:05:42 +01:00
sparc sparc64: Fix opcode filtering in handling of no fault loads 2021-03-30 14:36:58 +02:00
um block: genhd: add 'groups' argument to device_add_disk 2021-03-11 14:04:59 +01:00
unicore32
x86 KVM: x86: Cancel pvclock_gtod_work on module removal 2021-05-22 10:59:47 +02:00
xtensa xtensa: uaccess: Add missing __user to strncpy_from_user() prototype 2020-12-02 08:48:10 +01:00
.gitignore
Kconfig mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race 2020-11-05 11:08:38 +01:00