Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3131396ioo; Tue, 24 May 2022 13:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbTMBH2a/1lTwf2a0YrAceLcLnB6wXRDfVU/JaB7GY3ki0JUnC/Tx2TB/MnSJZhuJf5383 X-Received: by 2002:a17:902:a502:b0:15e:c251:b769 with SMTP id s2-20020a170902a50200b0015ec251b769mr28429138plq.115.1653425947603; Tue, 24 May 2022 13:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653425947; cv=none; d=google.com; s=arc-20160816; b=Dykaf0iFXwYkro7ZFonTCR9zkpu6pCXhBBsHPIAZ/C5Y6cYVzxR+Z6mI8TsbFhQpVz 4Mj2vwqVedOX9xEghCBUwSMFxBLttqn4WLYsvYHzVNb///NcJ+KA6GnU1WEmMnO/8boF jFQvH39j/uYA+AY/xpJIl0AMg75rLq8fs8oZEeiCMFb12uGd8iw8Fsav56NcOiND6HYf VLfus9tdHg0mNbsx3XfXtj2vClRVWzwcZ+AaDIXDC+MAeFtPWqUKCDwBWqrJXENTiZC0 8l0LXoQ6QvVUz/28B+priVJ+PSR286dGhWMyMLOHI1/MQTiRffoErRxA6kYfLt573i47 sEkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bP8kRhNwmItUataEWlKC3/a9/zDgSR+UCaI4XtaJeW8=; b=QJfsg18BmQDpd45iK9BNmwOqTSvx31q/YrgUugjjrrEU/wNme5wsGJ04/SpYpbdoT2 s5bH/f7Oi/dFsli11RKtIODZlHDMK+UfZRPgcqVKYPpUxrOCP4IjmmX6Q0bvLWRbIFjp 601Ne/CNloXntZr2s1hpVQAi49VWs0iSFuTmVUu8tEhToUiKwfF+z47glbpYtxNdmEf9 WVosR5htDH7SCEYYdGxJpHGLF3GdLqZ+gJtxNE7YPsOg0lFU8GRmItv31yHZquDjlsMv +uPgMiw9ZJ4Eu+ojh7XG5nKnB1PEnbAZ+YsaNjStr4UaHWiz7wBh8C4AJJHQwmDD4r54 KzrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=XzMEoSZM; 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 l192-20020a6391c9000000b003f9dd67d2b7si14903193pge.34.2022.05.24.13.58.55; Tue, 24 May 2022 13:59:07 -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=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=XzMEoSZM; 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 S234586AbiEXLWn (ORCPT + 99 others); Tue, 24 May 2022 07:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbiEXLWl (ORCPT ); Tue, 24 May 2022 07:22:41 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B0E878907 for ; Tue, 24 May 2022 04:22:40 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id p19so1938120wmg.2 for ; Tue, 24 May 2022 04:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bP8kRhNwmItUataEWlKC3/a9/zDgSR+UCaI4XtaJeW8=; b=XzMEoSZMGBZwlINe84xBxoGx1pKIgVbH99vxCzUkPIJzN3JV0eDFsCR8EAx/1BygLJ cePe2lrU+5GgaHk+UR8j+kecsKslpF/sU0BVFAmewkEObHuVLp/pcJ4cBRux2GupvwxR cMW11jOIirzCYBcEIjHYc3LlTXrLnCg80SWwOUfgBUdi98+F2fOPcdV/An2ZIYxZJqB5 V+ukL+BZGcB+6UUe3A5Tht/JpbErBZjDv3ZKFKlKj2nhxsG306pNeiHeRDWrmorkCzP4 XhtP2PDthBK4pw5omr8V52y0ul+yqw/3qxueGmkCFMGeE2U5MBBgJXlL4MqlHuZxYuPv vNdA== 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; bh=bP8kRhNwmItUataEWlKC3/a9/zDgSR+UCaI4XtaJeW8=; b=cTcodiJgviSrPml+c72ymXAhQk7CR4sowKxLxG+xfmldqA3Uoki4EboIxa/RJkFUB+ Y+qGLNg0Dscaa3WdCErh3x8wD7i8rk/FYignH9CKDK3P3Re0awher7sOQIjsDOU8bCaL /VG3tRI1VMNfMhggPh1lHcEZ8dZxd0NMeLLl+HgSq3/02NQacXPwUdgXuDAONvgW4zi+ b2OIAEuGTIouE9Q3rnZ6KrwYx50p8Vo43Lw1r3bH+a27OydOVOSqpkcVwSbYJonAhx16 hTuyor1NpsGArDuuDls7wM5WW0T7Em0Rs7O0jnazfYeSQHrfWCPdbAOCyCEkc4jQaZuQ MekQ== X-Gm-Message-State: AOAM531yAnhWZZXApGELkbLqfbq135aMDsnKQ4M07YxqpSavIkFvye9g B4cv0IQDMWxPfqqdyk7pxZ1tRExrQf0r4IwDIZrBoinjkt+2K68r X-Received: by 2002:a05:600c:4fd5:b0:394:55ae:32c7 with SMTP id o21-20020a05600c4fd500b0039455ae32c7mr3332614wmq.73.1653391358329; Tue, 24 May 2022 04:22:38 -0700 (PDT) MIME-Version: 1.0 References: <20220513015522.910856-1-atishp@rivosinc.com> <20220513015522.910856-4-atishp@rivosinc.com> In-Reply-To: <20220513015522.910856-4-atishp@rivosinc.com> From: Anup Patel Date: Tue, 24 May 2022 16:52:26 +0530 Message-ID: Subject: Re: [PATCH v2 3/3] RISC-V: Fix SBI PMU calls for RV32 To: Atish Patra Cc: "linux-kernel@vger.kernel.org List" , Atish Patra , Jisheng Zhang , linux-riscv , Palmer Dabbelt , Paul Walmsley , Rob Herring Content-Type: text/plain; charset="UTF-8" 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_NONE, 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 Fri, May 13, 2022 at 7:25 AM Atish Patra wrote: > > 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 Looks good to me. Reviewed-by: Anup Patel Regards, Anup > --- > 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 7ad92039a718..fab0dd497393 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.25.1 >