linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: add simd.h implementation specific to PowerPC
@ 2019-05-12 16:50 Shawn Landden
  2019-05-13  0:51 ` [PATCH RESEND] " Shawn Landden
  0 siblings, 1 reply; 24+ messages in thread
From: Shawn Landden @ 2019-05-12 16:50 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman
  Cc: Shawn Landden, linuxppc-dev, linux-kernel

It is safe to do SIMD in an interrupt on PowerPC.
Only disable when there is no SIMD available
(and this is a static branch).

Tested and works with the WireGuard (Zinc) patch I wrote that needs this.
Also improves performance of the crypto subsystem that checks this.

Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=203571
Signed-off-by: Shawn Landden <shawn@git.icu>
---
 arch/powerpc/include/asm/simd.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 arch/powerpc/include/asm/simd.h

diff --git a/arch/powerpc/include/asm/simd.h b/arch/powerpc/include/asm/simd.h
new file mode 100644
index 000000000..b3fecb95a
--- /dev/null
+++ b/arch/powerpc/include/asm/simd.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#include <asm/cpu_has_feature.h>
+
+/*
+ * may_use_simd - whether it is allowable at this time to issue SIMD
+ *                instructions or access the SIMD register file
+ *
+ * As documented in Chapter 6.2.1 Machine Status Save/Restore Registers
+ * of Power ISA (2.07 and 3.0), all registers are saved/restored in an interrupt.
+ */
+static inline bool may_use_simd(void)
+{
+	return !cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE);
+}
-- 
2.21.0.1020.gf2820cf01a


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2019-05-18 16:07 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-12 16:50 [PATCH] powerpc: add simd.h implementation specific to PowerPC Shawn Landden
2019-05-13  0:51 ` [PATCH RESEND] " Shawn Landden
2019-05-13 11:53   ` Michael Ellerman
2019-05-14  1:44   ` [PATCH 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-14  1:44     ` [PATCH 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-14  5:43     ` [PATCH 1/2] [PowerPC] Add simd.h implementation Benjamin Herrenschmidt
2019-05-14 15:44       ` Shawn Landden
2019-05-14 15:46     ` [v3 " Shawn Landden
2019-05-14 15:46       ` [v3 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-15  1:03         ` kbuild test robot
2019-05-14  2:23   ` [v2 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-14  2:23     ` [v2 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-14  7:22       ` Russell Currey
2019-05-14 15:35         ` Shawn Landden
2019-05-14 12:49   ` [PATCH] powerpc: Allow may_use_simd() to function as feature detection Shawn Landden
2019-05-14 18:06     ` Segher Boessenkool
2019-05-14 19:00       ` Shawn Landden
2019-05-15  1:36   ` [PATCH 1/2] [PowerPC] Add simd.h implementation Shawn Landden
2019-05-15  1:37   ` [v4 PATCH " Shawn Landden
2019-05-15  1:37     ` [v4 PATCH 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden
2019-05-15  6:27     ` [v4 PATCH 1/2] [PowerPC] Add simd.h implementation Christophe Leroy
2019-05-16  1:12       ` Shawn Landden
2019-05-18 16:04     ` [RESEND v4 " Shawn Landden
2019-05-18 16:04       ` [RESEND v4 PATCH 2/2] [PowerPC] Allow use of SIMD in interrupts from kernel code Shawn Landden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).