From patchwork Thu Mar 9 05:51:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mayuresh Chitale X-Patchwork-Id: 1754420 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.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=Srcn7o2d; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=BFBa2RxY; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PXJGW23Tlz246y for ; Thu, 9 Mar 2023 16:51:47 +1100 (AEDT) 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=4EYerPnigg1jK2UAtMXd4nUgCAj+F9hIvDjqe+KxQ7E=; b=Srcn7o2d84cg2a C6swZN7ep9GePt0PE43i4Zjl4kf93a6REoXCtEU5//SMOkpu29CVOXNGWEosRKN+8hQ3Ap6CbREMt PLtkuLTvwZ75byY5mwVGmARIDs3rVZzv+MEtS3DH86P/A9MFNOzHM9nsAYWphGSKHA72NszAXUqo/ eV53pIvK5fWhaEj1EQLA3Xkc3Zr4D1lqKKJ0SkIi1tFhmNjkl8KF2qX6lAuniN6Hg1B51PVEzz8Sh VlhvPyXFij1C0mFa1pegEFkwkv03KNeLQGWi9LxIVicPNW2tEYxx8V3A96u3lU5DRQweoQ8qFe0Ia Vw0MgDqqChUHcMMliWmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pa9BX-007z27-Es; Thu, 09 Mar 2023 05:51:27 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pa9BU-007z0u-PO for opensbi@lists.infradead.org; Thu, 09 Mar 2023 05:51:26 +0000 Received: by mail-pj1-x102f.google.com with SMTP id l1so1124414pjt.2 for ; Wed, 08 Mar 2023 21:51:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1678341081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1dfhhsImxIYEVmMizOv/uXWCNaK4NjWRpPt5dV/S7Y8=; b=BFBa2RxYBa9qFzBtJav04nH+tjzv1Qu47r7ZAf5EJ5DTau3edglLQYbN5FokHTPOx9 8mNvd06/5cMs/Bwj+RV76Wbu77fqLy/8ycpBEkj/sWav/YwpCs29Eoh7b/0sMWOC569y Bd2FUNBmKO1kgKeWQRYz/GpuZEWLfrfOmVbU1DnmIqghIItMPqVR96i4YPlC41sF3atS u+0haCamoplVG+9T8XjGA063ngWwEaFf50mS958F90e16bM6LXTPbl8Z6qmLQGipn/Sj AaoePHY5Da8TeNomJRtNVnTdsuQc7UMx911I+o5hb0FeNJopQ3xGLkGRHkcU7gQPZ9IX jJrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678341081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1dfhhsImxIYEVmMizOv/uXWCNaK4NjWRpPt5dV/S7Y8=; b=YD7BsBUwF2i9YadACr2ESaan6QJeClrf6Preb5L6ZHi/fxnv1v3CuQAxPbUx9ri4p0 YQYlZaoWzqLV7DtXWoINZk18m2mWGeS/vYZYUNIIBuXJn1kPOgGzWz4Cwhg/5tRZpl5t NVFApVCAYd21TZlreJiKrBN7crS9zvtClI1FyX8puLQLlB0walfPMf03H4pUvycNrnSD cNQwCC/+S6M4Ah4kbieQ6FOLqZnRIHlrB++S4r/Gi0NM/X58bkuez//BrTiDEBeSUdCR UIeMlekLER6CWysmwi9KYJu77zXTrOnyd3nrVJNePqEniKl4bcbU2EZFGrx+M0at+QBX sl6A== X-Gm-Message-State: AO0yUKXlvHr/EFqncOpOhGXju7VD2hbxVq/bXGx/sQHrMFn0iqQhMW9D FoJOU+t72Hidcx6EaLaoTn5HQ3u/kKvocr6Qw+7Itg== X-Google-Smtp-Source: AK7set8dXMgtCbYaf5XYypm/51SlXJa0b65FxcFKH8mJkfoiKxqxNmgdWyk2xakrG6aJ5Naz4om2FA== X-Received: by 2002:a17:902:a985:b0:19e:7f80:4165 with SMTP id bh5-20020a170902a98500b0019e7f804165mr16734138plb.17.1678341081416; Wed, 08 Mar 2023 21:51:21 -0800 (PST) Received: from mchitale-vm.. ([103.97.165.210]) by smtp.googlemail.com with ESMTPSA id 13-20020a170902e9cd00b0019ac9c4f32esm10590724plk.309.2023.03.08.21.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 21:51:21 -0800 (PST) From: Mayuresh Chitale To: opensbi@lists.infradead.org Cc: Mayuresh Chitale , Atish Patra Subject: [PATCH v3 1/8] lib: sbi_pmu: add callback for counter width Date: Thu, 9 Mar 2023 11:21:05 +0530 Message-Id: <20230309055112.1516581-2-mchitale@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309055112.1516581-1-mchitale@ventanamicro.com> References: <20230309055112.1516581-1-mchitale@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_215124_843555_488B403A X-CRM114-Status: GOOD ( 11.61 ) X-Spam-Score: -0.2 (/) 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: This patch adds a callback to fetch the number of bits implemented for a custom firmware counter. If the callback fails or is not implemented then width defaults to 63. Signed-off-by: Mayuresh Chitale Reviewed-by: Atish Patra --- include/sbi/sbi_pmu.h | 5 +++++ lib/sbi/sbi_pmu.c | 6 ++++++ 2 files changed, 11 insertio [...] 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 [2607:f8b0:4864:20:0:0:0:102f listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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 This patch adds a callback to fetch the number of bits implemented for a custom firmware counter. If the callback fails or is not implemented then width defaults to 63. Signed-off-by: Mayuresh Chitale Reviewed-by: Atish Patra Reviewed-by: Anup Patel --- include/sbi/sbi_pmu.h | 5 +++++ lib/sbi/sbi_pmu.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/sbi/sbi_pmu.h b/include/sbi/sbi_pmu.h index c365243..b3b75c1 100644 --- a/include/sbi/sbi_pmu.h +++ b/include/sbi/sbi_pmu.h @@ -41,6 +41,11 @@ struct sbi_pmu_device { bool (*fw_counter_match_code)(uint32_t counter_index, uint32_t event_idx_code); + /** + * Fetch the max width of this counter in number of bits. + */ + int (*fw_counter_width)(void); + /** * Read value of custom firmware counter * Note: 0 <= counter_index < SBI_PMU_FW_CTR_MAX diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c index 154dbda..a99c045 100644 --- a/lib/sbi/sbi_pmu.c +++ b/lib/sbi/sbi_pmu.c @@ -761,6 +761,7 @@ unsigned long sbi_pmu_num_ctr(void) int sbi_pmu_ctr_get_info(uint32_t cidx, unsigned long *ctr_info) { + int width; union sbi_pmu_ctr_info cinfo = {0}; struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); @@ -782,6 +783,11 @@ int sbi_pmu_ctr_get_info(uint32_t cidx, unsigned long *ctr_info) cinfo.type = SBI_PMU_CTR_TYPE_FW; /* Firmware counters are always 64 bits wide */ cinfo.width = 63; + if (pmu_dev && pmu_dev->fw_counter_width) { + width = pmu_dev->fw_counter_width(); + if (width) + cinfo.width = width - 1; + } } *ctr_info = cinfo.value;