[PATCH v8 0/2] perf: Add Raspberry Pi AXI PMU driver
Ian Rogers
irogers at google.com
Wed Aug 12 23:42:26 PDT 2026
This patch series adds an uncore Performance Monitoring Unit (PMU) driver
for Broadcom AXI system and VideoCore VPU performance monitors found on
Raspberry Pi SoCs (BCM2835 through BCM2712 / Raspberry Pi 1 through 5).
Motivation & Background
=======================
Currently, Linux lacks a standard perf-API compatible driver for the
Broadcom AXI performance counter blocks on Raspberry Pi platforms. Prior
out-of-tree vendor solutions relied on custom debugfs nodes and ad-hoc
kthreads, preventing integration with standard Linux perf tooling.
This driver implements standard `struct pmu` hardware uncore callbacks
under `drivers/perf/`, exposing human-readable sysfs event aliases, unit
scaling (`Bytes`), and bus filtering directly to user space.
Key Architectural Improvements & Features
=========================================
1. Standard Linux Perf Integration:
- Exposes uncore AXI interconnect events via sysfs boundaries.
- Supports event sampling and hardware counter accumulation,
automatically managing 31-bit hardware counter wraparound.
2. CPU Hotplug Support (`cpuhp`):
- Registers dynamic CPU hotplug notifiers (`CPUHP_AP_ONLINE_DYN`).
- Automatically migrates PMU context to an online CPU core when a
designated CPU goes offline, avoiding stale uncore state.
3. Hybrid Memory-Mapped & Mailbox Work Queue Architecture:
- System Monitor (MMIO): Performs fast atomic-safe memory reads
directly mapped over ARM physical memory space.
- VPU Monitor (Mailbox IPC): For Broadcom BCM2835-BCM2711 platforms,
VideoCore VPU monitor IPC calls are offloaded to process context via
a dedicated workqueue (`vpu_work`) and serialized.
4. PREEMPT_RT & Safety Hardening:
- Uses HRTIMER_MODE_REL_SOFT for timer callbacks to execute in softirq
context, avoiding local hard interrupt nesting priority deadlocks.
5. SoC Generation Support:
- Patch 1 adds core driver support for Broadcom BCM2835-BCM2711.
- Patch 2 expands support for Broadcom BCM2712 (Raspberry Pi 5).
Changes in v8
=============
- Fully transitioned locking architecture from 'spinlock_t' globally to
'raw_spinlock_t' to mathematically guarantee fastpath safety against
"scheduling while atomic" crashes during PREEMPT_RT deployment where
the perf core unconditionally disables hard IRQs prior to PMU callbacks.
- Re-architected 'RPI_AXI_PMU_TIMER_INTERVAL' significantly downward from
2000ms natively to 100ms. This acts as a structural baseline compromise
that prevents excessive VideoCore Mailbox IPC context-switch wakeovers
on older Pi 1/2 boards, while safely minimizing uncollected residuals
causing 0-byte dropouts during time multiplexing/undersubscribed traces.
- Enforced strict 100-column sysfs string macro breakages globally.
- Added proper .scale and .unit bytes aliases across all AXI transaction
events.
- Fixed a fatal use-after-free initialization race condition catching cases
where cpuhp_state instances were registered prior to the PMU backend,
which allowed concurrent CPU hotplug migrations to panic aggressively
against unregistered core structures.
Ian Rogers (2):
perf: Add Raspberry Pi BCM2835 AXI PMU driver
perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support
drivers/perf/rpi_axi_pmu.c | 2884 ++++++++++++++++++++++++++++++++++++
1 file changed, 2884 insertions(+)
create mode 100644 drivers/perf/rpi_axi_pmu.c
--
2.47.0
More information about the linux-arm-kernel
mailing list