The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3 0/8] arm64: arch_timer: Improve errata handling
@ 2026-08-02 16:53 Marc Zyngier
  2026-08-02 16:53 ` [PATCH v3 1/8] clocksource/drivers/arm_arch_timer: Add read_sched_clock_is_arch_counter() predicate Marc Zyngier
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Marc Zyngier @ 2026-08-02 16:53 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: Catalin Marinas, Will Deacon, Mark Rutland, Thomas Gleixner,
	Ben Horgan, Daniel Lezcano

This is the third version of this series addressing a couple of
embarrassing bugs in the prolific arm64 timer errata handling
department. See below for the changes since v2.

Time is hard. Timers are harder. As a consequence, we have plenty of
broken counter/timer implementations in the wild, and an
infrastructure to deal with them.

However, what we have today suffers from a number of issues:

- if, on an heterogeneous system, affected CPUs are secondaries, we do
  record their broken state but don't correct anything

- we always play games with preemption in order to access per-CPU
  state, irrespective of the presence of broken CPUs

I hear someone saying "just use a static key to enable the errata and
be done with it". Good call, except that we need to do that from a
CPUHP callback, and that's deadlock central. We can't do it later,
because this could affect the CPU before the workaround is enabled.

However, not everything is lost if we turn the logic on its head:

- always start with the mitigations enabled, even if we don't know of
  any affected CPU

- once all CPUs have been seen once, and that we still haven't
  enabled any workaround, disable the mitigations globally.

With that, a normal kernel boot with all CPUs will quickly switch to
no mitigation on decent HW. If you're booting with CPUs disabled, this
will only kick in once you have booted them all.

Patches on top of 7.2-rc4.

* From v2 [1]:

  - Added a fix for the PMUv3 driver that really wants to know whether
    it is operating with the architected timer. This has been broken
    for some time (since 24ee7607b286b ("arm64/arch_timer: Provide
    noinstr sched_clock_read() functions"))

  - Make arch_timer_read_counter a function, and not just a function pointer

  - Added a command-line option to allow the user to promise that no
    erratum is required (Will)

  - Dropped the internal CPU mask and iterate over the existing
    per-cpu variable (Will)

  - Picked Catalin's Ack, with thanks

[1] https://lore.kernel.org/all/20260508094203.2913880-1-maz@kernel.org/

Marc Zyngier (8):
  clocksource/drivers/arm_arch_timer: Add
    read_sched_clock_is_arch_counter() predicate
  clocksource/drivers/arm_arch_timer: Add a static key indicating the
    need for a runtime workaround
  clocksource/drivers/arm_arch_timer: Convert counter accessors to a
    static key alternative
  clocksource/drivers/arm_arch_timer: Drop the
    arch_counter_get_cnt{p,v}ct_stable() accessors
  clocksource/drivers/arm_arch_timer: Turn arch_timer_read_counter into
    a function
  clocksource/drivers/arm_arch_timer: Add command-line control over the
    counter errata management
  clocksource/drivers/arm_arch_timer: Expose a direct accessor for the
    virtual counter
  arm64: Convert __delay_cycles() to arch_timer_read_vcounter()

 .../admin-guide/kernel-parameters.txt         |  13 ++
 arch/arm64/lib/delay.c                        |   5 +-
 drivers/clocksource/arm_arch_timer.c          | 156 ++++++++++++------
 drivers/perf/arm_pmuv3.c                      |   2 +-
 include/clocksource/arm_arch_timer.h          |  11 +-
 5 files changed, 131 insertions(+), 56 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-08-02 16:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 16:53 [PATCH v3 0/8] arm64: arch_timer: Improve errata handling Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 1/8] clocksource/drivers/arm_arch_timer: Add read_sched_clock_is_arch_counter() predicate Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 2/8] clocksource/drivers/arm_arch_timer: Add a static key indicating the need for a runtime workaround Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 3/8] clocksource/drivers/arm_arch_timer: Convert counter accessors to a static key alternative Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 4/8] clocksource/drivers/arm_arch_timer: Drop the arch_counter_get_cnt{p,v}ct_stable() accessors Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 5/8] clocksource/drivers/arm_arch_timer: Turn arch_timer_read_counter into a function Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 6/8] clocksource/drivers/arm_arch_timer: Add command-line control over the counter errata management Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 7/8] clocksource/drivers/arm_arch_timer: Expose a direct accessor for the virtual counter Marc Zyngier
2026-08-02 16:53 ` [PATCH v3 8/8] arm64: Convert __delay_cycles() to arch_timer_read_vcounter() Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox