From patchwork Fri Mar 19 22:12:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1456048 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=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.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=desiato.20200630 header.b=poZECQm6; 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=jElErmsP; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4F2J7n483kz9sVS for ; Sat, 20 Mar 2021 09:13:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=poZECQm6iSJOtdqCpT+cRHqzU F4og7+MepTBVotzVyBJbMYGX/AEyQoOBNgF+6t7i4dmK25sPTd9AuBcd/6noq/DIcQ+kHQJbFpNjR zsYe9RKzj5NVFmQQRqmCGwS0359zfR69WkhVERjKzrVVbel8ZhtLOazYT1lSfbfdWMpzUHqanyqDU kL7OxvYzvzIKfMRmTltde7qCa+Et5+QamrUkfUaLyDF6cnf3bBBpjmIBRzpsB51LnQ/kn2nm0J2uI j1EOLj5igsFcXuIYoADITl1/CeA/OlMGiBcC8H6umwLuRZ9VZnyikaRlUT21NquDvLx+uDW9o4UoX Qun8ZL3Bg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNNNA-008FMB-4l; Fri, 19 Mar 2021 22:13:36 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lNNN4-008FJO-Ri for opensbi@lists.infradead.org; Fri, 19 Mar 2021 22:13:33 +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=1616192011; x=1647728011; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZvWoSsciAV2fx0wXl3hlZRB1JjNGBbHAq198zpY9uh8=; b=jElErmsPR84n8OqKdO8DZBfpe4JpenrbRac4CudnJkoVBJF5EqTo2HBs whLMNviWVYtSpKTBvnAtn+X7ByVIHZ8NRPOF8hPpBuqXUDJFlE54d+oj6 E1pyI3UlkqDBR33zKOzwJwAlu9UNFr89oonzfasieZMc518WlZ4Dv99EB sTOkvAwZXJswaqhWBFwPosMJx4ayoSP/YTYTsMygvNHd8qWVFwnNRuNLa Ctk29C8TxgkNys7PeeGzSDQPmp3A2pPrAtO52R+msc2JxRI4HqT0h9k+Z U7iO6wjJm73p68BWXMk2kUKhrQZYuE+Qghd3bBrCpTjpl7/7sYG1Ui/jm Q==; IronPort-SDR: CBleSRzYtCpZgYlA0efSbyVWIVKmXBw9FQPIyttPV+JVq2zGT7T4CZCi9k2UuU4ZD7P2WT0DT2 9fOKcvj6T7/mMXNpXYB8Lnoeyz+hTFa7TNp2gr3kEEL+vDKOedRKRXWOGYJXPNdxdVPNM9pOi+ 3GR/8XElMVFTtpdFtWIe2wN3EmQ5s+D1sDnub3j4A4ZqihzXWYOpSpbBM1YEAtG0Rl/0+RJ1BL dvX18A2K7JmYkOHe0GFQxIuoWlhjjG/C+CDMkgc8e3CroTih/XkjNvXbKbsuAMs2rTlhHXKqOP XHY= X-IronPort-AV: E=Sophos;i="5.81,263,1610380800"; d="scan'208";a="163713900" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Mar 2021 06:13:18 +0800 IronPort-SDR: XBEkyK/op4e3yaSpCPFZ9QExkOQM7SkYc007mWPBRkN/Cda/NbouL5EmnJdmzxThBXuKv2hpeO 3jqW5oEfBCIu3FALg3TYHwTppj3tYOYERtEzjiAqilnydcYgeQKAVCo7dYUkTe0yw0gIoynHIq 3d3xZYIOEcX+PT+E8r8i+yd3YfjufHT/p9S0MwYpZIm7wZHfZ3AnAaPdmhAh9gd3IzpT88bweZ pQdxWWZHq7nVeZpbpf/vLkSXLa8g3tSyf1xZLWEwHsXt8u02gzbrJxyGNqP9yj/hGmVCgSa0Pq QgC4abB3tTLTS/5wEDRwPvC4 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Mar 2021 14:53:49 -0700 IronPort-SDR: 5HoZimTPv/uzDdmBK5jhf4u8iH8C+v8//HP0GxTZnELk5wmZqtR91MdOK1PCZQsGvUFm1lSMS/ pIGHQ28lWaCibXfqYmVtbqM7YS80W+whHkYmKujeCaRBlMRyeqY5huK3sXOBwjNla4Sw5mlYUa FVf0vF+l2zakFNTleOAu1xfiPQpVIzlJwvx3dBdGwaHIcMlyCXHsQi8SW6Ax7gPktJrLwFO0Zf 9CrZHh2b6jhreE2AD/cAVuKAywJIeX3A0jkadQRP7C7UwT8F6+OcMb+gPov5mG0WTBYeClY8ke wP8= WDCIronportException: Internal Received: from ind002560.ad.shared (HELO jedi-01.hgst.com) ([10.86.48.105]) by uls-op-cesaip01.wdc.com with ESMTP; 19 Mar 2021 15:13:17 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , anup.patel@wdc.com Subject: [RFC 01/14] docs: Add device tree bindings for SBI PMU extension Date: Fri, 19 Mar 2021 15:12:52 -0700 Message-Id: <20210319221305.2138412-2-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319221305.2138412-1-atish.patra@wdc.com> References: <20210319221305.2138412-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-20210319_221331_350208_68C89DC1 X-CRM114-Status: GOOD ( 20.09 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [216.71.154.45 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's 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 --- 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>, +}; + +```