Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp139485iob; Thu, 12 May 2022 21:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5DTcjVATdGijrrktHzaLJFu21Zo84qdRmjOcRlid9EWZkhx1xgfiZZidRP8TPure0C8Zs X-Received: by 2002:a17:906:90d5:b0:6fd:eefb:8803 with SMTP id v21-20020a17090690d500b006fdeefb8803mr2509923ejw.244.1652414604179; Thu, 12 May 2022 21:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652414604; cv=none; d=google.com; s=arc-20160816; b=uwA0NjmCJNasuikvh1tmeLdntNGEsB5Tp6QPYotXeMwkVQRMLPKoOrCU/VGcTWIEJM sjaxvK/0V2arL6uuVS0pT4z11FxurJ+PgY4MidVimnZ5uU0C8peedFDu6T6ITvKwOZz0 gXTPhLUnwI4feQOMgEXNMDi+DAEWc5fkul6oyMFg4uw+DqPFBshxMg5Lhl8ngjJkNp1X RVQnweQbB+Vt0XSqL1ljXmy/7xYEGnrDq2vFXtaBqsUwBVAa1vBlnmu/qZsjUoVMF1ww UKAkoKtZU1YbvUgPjD2DjUTa18sBQEoLwUZ9Lk61jXT4PaqcrAcpUXAI7BMYKYiTPoHH wuPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=k5uBtUuVEeyc/uDRq1ERjuwGFNzbvMoQDv2ORcXlb34=; b=NGWBXo1P7AbxYuovnkjAFJrfli/ipiL95/A/HbdOm8t2RkBsb+o6Kd/j8VWOvQm+N1 nfDKkDHNc0AUl8LmVnRMam0wn21lefvjD7ywAFdOjaOPWyvIhct22jmOIDFkGAo4Cr0f FgY60pcni5C4NH+8GOnQhUdhMDQvClzpxQRGusvFBrSXWU8GuxKzNOwLSg1akMGTZWdr Hmoav+/AtCktcy9Zdv3L1jEyALkn6akBqIZJ6YZqa54upYCpZn6tnWwK6w9eizaEqGXv e3zN79Xx/yAqmCasMLhRR4JkJLeNZhL26txw59sYsqKsR+YQRpARKu0rKSVUwRAIahTF UXCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=zSde4Tis; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a056402359500b00427f9b748c5si1053909edc.519.2022.05.12.21.02.53; Thu, 12 May 2022 21:03:24 -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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=zSde4Tis; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356988AbiELRWO (ORCPT + 99 others); Thu, 12 May 2022 13:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356987AbiELRWL (ORCPT ); Thu, 12 May 2022 13:22:11 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9DA663E7 for ; Thu, 12 May 2022 10:22:09 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id l19so7340647ljb.7 for ; Thu, 12 May 2022 10:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=k5uBtUuVEeyc/uDRq1ERjuwGFNzbvMoQDv2ORcXlb34=; b=zSde4TismK45+H65/WKteA+kIU8dYdT5m6nUNBnPGE10a/oyMx9hE8U3rDy16Xu1eQ 5vWYkxU0GKQp6i6p6DMtPshoptRmUTYUYsUWN/vePrAPF5fClSkzPdwBZGYs4dzlulKF 3mg7REuBmBQrPAJsvOPivBw3HuAXK9PIwQRoVEmM2bXYJers3CHKHzuva4OQ6cAW80Vw Hatmw/L8aLsB4rJ8IyF4OGEEf3na/ogfoTln7b/NDIDnoVAmREbxmA1FdstbMiU8i3WQ iFXW3Qb62yRy+N0sGcJo7YJR4i0sfyNVx9bND0XVIZ8BhwvhFJ9lFaz/4QJt43NMNFq/ hRuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=k5uBtUuVEeyc/uDRq1ERjuwGFNzbvMoQDv2ORcXlb34=; b=fwrpxzFSn8rJLYb7dm30N+miX+CdxY4TYzjZ5gI6RSUYJty+512Oz1SVbxNfqIP6Tf N+WKxHgnSDuvWWwwIiF7dpIQwm3zF2ALdAwTwfkQhqOu1MD3vLtuDsYxVXrwZAJfJfAl 9VzpY86F1tBo/nRoEY8Hatzq45nCXa1/QOqrRjMi9Tc0Jy6bLHEznYRWEALv3S8Gk4r+ wdIfPQrsIq2B27qVxkSu8+t2TlBJDmcC4WePzrTXLxA56DNa5DWlzsu8QowRe/m1jWde DuPQkslCIa30xKTHbaao3QzmV9SsY6RGDPhRo0JHURxSqsk91Kc1UBbGIU6NEMTcWKly nrag== X-Gm-Message-State: AOAM531wE+M96OPBAsDq6/b4Np9k/TmNrM4xb6kjN8MKEWuW42oOvNEy 2GwMpLXzkTUy2byM/k9SEB8HbFHYj2p2yuVbzE6ekw== X-Received: by 2002:a2e:82c5:0:b0:247:e81f:8b02 with SMTP id n5-20020a2e82c5000000b00247e81f8b02mr644883ljh.90.1652376128189; Thu, 12 May 2022 10:22:08 -0700 (PDT) MIME-Version: 1.0 References: <20220511201107.2311757-1-atishp@rivosinc.com> <23274575.ouqheUzb2q@diego> In-Reply-To: From: Atish Kumar Patra Date: Thu, 12 May 2022 10:21:56 -0700 Message-ID: Subject: Re: [PATCH 1/2] RISC-V: Fix counter restart during overflow for RV32 To: Anup Patel Cc: =?UTF-8?Q?Heiko_St=C3=BCbner?= , linux-riscv , "linux-kernel@vger.kernel.org List" , Albert Ou , Atish Patra , Damien Le Moal , DTML , Jisheng Zhang , Palmer Dabbelt , Paul Walmsley , Rob Herring Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 On Thu, May 12, 2022 at 8:36 AM Anup Patel wrote: > > On Thu, May 12, 2022 at 6:12 PM Heiko St=C3=BCbner wrot= e: > > > > Am Donnerstag, 12. Mai 2022, 06:44:12 CEST schrieb Anup Patel: > > > On Thu, May 12, 2022 at 1:41 AM Atish Patra wro= te: > > > > > > > > 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 > > > > --- > > > > drivers/perf/riscv_pmu_sbi.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_= sbi.c > > > > index a1317a483512..24cea59612be 100644 > > > > --- a/drivers/perf/riscv_pmu_sbi.c > > > > +++ b/drivers/perf/riscv_pmu_sbi.c > > > > @@ -526,7 +526,7 @@ static inline void pmu_sbi_start_overflow_mask(= struct riscv_pmu *pmu, > > > > max_period =3D riscv_pmu_ctr_get_width_mask= (event); > > > > init_val =3D local64_read(&hwc->prev_count)= & max_period; > > > > sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_= START, idx, 1, > > > > - flag, init_val, 0, 0); > > > > + flag, init_val, init_val >> 32, 0= ); > > > > > > This should be under "#if __riscv_xlen =3D=3D 32". > > > > What's the difference between using CONFIG_32BIT > > and checking the __riscv_xlen flag value? > > It's one and the same. > > > > > CONFIG_32BIT seems to be a bit the more kernel'ish > > way to do this, but it looks like most SBI parts check the > > __riscv_xlen instead. > Not only SBI parts, there are more users of __riscv_xlen compared CONFIG_32BIT in arch/riscv. > I agree with you. We should prefer "#ifdef CONFIG_32BIT" > in this case to match the kernel coding style. > Sure. I will change it to CONFIG_32BIT. > Currently, OpenSBI does not have CONFIG_xyz defines so > over there we use "#if __riscv_xlen =3D=3D 32". > > Regards, > Anup > > > > > > > In any case, looking at the opensbi-side of the call, > > this fix is abviously correct, so > > > > Reviewed-by: Heiko Stuebner > > > > > >