Skip to content

Commit 4b43f1c

Browse files
mrutland-armctmarinas
authored andcommitted
arm64: make ARM64_HAS_GIC_PRIO_MASKING depend on ARM64_HAS_GIC_CPUIF_SYSREGS
Currently the arm64_cpu_capabilities structure for ARM64_HAS_GIC_PRIO_MASKING open-codes the same CPU field definitions as the arm64_cpu_capabilities structure for ARM64_HAS_GIC_CPUIF_SYSREGS, so that can_use_gic_priorities() can use has_useable_gicv3_cpuif(). This duplication isn't ideal for the legibility of the code, and sets a bad example for any ARM64_HAS_GIC_* definitions added by subsequent patches. Instead, have ARM64_HAS_GIC_PRIO_MASKING check for the ARM64_HAS_GIC_CPUIF_SYSREGS cpucap, and add a comment explaining why this is safe. Subsequent patches will use the same pattern where one cpucap depends upon another. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Cc: Mark Brown <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent c888b7b commit 4b43f1c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,7 +2046,15 @@ early_param("irqchip.gicv3_pseudo_nmi", early_enable_pseudo_nmi);
20462046
static bool can_use_gic_priorities(const struct arm64_cpu_capabilities *entry,
20472047
int scope)
20482048
{
2049-
return enable_pseudo_nmi && has_useable_gicv3_cpuif(entry, scope);
2049+
/*
2050+
* ARM64_HAS_GIC_CPUIF_SYSREGS has a lower index, and is a boot CPU
2051+
* feature, so will be detected earlier.
2052+
*/
2053+
BUILD_BUG_ON(ARM64_HAS_GIC_PRIO_MASKING <= ARM64_HAS_GIC_CPUIF_SYSREGS);
2054+
if (!cpus_have_cap(ARM64_HAS_GIC_CPUIF_SYSREGS))
2055+
return false;
2056+
2057+
return enable_pseudo_nmi;
20502058
}
20512059
#endif
20522060

@@ -2537,11 +2545,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
25372545
.capability = ARM64_HAS_GIC_PRIO_MASKING,
25382546
.type = ARM64_CPUCAP_STRICT_BOOT_CPU_FEATURE,
25392547
.matches = can_use_gic_priorities,
2540-
.sys_reg = SYS_ID_AA64PFR0_EL1,
2541-
.field_pos = ID_AA64PFR0_EL1_GIC_SHIFT,
2542-
.field_width = 4,
2543-
.sign = FTR_UNSIGNED,
2544-
.min_field_value = 1,
25452548
},
25462549
#endif
25472550
#ifdef CONFIG_ARM64_E0PD

0 commit comments

Comments
 (0)