Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3014022rwb; Mon, 15 Aug 2022 16:09:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lTRIKyYJNbYh8YQQvu/Hgpb/+yOE68DBwoY88lUxSyw7w0K8CTYCAFAc/MqtcWsbBtKtj X-Received: by 2002:a17:906:5a49:b0:730:aced:aa0e with SMTP id my9-20020a1709065a4900b00730acedaa0emr11786109ejc.31.1660604994161; Mon, 15 Aug 2022 16:09:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660604994; cv=none; d=google.com; s=arc-20160816; b=yUri6s372uaej6xTsE0cw70ZtZ712lWAzM9Cc9P6f3DpWXyUB/qKE2B4hb+YTxmBbo lew3T7lXTOgYAom5KIDyU1lUatp9B//4urHqiiNfamLAvm8Wr/e+fycnvU+kIs6zoo8+ /YFHA/FPyLKeUsi9VCOPsCI6N3d2v89dCXy8X8aTUE/NPWUugqpKvjmhf5as6JlGoOzu v7XeWFDSY3IIj1YGZWkJE93VSLvJ1Pl/m1Hhor/gjlGZJ86xtN5GWqyhFki2gRogxDNs SEBasWLLYEHp4FfmEHl7KkfjRjOaOmcugfeo/iPxAMRheuaB6B5SpsE51zCYdL5l7BNn c0Nw== 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=aX+lDWdVVNf5/iwJGxKK/L33s7ykSKB6cS5lf6icmAk=; b=drTxL6CntIICtf/Oo+6Pn2aTa4si5ecUqJZUVXALWONWFG1HWpzmtDFayt2hFEu14X 6DfqMwDRMFQfm6M7WhNME2nu26kGx82NdYUPZQpis+38Ig8G18MmAYswKWak2e5QzEJJ 4rrT1r7ZPV6weSyPZqUmWjfuah10W2XMv70ipgHVgbVaPpiJjenFwnQ9Ji+XZz4/DP3I rItdfT5qeb2vZdBXLuJL1iDf/5vnK23PeUquP/5SUFufcPaPrnfNfqXzqTw7ErIF+m5t SRRoQcDUcza7bsT+p3dPOMWxHOH8ssQBoak/NwUL5hyLEY8Leaq8Ynmir27Ln8UHixZ8 thQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LszV3+6p; 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 ht12-20020a170907608c00b0073836824062si5317309ejc.202.2022.08.15.16.09.28; Mon, 15 Aug 2022 16:09:54 -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=LszV3+6p; 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 S244735AbiHOWIN (ORCPT + 99 others); Mon, 15 Aug 2022 18:08:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344113AbiHOWCw (ORCPT ); Mon, 15 Aug 2022 18:02:52 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B1F082D24; Mon, 15 Aug 2022 12:37:11 -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 84CCBB80EAD; Mon, 15 Aug 2022 19:37:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B603BC433D6; Mon, 15 Aug 2022 19:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592228; bh=QJS/R1P+cg/xZTzIpbbkM8/b12fmW1LwuZjmzleKuTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LszV3+6pbsKXUvlaee9+jBG3X39jBaMvEdCFAufllCtkD5T2q2eS8ejIHFv8OOcVd BY4/kZvzBRsDsVjXqdRvUAI6IsUHCPcPJ80WMIDo+BfnIZdLm3IUGvN5FcszovwX/1 UmlXgF+fCQp5y4pSS4UnMI6eNtTFErZgBiHJsGl0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Atish Patra , Guo Ren , Palmer Dabbelt Subject: [PATCH 5.19 0077/1157] RISC-V: Fix counter restart during overflow for RV32 Date: Mon, 15 Aug 2022 19:50:33 +0200 Message-Id: <20220815180442.608060612@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 acc1b919f47926b089be21b8aaa29ec91fef0aa2 upstream. Pass the upper half of the initial value of the counter correctly for RV32. Fixes: 4905ec2fb7e6 ("RISC-V: Add sscofpmf extension support") Signed-off-by: Atish Patra Reviewed-by: Guo Ren Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220711174632.4186047-2-atishp@rivosinc.com Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- drivers/perf/riscv_pmu_sbi.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/perf/riscv_pmu_sbi.c +++ b/drivers/perf/riscv_pmu_sbi.c @@ -525,8 +525,13 @@ static inline void pmu_sbi_start_overflo hwc = &event->hw; max_period = riscv_pmu_ctr_get_width_mask(event); init_val = local64_read(&hwc->prev_count) & max_period; +#if defined(CONFIG_32BIT) + sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, idx, 1, + flag, init_val, init_val >> 32, 0); +#else sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_START, idx, 1, flag, init_val, 0, 0); +#endif } ctr_ovf_mask = ctr_ovf_mask >> 1; idx++;