From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1ADEFC5B572 for ; Thu, 13 Aug 2026 07:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c55HlxdAuLgeE4D6zJzLV99h/PLClnRkIxVnHbAj8Zc=; b=becQM7+eNCmBN7l1/dpuDCU96t ISxdJORC/3GrA77wlPUd2/I4RW0xaETUKFzxuzaqWg7jqIzCXZ6v8XK6St+fkTvFbm9cJuwtxdgid htEfgtoSLqUdN3PxHUdZdj5vloYZ1twB4UhZxwtvpoVihl2XzR7GTJVADv1nTKiE97L8AJCb5JT14 oW+4dH4pSu+/aogzsZFumU/fs+8iQtTBtriQHpwNo+vJnaW8hzWrUWmK4xO9tUgGwDPhSQMM9+YgD jEQ3VQjbTNqEQbWaa1YkrEJU2It4ZT79ykDSvY2hGK0DqV2+3GISJISRvQTpAfOZUEaJf6XN06D3T 8nPjdBNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wuPtu-000000000e9-2X6d; Thu, 13 Aug 2026 07:30:54 +0000 Received: from mail-pj1-x1047.google.com ([2607:f8b0:4864:20::1047]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wuPtr-000000000d7-3LsY for linux-arm-kernel@lists.infradead.org; Thu, 13 Aug 2026 07:30:53 +0000 Received: by mail-pj1-x1047.google.com with SMTP id 98e67ed59e1d1-38e11baa66eso2061012a91.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=lists.infradead.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=VUEayLUrOjPh48YcL+Rtf1kr5zpcdK0fnYJj9jXyoYJ6x+s/VP54fv7DtdAmGHA9UE 71KBGaKFIrTsUGbNs7ygK83e4fRhpiQamsrEHu3rHtDzJ3s48PBXkm/ZsZb8XOYcPNq3 b1RvM0APUq71cQYr7mTaeIqcxxZCuTKSLIJ69OkTGPqxJv53o3mu7vhmWz6lOa/qCKuB SGOp4bdoJFr5Z2H0l6FKbyQiySpZNhtn1MSFjphoX41TOL9xvYBQr9pK5Fey5CAD8DtI SluhLUx66Yw9koFHnsRjzkxkRGQzUheVpXzCazC1iRnj4xKbqTz4ZaDGILweyNlaHEcS IyTA== 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=Kb+/kv9L9YySUu2R993ZFX85eXKRdFb3TfvCtkP7RX8L4Ams45s9+VCLsgKiAnU+qd hSKvGwSaD+RKYECPhHyCVNlGC+g5yGxpti82LDeVvgSypvwfrrUdKShMndNVqNEL4IQi kCeZkrVm6Tjvk3wGOV8NOiD6x2tkbWmqguWwOem3F3w8ZEtgB63MCvOw8wBukVnLgEI6 GHLr9vYIp6EzdCMOWbVhKilb4SHI5E0BhLstm70BiV6eG5khpOClUncxXttnnx55hdWO BidnGfQrLIT3fa6aWNUpmV34Bv4Tn5sIKfyYr3SRVA8E8uMsDbY1ADZKwjpkMUYI0X7z u+tQ== X-Gm-Message-State: AOJu0YzXDppjoFgHbmTiZz7+6a3hhks227DfojYFzwAEf81NiwY77eix 3v+Yn931mxNYkvRWVwmaMhTTQ666dVH6l2L+8hczZIx+ds0RDX+1QCkHO50UpB5GmYxVXRSl+Ql UlRMt+Vu2ng== 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> 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" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260813_003051_904844_FF5B73E5 X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) (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 DDC0843B6E2 for ; Thu, 13 Aug 2026 08:03:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786608196; cv=none; b=Pa2gwItjokPEmJFYUuxAKI3eR0ji/xMD9ger1RUMT88RbgFmfu4m7EkXJrVW4JzRw9zjC9H1aU4j+CjNbeKr0Scrx+XH+QDWe6mZhDnYMHPsUhJEBzWnnDLDQsGheFSUIGY7+HBkKx1Ov2nVz6C8kIY8OtX26XNdABv3AsaPWiM= 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.199 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-f199.google.com with SMTP id 41be03b00d2f7-cb6cf425e86so706147a12.1 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=kp4WDjHxeSIqY66kr66p7AvzXsV+gTxzttAi7hRjXVnosEu9KiEDMv2y17Tnpwb6mY Oi6LBT18XVf0llJiyVh8oek7HZulUbe1Jf06iA4qi6t/CjrHFrHlWUzMziJrg0Nnp5DV hGRuuZTaLuHsAy1ywqb0ZzE4bcgzrCrZ2pDi5mNOR2f/GU748DkHotIu1L7FbvzHtS03 u+3X7hX0mMLfF1BUK6SQUvbHYwSpLKDbAthBOxuE46XascCMxAoir6d+bmSS02qyFCLa Z06CnfiqCJ53VLDBRRVuvJVq+HgknM9bw3V6vFnlnP7TCnI9sDPFM8Ali9Zl6ZmBxrZO S63Q== X-Forwarded-Encrypted: i=1; AHgh+Rp35B+lHfNaVv3VrOgzNL0UREiN4X7xa8bAFvxWgVSwUlWtst5Z7o4HxJdDhLxsajye//jbQ9rMmTb1jHhaeTsV@vger.kernel.org X-Gm-Message-State: AOJu0YwSW+9v6cAF2h+L67xO44NqMU7z5hCOOvVLu/VN61mjwlU8X4N5 lD+xyXGtUfXxj4g4kONdws+w9BoJ50VBTjRIhIxmcYzePjPfEPWv3CY74naRkOFnm66Gvkt/9i6 38n0dED+gvQ== 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-perf-users@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-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (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 BFD454756CA for ; Thu, 13 Aug 2026 14:26:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786631170; cv=none; b=PXDhoFRn8ifKRHzHXyn1IIqDrvhJT2bYnspOV1IJJYEIfsLOZrCxn5MDN8p5PsYVut+2XT0rK6XdHwesXAgNXFzPj59gJx7eZFhV1ZsyyW99825FOJNsVHduNw/O6Q4F/YOc9SraZZMB5eKvs6dMbgFWOnl+B3ybvoY+yMHZkn8= 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.198 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-f198.google.com with SMTP id 41be03b00d2f7-ca6bd8a190cso1059739a12.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=g/lyNVd+ArFBz7ov6M5ii87bSB5n4mkpataLwlc9MBw/ZXDQqyWh0jFO3NK80TTmk5 +lOxVXP4fPv/OLb0X2pefjVCcm5xBY+wjw/M+/kmlUhycDp+jY/akbvyIb3BZWq+faCU 5+6q3NjDPdss75RM84CryZbnVRKOdrVFGYjv7nQAI1qD84w02kjFZJgijg+NuFIjbvWB YFqqJ0An3xFZWpvs7R+xo5J2jy7jPorF/x1TEO84U4LCwt+fjQqV1Y1eCEeQPMSUaktS +k/hGo3ojWPXgH5twDLmlh9CjPetV6ETNOvXUw7eOvj4pc0rniBYSA2D7QqM2oEb87Wh j+yw== X-Forwarded-Encrypted: i=1; AHgh+RowG3WTfM+MNVVzD8xTlXfN7dmweZZeoybjx5KeU2VIFA1IZloKv6WOAzX46mVxl68K0IjuqzT21ydc/j9P+4qV@vger.kernel.org X-Gm-Message-State: AOJu0YxGetvYDZA5Atsa5qqtrsNtVfC1huLenp2Q2UWb3j8e7LLi73eD rZ4sQbvwJLprGR8B6V5DXSfCCroTZKV5+ODFL+NUIPjvFlZOm6itVEcJXDmHlyVPMHiO0kdDjzH eVc7aA+uX1Q== 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-perf-users@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