From patchwork Thu May 27 00:30:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1484373 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=a/g6klS0; 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=S7sGsPIq; 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 4Fr7zR4CSsz9s24 for ; Thu, 27 May 2021 10:31:31 +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=CMCh6z84t6VEEDoEIOHMbo3Tsm0ZMezEFLD8elQUp1A=; b=a/g6klS05/i5uN zqmdTEHYqPWGOppPrI2xe6ekPBkYjfW2KDbg6vOAw7TXTp5MALwMMM/ArEWJHS3aJKKQ7yztDSqnc k6z8LrFg2AFHZih1dn53zr2phEWK4egniDhldlhn2Pi9LUBM6JEfa8oMHSmCWIABzaUq13mFfAMky PyHNRFGtcUR1FvWGtlKuA9IEvi4+ZGtdzty5NyvTkYj61BqkUJtTGfQzfqCAJbk+9xtGUlTYNIqXk +L8K5F7UuCmDRxtdpAUxiwrl93VsTx4fLELADwrFfnFSz9JM0kQmCTo/wd4tIAj0IRjniKmOa0uCM ADi52CC36EaeRspZugeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lm3vq-001AaY-Ki; Thu, 27 May 2021 00:31:26 +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 1lm3vn-001AYD-VN for opensbi@lists.infradead.org; Thu, 27 May 2021 00:31:25 +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=1622075487; x=1653611487; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ECsGahwjVpWWW2ENAEmFlTs6FzLlukA/kVcO4ktoz6k=; b=S7sGsPIq1nPZsGw366IYI51vitmPtTegEHFBXiU28Mfu1Bvzn6XX7xPu Jh6lzaKPgCt6+7BeOo1sZnG+eedF0ffxfBsQSke+HV6zSFCJ6eCjyEJ0O VCXDDEvlHrmxdTqaf/rQPu+Toa3J8LV6v5iIpfdHUQC1mTXDeIF10gWgE ki0ksRgCvlxkxgEGHn1EvZ6QfGM64NKt5cpxqBGZidlONjMgCW35KvmWs jsaDwqDM1V5Ee4C/E6+eN0TpCFs2wwcCwTvk+x1X095tgkoM71JxZHhUf c1HB416T46u4l4didHAAjj+VWWarChk3zo3yPjne36Z/UKP/MJqooknnM g==; IronPort-SDR: Mbk/VAn2fwKFdO9CBglUY9GRsk0CMA+44+sLvL9WdC3/3Vm2CgTLvcDqT8M4k99dWeczgcP+Ni YX2to6EdVyBg6NIz76I3HmFVugRGKwLNhbCe6iQ+/h4VLz61V5z+TX0hF4KZz64x3TvcTzNXIx XuZm0aRswSiFvkjXK7Ckqa1wb6fx3JpUbA0EY9q/RNdb7RYRc9Vdp+8PJAPUWD4YbzWI4Con9K sN8xfBgd+4a39cZ6Y5atPQilbu4L2qXqhR0Z3ngEMAjQKlSSrf9XfHvZY04Ou5Mh0LCXWTgFI3 k8c= X-IronPort-AV: E=Sophos;i="5.82,333,1613404800"; d="scan'208";a="273477800" 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:26 +0800 IronPort-SDR: wcA77nu//UsKtsxmpn+7uHNkxbrA10rouJZ1GrOflWTifeuTNB6LH245Sx42wCVYILyH5c4duD g5t2H1z0V0u6eN9ZUDxIgYnI7QimNyV7s+VbOkH20LKbK0e/oK+PgmFh7gHjJzMYCKpA34qp6/ hHJGD+QltyQL6OhEl86D+psRSVOonw+TqCul1ehctXZ7Yqid1UwcjUmp7bBlsnCFCpq7mINyxw e/ViXHMto2GHkDa7tQkWNlgjDm6F9t3sVMq93iLsuI8Bv7Za3dg4bt8YJA7lF8lpz1PkYVbqXJ BovsbR/7WEfwUgEYt5k3pNLz 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:49 -0700 IronPort-SDR: HcjfbWgyOWFZxs9sVM+d6Sbrg5RxeakFWvR7Ey6cKxvdi7oevJHywn+3dQLVCNxl4rio+59BEQ dLeyxTp6XERgwjrU03KbHKYA6EccggMlsJ2/ClabrwEFyqslcWLD4r9wKejstEU75vX8alvbMU ujAMhwYX7akJiiAo8D8CRf+jjDw7z4Y8kyZe5N+/CZoArJPnLHppxO/gtIgFTbi+BuL03fFEvx Q7pk0JpaHMkLy0MfV5bWmo1g38XGyrG45yPckeUE1zMdA/ydPy70xXXeDPQ/ExGvShq3mVpEHO B4k= 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:21 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , anup.patel@wdc.com Subject: [PATCH v2 09/15] lib: sbi: Add PMU specific platform hooks Date: Wed, 26 May 2021 17:30:38 -0700 Message-Id: <20210527003044.889681-10-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_173124_097959_20B0143B X-CRM114-Status: GOOD ( 13.36 ) 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: 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: (-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 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 Reviewed-by: Anup Patel --- include/sbi/sbi_platform.h | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index f8074d28db65..8e6caea6965b 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -89,6 +89,12 @@ struct sbi_platform_operations { /** Initialize (or populate) domains for the platform */ int (*domains_init)(void); + /** Initialize hw performance counters */ + int (*pmu_init)(void); + + /** Get platform specific mhpmevent value */ + uint64_t (*pmu_xlate_to_mhpmevent)(uint32_t event_idx, uint64_t data); + /** Initialize the platform console */ int (*console_init)(void); @@ -391,6 +397,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_pmu_xlate_to_mhpmevent(const struct sbi_platform *plat, + uint32_t event_idx, uint64_t data) +{ + if (plat && sbi_platform_ops(plat)->pmu_xlate_to_mhpmevent) + return sbi_platform_ops(plat)->pmu_xlate_to_mhpmevent(event_idx, + data); + return 0; +} + /** * Initialize the platform console *