arm64: kernel: Add cpufeature 'enable' callback
authorJames Morse <james.morse@arm.com>
Tue, 21 Jul 2015 12:23:28 +0000 (13:23 +0100)
committerWill Deacon <will.deacon@arm.com>
Mon, 27 Jul 2015 10:08:41 +0000 (11:08 +0100)
This patch adds an 'enable()' callback to cpu capability/feature
detection, allowing features that require some setup or configuration
to get this opportunity once the feature has been detected.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpufeature.c

index 9fafa7537997615e4996f992e7410c025cd679fb..484fa9425314110f70a9a25e722b5e29930465ad 100644 (file)
@@ -34,6 +34,7 @@ struct arm64_cpu_capabilities {
        const char *desc;
        u16 capability;
        bool (*matches)(const struct arm64_cpu_capabilities *);
+       void (*enable)(void);
        union {
                struct {        /* To be used for erratum handling only */
                        u32 midr_model;
index 5ad86ceac010167870ac8b3354f2711094b3864f..650ffc28bedcf96f89522a612a34dc2bebd86b47 100644 (file)
@@ -55,6 +55,12 @@ void check_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
                        pr_info("%s %s\n", info, caps[i].desc);
                cpus_set_cap(caps[i].capability);
        }
+
+       /* second pass allows enable() to consider interacting capabilities */
+       for (i = 0; caps[i].desc; i++) {
+               if (cpus_have_cap(caps[i].capability) && caps[i].enable)
+                       caps[i].enable();
+       }
 }
 
 void check_local_cpu_features(void)