From patchwork Fri Feb 16 00:08:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13559308 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 58028C4829E for ; Fri, 16 Feb 2024 00:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UzPnF+WkSRxTHa97eqjsxi9qn5dc2V3P55/g3o6wk3g=; b=u1GaxvxAeeWhlV 2iVwFXBzItvGkQeBcogALtCMPu+Hpzl7j81D1BpT2V/r0L5qlv/jAZl/IW5FTb0tEr+OP6gYR9uul eoFyOj4eGIAZPg4uhyw10l/v2VOcNVU4bFkkinz+dQvzqFS46OOXH/L6a9ChsMoZQgOnH3GalKEfJ T/VSm3emRoodhXF+8HErAY6b8rFtmIB0zCx0fnBVZlghS8YfHXWh1cTOZ/+c4c0/0lSF48Zl1WAck lNm+AlQoFqjYtbgoxrpqbhBY0pxtLbTqIuHilJKJCO3p1jKbOAf2RlH2VA7p+/8JKOJDnPO9jLQJ1 IqYIwEGoSdjoTSlnUBHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ralmX-00000000YZI-07Oc; Fri, 16 Feb 2024 00:08:45 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ralmT-00000000YXk-0zsC for linux-arm-kernel@lists.infradead.org; Fri, 16 Feb 2024 00:08:42 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d71cb97937so14994565ad.3 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=lists.infradead.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=QUHiZbokMLBGif8hqB8tT5HoakGoyktNm7IBfryD/jqSyx/k8hiq/OgIrXtI8mqSil zx9C8fO1UUGfV243e2r7tMWHn9S2Oy0bAfDzMp0hnz+eVlbvKZiGaHjn9xALE0YSAPVw TdKOExzW8e4YH06ZuUDQfTOhopI1YqetNdXXj9EYxTkA4D5qvn9VtlIbF3phDQ/Qr2Ut UCMK8xPT/TGaSYp2qp1yd44vZAfcrhMuAxk2JF0cM6nDj7Rzf8Mkd+xW2DDN6iaHvy00 rSNBtu7ycAPB6+CwEDYRbO5a+DclKSQT1D3mC+7nxdF20R7hP0UFzG3c8y8aQZcNeM0f K88g== 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=Y6gbWPr47sdZlk/xq5Gyvz0uyZaYnzvHR9EbKduJAR7bPvQvT69l+2kUxFnQOQwBVU d+U4U4TENzrKpufRkcIqpU8bCcf2eYFtjzuBp3Y9eo9X5SmHom9ndWFulrO5dWGGs0rt NQkb5KbuKfEIBldko7djD7aSvESwzS1Eb4X3jxBuzdlMGV4kZJWExt/h2PgkJIysKUzZ pMVPXyvTh4Xnq3LONLlduwBKi10qPpV1KnBTVI0FIx/5lyLLHNFcGC6Bb8iXtdLU/unG Sg2Oq9jobsZKdoBehd1+e2IfnHydr+IZzedLT8Le7ZwBp+EliioIqBtS0ySWUOzVP3eP 6STA== X-Forwarded-Encrypted: i=1; AJvYcCWApKZUgdnoTmzaFBqs0kbIJNAlGw6+hl2iQ8zoWVoobtMMjm8Q3p++KXJnkXZKcYQEWw4eP+HoG1p+JYrnQG4GxYfA6XyN/we1tnxQaRJl0v4/nQo= X-Gm-Message-State: AOJu0YyZlIH4fNFYwQg134TkRSkLBNmFmtTolY53yS65PyAQusxp7RTR FkTXGMSscKxDkc4rHC19ITSKhrcKX9LMKvI1tZSDNxogqkxRi730XPzuC3ETh6E= X-Google-Smtp-Source: AGHT+IEEuF0c7LmW9lUaWum18fP3MSd8qAJyzAs9OeCN6ADixKHSo/WOUDyw9k8YmlyzkxoW0t/waQ== 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 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_160841_316915_14CEFB67 X-CRM114-Status: GOOD ( 19.60 ) 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 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