arm64: Refactor check_cpu_capabilities
authorSuzuki K. Poulose <suzuki.poulose@arm.com>
Mon, 19 Oct 2015 13:24:49 +0000 (14:24 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 21 Oct 2015 14:35:57 +0000 (15:35 +0100)
check_cpu_capabilities runs through a given list of caps and
checks if the system has the cap, updates the system capability
bitmap and also runs any enable() methods associated with them.
All of this is not quite obvious from the name 'check'. This
patch splits the check_cpu_capabilities into two parts :

1) update_cpu_capabilities
 => Runs through the given list and updates the system
    wide capability map.
2) enable_cpu_capabilities
 => Runs through the given list and invokes enable() (if any)
    for the caps enabled on the system.

Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Suggested-by: Catalin Marinas <catalin.marinsa@arm.com>
Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
Tested-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/cpufeature.h
arch/arm64/kernel/cpu_errata.c
arch/arm64/kernel/cpufeature.c

index 1e281b27732b6b9b78f21b32193e753b328abcd4..12d883a067c4293d275d9ce67e733120043505fd 100644 (file)
@@ -137,7 +137,7 @@ static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0)
 
 void __init setup_cpu_features(void);
 
-void check_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
+void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
                            const char *info);
 void check_local_cpu_errata(void);
 void check_local_cpu_features(void);
index 6ffd914385609d0aab875813e4e9e8b690976421..09eab326ef9378e496295e5c60afdebc790abfa5 100644 (file)
@@ -88,5 +88,5 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
 
 void check_local_cpu_errata(void)
 {
-       check_cpu_capabilities(arm64_errata, "enabling workaround for");
+       update_cpu_capabilities(arm64_errata, "enabling workaround for");
 }
index a90a64dd905a9069dfdde7a4f7e1b9f2a2b04738..78c4cb7af20e678d7052b91e1978b6f8429f0e0c 100644 (file)
@@ -629,7 +629,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
        {},
 };
 
-void check_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
+void update_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
                            const char *info)
 {
        int i;
@@ -642,8 +642,15 @@ 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);
        }
+}
+
+/*
+ * Run through the enabled capabilities and enable() it on the CPUs
+ */
+void enable_cpu_capabilities(const struct arm64_cpu_capabilities *caps)
+{
+       int i;
 
-       /* 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();
@@ -652,7 +659,8 @@ void check_cpu_capabilities(const struct arm64_cpu_capabilities *caps,
 
 void check_local_cpu_features(void)
 {
-       check_cpu_capabilities(arm64_features, "detected feature:");
+       update_cpu_capabilities(arm64_features, "detected feature:");
+       enable_cpu_capabilities(arm64_features);
 }
 
 void __init setup_cpu_features(void)