diff mbox series

[37/37] arm64: Remove cpus_have_const_cap()

Message ID 20230919092850.1940729-38-mark.rutland@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64: Remove cpus_have_const_cap() | expand

Commit Message

Mark Rutland Sept. 19, 2023, 9:28 a.m. UTC
There are no longer any users of cpus_have_const_cap(), and therefore it
can be removed.

Remove cpus_have_const_cap(). At the same time, remove
__cpus_have_const_cap(), as this is a trivial wrapper of
alternative_has_cap_unlikely(), which can be used directly instead.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
---
 arch/arm64/include/asm/cpufeature.h | 38 ++---------------------------
 1 file changed, 2 insertions(+), 36 deletions(-)

Comments

Kristina Martšenko Oct. 3, 2023, 5:20 p.m. UTC | #1
On 19/09/2023 10:28, Mark Rutland wrote:
> There are no longer any users of cpus_have_const_cap(), and therefore it
> can be removed.
> 
> Remove cpus_have_const_cap(). At the same time, remove
> __cpus_have_const_cap(), as this is a trivial wrapper of
> alternative_has_cap_unlikely(), which can be used directly instead.

Nit: The comment above __system_matches_cap() still mentions
cpus_have_const_cap():

/*
 * This helper function is used in a narrow window when,
 * - The system wide safe registers are set with all the SMP CPUs and,
 * - The SYSTEM_FEATURE system_cpucaps may not have been set.
 * In all other cases cpus_have_{const_}cap() should be used.
 */

Kristina
Mark Rutland Oct. 5, 2023, 9:35 a.m. UTC | #2
On Tue, Oct 03, 2023 at 06:20:25PM +0100, Kristina Martsenko wrote:
> On 19/09/2023 10:28, Mark Rutland wrote:
> > There are no longer any users of cpus_have_const_cap(), and therefore it
> > can be removed.
> > 
> > Remove cpus_have_const_cap(). At the same time, remove
> > __cpus_have_const_cap(), as this is a trivial wrapper of
> > alternative_has_cap_unlikely(), which can be used directly instead.
> 
> Nit: The comment above __system_matches_cap() still mentions
> cpus_have_const_cap():
> 
> /*
>  * This helper function is used in a narrow window when,
>  * - The system wide safe registers are set with all the SMP CPUs and,
>  * - The SYSTEM_FEATURE system_cpucaps may not have been set.
>  * In all other cases cpus_have_{const_}cap() should be used.
>  */

Thanks! I missed that when grepping for cpus_have_const_cap().

Given we have a number of ways to check the cpucaps, I've deleted the last line
in its entirety.

Mark.
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 4deaa94de36e8..96cc1850589d1 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -462,19 +462,6 @@  static __always_inline bool cpus_have_cap(unsigned int num)
 	return arch_test_bit(num, system_cpucaps);
 }
 
-/*
- * Test for a capability without a runtime check.
- *
- * Before capabilities are finalized, this returns false.
- * After capabilities are finalized, this is patched to avoid a runtime check.
- *
- * @num must be a compile-time constant.
- */
-static __always_inline bool __cpus_have_const_cap(int num)
-{
-	return alternative_has_cap_unlikely(num);
-}
-
 /*
  * Test for a capability without a runtime check.
  *
@@ -487,7 +474,7 @@  static __always_inline bool __cpus_have_const_cap(int num)
 static __always_inline bool cpus_have_final_boot_cap(int num)
 {
 	if (boot_capabilities_finalized())
-		return __cpus_have_const_cap(num);
+		return alternative_has_cap_unlikely(num);
 	else
 		BUG();
 }
@@ -504,32 +491,11 @@  static __always_inline bool cpus_have_final_boot_cap(int num)
 static __always_inline bool cpus_have_final_cap(int num)
 {
 	if (system_capabilities_finalized())
-		return __cpus_have_const_cap(num);
+		return alternative_has_cap_unlikely(num);
 	else
 		BUG();
 }
 
-/*
- * Test for a capability, possibly with a runtime check for non-hyp code.
- *
- * For hyp code, this behaves the same as cpus_have_final_cap().
- *
- * For non-hyp code:
- * Before capabilities are finalized, this behaves as cpus_have_cap().
- * After capabilities are finalized, this is patched to avoid a runtime check.
- *
- * @num must be a compile-time constant.
- */
-static __always_inline bool cpus_have_const_cap(int num)
-{
-	if (is_hyp_code())
-		return cpus_have_final_cap(num);
-	else if (system_capabilities_finalized())
-		return __cpus_have_const_cap(num);
-	else
-		return cpus_have_cap(num);
-}
-
 static inline int __attribute_const__
 cpuid_feature_extract_signed_field_width(u64 features, int field, int width)
 {