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 B41DF41F5C8 for ; Thu, 13 Aug 2026 06:42:33 +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=1786603358; cv=none; b=HxhnhNMP85cuXZ6fjkiohmM8DOaecCfivJaQtcp4gpfC3myqoe1FShPJAwuaAAss0l6MWrcJQfiJHdH/Y3DIjanK/LYpRRz0MXzHmSekeVamY51UbwdiPtC5tmDQtIFzfDYXvjBxHgMr5MF00xNHMkWA4ttjfPTF0RfS/Dd6dRU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786603358; c=relaxed/simple; bh=xUtaHUary9iYhxzyqWpn4QRp0/aW560jaXkgKD5YXBU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Rd5dSd7lIrKhE5uAhuCV/BEqDReGGUSQLmRgGmr097xQiN6kwxclPSS4PLFtANXmV7ip7cpV2D2+H+P7LZg0OtxioEfx+ANovK/oP/mn6Vvn74mdmtzzydUWkLTtXIUOM8WeQYdyjcwtTt4gfT67w01oxAm1mP5W1uw8x7FUCWE= 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=oS1KcSGi; 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="oS1KcSGi" Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-38e22137fb3so2613237a91.0 for ; Wed, 12 Aug 2026 23:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786603352; x=1787208152; 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=Gb9MsvAU21XMuxBAL1AnROv8wUcrBW21oBvrQrAmcYU=; b=oS1KcSGi3JRvhoJBrhOz1gDoxo4DrhUtxTPpDlrkNYUW1Plp9jOZ6yV1kStbLoIeEG LUL588QDNX0DfZPJWNFISAKJHK0GAwceWLeXzaQ4PYVh6//mLKtSxrXZ3AdLoM2+2xzZ 1GJbTvRjZi2lOucrmMwmgf6q4f1+9djb/hw9T4mFrVZ5Ngts2jqOfiQWGX1BYUrqFQUz SV1RRlroUWGXJHkgScppaA9RI5cXHUOEwVIzu1Fhi7WhtqIxzDiYecnAZhUjDclgIF+q w8GHif55fRZevzUSM8gJCPvxTWolDTE5OwFqpcNwPNWpz+/G+v791sWv90gCgl1f+tl4 3q7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786603352; x=1787208152; 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=Gb9MsvAU21XMuxBAL1AnROv8wUcrBW21oBvrQrAmcYU=; b=UpvPCs20heGHY2LaWGVpTa0CbocVl8AdWJVnf26OqZBv8kk2x4qEn05zc/rUSj1Ddw oW570RRhNS+7XFts3hVZmZpxom7n7Tl6pPjvDGZUGpxbqJZEca1KwZe86/+4qAg3ira3 3JA7/ls4FeY95/DCxY2f1YOT1FPKhNJyC+E1jHRaJzEShjWeOUYDNQySrjn5kivEDlgd 0dZsc4qCQIseVgYlACOgNzdPpeSblJGiOLQFNffZRIfOsISQOrQQnsg7SmdUai3gGm9O pwuIUi5ZPdAcTr0JFCjUXwmN39/sDxkJ+mzFomvBnebQv6FdVO/iXiuFBtbEn9SQToIm wlmQ== X-Forwarded-Encrypted: i=1; AHgh+RpfV+F2YcdeXsz4yh9Zxf10O2sDAyhFtz6EbmC8zJx3UQi21LwSLqLoMCtqXCBoBxRVuYWNLePrYFkO2Pw=@vger.kernel.org X-Gm-Message-State: AOJu0Yxzx+53nhyn7wa/WbG4fRjvBWUN2JYZWarK90aNipnINRqopKQT gP7JRJvHrTzYyUKozbfnToKhFW2ZadMe92BG88joMaqUGamQAPifyV5dF1JQAWKV83fsBCTz6L4 Au4NfpXRaLw== X-Received: from dlbcm34.prod.google.com ([2002:a05:7022:68a2:b0:13f:c741:a50b]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:1602:b0:3b4:8f18:33a with SMTP id adf61e73a8af0-3cc54f4d129mr5116115637.1.1786603351538; Wed, 12 Aug 2026 23:42:31 -0700 (PDT) Date: Wed, 12 Aug 2026 23:42:26 -0700 In-Reply-To: <20260813052419.2770841-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: <20260813052419.2770841-1-irogers@google.com> X-Mailer: git-send-email 2.55.0.691.gc56d675ccc-goog Message-ID: <20260813064228.2799872-1-irogers@google.com> Subject: [PATCH v8 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. 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 sysfs boundaries. - Supports event sampling and hardware counter accumulation, automatically managing 31-bit hardware counter wraparound. 2. CPU Hotplug Support (`cpuhp`): - Registers dynamic CPU hotplug notifiers (`CPUHP_AP_ONLINE_DYN`). - Automatically migrates PMU context to an online CPU core when a designated CPU goes offline, avoiding stale uncore state. 3. Hybrid Memory-Mapped & Mailbox Work Queue Architecture: - System Monitor (MMIO): Performs fast atomic-safe memory reads directly mapped over ARM physical memory space. - VPU Monitor (Mailbox IPC): For Broadcom BCM2835-BCM2711 platforms, VideoCore VPU monitor IPC calls are offloaded to process context via a dedicated workqueue (`vpu_work`) and serialized. 4. PREEMPT_RT & Safety Hardening: - Uses HRTIMER_MODE_REL_SOFT for timer callbacks to execute in softirq context, avoiding local hard interrupt nesting priority deadlocks. 5. SoC Generation Support: - Patch 1 adds core driver support for Broadcom BCM2835-BCM2711. - Patch 2 expands support for Broadcom BCM2712 (Raspberry Pi 5). Changes in v8 ============= - Fully transitioned locking architecture from 'spinlock_t' globally to 'raw_spinlock_t' to mathematically guarantee fastpath safety against "scheduling while atomic" crashes during PREEMPT_RT deployment where the perf core unconditionally disables hard IRQs prior to PMU callbacks. - Re-architected 'RPI_AXI_PMU_TIMER_INTERVAL' significantly downward from 2000ms natively to 100ms. This acts as a structural baseline compromise that prevents excessive VideoCore Mailbox IPC context-switch wakeovers on older Pi 1/2 boards, while safely minimizing uncollected residuals causing 0-byte dropouts during time multiplexing/undersubscribed traces. - Enforced strict 100-column sysfs string macro breakages globally. - Added proper .scale and .unit bytes aliases across all AXI transaction events. - Fixed a fatal use-after-free initialization race condition catching cases where cpuhp_state instances were registered prior to the PMU backend, which allowed concurrent CPU hotplug migrations to panic aggressively against unregistered core structures. Ian Rogers (2): perf: Add Raspberry Pi BCM2835 AXI PMU driver perf: Add Raspberry Pi 5 (BCM2712) AXI PMU support drivers/perf/rpi_axi_pmu.c | 2884 ++++++++++++++++++++++++++++++++++++ 1 file changed, 2884 insertions(+) create mode 100644 drivers/perf/rpi_axi_pmu.c -- 2.47.0