Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6489823rwd; Mon, 19 Jun 2023 08:02:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sEzNX/KjyMB/y4JQQ8JQa1H7hPJaWfC0TZpdGHUwEQQCcylrJl6ntmUkk9q7O1NLPMuF1 X-Received: by 2002:a05:6830:22f2:b0:6b4:6226:352b with SMTP id t18-20020a05683022f200b006b46226352bmr5010319otc.11.1687186919904; Mon, 19 Jun 2023 08:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687186919; cv=none; d=google.com; s=arc-20160816; b=g/52A54pLoDHdRYcxLJmVN2fIv3t5kmEME7CV2OXX9fbQZ/oj/34E7gptCEbV64Jy9 oZt8rr8P2RGwAkIlTNs2qp/i0x2g84doz8m+YrRXXdxbpGC36BI7QGe2yHNwIfPh2TF7 DaBcFztJvnPLYz2ktlH0rB+PM/D6W6Zz8Uw+NX8EQpA0kpsipePm80I5oOrDBHlqpa+N UAWjpkdwDq+fYOJqDJzxKekLvr3bQ8aFZ7jgysHSrdUcr3SbPhEhcErQYv+nGa6SQ4cy +vZwg3+xW/ZNnYMjV8gQ5dquWLBfHZL+fNc7v0gF4NiB7j9ctch1yOOwiv+q4d1xFV2C xN8w== 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=Qxdbmd0dtQii5u90bRB5V0bWnJ9bzdUnyOROyNZnIhw=; b=A8fALJedntlfW+AohzP6InBPhVpSlzI73XnWzEhAXLgUw1BbV0d6v3YOsm9JiTfTQ7 gJDokgRlqC7hK+8d6C7O4D0TSdqf9skrUqecICjSURP/71IAvxZoYFh1M8wEyG5VJxcw br5vAqxKfCpyzT3G/1ej1I2k0xjJlA9+0AgsPodcydj/g0UkVTfGm2I4/lZGoMHu9Gpy kUxqFf9oVKdwiTgte2Z2IQinZdzaJnwUcy0sRSqhDtbGX9vtTAmwGIoNvjAvEf/tN2dZ DlJROlMGI7r2W4O0qEogyPprC4XULQxuJB7OANoOKB6J6XcUDfrJiPJ8artHBQBxYPGS r6Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=E3mHbkSB; 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=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t63-20020a637842000000b0052c54de0299si17503912pgc.637.2023.06.19.08.01.28; Mon, 19 Jun 2023 08:01:59 -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=@sifive.com header.s=google header.b=E3mHbkSB; 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=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231532AbjFSOIw (ORCPT + 99 others); Mon, 19 Jun 2023 10:08:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbjFSOIv (ORCPT ); Mon, 19 Jun 2023 10:08:51 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 510DCAB for ; Mon, 19 Jun 2023 07:08:50 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2b45e6e1b73so40579631fa.0 for ; Mon, 19 Jun 2023 07:08:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1687183728; x=1689775728; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Qxdbmd0dtQii5u90bRB5V0bWnJ9bzdUnyOROyNZnIhw=; b=E3mHbkSB27JCa80iuDg8Vr+HPDpn+9g2v80cy0b4U+fdHCR+jd4kcf1ocbg4WgNaYt vrmWCsbpqDVHCAkR1SRvsl6ap3KOgtCw0JSPkVc6MP/ngJygwhyMsmcmRgkX5sWlDeja qTJWuzfcpL13UNrhKtDV8VcRNoxMpxMkF/KCKV1jmmUmQCrJpwXBa7jKxtj8xN79xgYR p6laC0fZfvdKXJGyo2pJQs8jZONjf3M0PNwHpDkGMI5ygX8gfg5mZdnZwduuK85UmUWl ponUXKguiyioB0ID9zWl6K+WQ65AcC7zNbe1DbSer4WwfaZl0ivwKtjfkllPBDzt0eVk IjSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687183728; x=1689775728; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qxdbmd0dtQii5u90bRB5V0bWnJ9bzdUnyOROyNZnIhw=; b=JF5oQEE4ZGFTkj+yrq8IWLE4nMXH0516vbXNe5y+qe3bTgaTZ1oVHJtwF/R4UUJpis gwr2Kn47tLqIJQQcSj4zALm/buKn1S+sFYLE683vS3uRRUA6AiczFTHzu+V4fwI68oIm ESRwb7ANhTsaW6rBj0BeyglQTHjSJfc6N9UYMAAG3IiXBAMvHnO8OH8eIezZWpggpCUR GK14DCSxGyRBWUefSVjXLJeYKoX7PMy7meuyBoRQVW3iZUQUUj3w1FSa+sJVlmJgqSMX +qPMDolUPTFLz1MExGsdvwt/y0XuIGmNLVxAsFLjBFzTZnxpc8k4a/+qBBelHs0Jq2TK 5NtQ== X-Gm-Message-State: AC+VfDwfz8HHOeTpbHKwEwcCzsKplA6ysRNd487ScuPDwWJ/98XVzYhz et9MjaR4MrUXhWxWtsMtrOs/0CHkUw0TTG2t7dERmw== X-Received: by 2002:a2e:7003:0:b0:2b4:70b1:af01 with SMTP id l3-20020a2e7003000000b002b470b1af01mr2643840ljc.20.1687183728524; Mon, 19 Jun 2023 07:08:48 -0700 (PDT) MIME-Version: 1.0 References: <20230616063210.19063-1-eric.lin@sifive.com> <20230616063210.19063-3-eric.lin@sifive.com> In-Reply-To: From: Eric Lin Date: Mon, 19 Jun 2023 22:08:36 +0800 Message-ID: Subject: Re: [PATCH 2/3] soc: sifive: Add SiFive private L2 cache PMU driver To: Christophe JAILLET Cc: conor@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, maz@kernel.org, will@kernel.org, nnac123@linux.ibm.com, pierre.gondois@arm.com, jgross@suse.com, chao.gao@intel.com, maobibo@loongson.cn, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, dslin1010@gmail.com, Greentime Hu , Zong Li , Nick Hu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Hi Christophe, On Sat, Jun 17, 2023 at 3:05=E2=80=AFAM Christophe JAILLET wrote: > > Le 16/06/2023 =C3=A0 08:32, Eric Lin a =C3=A9crit : > > From: Greentime Hu > > > > This adds SiFive private L2 cache PMU driver. User > > can use perf tool to profile by event name and event id. > > > > Example: > > $ perf stat -C 0 -e /sifive_pl2_pmu/inner_acquire_block_btot/ > > -e /sifive_pl2_pmu/inner_acquire_block_ntob/ > > -e /sifive_pl2_pmu/inner_acquire_block_ntot/ ls > > > > Performance counter stats for 'CPU(s) 0': > > > > 300 sifive_pl2_pmu/inner_acquire_block_btot/ > > 17801 sifive_pl2_pmu/inner_acquire_block_ntob/ > > 5253 sifive_pl2_pmu/inner_acquire_block_ntot/ > > > > 0.088917326 seconds time elapsed > > > > $ perf stat -C 0 -e /sifive_pl2_pmu/event=3D0x10001/ > > -e /sifive_pl2_pmu/event=3D0x4001/ > > -e /sifive_pl2_pmu/event=3D0x8001/ ls > > > > Performance counter stats for 'CPU(s) 0': > > > > 251 sifive_pl2_pmu/event=3D0x10001/ > > 2620 sifive_pl2_pmu/event=3D0x4001/ > > 644 sifive_pl2_pmu/event=3D0x8001/ > > > > 0.092827110 seconds time elapsed > > > > Signed-off-by: Greentime Hu > > Signed-off-by: Eric Lin > > Reviewed-by: Zong Li > > Reviewed-by: Nick Hu > > --- > > [...] > > > +int sifive_pl2_pmu_probe(struct device_node *pl2_node, > > + void __iomem *pl2_base, int cpu) > > +{ > > + struct sifive_pl2_pmu_event *ptr =3D per_cpu_ptr(&sifive_pl2_pmu_= event, cpu); > > + int ret =3D -EINVAL; > > Nit: no need to init > OK, I will fix it in v2. > > + > > + /* Get counter numbers. */ > > + ret =3D of_property_read_u32(pl2_node, "sifive,perfmon-counters",= &ptr->counters); > > + if (ret) { > > + pr_err("Not found sifive,perfmon-counters property\n"); > > + goto early_err; > > + } > > + pr_info("perfmon-counters: %d for CPU %d\n", ptr->counters, cpu); > > + > > + /* Allocate perf_event. */ > > + ptr->events =3D kcalloc(ptr->counters, sizeof(struct perf_event),= GFP_KERNEL); > > + if (!ptr->events) > > + return -ENOMEM; > > + > > + ptr->event_select_base =3D pl2_base + SIFIVE_PL2_SELECT_BASE_OFFS= ET; > > + ptr->event_counter_base =3D pl2_base + SIFIVE_PL2_COUNTER_BASE_OF= FSET; > > + > > + if (!pl2pmu_init_done) { > > + ret =3D perf_pmu_register(sifive_pl2_pmu.pmu, sifive_pl2_= pmu.pmu->name, -1); > > + if (ret) { > > + cpuhp_state_remove_instance(CPUHP_AP_PERF_RISCV_S= IFIVE_PL2_PMU_ONLINE, > > + &sifive_pl2_pmu.node)= ; > > + pr_err("Failed to register sifive_pl2_pmu.pmu: %d= \n", ret); > > + } > > + sifive_pl2_pmu_pm_init(); > > + pl2pmu_init_done =3D true; > > + } > > + > > + return 0; > > + > > +early_err: > > + return ret; > > +} > > + > > +int sifive_pl2_pmu_init(void) > > +{ > > + int ret =3D 0; > > Nit: no need to init OK, I will fix it in v2. > > > + > > + ret =3D cpuhp_setup_state_multi(CPUHP_AP_PERF_RISCV_SIFIVE_PL2_PM= U_ONLINE, > > + "perf/sifive/pl2pmu:online", > > + sifive_pl2_pmu_online_cpu, > > + sifive_pl2_pmu_offline_cpu); > > + if (ret) > > + pr_err("Failed to register CPU hotplug notifier %d\n", re= t); > > + > > + ret =3D cpuhp_state_add_instance(CPUHP_AP_PERF_RISCV_SIFIVE_PL2_P= MU_ONLINE, > > + &sifive_pl2_pmu.node); > > + if (ret) > > + pr_err("Failed to add hotplug instance: %d\n", ret); > > + > > + return ret; > > Nit: return 0; OK, I will fix it in v2. Thanks for your review. Best regards, Eric Lin > > > +} > > [...] >