From patchwork Thu May 27 00:30:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1484365 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JBHvIP7b; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=adswAJxU; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fr7z809QHz9s5R for ; Thu, 27 May 2021 10:31:16 +1000 (AEST) 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=zuiJK0UaY7YW6iC/gJeINWC0KwqrGrNHzQ55P0+Ise0=; b=JBHvIP7bL74btl z5mvZjKJoQ+YjGUDa7+DDG3eo7BopR+SU7/1wprDccmhUamkND7iNsvbj5GN4YxuEsglu34OKjKKU MlkyKMW1MLHtgNqw0r5T2kkeV1tTIn2rdSKiTelJV4An4CbgjxG2uMN91QVgXw2L1yfLeeM8IlN1L +K6Pw6yyHYRQG7K44hC04erWm+KAwJIQiombZbakjlrjGMKKHNFI2pytFgGabfPlh8zF6BJEcKfrG HirseFeChnTUQDRYccdLoFFg95od3K1UW92iNWMNGWiermdQhJb70MyfUYKj2P7a/LdlTVSWsp/zN wBEUWASp46iy9hqNSKbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lm3vY-001ALD-GR; Thu, 27 May 2021 00:31:08 +0000 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lm3vS-001AIb-SA for opensbi@lists.infradead.org; Thu, 27 May 2021 00:31:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1622075480; x=1653611480; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=M/F4zdCRA9KEh/NKkySwxHmu5zshrStysR9TyjVrA/s=; b=adswAJxUqbLYtfw3qMKA1S2MB4OR8U4PsOrTzYrny7F4E0y1mgnC3LEW zGaeNXEi0YKAyPY4clBoOAtmHeIfG+dfQrsIskyJz/dIE5fk0iSFLvGrB /9+M5IrdNdThjFCcL32gLLLNYYtb8PUo/5HYHeD+694wZP/Y29A1MjEgG hGRDDuQv9jPAB6TPTT2Nm8XxANRRyTijCch+qRyT0bB3qrlW8pwAK/vaH uxYWWWMMDVKvb06Rsv/5378uIF33ok9do+AX3YUucI6eVXrcBipVvmQfM n35Nk5asNBFnucUklZBOyoqKnaogXdd/97i/S67UaStaBb/g3M1uh6+MT w==; IronPort-SDR: FNLb3CLvVeU8Kx+tRyQs+pApRZVbWqo9vyumMO98KOECCvAgCHd29vNR+TZIEef/nrir1I9K/W gBaLtwMQ3xKdgE062jptiXLSA/6WcnDgNP/kfuWCyGMghht5DHxt0povzdHAG9t2V8JqBApE6Z 2w2Z04TLIA70Ebv1UbbKiDXslklbh0sPLED4K8gFmWbIR/MyaoInYktCk+G4PAFAK+bAvedhph GWJqrRR/xZiJ+8mgN8ccLp4yXH7KCEh19/MnU31BC0l9jA1kQTZFP/5z/a7p62fc3tPsdsy0n/ NCI= X-IronPort-AV: E=Sophos;i="5.82,333,1613404800"; d="scan'208";a="273477682" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 27 May 2021 08:31:17 +0800 IronPort-SDR: awjYswwdfi5rqbgXSUnfM/3qExSVSCNjIrQXac+YMqygq50ioZZMCunTGJi8XtxX/8Bdwd7uyk rTSHeO+tAioRTCEc9DIPivHf/SoFMqRPEmrFqBsPD+kozreWzrEqTHZhzy9tt9UMJl9OIFuNVd LQvytm29T3lQhfs3nnGwrOoA5zDb6ckiZkOs8/psg78eE8OmFBTUv07y1FZwKfQubJf7F3iv9H 6NcxF0/C127mAWrvA4bMrUZtVvoYdmBvRVO7bJo27zWhrToCz75/4l1gGKMEJ4bBTDnMf0pk9K 2/ObxHmgAy09E2v/EgFQheHn Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2021 17:10:26 -0700 IronPort-SDR: moQ1JoiN5nJVhCYCnQPFBu2aJ0iqZ8BV6ALfAps/5DYYcqPR/I17vzY0fk2s0oCqYmEbnJrv7g lOaMF+RcLWCm1DgnW3XHxiuIal2tvo7SD2kLGxgzzkO44OfXD23P4+0bbpXAC48PWmRj93KWBJ ho+Qt1CgmTjcjXn/GMLlTTid7iPoElFS/dgazvh+pkiG6XRpzF3WTw8pXk0RZJDollQ9aGcy+h icUvEVYyxcwY4w1i5kIWbRLhoX2T7b3d1wG8z2esQvOxCX34vvnwsq4B0QrHxKn6eDoyr0tJcd RK8= WDCIronportException: Internal Received: from unknown (HELO jedi-01.wdc.com) ([10.225.163.91]) by uls-op-cesaip02.wdc.com with ESMTP; 26 May 2021 17:30:58 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , anup.patel@wdc.com Subject: [PATCH v2 00/15] SBI PMU extension support Date: Wed, 26 May 2021 17:30:29 -0700 Message-Id: <20210527003044.889681-1-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210526_173103_018232_1E2DC14B X-CRM114-Status: GOOD ( 14.19 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The latest version of the SBI specification includes a Performance Monitoring Unit(PMU) extension[1] which allows the supervisor to start/stop/configure various PMU events. This series implements the [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The latest version of the SBI specification includes a Performance Monitoring Unit(PMU) extension[1] which allows the supervisor to start/stop/configure various PMU events. This series implements the SBI PMU extension in OpenSBI. It doesn't implement the bits required to support "Sscof" extension yet. That will be added later along with qemu support. This series can be found at github[4] as well. It has been tested with Linux kernel patches[3] for different hardware/firmware events on Qemu. This patch requires basic QEMU support series[2] to work. As the Qemu did not support mhpmevent/mhpmcounter before this series, these changes are not backward compatible to avoid code churn. Anybody who wants to use perf must include Qemu, OpenSBI, Linux kernel patches. [1] https://lists.riscv.org/g/tech-unixplatformspec/message/598 [2] https://github.com/atishp04/qemu/tree/riscv_pmu_v1 [3] https://github.com/atishp04/linux/tree/riscv_pmu_v2 [4] https://github.com/atishp04/opensbi/tree/riscv_pmu_v2 Changes from v1->v2: 1. Addressed all the comments from v1. 2. Improved the series by following latest SBI PMU extension[1] Atish Patra (15): docs: Add device tree bindings for SBI PMU extension lib: sbi: Detect mcountinihibit support at runtime lib: sbi: Remove stray '' character lib: sbi: Detect number of bits implemented in mhpmcounter lib: sbi: Disable m/scounteren & enable mcountinhibit include: Add a list empty check function lib: sbi: Remove redundant boot time print statement lib: sbi: Use csr_read/write_num to read/update PMU counters lib: sbi: Add PMU specific platform hooks lib: sbi: Add PMU support utils: fdt: Add fdt helper functions to parse PMU DT nodes lib: sbi: Implement SBI PMU extension lib: sbi: Implement firmware counters lib:sbi:tlb: Improve function naming platform: generic: Add PMU support docs/pmu_support.md | 83 +++++ include/sbi/sbi_ecall.h | 1 + include/sbi/sbi_ecall_interface.h | 138 ++++++- include/sbi/sbi_error.h | 2 + include/sbi/sbi_hart.h | 5 +- include/sbi/sbi_list.h | 11 + include/sbi/sbi_platform.h | 39 ++ include/sbi/sbi_pmu.h | 73 ++++ include/sbi_utils/fdt/fdt_pmu.h | 46 +++ lib/sbi/objects.mk | 2 + lib/sbi/riscv_asm.c | 35 ++ lib/sbi/sbi_ecall.c | 9 + lib/sbi/sbi_ecall_pmu.c | 78 ++++ lib/sbi/sbi_ecall_replace.c | 1 + lib/sbi/sbi_hart.c | 84 ++++- lib/sbi/sbi_illegal_insn.c | 2 + lib/sbi/sbi_init.c | 11 +- lib/sbi/sbi_ipi.c | 6 + lib/sbi/sbi_misaligned_ldst.c | 5 + lib/sbi/sbi_pmu.c | 600 ++++++++++++++++++++++++++++++ lib/sbi/sbi_timer.c | 2 + lib/sbi/sbi_tlb.c | 78 +++- lib/sbi/sbi_trap.c | 5 + lib/utils/fdt/fdt_fixup.c | 2 + lib/utils/fdt/fdt_pmu.c | 111 ++++++ lib/utils/fdt/objects.mk | 1 + platform/generic/platform.c | 30 ++ 27 files changed, 1431 insertions(+), 29 deletions(-) create mode 100644 docs/pmu_support.md create mode 100644 include/sbi/sbi_pmu.h create mode 100644 include/sbi_utils/fdt/fdt_pmu.h create mode 100644 lib/sbi/sbi_ecall_pmu.c create mode 100644 lib/sbi/sbi_pmu.c create mode 100644 lib/utils/fdt/fdt_pmu.c --- 2.25.1