clocksource/drivers/arm_arch_timer: validate arch_timer_rate
Using an arch timer with a frequency of less than 1MHz can potentially result in incorrect functionality in systems that assume a reasonable rate of the arch timer of 1 to 50MHz, described as typical in the architecture specification. Therefore, warn if the arch timer rate is below 1MHz, which is considered atypical and worth emphasizing. Suggested-by: Valentin Schneider <valentin.schneider@arm.com> Signed-off-by: Ionela Voinescu <ionela.voinescu@arm.com> Acked-by: Marc Zyngier <maz@kernel.org> Cc: Marc Zyngier <maz@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
This commit is contained in:
parent
cd0ed03a89
commit
c265861af2
|
@ -885,6 +885,17 @@ static int arch_timer_starting_cpu(unsigned int cpu)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int validate_timer_rate(void)
|
||||||
|
{
|
||||||
|
if (!arch_timer_rate)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
/* Arch timer frequency < 1MHz can cause trouble */
|
||||||
|
WARN_ON(arch_timer_rate < 1000000);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For historical reasons, when probing with DT we use whichever (non-zero)
|
* For historical reasons, when probing with DT we use whichever (non-zero)
|
||||||
* rate was probed first, and don't verify that others match. If the first node
|
* rate was probed first, and don't verify that others match. If the first node
|
||||||
|
@ -900,7 +911,7 @@ static void arch_timer_of_configure_rate(u32 rate, struct device_node *np)
|
||||||
arch_timer_rate = rate;
|
arch_timer_rate = rate;
|
||||||
|
|
||||||
/* Check the timer frequency. */
|
/* Check the timer frequency. */
|
||||||
if (arch_timer_rate == 0)
|
if (validate_timer_rate())
|
||||||
pr_warn("frequency not available\n");
|
pr_warn("frequency not available\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1594,9 +1605,10 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
|
||||||
* CNTFRQ value. This *must* be correct.
|
* CNTFRQ value. This *must* be correct.
|
||||||
*/
|
*/
|
||||||
arch_timer_rate = arch_timer_get_cntfrq();
|
arch_timer_rate = arch_timer_get_cntfrq();
|
||||||
if (!arch_timer_rate) {
|
ret = validate_timer_rate();
|
||||||
|
if (ret) {
|
||||||
pr_err(FW_BUG "frequency not available.\n");
|
pr_err(FW_BUG "frequency not available.\n");
|
||||||
return -EINVAL;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
arch_timer_uses_ppi = arch_timer_select_ppi();
|
arch_timer_uses_ppi = arch_timer_select_ppi();
|
||||||
|
|
Loading…
Reference in New Issue