From patchwork Fri Jul 2 18:01:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1500221 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=To6AlyTp; 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=D83wOEEi; 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 4GGjcw25xhz9sXN for ; Sat, 3 Jul 2021 04:03:44 +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:References:In-Reply-To: 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: List-Owner; bh=wIEjChbzms4M5YJh1pCPsXtm/gQE20r1ZGe89hPDT2k=; b=To6AlyTpppnQit opN6d+lR0ho5X3Zod0m++R5BcEgL9bIFcEaU8Nd1df0ImEyD4bu3TseUNs4FfQEkVio366OU8A8lb uJIgBtwmOQFEqCD5sYbVzXMveJs6Cgc1pE0+BI3nGplBKBjJ3NGWERzMuuDuwQtgEyktOfSNe2NS/ 7lNHw9T7qlQvW+uYKmLNZ50UKcj/P8V9NdI/yzVIRioqmX0rdKqeccsr+sPlzMNdf2UrAau/tAMqV sE32x0uljGAHuO9M87Lk06dCgPbP1+cop2HRzVANRCmajNws/qk/jhyqb2LW8A+j4oYzJpLHJCf0e tVnoWaBP9T/5udIpDvAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNVr-003iIM-6D; Fri, 02 Jul 2021 18:03:39 +0000 Received: from esa3.hgst.iphmx.com ([216.71.153.141]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNVn-003iH1-Sw for opensbi@lists.infradead.org; Fri, 02 Jul 2021 18:03:37 +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=1625249015; x=1656785015; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mOb9agP2qTmn3lGen66KZYltP66ZZRl7KKMuXvpjqRY=; b=D83wOEEiSaWvOz8g6KDfuu34v+beJ0S/BqNbvFfTJmsx+oxGBix0972d aOpmAlxPfTT5UZSlBX+IHaiGwSuBcVEAUyc7HJvfXyojZAy2OKRNyyikJ dpJfbNBnD91clLX+J0g+5Mn1D9jTvb5TcIF0zFXSKhlTuqlB4gdi8OZo3 JE7FYiWaXEY936AAxqLpJJf88gcvWGdhEfElcnk3lNdR42tSRoYcyY+/z 5xvuVBfyGZoY1nDP/eKtTSFgWTUjm3qz4dGb1a1dKoq8OEPKrJBfFOVNW vpryziQoDh4YA/wvDlSAeQXpVyrzjW9zuQ+raI9O44u3Ki8d7XVyGo85y w==; IronPort-SDR: NKg9stBxdh/cYjyB4njQ23rjH0+ytM/zdIVBHzed+Ws+cDbiQ2QPAdTfjIKGyKfGARcPuPDW57 sedtpPA6yzyf0TOVFQXtihrGdxWGI0ybmTmZ03r/x9uk6IyLZl8scNM6l4+Nq6+K+ba+jAC4T/ rbCVn/Xt7mJ2Xo9d7FoNX19Ir2SwBXqf7S6SxTo4OrTN6uLDmF9wtXClpJOzU02B2ZChdomiBd OZLEW4adaJAVYulTkDsobFzrFrRHVW68yYBkBJwsPSxvU1GnHY5sojTxlUEu8ljpT5Y/DzRB+b wkM= X-IronPort-AV: E=Sophos;i="5.83,319,1616428800"; d="scan'208";a="178382829" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 03 Jul 2021 02:03:33 +0800 IronPort-SDR: vLR5pmHXKgA44X3P+CGbxU5wA6e44bQpsXMhDr38XfdKiAdqQLmJhUIsTFo/rkDpGqQ6IHl5nM zUPDlG3ireNz82cjKcO1Z4D1+3VQ3nub2uLIVVqNtcoreVlQn4nkVqxDtAHXBz666a+RR6PuEo EZuAbG9tCYeaSDfxpuakeLclIqN2R6sInqvCYPk/iqgj5R/f9+0Fk4ENVerIDt/a0RvmzS6elV tupKSEYmGV4HqNSzgynWEHa25ZiEMrXhZd1z1MZ/kME/L9+pGMDhswE7hdLkXcu6co/lW7u8Rf SzP/XOTt6q1gFuklcHMO1J9/ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 10:40:39 -0700 IronPort-SDR: Knu0LAar0roz4/8xVyC2k24ytmDqa123bMdIlnzv+9UKx2Zhup1a8fcZQ3jHyiBp8dGi9D/AgP JlJfyK76odEjS+M5PXQqlBn7iAESJJyRQkPRS/TbsxArjhcqSwbvJsqbE/8P1zO2uZV4lXTyiN EZZB0LyZ1jd+82RWMepWATe7YLE1etKkcKHshUrp1z81jD3V/pX85N/mCLJ0qOpA/nlQLvWmu/ AN+6htn1B3QEaK+Tlln6EFaiWwKZC7QjtxEk4eC1Ol/urCXOlnhaAEXpOEueIT2vG/YKJKKj0c nog= WDCIronportException: Internal Received: from unknown (HELO fedora.wdc.com) ([10.225.163.29]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Jul 2021 11:03:32 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , Anup Patel Subject: [PATCH v4 01/15] docs: Add device tree bindings for SBI PMU extension Date: Fri, 2 Jul 2021 11:01:05 -0700 Message-Id: <20210702180119.912898-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210702180119.912898-1-atish.patra@wdc.com> References: <20210702180119.912898-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210702_110336_035181_8D4DD84F X-CRM114-Status: GOOD ( 19.84 ) 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: SBI PMU extension requires a firmware to be aware of the event to counter/mhpmevent mappings supported by the hardware. One approach is to encode that information in the device tree. Define a device tree binding that allows a hardware to describe all the PMU mappings required in concise format. Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.153.141 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 SBI PMU extension requires a firmware to be aware of the event to counter/mhpmevent mappings supported by the hardware. One approach is to encode that information in the device tree. Define a device tree binding that allows a hardware to describe all the PMU mappings required in concise format. Reviewed-by: Anup Patel Signed-off-by: Atish Patra --- docs/pmu_support.md | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 docs/pmu_support.md diff --git a/docs/pmu_support.md b/docs/pmu_support.md new file mode 100644 index 000000000000..f6b208aa8aa8 --- /dev/null +++ b/docs/pmu_support.md @@ -0,0 +1,79 @@ +OpenSBI SBI PMU extension support +================================== +SBI PMU extension supports allow supervisor software to configure/start/stop +any performance counter at anytime. Thus, an user can leverage full +capability of performance analysis tools such as perf if SBI PMU extension is +enabled. The OpenSBI implementation makes the following assumptions about the +hardware platform. + + * MCOUNTINHIBIT CSR must be implemented in the hardware. Otherwise, SBI PMU +extension will not be enabled. + + * The platform must provide information about PMU event to counter mapping +via device tree or platform specific hooks. Otherwise, SBI PMU extension will +not be enabled. + + * The platforms should provide information about the PMU event selector values +that should be encoded in the expected value of MHPMEVENTx while configuring +MHPMCOUNTERx for that specific event. This can be done via a device tree or +platform specific hooks. The exact value to be written to he MHPMEVENTx is +completely depends on platform. Generic platform writes the zero-extended event_idx +as the expected value for hardware cache/generic events as suggested by the SBI +specification. + +SBI PMU Device Tree Bindings +---------------------------- + +Platforms may choose to describe PMU event selector and event to counter mapping +values via device tree. The following sections describes the PMU DT node +bindings in details. + +* **compatible** (Mandatory) - The compatible string of SBI PMU device tree node. +This DT property must have the value **riscv,pmu**. + +* **opensbi,event-to-mhpmevent**(Optional) - It represents an ONE-to-ONE mapping +between a PMU event and the event selector value that platform expects to be +written to the MHPMEVENTx CSR for that event. The mapping is encoded in a +table format where each row represents an event. The first column represent the +event idx where the 2nd & 3rd column represent the event selector value that +should be encoded in the expected value to be written in MHPMEVENTx. +This property shouldn't encode any raw hardware event. + +* **opensbi,event-to-counters**(Optional) - It represents a MANY-to-MANY +mapping between a range of events and all the MHPMCOUNTERx in a bitmap format +that can be used to monitor these range of events. The information is encoded in +a table format where each row represent a certain range of events and +corresponding counters. The first column represents starting of the pmu event id +and 2nd column represents the end of the pmu event id. The third column +represent a bitmap of all the MHPMCOUNTERx. This property is mandatory if +event-to-mhpmevent is present. Otherwise, it can be omitted. This property +shouldn't encode any raw event. + +* **opensbi,raw-event-to-counters**(Optional) - It represents an ONE-to-MANY +mapping between a raw event and all the MHPMCOUNTERx in a bitmap format that can +be used to monitor that raw event. The information is encoded in a table format +where each raw represent a specific raw event. The first column stores the +expected event selector value that should be encoded in the expected value to be +written in MHPMEVENTx. The second column stores a bitmap of all the MHPMCOUNTERx +that can be used for monitoring the specified event. + +*Note:* A platform may choose to provide the mapping between event & counters +via platform hooks rather than the device tree. + +### Example + +``` +pmu { + compatible = "riscv,pmu"; + interrupts = <0x100>; + interrupt-parent = <&plic> + opensbi,event-to-mhpmevent = <0x0000B 0x0000 0x0001>, + opensbi,event-to-counters = <0x00001 0x00001 0x00000001>, + <0x00002 0x00002 0x00000004>, + <0x00003 0x0000A 0x00000ff8>, + <0x10000 0x10033 0x000ff000>, + opensbi,raw-event-to-counters = <0x0000 0x0002 0x00000f8>, + <0x0000 0x0003 0x00000ff0>, +}; + +```