]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
arm64: add cpu_capabilities bitmap
authorAndre Przywara <andre.przywara@arm.com>
Fri, 14 Nov 2014 15:54:07 +0000 (15:54 +0000)
committerWill Deacon <will.deacon@arm.com>
Tue, 25 Nov 2014 13:22:37 +0000 (13:22 +0000)
For taking note if at least one CPU in the system needs a bug
workaround or would benefit from a code optimization, we create a new
bitmap to hold (artificial) feature bits.
Since elf_hwcap is part of the userland ABI, we keep it alone and
introduce a new data structure for that (along with some accessors).

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/setup.c

index cd4ac0516488fe1f0d2357310a121f67855ce38c..20b2b3d6b7025c3794c21846e8068a6de0f2db8a 100644 (file)
 #define MAX_CPU_FEATURES       (8 * sizeof(elf_hwcap))
 #define cpu_feature(x)         ilog2(HWCAP_ ## x)
 
+#define NCAPS                  0
+
+extern DECLARE_BITMAP(cpu_hwcaps, NCAPS);
+
 static inline bool cpu_have_feature(unsigned int num)
 {
        return elf_hwcap & (1UL << num);
 }
 
+static inline bool cpus_have_cap(unsigned int num)
+{
+       if (num >= NCAPS)
+               return false;
+       return test_bit(num, cpu_hwcaps);
+}
+
+static inline void cpus_set_cap(unsigned int num)
+{
+       if (num >= NCAPS)
+               pr_warn("Attempt to set an illegal CPU capability (%d >= %d)\n",
+                       num, NCAPS);
+       else
+               __set_bit(num, cpu_hwcaps);
+}
+
 #endif
index 2e17bd3806c88113af7e6731fda307fb8d80bc50..c8629eb07ba65b494a30f064eea59e794b282219 100644 (file)
@@ -50,6 +50,7 @@
 #include <asm/cputype.h>
 #include <asm/elf.h>
 #include <asm/cputable.h>
+#include <asm/cpufeature.h>
 #include <asm/cpu_ops.h>
 #include <asm/sections.h>
 #include <asm/setup.h>
@@ -79,6 +80,8 @@ unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT;
 unsigned int compat_elf_hwcap2 __read_mostly;
 #endif
 
+DECLARE_BITMAP(cpu_hwcaps, NCAPS);
+
 static const char *cpu_name;
 phys_addr_t __fdt_pointer __initdata;