From patchwork Fri Mar 19 22:13:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1456056 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=Eg/o5jyD; 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=OEBqyvLZ; 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 4F2J8M2BYQz9sVS for ; Sat, 20 Mar 2021 09:14:11 +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=uzpppQxFDRSzBGY6K7qZ1CqnTN0PalA6YCYjt5NNkTw=; b=Eg/o5jyD9GW4WllLiymcIlKA4 E9CnFdmTiiSWhADNGHyAQ+D4+cj+9zeRXmKlYCrjEteITX68a56/XewIocKErm98Cy8MqB7WHKobd Y6NM6KyD29FxhmCDl9KbKaWFwtEP2BQ7S8ptgHovd23efQqK45LCOjZldw8wqpZBA+NcOSPTjxkhb /Kd3Nb2HI+A5aWS3pm7XzIRQFiBNX4vkhEjNrelrkBkGKWwJnlUAcqUntAMst6Os1U1FqHDlTFSCn WjhTcn5J47O6wCFFfZxwKDw+aXE3XCQ4LVTbngzRDzZeeYuJwloriggslQEt3jf/KxQxMy0t1UpDY HhgvCJe3g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lNNNf-008FXE-EJ; Fri, 19 Mar 2021 22:14:07 +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 1lNNNF-008FJO-N8 for opensbi@lists.infradead.org; Fri, 19 Mar 2021 22:13:44 +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=1616192022; x=1647728022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tvKpeHCWAqWHhZBqyIrUEQXUjmkoDDRv/U5VG5QZ27c=; b=OEBqyvLZOkPDzaZPeM0pWGUXcazQvqfZqMRdVgkYPhhNe0Ms99BuIByK Gzc3gbssaGJWFEnvj9MINh2hGP3OlFtGsuI33C0dWKPeSBOB3WexbIO+J DOSV3TD7DWURjb0gJf2AGKgKyy0QK6oqOo8RZuN3mXMLbKhTVevBcA4dS 0M/UJp5PhwXrXjVhGgAxUR5InuPdO4qtjU5qTAZFFOT4o0rBtw4ocDdkW vWJnMwXoJjnH/iRHn9JSsdhyRAr8Z6ao8X4gh1bislsxHuoHLDLLN2pWV 999G8VbGBCWRiIkMrK6sY5lM9n9+sbHL2C7kM1KH8wBe1lq2zgUZAxxDm g==; IronPort-SDR: aLqz1w0J8vuhMxH5W2pfdQjymukvVsfNUiF0jDOgioCTO0HHuO3ZNgTQCUYAUxUNiw0pKzL7nt qhtc/n0IOCzjcTBxfAAeunAW75PJxPlWCZXGmORgj5ggT1D4VXWz03Ma+1CVu6oKOhJAKkMujk AjZZjTn29A72cgGtZCTrBs/46xsCY2qYTgCoAgxQnLdK3A67qnyS3tGh9ICtKI/YxtDN6tf/6T xj0imB55Xjkw5FWd7qXDWQxtFtGukU8wIVksMZc510MKr7+xCJFvoUS5fw/b/74NutzB8vSvIs 9mQ= X-IronPort-AV: E=Sophos;i="5.81,263,1610380800"; d="scan'208";a="163713909" 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:20 +0800 IronPort-SDR: /tT1a0H3z8Mn+FGcwRPqZlIWL7QRNj7fHK5OPm0TkgoYL+9+XxScmsiN1aTLRif4cGw1r0SrAD B7M7TMSalzvBprdr5hcH78oVX4CGGFixGCVHACvxC4NrsNjLzBKt+cGlIjiua6bf/Mp52UTjfG Jrv1xc7jQIg4fgdS6SWlHcvHR28TorwDVHIn9fC9f4mWTqunjac5TdhTmKu/8qQu+SQjj4INdI ONjH6+L2egpMGq034Qw1aS7OA+dtAXHp8IpTxrMXYiSa59FqDXfR6pKnsYUeayo5jCIe4ECYnT GGPKEVTneFRZTPEH+Ytr1Wsb 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:51 -0700 IronPort-SDR: mWwLhJH8fOlVy0E/jjQmqifh06zZPfaSBdt4HOC/1p7kRSwuIcf33nffqnVz0AKWS6img4r/dV xzlfEETG4rcebM0XQfIpUkHSF8am8cM5ZLGtQC6NNSxaJTVVJoIE98tI2LeGrEvSeNjazCT3kP tkafRalVw+6qS0Pd0ocZndetS5tQ0VkYudfiKsTpCQKeA7nC5JpEOyP5CkT9L9d0zkqKlinQIe XeZ6GHcKCrFojhfcH7nEYzBdAJQZfa6Qog8tlv7v4wkHNHaWXd6etAEX2Ew2+TEqzNkN133Lm4 wBM= 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:19 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , anup.patel@wdc.com Subject: [RFC 09/14] lib: sbi: Add PMU specific platform hooks Date: Fri, 19 Mar 2021 15:13:00 -0700 Message-Id: <20210319221305.2138412-10-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_221342_230080_402F0268 X-CRM114-Status: GOOD ( 13.82 ) 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: A platform hook to initialize PMU allows platform vendors to provide their own mechanism to define pmu event-counter mappings in addition to the DT based approach. Another platform hook that allows platform vendors customize the final mhpmevent value configuration. 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 A platform hook to initialize PMU allows platform vendors to provide their own mechanism to define pmu event-counter mappings in addition to the DT based approach. Another platform hook that allows platform vendors customize the final mhpmevent value configuration. Signed-off-by: Atish Patra --- include/sbi/sbi_platform.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index dadbc1e94e18..02773f672443 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -97,6 +97,11 @@ struct sbi_platform_operations { /** Initialize (or populate) domains for the platform */ int (*domains_init)(void); + /** Initialize hw performance counters */ + int (*pmu_init)(void); + + uint64_t (*get_mhpmevent_value)(uint32_t event_idx, uint64_t data); + /** Write a character to the platform console output */ void (*console_putc)(char ch); /** Read a character from the platform console input */ @@ -514,6 +519,39 @@ static inline int sbi_platform_domains_init(const struct sbi_platform *plat) return 0; } +/** + * Setup hw PMU events for the platform + * + * @param plat pointer to struct sbi_platform + * + * @return 0 on success and negative error code on failure + */ +static inline int sbi_platform_pmu_init(const struct sbi_platform *plat) +{ + if (plat && sbi_platform_ops(plat)->pmu_init) + return sbi_platform_ops(plat)->pmu_init(); + return 0; +} + +/** + * Get the value to be written in mhpmeventx for event_idx + * + * @param plat pointer to struct sbi_platform + * @param event_idx ID of the PMU event + * @param data Additional configuration data passed from supervisor software + * + * @return expected value by the platform or 0 if platform doesn't know about + * the event + */ +static inline int sbi_platform_get_mhpmevent_value(const struct sbi_platform *plat, + uint32_t event_idx, uint64_t data) +{ + if (plat && sbi_platform_ops(plat)->get_mhpmevent_value) + return sbi_platform_ops(plat)->get_mhpmevent_value(event_idx, + data); + return 0; +} + /** * Write a character to the platform console output *