MIPS: GIC clocksource/irqchip improvements and fixes for multi-cluster systems
Status from this message: Applied, patch 4 & 5
Get series with b4
b4 am [email protected] change-id 20260717-sync-gic-counters-1cd6b40b968eVersions newest first
- v4 Latest5 patches 6 repliesApplied
- v35 patches 8 repliesSuperseded
- v25 patches 3 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 1 patch | 0 replies | Superseded |
Changes in v4 from the cover letter
- Patch 3: Don't unconditionally enable the interrupt when moving affinity across clusters (Thanks to Thomas Bogendoerfer for the review)
- Patch 5: Use a flag to avoid unregistering and re-registering the
clocksource (Thanks to Thomas Bogendoerfer for the review)
- Link to v3: https://patch.msgid.link/[email protected]
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | irqchip/mips-gic: Fix unbalanced cm_core_lock in for_each_online_cpu_gic()drivers/ | +6 | 0 replies | |
| 2/5 | irqchip/mips-gic: Fix recursive acquisition of gic_lock in gic_set_affinity()drivers/ | +10 | 0 replies | |
| 3/5 | irqchip/mips-gic: Transfer interrupt mask state across clustersdrivers/ | +20 | 1 reply | |
| 4/5 | clocksource: mips-gic-timer: Simplify gic_next_event() for per-cpu timerdrivers/ | +3 | 0 replies | |
| 5/5 | clocksource: mips-gic-timer: Use local counter on synced multi-cluster systemsdrivers/ | +117 | 3 replies |
Reviews trailers per patch
All 5 patches have a Reviewed-by or Acked-by.
| Patch | Thomas Bogendoerfer |
|---|---|
| 1/5 | R-b |
| 2/5 | R-b |
| 3/5 | R-b |
| 4/5 | R-b |
| 5/5 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v4 0/5] MIPS: GIC clocksource/irqchip improvements and fixes for multi-cluster systems
This series addresses multi-cluster MIPS GIC handling: it fixes a few cross-cluster and lock bugs, and allows the GIC timer to be used as a fast local clocksource on multi-cluster systems by synchronizing the per-cluster counters.
The first three patches are for the irq-mips-gic irqchip driver.
The first patch fixes the for_each_online_cpu_gic() macro which was releasing an unheld per-CPU cm_core_lock on every invocation on multi-cluster hardware. Move both the acquire and release into __gic_with_next_online_cpu() so they stay balanced and the for_each macro accesses all VP on a multi-cluster system.
The second patch fixes a recursive acquisition of gic_lock in gic_set_affinity() when moving interrupt SMP affinity across clusters, caused by a call to gic_set_type(). Split out a gic_set_type_locked() helper to resolve the issue.
The third patch transfers the interrupt mask state when moving affinity across clusters. The mask is per-cluster, so after a cross-cluster move the interrupt was left disabled in the destination cluster; and unconditionally enabling it would unmask an interrupt that was deliberately disabled. Save the mask state in the source cluster and restore it in the destination cluster.
The last two patches are for the mips-gic-timer clocksource driver.
The fourth patch simplifies gic_next_event() as it is guaranteed to be invoked on the CPU that owns the event, and adds the CLOCK_EVT_FEAT_PERCPU flag to document that guarantee.
The last patch is the main functional change, carried over from v1. It synchronizes each secondary cluster's GIC counter to cluster 0's counter as its CPUs come online. Once every cluster is in sync, it promotes the clocksource from the slow cross-cluster gic_hpt_read_multicluster() path to the fast local gic_hpt_read() and re-enables the GIC VDSO clock mode. The switch is done with a flag rather than by unregistering and re-registering the clocksource. On the dual-cluster Mobileye EyeQ6H SoC this makes clock_gettime(CLOCK_MONOTONIC) about four times faster on the secondary cluster and replaces the jiffies-based sched_clock with the high-precision GIC counter.
This series was tested on Mobileye SoCs with different cluster configurations:
* The EyeQ5 with two clusters but only one is equipped with VP (VP topology {2,2,2,2},{} total 8).
* The EyeQ6Lplus which is strictly single cluster (VP topology {4,4} total 8).
* The EyeQ6H with two identical clusters
(VP topology {4,4,4,4},{4,4,4,4} total 32).
Although I am posting this as a single series since the patches are all related to the GIC, the changes to the irqchip driver and to the clocksource driver are independent from each other and can be merged in different trees. I can split the series in two if it helps reviewing/merging.
---
Changes in v4:
- Patch 3: Don't unconditionally enable the interrupt when moving affinity across clusters (Thanks to Thomas Bogendoerfer for the review)
- Patch 5: Use a flag to avoid unregistering and re-registering the
clocksource (Thanks to Thomas Bogendoerfer for the review)
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Rebased on v7.3-rc1.
- Simplified gic_next_event() as it is strictly per-CPU instead of fixing
unused code.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Four new patches described above fixing multi-cluster
handling in the GIC irqchip and clocksource drivers.
- In the last patch, gic_clocksource_promote() is now deferred via a
workqueue instead of a CPUHP ONLINE callback, to avoid a lockdep
issue on clocksource_mutex.
- Link to v1: https://patch.msgid.link/[email protected]
---
Benoît Monin (5):
irqchip/mips-gic: Fix unbalanced cm_core_lock in for_each_online_cpu_gic() irqchip/mips-gic: Fix recursive acquisition of gic_lock in gic_set_affinity() irqchip/mips-gic: Transfer interrupt mask state across clusters
clocksource: mips-gic-timer: Simplify gic_next_event() for per-cpu timer
clocksource: mips-gic-timer: Use local counter on synced multi-cluster systems
drivers/clocksource/mips-gic-timer.c | 138 ++++++++++++++++++++++++++++++----- drivers/irqchip/irq-mips-gic.c | 59 +++++++++------ 2 files changed, 156 insertions(+), 41 deletions(-)
---
base-commit: cee9395acd8043be0644b25c34bfa86623f2b935
change-id: 20260717-sync-gic-counters-1cd6b40b968e
Best regards,
Signature · 3 lines
Benoît Monin, Bootlin Embedded Linux and Kernel engineering https://bootlin.com