From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v5 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support
Date: Wed, 12 Aug 2026 23:24:16 +0000 [thread overview]
Message-ID: <20260812232416.A458A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812230800.2646749-3-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] VPU bus watcher reconfiguration is skipped if a watcher slot is reallocated before asynchronous vpu_work executes, causing silent data corruption.
- [Medium] Broad substring matching in `rpi_axi_pmu_events_is_visible()` unintentionally hides newly added BCM2712-specific event aliases on the BCM2712 platform.
--
--- Patch [2]: [PATCH v5 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support ---
commit f428ceab1c23265b486b6b953b78aae6ae47a096
Author: Ian Rogers <irogers@google.com>
perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support
Expand the Raspberry Pi AXI PMU driver to support Broadcom BCM2712
(Raspberry Pi 5) system monitors, PCIe RP1 Southbridge links, HEVC decoder,
and Cortex-A76 DSU L3 interconnects.
> diff --git a/drivers/perf/rpi_axi_pmu.c b/drivers/perf/rpi_axi_pmu.c
> --- a/drivers/perf/rpi_axi_pmu.c
> +++ b/drivers/perf/rpi_axi_pmu.c
[ ... ]
> @@ -880,12 +1062,111 @@ static struct attribute *rpi_axi_pmu_events_attrs[] = {
[ ... ]
> +static umode_t rpi_axi_pmu_events_is_visible(struct kobject *kobj,
> + struct attribute *attr, int unused)
> +{
> + struct device *dev = kobj_to_dev(kobj);
> + struct pmu *pmu = dev_get_drvdata(dev);
> + struct rpi_axi_pmu *rpi_pmu = pmu_to_rpi_axi_pmu(pmu);
> + struct perf_pmu_events_attr *pmu_attr;
> +
> + pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr.attr);
> +
> + if (rpi_pmu->chip == CHIP_BCM2712) {
> + /*
> + * On RPi 5 (BCM2712), hide legacy VPU Mailbox IPC events (monitor=1)
> + * and legacy RPi 1-4 System Monitor aliases
> + */
> + if (strstr(pmu_attr->event_str, "monitor=1") ||
> + strstr(attr->name, "cpu0_") ||
> + strstr(attr->name, "cpu1_") ||
> + strstr(attr->name, "dma0_") ||
> + strstr(attr->name, "dma1_") ||
> + strstr(attr->name, "v3d0_") ||
> + strstr(attr->name, "v3d1_") ||
> + strstr(attr->name, "hvs_system") ||
> + strstr(attr->name, "isp_system") ||
> + strstr(attr->name, "usb_system") ||
> + strstr(attr->name, "ccp2tx_") ||
> + strstr(attr->name, "mphi_") ||
> + strstr(attr->name, "h264_") ||
> + strstr(attr->name, "v3d_") ||
> + strstr(attr->name, "peripheral_") ||
> + strstr(attr->name, "cpu_uc_") ||
[Severity: Medium]
Does this broad substring matching unintentionally hide the newly added
bcm2712_peripheral_* and bcm2712_cpu_uc_* event aliases on the BCM2712
platform?
Since the new aliases are named bcm2712_peripheral_rtrans and
bcm2712_cpu_uc_rtrans, they contain the exact substrings "peripheral_" and
"cpu_uc_". It looks like they might be incorrectly filtered out here, making
them unavailable in sysfs.
> + strstr(attr->name, "cpu_l2_") ||
> + strstr(attr->name, "l2_control_") ||
> + strstr(attr->name, "system_control_") ||
> + strstr(attr->name, "direct_control_") ||
> + strstr(attr->name, "direct_data_"))
> + return 0;
> + } else {
[ ... ]
> @@ -1507,15 +1831,17 @@ static void rpi_axi_pmu_del(struct perf_event *event, int flags)
> if (pmu->monitor[mon].hw_events.monitored_bus[idx] >= 0) {
> pmu->monitor[mon].hw_events.refcount[idx]--;
> if (pmu->monitor[mon].hw_events.refcount[idx] == 0) {
> - if (mon == MON__SYSTEM)
> - rpi_axi_pmu_disable_bus_watcher(pmu, mon, idx);
> pmu->monitor[mon].hw_events.monitored_bus[idx] = -1;
> pmu->monitor[mon].hw_events.filter[idx] = BCM2835_FLT__NONE;
> - pmu->monitor[mon].hw_events.enabled[idx] = false;
> pmu->monitor[mon].hw_events.num_monitored--;
[Severity: High]
Could removing this synchronous clear of enabled[idx] cause a race condition
leading to silent data corruption?
If a VPU monitor event is deleted here, refcount[idx] drops to 0,
monitored_bus[idx] becomes -1 (freeing the slot), and we schedule
pmu->vpu_work.
If a new VPU event is added before rpi_axi_pmu_vpu_work_handler() runs,
it will reuse this empty slot and increment refcount[idx] to 1.
Then when rpi_axi_pmu_vpu_work_handler() finally runs:
drivers/perf/rpi_axi_pmu.c:rpi_axi_pmu_vpu_work_handler() {
...
/* If VPU bus watcher is not enabled on hardware, enable it... */
if (!pmu->monitor[MON__VPU].hw_events.enabled[idx]) {
...
}
...
}
It appears the worker will skip configuring the new hardware because
enabled[idx] remained true from the old event.
Furthermore, the teardown of the old hardware is also skipped later in the
handler:
drivers/perf/rpi_axi_pmu.c:rpi_axi_pmu_vpu_work_handler() {
...
for (int idx = 0; idx < NUM_BUS_WATCHERS_PER_MONITOR; idx++) {
if (pmu->monitor[MON__VPU].hw_events.refcount[idx] == 0 &&
pmu->monitor[MON__VPU].hw_events.enabled[idx]) {
...
}
}
}
Since the new event already incremented refcount[idx], this block won't
execute, potentially leaving the hardware misconfigured and causing userspace
to receive PMU counts for a completely different AXI bus.
> - if (mon == MON__SYSTEM && pmu->monitor[mon].hw_events.num_monitored == 0) {
> - set_monitor_control(pmu, mon, GEN_CTL_RESET_BIT);
> - pmu->monitor[mon].hw_events.monitor_running = false;
> + if (mon == MON__SYSTEM) {
> + rpi_axi_pmu_disable_bus_watcher(pmu, mon, idx);
> + if (pmu->monitor[mon].hw_events.num_monitored == 0) {
> + set_monitor_control(pmu, mon, GEN_CTL_RESET_BIT);
> + pmu->monitor[mon].hw_events.monitor_running = false;
> + }
> + } else if (mon == MON__VPU) {
> + schedule_work(&pmu->vpu_work);
> }
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812230800.2646749-1-irogers@google.com?part=2
prev parent reply other threads:[~2026-08-12 23:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-11 8:38 [PATCH v1 0/2] perf: Add Raspberry Pi AXI PMU driver Ian Rogers
2026-08-11 8:38 ` [PATCH v1 1/2] perf: Add Raspberry Pi BCM2835 " Ian Rogers
2026-08-11 14:32 ` Uwe Kleine-König
2026-08-11 8:38 ` [PATCH v1 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support Ian Rogers
2026-08-11 23:51 ` [PATCH v2 0/2] perf: Add Raspberry Pi AXI PMU driver Ian Rogers
2026-08-11 23:51 ` [PATCH v2 1/2] perf: Add Raspberry Pi BCM2835 " Ian Rogers
2026-08-12 0:04 ` sashiko-bot
2026-08-11 23:51 ` [PATCH v2 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support Ian Rogers
2026-08-12 0:05 ` sashiko-bot
2026-08-12 0:27 ` [PATCH v3 0/2] perf: Add Raspberry Pi AXI PMU driver Ian Rogers
2026-08-12 0:27 ` [PATCH v3 1/2] perf: Add Raspberry Pi BCM2835 " Ian Rogers
2026-08-12 0:40 ` sashiko-bot
2026-08-12 0:27 ` [PATCH v3 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support Ian Rogers
2026-08-12 0:40 ` sashiko-bot
2026-08-12 5:24 ` [PATCH v4 0/2] perf: Add Raspberry Pi AXI PMU driver Ian Rogers
2026-08-12 5:24 ` [PATCH v4 1/2] perf: Add Raspberry Pi BCM2835 " Ian Rogers
2026-08-12 5:36 ` sashiko-bot
2026-08-12 5:24 ` [PATCH v4 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support Ian Rogers
2026-08-12 5:34 ` sashiko-bot
2026-08-12 8:27 ` [PATCH v4 0/2] perf: Add Raspberry Pi AXI PMU driver Will Deacon
2026-08-12 13:38 ` Ian Rogers
2026-08-12 16:26 ` Uwe Kleine-König
2026-08-12 21:37 ` Ian Rogers
2026-08-12 23:01 ` [PATCH v5 " Ian Rogers
2026-08-12 23:01 ` [PATCH v5 1/2] perf: Add Raspberry Pi BCM2835 " Ian Rogers
2026-08-12 23:15 ` sashiko-bot
2026-08-12 23:01 ` [PATCH v5 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support Ian Rogers
2026-08-12 23:18 ` sashiko-bot
2026-08-12 23:07 ` [PATCH v5 0/2] perf: Add Raspberry Pi AXI PMU driver Ian Rogers
2026-08-12 23:07 ` Ian Rogers
2026-08-12 23:07 ` [PATCH v5 1/2] perf: Add Raspberry Pi BCM2835 " Ian Rogers
2026-08-12 23:25 ` sashiko-bot
2026-08-13 0:06 ` Florian Fainelli
2026-08-12 23:08 ` [PATCH v5 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support Ian Rogers
2026-08-12 23:24 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260812232416.A458A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.