Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a16036e9 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'sparc64-optimized-fls'



Vijay Kumar says:

====================
sparc64: Optimize fls and __fls

SPARC provides lzcnt instruction (with VIS3) which can be used to
optimize fls, __fls and fls64 functions. For the systems that supports
lzcnt instruction, we now do boot time patching to use sparc
optimized fls, __fls and fls64 functions.

v3->v4:
 -  Fixed a typo.
v2->v3:
 -  Using ENTRY(), ENDPROC() for assembler functions.
 -  Removed BITS_PER_LONG from __fls.
 -  Using generic fls64().
 -  Replaced lzcnt instruction with .word directive.
v1->v2:
 - Fixed delay slot issue.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 9a08862a 46ad8d2d
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -22,10 +22,11 @@ void set_bit(unsigned long nr, volatile unsigned long *addr);
void clear_bit(unsigned long nr, volatile unsigned long *addr);
void clear_bit(unsigned long nr, volatile unsigned long *addr);
void change_bit(unsigned long nr, volatile unsigned long *addr);
void change_bit(unsigned long nr, volatile unsigned long *addr);


int fls(unsigned int word);
int __fls(unsigned long word);

#include <asm-generic/bitops/non-atomic.h>
#include <asm-generic/bitops/non-atomic.h>


#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/fls64.h>


#ifdef __KERNEL__
#ifdef __KERNEL__
+2 −0
Original line number Original line Diff line number Diff line
@@ -640,6 +640,8 @@ niagara4_patch:
	 nop
	 nop
	call	niagara4_patch_pageops
	call	niagara4_patch_pageops
	 nop
	 nop
	call	niagara4_patch_fls
	 nop


	ba,a,pt	%xcc, 80f
	ba,a,pt	%xcc, 80f
	 nop
	 nop
+3 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,9 @@ lib-$(CONFIG_SPARC64) += atomic_64.o
lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o
lib-$(CONFIG_SPARC32) += lshrdi3.o ashldi3.o
lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o
lib-$(CONFIG_SPARC32) += muldi3.o bitext.o cmpdi2.o
lib-$(CONFIG_SPARC64) += multi3.o
lib-$(CONFIG_SPARC64) += multi3.o
lib-$(CONFIG_SPARC64) += fls.o
lib-$(CONFIG_SPARC64) += fls64.o
obj-$(CONFIG_SPARC64) += NG4fls.o


lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o
lib-$(CONFIG_SPARC64) += copy_page.o clear_page.o bzero.o
lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o
lib-$(CONFIG_SPARC64) += csum_copy.o csum_copy_from_user.o csum_copy_to_user.o
+30 −0
Original line number Original line Diff line number Diff line
/* NG4fls.S: SPARC optimized fls and __fls for T4 and above.
 *
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
 */

#include <linux/linkage.h>

#define LZCNT_O0_G2	\
	.word	0x85b002e8

	.text
	.register	%g2, #scratch
	.register	%g3, #scratch

ENTRY(NG4fls)
	LZCNT_O0_G2	!lzcnt	%o0, %g2
	mov	64, %g3
	retl
	 sub	%g3, %g2, %o0
ENDPROC(NG4fls)

ENTRY(__NG4fls)
	brz,pn	%o0, 1f
	LZCNT_O0_G2	!lzcnt	%o0, %g2
	mov	63, %g3
	sub	%g3, %g2, %o0
1:
	retl
	 nop
ENDPROC(__NG4fls)
+9 −0
Original line number Original line Diff line number Diff line
@@ -3,6 +3,8 @@
 * Copyright (C) 2012 David S. Miller <davem@davemloft.net>
 * Copyright (C) 2012 David S. Miller <davem@davemloft.net>
 */
 */


#include <linux/linkage.h>

#define BRANCH_ALWAYS	0x10680000
#define BRANCH_ALWAYS	0x10680000
#define NOP		0x01000000
#define NOP		0x01000000
#define NG_DO_PATCH(OLD, NEW)	\
#define NG_DO_PATCH(OLD, NEW)	\
@@ -52,3 +54,10 @@ niagara4_patch_pageops:
	retl
	retl
	 nop
	 nop
	.size	niagara4_patch_pageops,.-niagara4_patch_pageops
	.size	niagara4_patch_pageops,.-niagara4_patch_pageops

ENTRY(niagara4_patch_fls)
	NG_DO_PATCH(fls, NG4fls)
	NG_DO_PATCH(__fls, __NG4fls)
	retl
	 nop
ENDPROC(niagara4_patch_fls)
Loading