From patchwork Fri Feb 17 14:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mayuresh Chitale X-Patchwork-Id: 1744267 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=TXedDs8L; 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=NzHeaYgi; 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 4PJF2s6k54z240g for ; Sat, 18 Feb 2023 01:44:53 +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=pUEZBXex0fbrGhkontTZYPDDc1avNpXKf5QS+j1ymVQ=; b=TXedDs8LB2rqQ6 Y7cTkQra/1+MKuSHKS3gNDe6saOt7/BrTyFJDsC+dLpx8TDJJXiQHHP/nUYwG1oNqxVpAF36IfYKO chLiKequh54/V8xujE+P11JHsfd3xLQHfy9P63EXsDpTO69MkoFpK06WSKpTqrTcsPHoVDqL8OQVz QaiAWqA9jGjgRzRbo3gGVFGAbBQgrhSE4Bk8uYXIoo3SO5p16bjoBpMgolDkGvdnzVQAMQfKY0hI8 PYrtAe+KJiRtqv1WI46zma2SvnV6cOua1SSBwo5XrS/RzzAlfAMC25O+t7tOtcdcvERvf/3DKWimY bz8omNXCbe1SqJQ2JOtA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pT1yX-00EbxJ-Oh; Fri, 17 Feb 2023 14:44:37 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pT1yU-00EbvH-BH for opensbi@lists.infradead.org; Fri, 17 Feb 2023 14:44:35 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-17068acb0c2so1686694fac.6 for ; Fri, 17 Feb 2023 06:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; 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=JHbjxnr2UBGk/qzzyFeDLPkbcu1BFvHU440yqEjaKkk=; b=NzHeaYgiJKSNr0JDrzZELC58j1+/nl3qTm9PFDNLJvwVkPia4XllExYCcIkTshMWqG jWmcBG253KN8+HWDh6xAsM4sKOMd30XxDWf0nx3epZrECM7U6B9FAFtwcGJNcyDno95v ftv80/owmPoq9Jg0GFFB39peOWKLy33kczyx0sYDUSJV1laNehWpEoP2yMSbXSoTTJuo olmnKP53b1QQBQ14DrqzytnSizAjvcmnJiWBYmXem0TOvnxDPsyVZsDj2O5XpmX9IymL WCVBlMJkYVbEtKV9KFzqz7Yydpf/3N8P6gMprT38jc3QH5fr9whKqWs5mfP52ytvmrh2 S6UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=JHbjxnr2UBGk/qzzyFeDLPkbcu1BFvHU440yqEjaKkk=; b=XMX0PAUo32/bmFRNotz+B82U1aPcnejguf8l8QoMqGz6LUgXjdFGFxGxQFijYhBR78 DrCPIJVpa2HP7cTEuNum4j62Dxd18W9msYNq14lz3xzco0aCvwLoAB6h1tEcndK70T7f QNzW34QL9Pa8mcD0hTm6whY2gTQ+TynPqQZIUN7jNi51rt0iCQ7/+s91HaAj5LLb1gC5 +qXWU9t7gJThU44AaZFY+mBBYVMmVnM3DZ3HY/IQjVs6VTUTcNbPeTxS/GfjI+TTv35y VJyu1EX3xhivoEzGKJn6trr1ICl07APobngs30Nzjqno7neLz71HEkFLBxkQKCzIoRHx kWhw== X-Gm-Message-State: AO0yUKVhPVpK0LvpVb1f/ZS0+Bs+xzE2LByfVFMNSOgOeQwbm0iS1rHI DUqlVqInZBulL3wlq0a6F+N/FnVsOk+if/kFKd0= X-Google-Smtp-Source: AK7set9vLYxzYLJYTLCS7mT5d5D3h1e982qKU2E2TtQcj6RVEFS2P2WcMqehyXFvKMrLBi/J7u2pLw== X-Received: by 2002:a05:6870:3929:b0:16e:8edf:42bb with SMTP id b41-20020a056870392900b0016e8edf42bbmr2348986oap.14.1676645072852; Fri, 17 Feb 2023 06:44:32 -0800 (PST) Received: from mchitale-vm.. ([182.70.74.242]) by smtp.googlemail.com with ESMTPSA id ec21-20020a0568708c1500b00143824af059sm1718888oab.7.2023.02.17.06.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Feb 2023 06:44:32 -0800 (PST) From: Mayuresh Chitale To: opensbi@lists.infradead.org Cc: Mayuresh Chitale Subject: [PATCH v2 1/5] lib: sbi_pmu: add callback for counter width Date: Fri, 17 Feb 2023 20:14:09 +0530 Message-Id: <20230217144413.3720307-2-mchitale@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230217144413.3720307-1-mchitale@ventanamicro.com> References: <20230217144413.3720307-1-mchitale@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230217_064434_425523_CD0B3F70 X-CRM114-Status: GOOD ( 11.76 ) 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 --- include/sbi/sbi_pmu.h | 5 +++++ lib/sbi/sbi_pmu.c | 6 ++++++ 2 files changed, 11 insertions(+) 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 [2001:4860:4864:20:0:0:0:31 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 --- 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;