From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33979349CE8 for ; Thu, 13 Aug 2026 07:30:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786606253; cv=none; b=a4X7B27q4WyeAblWaLlN4DF5GGtLfI7lAKfpi2L/zHi6pFvey3xMwpz8hPrRe1KvTMSu4nSmSKvrjmNfXwfI6rg4966yUwyJVe86coriGUrzNy+E2Ndy4fyvK/+FmyhEkihNiMvTXvLo9xQdLrJzN/ZVkIh0g/gdo0K0uUNLgVM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786606253; c=relaxed/simple; bh=oYzuOF1nti0ufCuBf1VsBRIdrv+WOAInCHk045FKsUE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kNYAm905OJ7fdCchR5WS4QtST/0e/0fEGA19W/tN6N5NlQeIJpO04x8E19TfeghtTA7+qX1s7PSXcvzR+8UvIQUJeQnswV4HnWG1YxaF7RB0l1jqBQ2SKgNirJGNrO88mIwouDtbQoxf08eqJ1Qkgt1MDolQgd7a6qCEouJdE64= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fihWQSrp; arc=none smtp.client-ip=209.85.216.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fihWQSrp" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e11baa66eso2061013a91.2 for ; Thu, 13 Aug 2026 00:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786606250; x=1787211050; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=c55HlxdAuLgeE4D6zJzLV99h/PLClnRkIxVnHbAj8Zc=; b=fihWQSrpNk56rLGBLWnhBkHeYAVUirolUvnL/wNn99wB22KW6oC7RB2NCharo0FtaA OqDJ+QU7wrZUNU4/zgcVCIzOnkpyKMUxMvj1eFA1h6JlYw9yz1OJgRejxIRS8Gv08pcD aw/kiLWwMle174H9hEW/7bEjZQaf/SFDbZzf7xQp0pvv1FlNT0QCRtZK2AK0cUk6oCma RJiWLpf7MEgdzR2mkZTLl7GJkpvwpTho2l0AMLOMrcZcvTZmu+OAi/yEF9xT9GSKWFut 7Rd/69we7vebRS8QxJHUUQytRECzKy0J2Oebp87mAiL/wqR8dEIbtwb7vTFyTG6DFKP2 Y3OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786606250; x=1787211050; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c55HlxdAuLgeE4D6zJzLV99h/PLClnRkIxVnHbAj8Zc=; b=R4malwF/pk117GW65+YHa5Y3TY61pNWMFidFXHbVsbD1s+ux78GGIwmq3vPpASao7W U/rqcw/DAPnuHLyMifo117PY5Vs+ohFhFLeRfY/+TxFhVQeBzsjg/t/bva/6AlNBwdY6 ik3KJv/+NrL+hR5dWsM6qYU+4jhpbNuVxMlIGPOTueanJH4LCMajfGppM0vKUfXdUpR9 KAzdRuyeg/aJ98+sbLCvVVTIcwXdqPNf8f9+Rn/6iThqQlgcE1HRxf1VarZDqIp5yT9Q JtNKEc4ntGXeZvHuVJCg/2tp91h/Mtb54XyTAggp93zK4xlrsbPcr+/c4pU/Awu32rWP DEwQ== X-Forwarded-Encrypted: i=1; AHgh+RqwEMTM+N42FvKI1QspNXsLf1n77iJii2CygNPbf//7rJnRixc43OfSmauYcOwqcyzFJLyTP7oqXT5hdYI=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5t8IsOO4cRPkx7oZo1qVnEkPpB/jiaxYdxdP3aiGLhopJ4sNG xj7ms7PvxyYXJvAQhrOxT9ZfwUn60EknUWpW9gwiQ5VlhelfhOTpUuePk+9Nk2nHKfXhBHOajHP ih3IvQOFEnw== X-Received: from dlb8.prod.google.com ([2002:a05:7022:608:b0:141:3f8:cbe2]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5288:b0:38e:ad9d:1151 with SMTP id 98e67ed59e1d1-3931dfd01b0mr4679263a91.4.1786606250339; Thu, 13 Aug 2026 00:30:50 -0700 (PDT) Date: Thu, 13 Aug 2026 00:30:43 -0700 In-Reply-To: <20260813064228.2799872-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260813064228.2799872-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.691.gc56d675ccc-goog Message-ID: Subject: [PATCH v9 0/2] perf: Add Raspberry Pi AXI PMU driver From: Ian Rogers To: irogers@google.com, linux-perf-users@vger.kernel.org, linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, u.kleine-koenig@baylibre.com, will@kernel.org Content-Type: text/plain; charset="UTF-8" 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 (`perf stat`, `perf list`, etc.). 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 `/sys/bus/event_source/devices/rpi_axi_pmu/`. - Supports event sampling and hardware counter accumulation (`local64_add`), automatically managing 31-bit hardware counter wraparound across high-bandwidth interconnect transfers. 2. CPU Hotplug Support (`cpuhp`): - Registers dynamic CPU hotplug notifiers (`CPUHP_AP_ONLINE_DYN`). - Automatically migrates PMU context (`perf_pmu_migrate_context`) to an online CPU core when a designated CPU goes offline, safely guarding memory teardown boundaries. 3. Hybrid Memory-Mapped & Mailbox Work Queue Architecture: - System Monitor (MMIO): Performs fast atomic-safe memory reads (~15ns) directly mapped over ARM physical memory space (`MON__SYSTEM`). - VPU Monitor (Mailbox IPC): For Broadcom BCM2835-BCM2711 platforms (RPi 1-4), VideoCore VPU monitor IPC calls are offloaded to process context via a dedicated workqueue (`vpu_work`) and serialized under `vpu_mutex`. This avoids atomic sleeps or blocking in timer/interrupt context. 4. SoC Generation Support: - Patch 1 adds core driver support for Broadcom BCM2835-BCM2711 (RPi 1-4). - Patch 2 expands support for Broadcom BCM2712 (Raspberry Pi 5), adding PCIe RP1 Southbridge links, HEVC decoder, HVS display engine, and Cortex-A76 DSU L3 interconnect monitoring. Hardware Validation ============================== The driver has been rigorously validated on real hardware: - Raspberry Pi 400 (BCM2711): Validated System L2, ARM CPU, and VideoCore VPU firmware mailbox IPC performance counters organically spanning multi-slice multiplexing boundaries. - Raspberry Pi 5 (BCM2712): Validated live byte throughput across HVS display refresh cycles, Cortex-A76 DSU L3 interconnect memory traffic, and PCIe RP1 Southbridge transfers independently configuring `bcm2712_` filters. Changes in v9 (Addressing upstream integration feedback) ============================== - Replaced `flush_work()` with `cancel_work_sync()` in the `rpi_axi_pmu__exit` and initialization error paths, rigorously ensuring no asynchronous VPU worker threads continue executing after PMU subsystem termination. - Inverted PMU and CPU hotplug initialization sequence in `probe()` to cleanly eliminate a theoretical `devm_kzalloc` memory UAF race. - Embedded a robust boolean initialization guard physically into the hotplug event handler, definitively securing offline context callbacks from concurrent access panics during concurrent failures. - Architecturally radically simplified BCM2712 sysfs generation loops by switching to an explicit inverse `bcm2712_` whitelist. This mathematically prevents ghost suffix parameters (`.unit` and `.scale`) from orphaned legacy VPU transactions bleeding into userspace dynamically. - Explicitly appended documentation notes organically defending the inclusion of the `#if LINUX_VERSION_CODE` legacy shim surrounding `hrtimer_setup` for seamlessly preserving downstream compatibility with Raspberry Pi LTS kernel deployments natively. Ian Rogers (2): perf: Add Raspberry Pi BCM2835 AXI PMU driver perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support drivers/perf/Kconfig | 10 + drivers/perf/Makefile | 1 + drivers/perf/rpi_axi_pmu.c | 2877 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2888 insertions(+) create mode 100644 drivers/perf/rpi_axi_pmu.c -- 2.41.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDB5A432BC9 for ; Thu, 13 Aug 2026 08:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786608196; cv=none; b=SsUOTxfM9QvcDQ9eY+QjaadFclawVpu7SdNqpHKwVAEgLgIP1hLuwqqN82pX80Ozb2ZAv99e06loPCpyHnDE0e7cMCXYMM3u4TUIVZw8aI2If5W8fmccBeEyCK4c8QUS+VxQeXjXNvUoDQYCsUxP96QlQdjmDjsHbFlu5kbPbaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786608196; c=relaxed/simple; bh=X81WrY4V3MgQCFMUv6BvP5J7Q2iluyhQv2PaSObpQYU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aaLS07MG6z8Q79owfUEdhs3ZZFABY+TjTE0wY5Ld0fkJ55G4W39/gAysBlrUp75FOJ4sYuBfOZLhtlEUA7pfarXBsV+Z5FEE+LgfytavJBV4XoFl+U5tW3YsW5YfoGe4DT87C68sgffCpY/Aq2FaMSHNXdjf16vrucWrcNEgNPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Awd73/Yg; arc=none smtp.client-ip=209.85.215.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Awd73/Yg" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-cbee6bb8408so670503a12.3 for ; Thu, 13 Aug 2026 01:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786608194; x=1787212994; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=DgD/Qr6ThMB9P0bXoLiCRwMAEs2jUFNRi7uUt5JWbEM=; b=Awd73/YgMaTK4aEc9qKLtDjVj8ooONqifSwUzKZGE5REyJ55+ecQMsG5QL+w7v8Gmp IAvONTHeeGq2ANaSlPdMw7q/MZEC3NcpC85kHpp5C7dO7mH7Dt643fXJvcRx9kT1sKhN Quc0QMDwLVZp/GJestFum/kkIh6CscbNUS8ZUft/4WOJBS/BE4n7nxRJKaQxfEFZoR0V vhX0JJKEda5wiRBe5dCG3rrXZKn+WirIB/SRVWtGxvqcL5NrlgOmmQRqVUb5mdzeMr2P cWdNhYVBJBK582GlyGHg8VhgSc9HNo99huixzp4EWUmLI9p+5sra46VegqhAmxKb0k37 BOog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786608194; x=1787212994; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DgD/Qr6ThMB9P0bXoLiCRwMAEs2jUFNRi7uUt5JWbEM=; b=MY9oI69VzM3Uz3HtDKRZvfo78x8BVvQ1QJbvqrB7OAH60ZAxfH8YjO2JTyZHJRolOd TPAkcC/scfBEFEASXo0AxuIKBIKaZE8mbxhg+CsADwaTMl4nfRaT82BbAezyjTvMsfdb inx2CPOT7D0Wa/7oUlncrII5LR52U80EK8nk4qyqQJr5xx0icldmpkTE0N7K4XiuGkH4 2QSTQMsc87ZXX2TY47I92GwkOKT/06/L9KDr+0qTkyKuftwkOECJWcVTFYsXTidG+MXv aYRIxDTlLNZcYa9w++gOCCBvDswGtYdXNj5zkngzjBazB4VRCOkTiy82GLSu3amYud9u eM8A== X-Forwarded-Encrypted: i=1; AHgh+Rrw6VSsn6GHb7cFyFsSHwmpZYuA60fPrd7JG8uG6vhQii3rVsF6kp3kE3CqOV7Ff5h0OKiAP0MnMo+lUQA=@vger.kernel.org X-Gm-Message-State: AOJu0YzJLnRR+sqVFfxpSR7w2nF/Bogds02KMc1r+wx9jla3h+APSN+s FT4+8fQMjoMrRMJuEJii8oSaGASuMknws4Lexi9HumTxWAED2ZNY/suuMrMKtFM5b5LlONQ+Ngk RVwCRS1cL5g== X-Received: from dlbpy9.prod.google.com ([2002:a05:7022:e989:b0:13d:311a:396b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:3ca7:b0:3c3:b226:f165 with SMTP id adf61e73a8af0-3cc553a59a7mr5906268637.35.1786608193966; Thu, 13 Aug 2026 01:03:13 -0700 (PDT) Date: Thu, 13 Aug 2026 01:03:07 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.55.0.691.gc56d675ccc-goog Message-ID: Subject: [PATCH v10 0/2] perf: Add Raspberry Pi AXI PMU driver From: Ian Rogers To: irogers@google.com, linux-perf-users@vger.kernel.org, linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com, will@kernel.org Content-Type: text/plain; charset="UTF-8" Message-ID: <20260813080307.qnUuB-qX2ytxIKTn2jaei_1s4wkYhYplFE1IFmQBA7k@z> 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 (`perf stat`, `perf list`, etc.). 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 `/sys/bus/event_source/devices/rpi_axi_pmu/`. - Supports event sampling and hardware counter accumulation (`local64_add`), automatically managing 31-bit hardware counter wraparound across high-bandwidth interconnect transfers. 2. CPU Hotplug Support (`cpuhp`): - Registers dynamic CPU hotplug notifiers (`CPUHP_AP_ONLINE_DYN`). - Automatically migrates PMU context (`perf_pmu_migrate_context`) to an online CPU core when a designated CPU goes offline, safely guarding memory teardown boundaries. 3. Hybrid Memory-Mapped & Mailbox Work Queue Architecture: - System Monitor (MMIO): Performs fast atomic-safe memory reads (~15ns) directly mapped over ARM physical memory space (`MON__SYSTEM`). - VPU Monitor (Mailbox IPC): For Broadcom BCM2835-BCM2711 platforms (RPi 1-4), VideoCore VPU monitor IPC calls are offloaded to process context via a dedicated workqueue (`vpu_work`) and serialized under `vpu_mutex`. This avoids atomic sleeps or blocking in timer/interrupt context. 4. SoC Generation Support: - Patch 1 adds core driver support for Broadcom BCM2835-BCM2711 (RPi 1-4). - Patch 2 expands support for Broadcom BCM2712 (Raspberry Pi 5), adding PCIe RP1 Southbridge links, HEVC decoder, HVS display engine, and Cortex-A76 DSU L3 interconnect monitoring. Hardware Validation ============================== The driver has been rigorously validated on real hardware: - Raspberry Pi 400 (BCM2711): Validated System L2, ARM CPU, and VideoCore VPU firmware mailbox IPC performance counters organically spanning multi-slice multiplexing boundaries. - Raspberry Pi 5 (BCM2712): Validated live byte throughput across HVS display refresh cycles, Cortex-A76 DSU L3 interconnect memory traffic, and PCIe RP1 Southbridge transfers independently configuring `bcm2712_` filters. Changes in v10 (Addressing upstream integration feedback) ============================== - Removed the unused `num_started` state tracking variable from `struct rpi_axi_hw_events` and its associated start/stop increments, cleanly addressing a reviewer's note on dead code. - Replaced `flush_work()` with `cancel_work_sync()` in the `rpi_axi_pmu__exit` and initialization error paths, rigorously ensuring no asynchronous VPU worker threads continue executing after PMU subsystem termination. - Inverted PMU and CPU hotplug initialization sequence in `probe()` to cleanly eliminate a theoretical `devm_kzalloc` memory UAF race. - Embedded a robust boolean initialization guard physically into the hotplug event handler, definitively securing offline context callbacks from concurrent access panics during concurrent failures. - Architecturally radically simplified BCM2712 sysfs generation loops by switching to an explicit inverse `bcm2712_` whitelist. This mathematically prevents ghost suffix parameters (`.unit` and `.scale`) from orphaned legacy VPU transactions bleeding into userspace dynamically. - Explicitly appended documentation notes organically defending the inclusion of the `#if LINUX_VERSION_CODE` legacy shim surrounding `hrtimer_setup` for seamlessly preserving downstream compatibility with Raspberry Pi LTS kernel deployments natively. Ian Rogers (2): perf: Add Raspberry Pi BCM2835 AXI PMU driver perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support drivers/perf/Kconfig | 10 + drivers/perf/Makefile | 1 + drivers/perf/rpi_axi_pmu.c | 2877 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2888 insertions(+) create mode 100644 drivers/perf/rpi_axi_pmu.c -- 2.41.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE38D404BFF for ; Thu, 13 Aug 2026 14:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786631170; cv=none; b=l/wspxgqwQeHBjzTFuSCEYUfUkqGrt88spKsAUDYtH4kFwzoWCOe5jKauSxahQjDhXNF0sRgqXx3SzsuyMLZYVrYeACupT0xaNdKvdFMxFiLxqrC8tnxdpRrfdJxGw2Hxz/ix+l8D7eYW0I0+krbJwIIFYQCnMyaYqhhhKyaICk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786631170; c=relaxed/simple; bh=vhgZHuMvUoFFvNQ8BMqZR1WpBTzAsFfJJljmuoi4Ryk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tUgnaDjboBBpS5z8z0rKSspqzDpj/yx0xn4Z2pIOoD45AB051e9v4XufNyHG9mutBEeDcgNWCoMmRoWUZgvMGcHUzd8QE7am1wMpLSKx6OTJaiV8OKyrxcqzsRhKvxE8RL0aYizekI2/aePoSGUH+p7VZ5ME5mlyw9CyraBDSi8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=NRIZplVJ; arc=none smtp.client-ip=209.85.215.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="NRIZplVJ" Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-ca6bd8a190cso1059737a12.0 for ; Thu, 13 Aug 2026 07:26:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786631168; x=1787235968; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=CtE5+SwfaqiVt1ovz5nhzu1q4YH4d9K6aiYS2Nt3N1g=; b=NRIZplVJ4DsOULpzAEYZOURXfj+5dWjEH3XBnw2MOIPCYA7cqQlx7uO4EZPIyX4N0d +z3oZhytdDW3H1CHz+zLQY5gqdaOE6mfpecrJA+QY3fgOc3gwp10XveWFKwwLX1cNO6P 2axfBUEfkEw07DOUpbpWrTn3VT+dZrkqKjRpgunCbO/M9+eoWOiplnHP8p/prYWkgkLJ 9zBhN3A64eoCzbS6sFTz3kj98/By1cd8QvwPWTthFAMhABUjYF8e8Osm3Cj+vkb1svrV RYQG3Mh9QEYKV0CUT1FfeB87M5oPSsMPeQQkRjwSUNMi1bAH2U1HCMGexBZHYShIpycF +qrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786631168; x=1787235968; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CtE5+SwfaqiVt1ovz5nhzu1q4YH4d9K6aiYS2Nt3N1g=; b=DVuOZPZxiUc7123Ujg0wtVLAFRd8d1rz6YDx96fdU+m8WIHRCpbvGVEfsqtCRHEZjF 50Ul5XTksC5zXBZ2LsV5SsG09utGtgCDLFKqd5cM5+m3TA+Iy99wV8UG4PMt0H9HrsPQ xqKbcJ541bkCKHxM39s7+7YtSbT50lVu2y2dVSryYVMAVlMLm9JPE1oLHno5uSyhHUE5 q5Es60JnEds6be8Uzu349C7bb8QmbcNZyrUJ2DAstrw7V2WVmDY6lhlbN0M/Qzh0WsN0 0Q05oKDtDx/i5mYvv1pxLhdyyATLETwi5cVRAaELVuCa00uTMdfNtz0aINpRdq/XT1io JTcw== X-Forwarded-Encrypted: i=1; AHgh+RrjCCj8VUHAqGzBDFjFNclnX6w672dJO9e7puogy80zLKGfeXs7HasuH2mOg9bkordgRH/bOGBlQZWlzSg=@vger.kernel.org X-Gm-Message-State: AOJu0Yzb/xCTCEhKoDqMuOEjM6ewxAxr7uDdof9hkX0I/f0bfeBwzsMB lhV1cDqSrc8GNW2v9lw+B5n+XGk/k6gWjym3nRj7tNmXGksmR5eM+AMP0mgLqm6uwrPY46WwFHY r57M1kYb+gg== X-Received: from dled8-n1.prod.google.com ([2002:a05:701b:42c8:10b0:13b:8289:9a55]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:999d:b0:3c3:9a7f:7307 with SMTP id adf61e73a8af0-3cc55319ed3mr6860167637.24.1786631167816; Thu, 13 Aug 2026 07:26:07 -0700 (PDT) Date: Thu, 13 Aug 2026 07:26:02 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.55.0.691.gc56d675ccc-goog Message-ID: Subject: [PATCH v11 0/2] perf: Add Raspberry Pi AXI PMU driver From: Ian Rogers To: irogers@google.com, linux-perf-users@vger.kernel.org, linux-rpi-kernel@lists.infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mark.rutland@arm.com Content-Type: text/plain; charset="UTF-8" Message-ID: <20260813142602.xMUIIMiPilE_F_nl2maItT-TgkSFp1o7aYdAgKaeTdE@z> 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 (`perf stat`, `perf list`, etc.). 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 `/sys/bus/event_source/devices/rpi_axi_pmu/`. - Supports event sampling and hardware counter accumulation (`local64_add`), automatically managing 31-bit hardware counter wraparound across high-bandwidth interconnect transfers. 2. CPU Hotplug Support (`cpuhp`): - Registers dynamic CPU hotplug notifiers (`CPUHP_AP_ONLINE_DYN`). - Automatically migrates PMU context (`perf_pmu_migrate_context`) to an online CPU core when a designated CPU goes offline, safely guarding memory teardown boundaries. 3. Hybrid Memory-Mapped & Mailbox Work Queue Architecture: - System Monitor (MMIO): Performs fast atomic-safe memory reads (~15ns) directly mapped over ARM physical memory space (`MON__SYSTEM`). - VPU Monitor (Mailbox IPC): For Broadcom BCM2835-BCM2711 platforms (RPi 1-4), VideoCore VPU monitor IPC calls are offloaded to process context via a dedicated workqueue (`vpu_work`) and serialized under `vpu_mutex`. This avoids atomic sleeps or blocking in timer/interrupt context. 4. SoC Generation Support: - Patch 1 adds core driver support for Broadcom BCM2835-BCM2711 (RPi 1-4). - Patch 2 expands support for Broadcom BCM2712 (Raspberry Pi 5), adding PCIe RP1 Southbridge links, HEVC decoder, HVS display engine, and Cortex-A76 DSU L3 interconnect monitoring. Hardware Validation ============================== The driver has been rigorously validated on real hardware: - Raspberry Pi 400 (BCM2711): Validated System L2, ARM CPU, and VideoCore VPU firmware mailbox IPC performance counters organically spanning multi-slice multiplexing boundaries. - Raspberry Pi 5 (BCM2712): Validated live byte throughput across HVS display refresh cycles, Cortex-A76 DSU L3 interconnect memory traffic, and PCIe RP1 Southbridge transfers independently configuring `bcm2712_` filters. Changes in v11 (Addressing upstream integration feedback) ============================== - Removed the unused `num_started` state tracking variable from `struct rpi_axi_hw_events` and its associated start/stop increments, cleanly addressing a reviewer's note on dead code. - Eliminated KCSAN data race warnings in `rpi_axi_pmu_read_counter()`. Annotated the `enabled[idx]` flag with `READ_ONCE()` during lockless VPU thread polling, and matching `WRITE_ONCE()` barriers during subsystem teardowns. - Restored `flush_work()` in `rpi_axi_pmu__exit`. When the module is unloaded, `perf_pmu_unregister()` asynchronously schedules `vpu_work` to gracefully disable the physical VideoCore IPC hardware. Using `cancel_work_sync()` was blindly dropping these critical queued disables, silently leaking running hardware monitors! Included an explicit defensive comment mathematically documenting this dependency. - Inverted PMU and CPU hotplug initialization sequence in `probe()` to cleanly eliminate a theoretical `devm_kzalloc` memory UAF race. - Embedded a robust boolean initialization guard physically into the hotplug event handler, definitively securing offline context callbacks from concurrent access panics during concurrent failures. - Architecturally radically simplified BCM2712 sysfs generation loops by switching to an explicit inverse `bcm2712_` whitelist. This mathematically prevents ghost suffix parameters (`.unit` and `.scale`) from orphaned legacy VPU transactions bleeding into userspace dynamically. - Explicitly appended documentation notes organically defending the inclusion of the `#if LINUX_VERSION_CODE` legacy shim surrounding `hrtimer_setup` for seamlessly preserving downstream compatibility with Raspberry Pi LTS kernel deployments natively. Ian Rogers (2): perf: Add Raspberry Pi BCM2835 AXI PMU driver perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support drivers/perf/Kconfig | 10 + drivers/perf/Makefile | 1 + drivers/perf/rpi_axi_pmu.c | 2877 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2888 insertions(+) create mode 100644 drivers/perf/rpi_axi_pmu.c -- 2.41.0