Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp22721rdb; Mon, 4 Dec 2023 18:44:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IER3cd9MVMrmWXZadku4q9XQL7l2XLUCQ5nmDuL8SSQ0dVUtvD7NRyOpJ3o4crh6kMqXupr X-Received: by 2002:a05:6808:d9:b0:3b8:b063:ae14 with SMTP id t25-20020a05680800d900b003b8b063ae14mr5431747oic.113.1701744241114; Mon, 04 Dec 2023 18:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701744241; cv=none; d=google.com; s=arc-20160816; b=kB34jz3NmBFt28/+GGmX6hzL93rkBvWP0Wb14wGG8jsB/7n8GvURH28khCbIH0eDv0 h/fZdUtszICmvYMTRhw1Aq5pYbHaOjjSFxs8Z8BCHdH4k0uO7YLiK/8CpTJPl+ocLUjn VQnfWCoyoB+Sh0U28MfLxcYxl/KpiO2f1SOhnQ4ulKKqeZCr+NTTzVhrEMEKqxiX0auQ C8O0ZKoBVO8m1DzNHo2kI2qK5xiNofqojmO5cceeWtoiNXIzlvOvvkNaANbgSXwRXKQL IpiXaMCBhJ0lw75RrW0WMSVIATPtMzMLPZoS6iZA7BUgJpF2m6CcaB9c7kxMexYIBJFh wO+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ESe2+H6xRcIvQHZC4sCC1Ujc/nu3bNcuHE36+amdpNs=; fh=hdWWmqr42gXb2LKR5pVlTakVhLV/lVdx71bRf5NvIOA=; b=HGUtpWdcbmEAJwSI2cpBVIFc0QT5rLJrUdvEhKvTNfLpD/ErnJVYog+cFtSr9kvBdj GDbqyuBqLlamOJoYLRuIB1k3mOcK9L+MxieKkCKW1KEDslHGZ3ePadYhDuavSywFPDbE HIlXI3C2ZdTHKc9/w+5WrPLJkftzl1urdUVyKVo6SQb2/ex0hxg28ixLNdZiRtvUrFeI r0Y1oq93GH3FexOPvLodHr6Qb1CMol5F78d/SE6M831HdYIEbwTIasjrwGHl/X+WiXWL FLwoyLGgRseXPjrYTGjzgZ2k8MNGsK7J1VvvTF2lERPS8Fofup6k6uSFbvJPJWgU5r+h nqEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="Y+ciD/tN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id u8-20020a6540c8000000b005add209e106si8488831pgp.442.2023.12.04.18.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 18:44:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="Y+ciD/tN"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 35FD280A0DEC; Mon, 4 Dec 2023 18:43:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346641AbjLECn3 (ORCPT + 99 others); Mon, 4 Dec 2023 21:43:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346337AbjLECn2 (ORCPT ); Mon, 4 Dec 2023 21:43:28 -0500 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 870DECD for ; Mon, 4 Dec 2023 18:43:34 -0800 (PST) Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6d87a83ec27so1843951a34.2 for ; Mon, 04 Dec 2023 18:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1701744213; x=1702349013; darn=vger.kernel.org; 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=ESe2+H6xRcIvQHZC4sCC1Ujc/nu3bNcuHE36+amdpNs=; b=Y+ciD/tNCJQ8NcC2aGaOUHpwaeXN8Bf4qOEpdx8qdaMxXj+XhQ0CJGVcbaW2iopBha EWPptcxKOXaAIF44bTipFnQAzSBJax29OwbCbYsdm96LVzlQqU34IvNM2H5mDmVLqJW9 ctBByOzacU7BTiAoLrbLg0SDJIktlQUEnFSX4nvhA/HGoXe2XF2M0rbLeYyqZg/Gvuht AjCdMW3YlZt29/NrIT3WYz6bIbU/ERucE2PS0Qp6SNUk0hGWCXp2WGOwN6EO1aOGAgVm S1T1NEUI/PzvYqnC0uBE6LbmffXt8h5AUhB/S1hoJNQPP3xlWCHjN1+RyJ8JL/bDnxTW e3ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701744213; x=1702349013; 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=ESe2+H6xRcIvQHZC4sCC1Ujc/nu3bNcuHE36+amdpNs=; b=Y8UMd3RLuQ6OYkGgT8X2uIS6XFEt+QUGz6Vs1h0+q7WyuYa1b1Cy7oMob6hWaXjbBd J721jhi7HOR9e5CjFR76OcHIvXDtxF2625mxp2Y1gy3FnXTFLjX5ufDsZ6bCDwetse3k Ey54usXnl/EzagBmO+4o0CfAk4+Jh/KznNdFwjYcsOjbkdTcTJsObxzMF7njxvTYcwqS mzLW5O/hpwqh994dYt+U3q3leCsCgyyLd9zCCxcDlPm9GtxQvWTBgwWofeQ9bGSSIGbT MYS7id8ndSj0312B/4AXt4o3dZM6pRmDqYW2ucMOMm9DQw2YWKKfy9z9T6JT64YOlWZQ nMCw== X-Gm-Message-State: AOJu0YxSLW9bz/v7RfSTRlHIoXHLbw/BZYm4zAefD2eNuqjoGN+fjl5S XWMRl9flzS3AZJNFy87PGPfMvRfvX2UsbeiE2usatw== X-Received: by 2002:a9d:748b:0:b0:6d9:9ef8:84b7 with SMTP id t11-20020a9d748b000000b006d99ef884b7mr2852315otk.26.1701744213065; Mon, 04 Dec 2023 18:43:33 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id z17-20020a9d62d1000000b006b9848f8aa7sm2157655otk.45.2023.12.04.18.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 18:43:32 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Anup Patel , Atish Patra , Conor Dooley , Guo Ren , Icenowy Zheng , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Will Deacon Subject: [RFC 2/9] drivers/perf: riscv: Add a flag to indicate SBI v2.0 support Date: Mon, 4 Dec 2023 18:43:03 -0800 Message-Id: <20231205024310.1593100-3-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231205024310.1593100-1-atishp@rivosinc.com> References: <20231205024310.1593100-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 04 Dec 2023 18:43:56 -0800 (PST) SBI v2.0 added few functions to improve SBI PMU extension. In order to be backward compatible, the driver must use these functions only if SBI v2.0 is available. Signed-off-by: Atish Patra --- drivers/perf/riscv_pmu_sbi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 16acd4dcdb96..40a335350d08 100644 --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -35,6 +35,8 @@ PMU_FORMAT_ATTR(event, "config:0-47"); PMU_FORMAT_ATTR(firmware, "config:63"); +static bool sbi_v2_available; + static struct attribute *riscv_arch_formats_attr[] = { &format_attr_event.attr, &format_attr_firmware.attr, @@ -1108,6 +1110,9 @@ static int __init pmu_sbi_devinit(void) return 0; } + if (sbi_spec_version >= sbi_mk_version(2, 0)) + sbi_v2_available = true; + ret = cpuhp_setup_state_multi(CPUHP_AP_PERF_RISCV_STARTING, "perf/riscv/pmu:starting", pmu_sbi_starting_cpu, pmu_sbi_dying_cpu); -- 2.34.1