All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-arm-kernel@lists.infradead.org
Cc: catalin.marinas@arm.com, will@kernel.org,
	Ard Biesheuvel <ardb@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: [PATCH 1/2] arm64/xor: use static calls for inner NEON helpers
Date: Tue,  9 Nov 2021 13:03:35 +0100	[thread overview]
Message-ID: <20211109120336.3561463-2-ardb@kernel.org> (raw)
In-Reply-To: <20211109120336.3561463-1-ardb@kernel.org>

Call the inner NEON helpers using static calls rather than loading
their addresses from a struct. This will be used in a subsequent patch
to switch between NEON and SHA3 based implementations of the XOR code.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm64/include/asm/xor.h | 24 ++++++++++++++++----
 arch/arm64/lib/xor-neon.c    | 20 +++++++++-------
 2 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/arch/arm64/include/asm/xor.h b/arch/arm64/include/asm/xor.h
index 947f6a4f1aa0..f52dbb05b4b1 100644
--- a/arch/arm64/include/asm/xor.h
+++ b/arch/arm64/include/asm/xor.h
@@ -7,19 +7,33 @@
  */
 
 #include <linux/hardirq.h>
+#include <linux/static_call.h>
 #include <asm-generic/xor.h>
 #include <asm/hwcap.h>
 #include <asm/neon.h>
 
 #ifdef CONFIG_KERNEL_MODE_NEON
 
-extern struct xor_block_template const xor_block_inner_neon;
+void xor_arm64_neon_2(unsigned long bytes, unsigned long *p1,
+		      unsigned long *p2);
+void xor_arm64_neon_3(unsigned long bytes, unsigned long *p1,
+		      unsigned long *p2, unsigned long *p3);
+void xor_arm64_neon_4(unsigned long bytes, unsigned long *p1,
+		      unsigned long *p2, unsigned long *p3,
+		      unsigned long *p4);
+void xor_arm64_neon_5(unsigned long bytes, unsigned long *p1,
+		      unsigned long *p2, unsigned long *p3,
+		      unsigned long *p4, unsigned long *p5);
+
+DECLARE_STATIC_CALL(xor_arm64_3, xor_arm64_neon_3);
+DECLARE_STATIC_CALL(xor_arm64_4, xor_arm64_neon_4);
+DECLARE_STATIC_CALL(xor_arm64_5, xor_arm64_neon_5);
 
 static void
 xor_neon_2(unsigned long bytes, unsigned long *p1, unsigned long *p2)
 {
 	kernel_neon_begin();
-	xor_block_inner_neon.do_2(bytes, p1, p2);
+	xor_arm64_neon_2(bytes, p1, p2);
 	kernel_neon_end();
 }
 
@@ -28,7 +42,7 @@ xor_neon_3(unsigned long bytes, unsigned long *p1, unsigned long *p2,
 		unsigned long *p3)
 {
 	kernel_neon_begin();
-	xor_block_inner_neon.do_3(bytes, p1, p2, p3);
+	static_call(xor_arm64_3)(bytes, p1, p2, p3);
 	kernel_neon_end();
 }
 
@@ -37,7 +51,7 @@ xor_neon_4(unsigned long bytes, unsigned long *p1, unsigned long *p2,
 		unsigned long *p3, unsigned long *p4)
 {
 	kernel_neon_begin();
-	xor_block_inner_neon.do_4(bytes, p1, p2, p3, p4);
+	static_call(xor_arm64_4)(bytes, p1, p2, p3, p4);
 	kernel_neon_end();
 }
 
@@ -46,7 +60,7 @@ xor_neon_5(unsigned long bytes, unsigned long *p1, unsigned long *p2,
 		unsigned long *p3, unsigned long *p4, unsigned long *p5)
 {
 	kernel_neon_begin();
-	xor_block_inner_neon.do_5(bytes, p1, p2, p3, p4, p5);
+	static_call(xor_arm64_5)(bytes, p1, p2, p3, p4, p5);
 	kernel_neon_end();
 }
 
diff --git a/arch/arm64/lib/xor-neon.c b/arch/arm64/lib/xor-neon.c
index 11bf4f8aca68..ee4795f3e166 100644
--- a/arch/arm64/lib/xor-neon.c
+++ b/arch/arm64/lib/xor-neon.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/raid/xor.h>
+#include <linux/static_call.h>
 #include <linux/module.h>
 #include <asm/neon-intrinsics.h>
 
@@ -36,6 +37,7 @@ void xor_arm64_neon_2(unsigned long bytes, unsigned long *p1,
 		dp2 += 8;
 	} while (--lines > 0);
 }
+EXPORT_SYMBOL(xor_arm64_neon_2);
 
 void xor_arm64_neon_3(unsigned long bytes, unsigned long *p1,
 	unsigned long *p2, unsigned long *p3)
@@ -71,6 +73,7 @@ void xor_arm64_neon_3(unsigned long bytes, unsigned long *p1,
 		dp3 += 8;
 	} while (--lines > 0);
 }
+EXPORT_SYMBOL(xor_arm64_neon_3);
 
 void xor_arm64_neon_4(unsigned long bytes, unsigned long *p1,
 	unsigned long *p2, unsigned long *p3, unsigned long *p4)
@@ -114,6 +117,7 @@ void xor_arm64_neon_4(unsigned long bytes, unsigned long *p1,
 		dp4 += 8;
 	} while (--lines > 0);
 }
+EXPORT_SYMBOL(xor_arm64_neon_4);
 
 void xor_arm64_neon_5(unsigned long bytes, unsigned long *p1,
 	unsigned long *p2, unsigned long *p3,
@@ -166,15 +170,15 @@ void xor_arm64_neon_5(unsigned long bytes, unsigned long *p1,
 		dp5 += 8;
 	} while (--lines > 0);
 }
+EXPORT_SYMBOL(xor_arm64_neon_5);
 
-struct xor_block_template const xor_block_inner_neon = {
-	.name	= "__inner_neon__",
-	.do_2	= xor_arm64_neon_2,
-	.do_3	= xor_arm64_neon_3,
-	.do_4	= xor_arm64_neon_4,
-	.do_5	= xor_arm64_neon_5,
-};
-EXPORT_SYMBOL(xor_block_inner_neon);
+DEFINE_STATIC_CALL(xor_arm64_3, xor_arm64_neon_3);
+DEFINE_STATIC_CALL(xor_arm64_4, xor_arm64_neon_4);
+DEFINE_STATIC_CALL(xor_arm64_5, xor_arm64_neon_5);
+
+EXPORT_STATIC_CALL(xor_arm64_3);
+EXPORT_STATIC_CALL(xor_arm64_4);
+EXPORT_STATIC_CALL(xor_arm64_5);
 
 MODULE_AUTHOR("Jackie Liu <liuyun01@kylinos.cn>");
 MODULE_DESCRIPTION("ARMv8 XOR Extensions");
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-11-09 12:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09 12:03 [PATCH 0/2] arm64: use SHA3 instructions to speed up XOR Ard Biesheuvel
2021-11-09 12:03 ` Ard Biesheuvel [this message]
2021-11-09 12:03 ` [PATCH 2/2] arm64/xor: use EOR3 instructions when available Ard Biesheuvel
2021-12-13 13:24   ` Catalin Marinas
2021-12-13 13:33     ` Ard Biesheuvel
2021-12-13 15:05       ` Catalin Marinas
2021-12-13 15:10         ` Ard Biesheuvel

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=20211109120336.3561463-2-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=peterz@infradead.org \
    --cc=will@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.