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:18:34 +0000 [thread overview]
Message-ID: <20260812231835.14C321F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260812230145.2644281-3-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Removing `enabled[idx] = false` from `rpi_axi_pmu_del` causes bus watcher misconfiguration when a watcher index is rapidly reused.
- [Medium] Overly broad substring matching inadvertently hides newly added BCM2712 events on RPi 5 while exposing them on RPi 1-4.
- [Medium] The VPU monitor hardware is not reliably disabled during module unload because `cancel_work_sync()` is used instead of `flush_work()`.
--
--- Patch [2]: [PATCH v5 2/2] perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support ---
commit 71567bad9b4b4c6115df3982a734e87c6c908033
Author: Ian Rogers <irogers@google.com>
perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support
This patch expands the Raspberry Pi AXI PMU driver to support Broadcom
BCM2712 system monitors. It adds new monitored buses, filter options,
and event aliases for the Raspberry Pi 5 platform.
> diff --git a/drivers/perf/rpi_axi_pmu.c b/drivers/perf/rpi_axi_pmu.c
> index e5cc86fc78b25..a24b6587f8718 100644
> --- a/drivers/perf/rpi_axi_pmu.c
> +++ b/drivers/perf/rpi_axi_pmu.c
[ ... ]
> @@ -1113,31 +1203,66 @@ static umode_t rpi_axi_pmu_events_is_visible(struct kobject *kobj,
> struct attribute *attr, int unused)
> {
[ ... ]
> 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, "peripheral_") ||
> strstr(attr->name, "cpu_uc_") ||
[ ... ]
> return 0;
> } else {
> /* On RPi 1-4 (BCM2835-BCM2711), hide RPi 5 specific events */
> if (strstr(attr->name, "pcie_rp1") ||
[ ... ]
> return 0;
> }
>
> return attr->mode;
> }
[Severity: Medium]
Will these substring matches inadvertently hide the newly added BCM2712 events
on RPi 5?
The new BCM2712 events are named "bcm2712_peripheral_rtrans" and
"bcm2712_cpu_uc_rtrans", which will match "peripheral_" and "cpu_uc_"
and be hidden here.
Conversely, won't these same new events be mistakenly exposed on older chips
because they don't match any of the substrings in the `else` block?
[ ... ]
> @@ -1810,14 +1831,16 @@ 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--;
> - 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);
> }
> }
> }
[Severity: High]
Is it safe to remove `pmu->monitor[mon].hw_events.enabled[idx] = false` here?
If a VPU event is deleted, the watcher slot is marked as free. If a new VPU
event is added immediately before `vpu_work` runs to perform the teardown,
the new event could claim this slot.
When `vpu_work` runs, it checks `if (!enabled[idx])` to program the hardware.
Since `enabled[idx]` is still true from the deleted event, it skips
initialization, causing the hardware to monitor the old bus while the new
perf event incorrectly reports those counts.
[ ... ]
> @@ -2014,9 +2065,10 @@ static void rpi_axi_pmu__exit(struct rpi_axi_pmu *pmu)
> {
> - perf_pmu_unregister(&pmu->pmu);
> cpuhp_state_remove_instance(rpi_axi_pmu_cpuhp_state, &pmu->cpuhp_node);
> +
> + perf_pmu_unregister(&pmu->pmu);
> hrtimer_cancel(&pmu->hrtimer);
> cancel_work_sync(&pmu->vpu_work);
> if (pmu->firmware)
[Severity: Medium]
Since `rpi_axi_pmu_del()` was updated to schedule `vpu_work` to disable the
VPU hardware, does this `cancel_work_sync()` prevent the hardware teardown
from completing during module unload?
`perf_pmu_unregister()` will call `rpi_axi_pmu_del()`, which schedules
the asynchronous teardown. Canceling it immediately after means the VPU AXI
bus watchers could be left running. Should this be `flush_work()` instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260812230145.2644281-1-irogers@google.com?part=2
next prev parent reply other threads:[~2026-08-12 23:18 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 [this message]
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
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=20260812231835.14C321F00A3A@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox