Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2891285rwb; Mon, 15 Aug 2022 13:25:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR59JiaE4HswOCF4Y+xi8ouoXgP8ytBxP1mqVKT1SUS0YLs/P8BBx2PQ5GvdKM6aeyrU5iY0 X-Received: by 2002:a17:906:5a6a:b0:730:bc8a:57dd with SMTP id my42-20020a1709065a6a00b00730bc8a57ddmr11001024ejc.301.1660595145877; Mon, 15 Aug 2022 13:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660595145; cv=none; d=google.com; s=arc-20160816; b=SHaPW1x+JlwQEi9N5xZsDlcPGbeJBnlotzEfXOTbwjMYwwetJ8+gy67gf1N4dYh/VF vDBFj0EKEUXXpw4wNzLHpB38iT/stk8CCgwTN+0+hOmMYnBC9/AmsQK5zDG3SOcibuN/ RTVwPJqzCIHOSGnmImzsllJ7MVAc8NzIcVp+xBPAJmj7jH+LXNL28rssJqbsXRuBVFcr bKFeyk8dkynKFNtxysS8Vzfsakq2/pCthwdyBrWzvvzmV6X2rwFyJHHMZdpnjjbWveHa arYF0xGnrXO+kwBMl0EkQ9aucRwBCd5RwrhgRon1tWnA8DcddYpZejMgO5YEaFLYnYDk WbMA== 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=yM/rv/l4zJ963FhbTIloxhYdFsEna55CA0NIqyqoAnU=; b=qPB3ggbug22OsJs86XcJl/MiDnsZtDoaucWduc+8rZxSzBuoyq5vF19vdYOoPNUGrZ 728sKkeLpjhpGbNj4ijB5ymY0IIuNHfkNYrQRfFg0GGiQBKGjz85DWHXMqSngE9mVIoS FgNa8VpNsqOV2XXz6aFpCFPHcyPEpdBLOZYI+2YErarWFTCkr8ecyoBgnx/jH2orgucE c3mcGFq5JHJmeAst2w5TP9tb66xUXrl8CimGb2MopJKWZ5pAYHz0xtF2AUQ0fpEEIp1z 9xEbpWN3gAOJVyP3OKrCCZe6wMCkqB4zWzCxWnc+DEllaufqH6fs5sTT/ZT1UU4zVaKl lGgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Oyr1DeKi; 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 t9-20020a50ab49000000b0043c891e0f0fsi8813030edc.356.2022.08.15.13.25.11; Mon, 15 Aug 2022 13:25:45 -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=Oyr1DeKi; 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 S1346500AbiHOUWr (ORCPT + 99 others); Mon, 15 Aug 2022 16:22:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242813AbiHOUNO (ORCPT ); Mon, 15 Aug 2022 16:13:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5900132EF3; Mon, 15 Aug 2022 11:59:10 -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 ams.source.kernel.org (Postfix) with ESMTPS id 86F70B810C5; Mon, 15 Aug 2022 18:59:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE280C433C1; Mon, 15 Aug 2022 18:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589947; bh=hFLdWtZlm6m47mimf7VH2hREI4jtWZfe2DLf4xlZbfc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oyr1DeKiXKi+f8q6NKgzXKdQJWpBpsjp+cRa8cZffpH2HpAjw0VQacGDYXPBv++fR hqqpyHiXj6BYJ6mG/OmYAXY7lWFfQVbolwolnwEBOKmVY64OF9bqSoOyrgmg2t+7Hm 2V+XlX8juld8ud1xPfnWXDJymRV0L4lxJMYtVKHA= 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.18 0070/1095] RISC-V: Fix SBI PMU calls for RV32 Date: Mon, 15 Aug 2022 19:51:09 +0200 Message-Id: <20220815180432.414248634@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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(+) diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c index 3735337a4cfb..bae614c73b14 100644 --- 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 perf_event *event) 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 perf_event *event, u64 ival) 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)); -- 2.37.1