Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp792227rdb; Thu, 15 Feb 2024 16:08:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXYrU0bNiaVOjU2AieXlreRUIky095cI9wnB/eeeSLzBR5Qt/fceYOyz24NqrO8Z0WpOiwoJl2BoU3kHGi84xD6dpzJHfmP8ewsIyYLFg== X-Google-Smtp-Source: AGHT+IEnoE97RHLgwQzXCapzTVEh/0t5Fb+QTgoBBSi6GGPA9C1nTyk0GHwY3wcUGyDCc6aZVbxw X-Received: by 2002:a17:90b:1055:b0:299:2bda:da3f with SMTP id gq21-20020a17090b105500b002992bdada3fmr1517195pjb.26.1708042128629; Thu, 15 Feb 2024 16:08:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708042128; cv=pass; d=google.com; s=arc-20160816; b=ugYEkAc6BO7uiIsYm8ChcdEVLSCLJ+W6a0RsRZJwSkzI0l+xjWLP0VDEyxdqkyVX6d UgVXSFxZi+Bmq9Rts11r4pBm4B+a1ueS/FLYpkMvecuoA/9ubEBE3TcYuey1uoiGCsq0 Byg9iEYJWSfkO04rYlAJfb2B6XCHrcyrW4SLuXIgWBbVZSUOTpseXQ5TdvHj7VRsHPLM C4vum1A/SREr2o01ghcJAa0FN/Ms/frixN7iqkwFEaT+Dd66vvjLj0pdZLZ9sZeWvpCH 3jSuE8bsf3T5rWlL5K9KAAedV+HtNJaiuVnoKe2NO47VhscjmbFq/WEUC49PFqNVf6qg rrfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=B80341bISXEJg7kkhbXc2oX5/huCFSNjahGhVu6ondM=; fh=X4kt8051V7Z1X3w5S1km6MNzJloaW317xDgyqxYtXDQ=; b=Cdp+XUBd5Vki3IZkemyiuZvym1nz3h+rlThzsfBpzoeoIZO5zVuy3Kjs4jFvKdYrJ5 Y7hyt1QuEIUZr+OL14VqTFmB1V37OZeAub6g/ImUQNDAbNcDkaxmUIbFlTSeGWVzhKsr 4V5x28oQMdkZvjskGaF5wHw9cDB+ZiyyJuIA4eMb0JOb4AMK+jWFOI0reRnNbxHJE9Qm 3tdELO2h1dVhDzcktRONDAEsUSmlF4Bd9/yMJBv1/byY4ddMItKE5KAub4JWV5x+0JXQ a7mBjFqmDn4nU4w3q8hAIwf4CvC0JEl1xnIYL6Z2c6c42n/OHQ3UsaOk3tD1oODXeFU9 vnOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=EC4M+qPn; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-67873-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67873-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id r5-20020a17090ad40500b00298ef3a2dbfsi2012482pju.22.2024.02.15.16.08.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 16:08:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67873-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=EC4M+qPn; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-67873-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67873-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 490992870AE for ; Fri, 16 Feb 2024 00:08:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A2E31C11; Fri, 16 Feb 2024 00:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="EC4M+qPn" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 CA4D138F for ; Fri, 16 Feb 2024 00:08:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708042122; cv=none; b=fiyprE3AONl8zuTcrAjG/vAIbhSfda7aaxDn4Ym9WX5PcOD8aa7rbz7GWHx9U4tjaXJAppguKdOTZYHohgjtcvIYdWPHUyFtZtghZrXttRv7LP3HzI7ygrqzZwJET0S1729Hu4OW+hA0yK1sznFbncUD0tRr2SezBSUBnpemn8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708042122; c=relaxed/simple; bh=wilcIZvJ/x2WKbnzX+mmzsMLHlca/WywYpRCsQDmwww=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PU4VEywR8MyqImTQiIAIVzXmHskAb/rxWMYlZIxCRF8evLfIFeShlNBuLQur2a4Peq2i48GPbrkAVj84bQGzeeVWL6y1w2qzVyZdTlrMzinUuR0NUt+l81anVspkRRITcCe8eHvL5JI5PEnsErLwwiAT8gAWpO00QRzJBJnxD6Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=EC4M+qPn; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1d932f6ccfaso12998075ad.1 for ; Thu, 15 Feb 2024 16:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708042120; x=1708646920; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=B80341bISXEJg7kkhbXc2oX5/huCFSNjahGhVu6ondM=; b=EC4M+qPnjeOd0i1tU2ZbepLIJMf3Sj8cPQJh1UORZZBqM/DFFi+80azk+JAOSOAyHl 0kVFPuRylocuX8/lv55c6o5wSw6a2lfU+jHNs5ngSfzCOUHQvyU5ca+SrP4/gcV4hXxj PymOOlgEnQMmN3WCQdMZGwLMeQa12acACv4BX9SYtpFhA88ePdLGOICexIHFmEyDGcPT 748hf8jJqYavCisBe83X03kARuey5SVHHnjL+0+SGu8yGoY9HPU32piXAi5t4ik6n6/Z ccZdKhRHs38ZxubYrr19AyvDmWXpu9j7indWSChusfMCvB0tBVj8u3UuQDUAhwmp+a30 PCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708042120; x=1708646920; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=B80341bISXEJg7kkhbXc2oX5/huCFSNjahGhVu6ondM=; b=brCDOenxSXXqfJCsJsJ6VNholdYAI2QWNYHXs55kwNY4radstxYl28F9uhWxd7bd9K Gm8lFsRoA2VfvSjVA3HfJ91vowwxeL6svb8407EtV9lfOAWcperV6BA9hunbiH1A0HeD o3dkrkxEf1Z1USh2HH9ZxUo/UOp/1QXaHEiACFIhym6L5LbudJhqKvNim/Kf+bdHLYYe aISH2qJYwJ1zkaKgno+B6b6G9t13D/PNAtLi/IE7OWPEmssb7uukcC9qhV/xG9QhZDjo Mu1C24TJ1X/balnDLfboHRs/xtykLAdp3mptBiDR8Vo10mruhTUBEXYNkCoYqJ5XmqMf AV7w== X-Forwarded-Encrypted: i=1; AJvYcCVdf9iXqEieKn/6tV2zTDtP/0YdNUjQhDwFAYMgTCqxzFHcRbMo8ar5rlvxzHE7FELxyqy2eaMzGD+UmUvSRsORCely+lhC5wXbRby/ X-Gm-Message-State: AOJu0YxREHRfgtDXiFKR4FrgGe4rfZ+IcSPuVZwKXjd1zN8AfKIlml/g 6T316Mr4uAiMcCrUmaXWMNYvNsFvTzp8YFwHOyLZJQHbX4hqh2xFCvWLDrVPa3o= X-Received: by 2002:a17:902:e843:b0:1db:299f:5b0e with SMTP id t3-20020a170902e84300b001db299f5b0emr4475230plg.1.1708042120079; Thu, 15 Feb 2024 16:08:40 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id bb6-20020a170902bc8600b001db3d365082sm1789486plb.265.2024.02.15.16.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 16:08:39 -0800 (PST) From: Samuel Holland To: Will Deacon , Mark Rutland , Eric Lin , Conor Dooley Cc: Palmer Dabbelt , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Paul Walmsley , linux-riscv@lists.infradead.org, Rob Herring , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, Samuel Holland Subject: [PATCH v1 0/6] SiFive cache controller PMU drivers Date: Thu, 15 Feb 2024 16:08:12 -0800 Message-ID: <20240216000837.1868917-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch series adds bindings and drivers for the Performance Monitoring Units (PMUs) found in three SiFive cache controllers. Composable Cache and Extensible Cache support system-wide profiling with a single hardware instance. Private L2 Cache supports per-task profiling with a separate hardware instance per core. All three PMUs have a similar register interface and event encoding, though the set of supported events is different. The Extensible Cache additionally contains a pmCounterInhibit register which allows atomically monitoring multiple counters. All three of these cache controllers (with PMUs) have been integrated in SoCs by our customers. However, as none of those SoCs have been publicly announced yet, I cannot include SoC-specific compatible strings in this version of the devicetree bindings. This series is a follow-up to Eric Lin's series "[PATCH v2 0/3] Add SiFive Private L2 cache and PMU driver": https://lore.kernel.org/linux-riscv/20230720135125.21240-1-eric.lin@sifive.com/ Changes in v1: - Add back select: clause to binding - Make sifive,pl2cache1 the fallback for sifive,pl2cache0 - Fix the order of the reg property declaration - Document the sifive,perfmon-counters property - Drop the non-PMU part of the PL2 cache driver, as the config register save/restore logic will be moved to M-mode - Add missing events to PL2 sets 2, 4, and 5 - Use event_base and config_base to precompute register addresses - Check event validity earlier, in the .event_init hook - Implement .filter for systems where only some CPUs have a PL2 - Only allocate percpu data when probing each PL2 instance - Reference count the `struct pmu` to fix unbind/bind crashes - Probe via DT since the PMU driver is now the only PL2 driver - Allow the driver to be built as a module Eric Lin (4): drivers/perf: Add SiFive Composable Cache PMU driver dt-bindings: cache: Add SiFive Extensible Cache controller drivers/perf: Add SiFive Extensible Cache PMU driver dt-bindings: cache: Add SiFive Private L2 Cache controller Greentime Hu (1): drivers/perf: Add SiFive Private L2 Cache PMU driver Samuel Holland (1): dt-bindings: cache: Document the sifive,perfmon-counters property .../bindings/cache/sifive,ccache0.yaml | 5 + .../cache/sifive,extensiblecache0.yaml | 136 ++++ .../bindings/cache/sifive,pl2cache0.yaml | 81 ++ drivers/perf/Kconfig | 29 + drivers/perf/Makefile | 3 + drivers/perf/sifive_ccache_pmu.c | 577 ++++++++++++++ drivers/perf/sifive_ecache_pmu.c | 675 ++++++++++++++++ drivers/perf/sifive_pl2_pmu.c | 748 ++++++++++++++++++ include/linux/cpuhotplug.h | 2 + 9 files changed, 2256 insertions(+) create mode 100644 Documentation/devicetree/bindings/cache/sifive,extensiblecache0.yaml create mode 100644 Documentation/devicetree/bindings/cache/sifive,pl2cache0.yaml create mode 100644 drivers/perf/sifive_ccache_pmu.c create mode 100644 drivers/perf/sifive_ecache_pmu.c create mode 100644 drivers/perf/sifive_pl2_pmu.c -- 2.43.0