Repository navigation
Raspberry Pi support for AXI bus events in Linux perf tool - #7671
captain5050 wants to merge 3 commits into
Conversation
Add device tree bindings for the Broadcom Raspberry Pi AXI PMU block found on BCM2835, BCM2711, and BCM2712 SoCs. Depending on the SoC and security configuration, these PMUs support either direct MMIO access for the System monitor or routing via the Raspberry Pi firmware mailbox IPC for the VideoCore VPU monitor. Signed-off-by: Ian Rogers <irogers@google.com>
Add a PMU driver for the Raspberry Pi AXI performance monitors. It provides access to the System and VideoCore performance counters on Broadcom BCM2835 and BCM2711 platforms natively through the perf subsystem. The driver implements bus-watcher refcounting, group validation, CPU hotplug migration, and sysfs event aliases mapping hardware-specific events to AXI pipelines (such as DMA, V3D, HVS, and ISP). Memory-mapped endpoints for the primary System bus are read synchronously, while the VideoCore VPU monitor is polled asynchronously in process context via the Raspberry Pi firmware mailbox interface. Signed-off-by: Ian Rogers <irogers@google.com>
Extend the Raspberry Pi AXI PMU driver to support the Broadcom BCM2712 architecture used in the Raspberry Pi 5. The BCM2712 SoC drops the legacy VideoCore VPU monitor and exposes a unified System monitor via MMIO mapping distinctly different hardware pipelines (such as DISPLAY_TOP, ARGON_TOP, BSTM_TOP, PCIE_01, and XPT) and expanded 6-bit AXI master ID filter tables. Signed-off-by: Ian Rogers <irogers@google.com>
|
Got a quite long Claude review. I've been through the specs and tested poking registers on 2711, 2712 and 2712D0 so the points in the review should be accurate. Note, there were some bugs in downstream driver (and some new ones in the new code). If you'd like I can get claude to suggest patches to your commits (but it is also fine if you'd like to do this). |
|
Thanks for the update — this is a big improvement on #7571. I checked it against What's fixed since #7571
Blocking1. The driver can't be enabled in any Raspberry Pi defconfig
2. The BCM2712 VPU monitor has been dropped
2712 should take the same mailbox path as 2711, using the 2711 VPU table, which is identical to downstream's 2712 one. The VPU address in the DT is wrong, though: see the VPU monitor section below. 3. The binding doesn't match the in-tree DT
Related: the driver finds the firmware with 4. Register layout doesn't match the hardware docs (2711 B0, 2712 C0, 2712 D0)I checked the system monitor (APERF0) register docs for 2711 B0, 2712 C0 and 2712 D0. The bus-watcher layout changes between chip revisions, and some of it is wrong in both this driver and the downstream one.
Counter registers
VPU monitor (APERF1)
Hardware testsI tested directly on three boards, using
So, whether the VPU monitor works depends on the firmware. The Pi 4 firmware I have checks addresses against On bus 3, IDs 16 to 43 all count, with steadily falling totals. Those are the ARM's own AXI IDs, which the docs say don't follow the master-ID scheme, so a master filter means nothing on the ARM bus (and, per the docs, on V3D). The bus names may also be misleading. Network DMA from RP1 (PCIe2) shows up on bus 5 ( Should fix
Minor / style
|
|
Thanks again for the help! Wrt Claude helping with my patches or me acting on the reviews, I'm easy. There's a bit of a delay with me getting the work done, but also the patches aren't urgent. If you would like to have a crack at it I don't mind. The next version should address the feedback above and also some device tree nits that were posted on LKML: https://lore.kernel.org/linux-perf-users/20261002175738.3242646-1-irogers@google.com/ |
|
I've pushed a tree with some claude fixes to https://github.com/popcornmix/linux/tree/captain5050 |
|
firmware (for pi0-4) : here I've updated my branch to include any fixes I've found: https://github.com/popcornmix/linux/tree/captain5050 |
Raspberry Pi AXI PMU: hardware validationThis describes how the bus tables, master IDs and register handling in
The Broadcom documentation for BCM2712 describes the set-top box variant of the chip. Several of its port names refer to blocks that aren't used on a Raspberry Pi, and on BCM2712 D0 the port numbering differs from the documentation. Where the documentation and the measurements disagree, the driver follows the measurements. Hardware
All boards ran a 6.18 Raspberry Pi kernel with current firmware. Method1. Direct register probing (driver unloaded)A small user-space tool programmed the bus watchers directly:
Working outside the driver allowed:
For each workload, the tool:
2. Workloads used to exercise known masters
3. Checks through the driverThe driver was then loaded and checked with
Results: System monitor (APERF0)"Unconfirmed" means no available workload produced traffic on that bus. The name is kept from the documentation (or from the downstream driver, where the documentation gives none). BCM2835 (event names as in the driver)
BCM2837 (same table as BCM2835)
BCM2711 B0
On BCM2711, none of these appeared on any bus of either monitor:
These blocks seem to sit outside the part of the fabric that the monitors cover. BCM2712 C0
Bold names differ from the documentation, because the documented name describes a block the Pi doesn't use. BCM2712 D0On D0, three ports are removed: XPT, PCIE_01 and HVDP. The rest are renumbered to fill the gaps, and the external PCIe moves onto the The driver detects D0 at probe time: only D0 lets the watcher's ID mask field be written.
These measurements were spread across two D0 boards (a Pi 5 rev 1.2 and a Pi 500), and every bus the two have in common agreed. Indices beyond the tableOn every chip, bus indices past the end of the table count nothing at idle. Under heavy load, some of them count once per clock cycle. They are not real ports, so the driver rejects any bus number beyond each chip's table. Results: VPU monitor (APERF1)The downstream BCM2835 VPU table is wrong from index 5 onward, on both BCM2835 and BCM2837. All three older chips actually follow the BCM2711 layout, which has no L2_FLUSH entry, and BCM2835/BCM2837 add a working index 14. The driver now uses this layout for all of them. BCM2712 uses the BCM2711 list, and its bus 13 was measured.
Results: master IDs (filter values)BCM2835–BCM2711 (5-bit filter)Measured, matching the downstream filter list:
Exceptions:
BCM2712 (6-bit filter, the master number at AXI ID bits [8:3])The documentation's numbering is sparse, with gaps. The previous driver table numbered the masters consecutively instead, so from VPU_L2 onward every filter selected the wrong master. The driver now uses the documented numbers. Measured:
Notes:
Never seen on any bus, under every workload available:
Results: register layout and countersWatcher control fieldsThe writable bits were found by writing all ones to
On D0 the driver writes the ID mask explicitly. With a mask of 0, every transaction matches, so a filter would count all traffic. That was observed on hardware. Counters
The driver masks counter deltas to these widths, and reports Global control
Results: firmware access to the VPU monitorThe VPU monitor isn't accessible from the ARM. The driver reaches it through the firmware's
The device-tree changes in this series set these addresses. Older firmware either rejects these calls or returns zeros. At probe, the driver writes a GEN_CTRL bit through the firmware and reads it back. If that fails, it logs one warning and hides the VPU events, so it never reports counts of zero by mistake. A single 44-word Results: checks through the driverAll of the following were run with
Known hardware quirks found during testing
|
I've addressed review feedback from:
#7571
but in doing so accidentally closed the PR. Apologies, hopefully things are in a better state this time.