diff mbox series

[4/4] arm64: cpufeature: fold cpus_set_cap() into update_cpu_capabilities()

Message ID 20230601100812.2303944-5-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: cpucap cleanup | expand

Commit Message

Mark Rutland June 1, 2023, 10:08 a.m. UTC
We only use cpus_set_cap() in update_cpu_capabilities(), where we
open-code an analgous update to boot_cpucaps.

Due to the way the cpucap_ptrs[] array is initialized, we know that the
capability number cannot be greater than or equal to ARM64_NCAPS, so the
warning is superfluous.

Fold cpus_set_cap() into update_cpu_capabilities(), matching what we do
for the boot_cpucaps, and making the relationship between the two a bit
clearer.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Suzuki Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/cpufeature.h | 10 ----------
 arch/arm64/kernel/cpufeature.c      |  3 ++-
 2 files changed, 2 insertions(+), 11 deletions(-)

Comments

Mark Brown June 1, 2023, 11:14 a.m. UTC | #1
On Thu, Jun 01, 2023 at 11:08:12AM +0100, Mark Rutland wrote:
> We only use cpus_set_cap() in update_cpu_capabilities(), where we
> open-code an analgous update to boot_cpucaps.
> 
> Due to the way the cpucap_ptrs[] array is initialized, we know that the
> capability number cannot be greater than or equal to ARM64_NCAPS, so the
> warning is superfluous.

Reviewed-by: Mark Brown <broonie@kernel.org>
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 6de2a5b232fce..7a95c324e52a4 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -504,16 +504,6 @@  static __always_inline bool cpus_have_const_cap(int num)
 		return cpus_have_cap(num);
 }
 
-static inline void cpus_set_cap(unsigned int num)
-{
-	if (num >= ARM64_NCAPS) {
-		pr_warn("Attempt to set an illegal CPU capability (%d >= %d)\n",
-			num, ARM64_NCAPS);
-	} else {
-		__set_bit(num, system_cpucaps);
-	}
-}
-
 static inline int __attribute_const__
 cpuid_feature_extract_signed_field_width(u64 features, int field, int width)
 {
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 82e6819528347..bfadac361ac14 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -2903,7 +2903,8 @@  static void update_cpu_capabilities(u16 scope_mask)
 
 		if (caps->desc)
 			pr_info("detected: %s\n", caps->desc);
-		cpus_set_cap(caps->capability);
+
+		__set_bit(caps->capability, system_cpucaps);
 
 		if ((scope_mask & SCOPE_BOOT_CPU) && (caps->type & SCOPE_BOOT_CPU))
 			set_bit(caps->capability, boot_cpucaps);