From patchwork Thu May 27 00:30:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1484366 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=evfnjYHN; 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=Ie/rfeFs; 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 4Fr7z8094rz9s24 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: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=nvwXiQ9QwVg0nibZtN2MrMoaIgiYeH8iD/3z2ik87uU=; b=evfnjYHNbfPGCp c7L/qu3CwoDyTlzBNb3z8BNclxdifWGXRCEwS02nNZQgqtkwIFndhHBTw8snNI7jr6I+jHscqzcs4 x9V/lcOHfmklinD5CMdIVfECDQxNj82ZBosD1+TrKJYVDaCX6gg7z69Fts8rn+uEd1Nj/W9KcKnnU x+wDCchW4Oqhy5kokow9aCPu45m8zYhv4lmqJRovkKlMgkCLTixJUUitwmZrSuWmkkeQ3D3kwLl11 09Dr8fY/XWtlcunNGgrL6suqqiMlrPH5YHyF/00rEMO+JwllJxuIJi9kQq2QYIXKrJdLeszlZiYA/ X+OV6HwSDx5ZsLOzDbqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lm3vY-001ALP-Ut; 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 1lm3vT-001AJC-LE for opensbi@lists.infradead.org; Thu, 27 May 2021 00:31:08 +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=1622075481; x=1653611481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZvWoSsciAV2fx0wXl3hlZRB1JjNGBbHAq198zpY9uh8=; b=Ie/rfeFszmrQkBx30+JLAJ9f7fmrKQRTQ/aMaUCGdRFSow9SzT3M80wx V+NhuRgA8Luhm49ZId/CGEu+XfhQ2YT10RRAxdgcDWHpxSVvGbXrue8ca 2tILZhC0YTCxTDXkt0igI0y7PAZNZHK8d5RVCL4iBxX1+jMGXaZ2bGC5T 3zPKmZYmoJSqbHPSELrxO1V1yNpvAkCZjJHZ/4y7nmG6N8aacuwAxlqgy cb8mzsgY+JVqOFYr37JNeRbZVlHDXNjZftqGQQTut30szFGJ2F59HRTQB P5heYzPzqElXpztc1GuYlGtIjsuYmEgUPf8SFRnr/q4e50aCkqD8wVzII w==; IronPort-SDR: bwhYAuBDJol6nXg/RWQRFYUpiuPl6Il5y7bnyo4eXhLXMUI8jjLAR+Sj+2F2WJPXQZmXr1HuLC hTmClfAJbg2kTAXlFYjCrVmPOXJyjlf6KVteOCJ1QhsKVqpOX0/gkKhKU6KbEUCH96LLS5Pt5W QXn4V8jKYZuFDuz+kR+vYqamJBiw9BfzYuObnGDthlQy7FwLYpNfPU/SkBknl0u4TYxtqn1fzj JrHyVClMgOtpGIwBWjW7hr7azqFtUyqLAqXqdlDpycd9k/QcrSfpUii6Q1cEneM2EU1cxdcCnD WIQ= X-IronPort-AV: E=Sophos;i="5.82,333,1613404800"; d="scan'208";a="273477694" 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:20 +0800 IronPort-SDR: mhiUUeqT859C2ihQbmKCVac8CEoe7XSiUYZKi67aeLNLkELg5mqr3Vp3/gqK3NxlqWWalicDP0 SzGa/tyq9CbbliSYOhg3cA6af5pPrLgIsvPGT9CXdgJVJrAkh3vFzqAWvq1QQAxS9/CQcmJPQ1 F6aiZ8C4qWXhznJYgF9dIislQ3bD1sBtQ7dlkXFv9/nJi4nMghfFbFoE8WcZU/EuRynBuykBw6 ncCoVv8HaJgWhW9o4BLmF02YkPWVZv30DPFVST+GKrxfo/OP31X0rdoiKI9W6Khv8HRVr++0K5 SbUNXKsZT02LbBQqyjIdg2kI 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:28 -0700 IronPort-SDR: cUtCNqdoBFmcy4DKl3kiNsTSiNGCOcDaqwumwHaUqsq65IomjR3kXyrglmQe+bSnhN/8ulAW3M s44PmeMKEl0nuw4jZ2WbYQtPLWc9Gp9zKcUXcoXzEbgVZMNKSeGCg5LyEka+mdW8m6ZX3371/j 3Ue5+BPrggHpRVoA2GNAM+0hYlCGJzutfQQT478tcw6PZiuIBYzLQqZv0/ayNCuNSw7sz2xYTN iL7a/JsnY7HbkugENrTBG6U2hz/M29fk/SVtX8yWXXr1rJDaVIZYUUYDzsgFjsb2+QUVIySWCw qmk= 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:31:01 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , anup.patel@wdc.com Subject: [PATCH v2 01/15] docs: Add device tree bindings for SBI PMU extension Date: Wed, 26 May 2021 17:30:30 -0700 Message-Id: <20210527003044.889681-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210527003044.889681-1-atish.patra@wdc.com> References: <20210527003044.889681-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-20210526_173103_780417_92DFDD76 X-CRM114-Status: GOOD ( 19.55 ) 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 [68.232.143.124 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 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 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. Signed-off-by: Atish Patra Reviewed-by: Anup Patel --- docs/pmu_support.md | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 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..8535a1dccbeb --- /dev/null +++ b/docs/pmu_support.md @@ -0,0 +1,83 @@ +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 platform specific. Generic platform writes a default value to +the MHPMEVENTx CSR where is formatted as described below. +``` + xyz[0:19] : event_idx + xyz[20:XLEN] : event_data[0:(XLEN-20)] + +``` + +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>, +}; + +```