From: Vijay Kumar <vijay.ac.kumar@oracle.com>
To: davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org,
babu.moger@oracle.com, rob.gardner@oracle.com
Subject: [PATCH v2 2/2] sparc64: Use lzcnt instruction for fls and __fls
Date: Wed, 27 Sep 2017 13:25:26 -0600 [thread overview]
Message-ID: <1506540326-9604-3-git-send-email-vijay.ac.kumar@oracle.com> (raw)
In-Reply-To: <1506540326-9604-1-git-send-email-vijay.ac.kumar@oracle.com>
For T4 and above, patch fls and __fls functions
at the boot time to use lzcnt instruction.
Signed-off-by: Vijay Kumar <vijay.ac.kumar@oracle.com>
Reviewed-by: Babu Moger <babu.moger@oracle.com>
---
arch/sparc/Makefile | 1 +
arch/sparc/kernel/head_64.S | 2 ++
arch/sparc/lib/Makefile | 3 +++
arch/sparc/lib/NG4fls.S | 30 ++++++++++++++++++++++++++++++
arch/sparc/lib/NG4patch.S | 9 +++++++++
5 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index 8496a07..0763cd8 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -48,6 +48,7 @@ KBUILD_CFLAGS += -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare
KBUILD_CFLAGS += -Wa,--undeclared-regs
KBUILD_CFLAGS += $(call cc-option,-mtune=ultrasparc3)
KBUILD_AFLAGS += -m64 -mcpu=ultrasparc -Wa,--undeclared-regs
+KBUILD_AFLAGS += -Wa,-Asparc4
ifeq ($(CONFIG_MCOUNT),y)
KBUILD_CFLAGS += -pg
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
index 78e0211..1165254 100644
--- a/arch/sparc/kernel/head_64.S
+++ b/arch/sparc/kernel/head_64.S
@@ -628,6 +628,8 @@ niagara4_patch:
nop
call niagara4_patch_pageops
nop
+ call niagara4_patch_fls
+ nop
ba,a,pt %xcc, 80f
nop
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index eefbb9c..72d2d8c 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -46,3 +46,6 @@ lib-$(CONFIG_SPARC64) += mcount.o ipcsum.o xor.o hweight.o ffs.o
obj-$(CONFIG_SPARC64) += iomap.o
obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
obj-$(CONFIG_SPARC64) += PeeCeeI.o
+
+obj-$(CONFIG_SPARC64) += fls.o
+obj-$(CONFIG_SPARC64) += NG4fls.o
diff --git a/arch/sparc/lib/NG4fls.S b/arch/sparc/lib/NG4fls.S
new file mode 100644
index 0000000..eb239aa
--- /dev/null
+++ b/arch/sparc/lib/NG4fls.S
@@ -0,0 +1,30 @@
+/* NG4fls.S: SPARC optimized fls and __fls for T4 and above.
+ *
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ */
+
+ .text
+ .align 32
+
+ .globl NG4fls
+ .globl __NG4fls
+ .type NG4fls, #function
+ .type __NG4fls, #function
+
+NG4fls:
+ lzcnt %o0, %o1
+ mov 64, %o2
+ retl
+ sub %o2, %o1, %o0
+ .size NG4fls, .-NG4fls
+
+__NG4fls:
+ brz,pn %o0, 1f
+ mov %o0, %o1
+ lzcnt %o1, %o0
+ mov 63, %o2
+ sub %o2, %o0, %o0
+1:
+ retl
+ nop
+ .size __NG4fls, .-__NG4fls
diff --git a/arch/sparc/lib/NG4patch.S b/arch/sparc/lib/NG4patch.S
index 3cc0f8c..1010d53 100644
--- a/arch/sparc/lib/NG4patch.S
+++ b/arch/sparc/lib/NG4patch.S
@@ -52,3 +52,12 @@ niagara4_patch_pageops:
retl
nop
.size niagara4_patch_pageops,.-niagara4_patch_pageops
+
+ .globl niagara4_patch_fls
+ .type niagara4_patch_fls,#function
+niagara4_patch_fls:
+ NG_DO_PATCH(fls, NG4fls)
+ NG_DO_PATCH(__fls, __NG4fls)
+ retl
+ nop
+ .size niagara4_patch_fls,.-niagara4_patch_fls
--
1.7.1
next prev parent reply other threads:[~2017-09-27 19:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-27 19:25 [PATCH v2 0/2] sparc64: Optimize fls, fls64 " Vijay Kumar
2017-09-27 19:25 ` [PATCH v2 1/2] sparc64: Define SPARC default fls " Vijay Kumar
2017-09-27 19:50 ` Sam Ravnborg
2017-09-27 19:59 ` Sam Ravnborg
2017-09-27 19:25 ` Vijay Kumar [this message]
2017-09-27 19:56 ` [PATCH v2 2/2] sparc64: Use lzcnt instruction for " Sam Ravnborg
2017-09-27 20:29 ` Vijay Kumar
2017-09-27 21:02 ` David Miller
2017-09-27 21:45 ` Anthony Yznaga
2017-09-27 22:10 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1506540326-9604-3-git-send-email-vijay.ac.kumar@oracle.com \
--to=vijay.ac.kumar@oracle.com \
--cc=babu.moger@oracle.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=rob.gardner@oracle.com \
--cc=sparclinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome