ARM: 9268/1: vfp: Add hwcap FPHP and ASIMDHP for FEAT_FP16
authorAmit Daniel Kachhap <amit.kachhap@arm.com>
Thu, 17 Nov 2022 05:28:22 +0000 (06:28 +0100)
committerRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 28 Nov 2022 11:57:32 +0000 (11:57 +0000)
Floating point half-precision (FPHP) and Advanced SIMD half-precision
(ASIMDHP) are VFP features (FEAT_FP16) represented by MVFR1 identification register. These capabilities can optionally exist with VFPv3 and mandatory with VFPv4. Both these new features exist for Armv8 architecture in AArch32 state.

These hwcaps may be useful for the userspace to add conditional check
before trying to use FEAT_FP16 feature specific instructions.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
arch/arm/include/asm/vfp.h
arch/arm/include/uapi/asm/hwcap.h
arch/arm/kernel/setup.c
arch/arm/vfp/vfpmodule.c

index 19928bfb4f9cdb729885e829b175e1527a1dd0d1..157ea34261586d136ab574cf4f4bed8e3148dfb1 100644 (file)
 #define MVFR0_DP_BIT           (8)
 #define MVFR0_DP_MASK          (0xf << MVFR0_DP_BIT)
 
+/* MVFR1 bits */
+#define MVFR1_ASIMDHP_BIT      (20)
+#define MVFR1_ASIMDHP_MASK     (0xf << MVFR1_ASIMDHP_BIT)
+#define MVFR1_FPHP_BIT         (24)
+#define MVFR1_FPHP_MASK                (0xf << MVFR1_FPHP_BIT)
+
 /* Bit patterns for decoding the packaged operation descriptors */
 #define VFPOPDESC_LENGTH_BIT   (9)
 #define VFPOPDESC_LENGTH_MASK  (0x07 << VFPOPDESC_LENGTH_BIT)
index 990199d8b7c670333946837c10d679e9b12a6543..8b6f690f0ac492cd5c5792029633274a97cae698 100644 (file)
@@ -28,6 +28,8 @@
 #define HWCAP_IDIV     (HWCAP_IDIVA | HWCAP_IDIVT)
 #define HWCAP_LPAE     (1 << 20)
 #define HWCAP_EVTSTRM  (1 << 21)
+#define HWCAP_FPHP     (1 << 22)
+#define HWCAP_ASIMDHP  (1 << 23)
 
 /*
  * HWCAP2 flags - for elf_hwcap2 (in kernel) and AT_HWCAP2
index 1e8a50a97edf2e49dc2075b5b119a5d561010b86..870e5d5c5b5bf7a817f5c781402a5ca379352fc5 100644 (file)
@@ -1249,6 +1249,8 @@ static const char *hwcap_str[] = {
        "vfpd32",
        "lpae",
        "evtstrm",
+       "fphp",
+       "asimdhp",
        NULL
 };
 
index 2cb355c1b5b71694082caa306465996efa96e532..55dcd96c7e3b522b65b5cfe574dfc2cb6a1d3f2b 100644 (file)
@@ -831,6 +831,10 @@ static int __init vfp_init(void)
 
                        if ((fmrx(MVFR1) & 0xf0000000) == 0x10000000)
                                elf_hwcap |= HWCAP_VFPv4;
+                       if (((fmrx(MVFR1) & MVFR1_ASIMDHP_MASK) >> MVFR1_ASIMDHP_BIT) == 0x2)
+                               elf_hwcap |= HWCAP_ASIMDHP;
+                       if (((fmrx(MVFR1) & MVFR1_FPHP_MASK) >> MVFR1_FPHP_BIT) == 0x3)
+                               elf_hwcap |= HWCAP_FPHP;
                }
        /* Extract the architecture version on pre-cpuid scheme */
        } else {