Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3023527rwb; Mon, 15 Aug 2022 16:21:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Jl759vdp5Mwg/lvzgSIqd/grQVvjKxovc8yzZyKkgJ3Zssaci1ffPlJ0avVHLYbTLGD+O X-Received: by 2002:a17:907:6930:b0:733:621:8437 with SMTP id rb48-20020a170907693000b0073306218437mr11721736ejc.111.1660605666476; Mon, 15 Aug 2022 16:21:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605666; cv=none; d=google.com; s=arc-20160816; b=O0YbADzVwBEYBYCZoL7twinhsvxN0nv1w1eNSyJSoiw8jWIZXCJ10Z5ZONe3cPpQnI 0lFiftjadUvlO71uxvirj+cDcWBwpj7SvnwsJVU69b2z+q78IR8lVmqO+pS1UChBSE8t 3qyF5563CcgAhee6G8ul2sisSuDztyFG6/eMNiQ4620NdigsFupQZX0Ze738bSnxPX+P LjuMYLCZitTg306oq0EpVi7Fl16UG5AMEn96j3n6x5v5PXi/74UhyJWW/k96YoFmuprQ 1/jnvgEfXhxhpD8M1TpGRFj3iaSNf6VxT+7yP1xEPIeNpuowtexLaYXskwYwryFzQ5Vs cwAg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hFwXOqSZpZ/XA/GfnlAvw7ZoAKOkUIYc9BYHI/xIxA0=; b=ho/1/bYVLhPcTe1p7anbF0cDK0yOsFI2E1J4Rd9iXANghea2LgIRdXfF3wm9KzCBT4 +G8XY3e0cl6LKtxsg2mUVwXcchSTwnYOrbcXPLqxw4a5nceo2mXP20WPKxNeVPf9FuYR 2VNfzvlot/WQwkpuEhZLlqVn63E68oyBGcsdRRYeYN2YAf9h831aLC0urmulNzs2k3U/ m47LfTsGI0fqjCnHxi6byohcY6bG4NFkOpLHS+aTFT8EAgMV8kgNuax9vA4nBNxbHEBv fomvtRenouGBPaF/TWvqXD7yb5NB0vf8S5PNLcwQ2bHX+ebprnsWquiu7tsnzVTmw6aF 7i6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f3+yhsaV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qb40-20020a1709077ea800b00731745a7f19si8174302ejc.271.2022.08.15.16.20.41; Mon, 15 Aug 2022 16:21:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f3+yhsaV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347172AbiHOWIb (ORCPT + 99 others); Mon, 15 Aug 2022 18:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347480AbiHOWDl (ORCPT ); Mon, 15 Aug 2022 18:03:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE03F1156C9; Mon, 15 Aug 2022 12:37:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E7087610A5; Mon, 15 Aug 2022 19:37:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E254FC433C1; Mon, 15 Aug 2022 19:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592234; bh=ym45XOUbfUhjuPKdowugKqXwVFv3rbZiB+V2T/TItmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3+yhsaVkRmyelhkKM4vkqV6LjoBZ27rPx4O/1gUnxfskPgn1HoTjwV4ZlnVKVxNS k8TnqMDQdM8ZBFSoc1znz0ta+lR+iMfUqhq8JsNVOsu3YLltXpPsWEDOuOauAlXqrF TGzDBMLbROQyq09YcIrfiOwhewlAVKBTRXrxB9hI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Atish Patra , Palmer Dabbelt Subject: [PATCH 5.19 0078/1157] RISC-V: Fix SBI PMU calls for RV32 Date: Mon, 15 Aug 2022 19:50:34 +0200 Message-Id: <20220815180442.646510945@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Atish Patra commit 0209b5830bea42dd3ce33ab0397231e67ec3b751 upstream. Some of the SBI PMU calls does not pass 64bit arguments correctly and not under RV32 compile time flags. Currently, this doesn't create any incorrect results as RV64 ignores any value in the additional register and qemu doesn't support raw events. Fix those SBI calls in order to set correct values for RV32. Fixes: e9991434596f ("RISC-V: Add perf platform driver based on SBI PMU extension") Signed-off-by: Atish Patra Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220711174632.4186047-4-atishp@rivosinc.com Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- drivers/perf/riscv_pmu_sbi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -274,8 +274,13 @@ static int pmu_sbi_ctr_get_idx(struct pe cflags |= SBI_PMU_CFG_FLAG_SET_UINH; /* retrieve the available counter index */ +#if defined(CONFIG_32BIT) + ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, cmask, + cflags, hwc->event_base, hwc->config, hwc->config >> 32); +#else ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase, cmask, cflags, hwc->event_base, hwc->config, 0); +#endif if (ret.error) { pr_debug("Not able to find a counter for event %lx config %llx\n", hwc->event_base, hwc->config); @@ -417,8 +422,13 @@ static void pmu_sbi_ctr_start(struct per struct hw_perf_event *hwc = &event->hw; unsigned long flag = SBI_PMU_START_FLAG_SET_INIT_VALUE; +#if defined(CONFIG_32BIT) ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, hwc->idx, 1, flag, ival, ival >> 32, 0); +#else + ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, hwc->idx, + 1, flag, ival, 0, 0); +#endif if (ret.error && (ret.error != SBI_ERR_ALREADY_STARTED)) pr_err("Starting counter idx %d failed with error %d\n", hwc->idx, sbi_err_map_linux_errno(ret.error));