Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3057539ybt; Mon, 29 Jun 2020 14:09:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpA4TXAwu+cKqvfyRPWAsFl/DtT/g+JdD0cqgaWOtsGSySvp9QI59gPwlmVjfqbtFAUeKW X-Received: by 2002:aa7:dcc8:: with SMTP id w8mr20148533edu.305.1593464954782; Mon, 29 Jun 2020 14:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593464954; cv=none; d=google.com; s=arc-20160816; b=QJHm+RwCMQW0r0E+viYMVnyPNDvqKdOr5l9BHgD5wltSh5F9jIvSlPtPes9moXXqKZ +6VLTrxrISaGtrOE1ZN3sV+gYyPBSd9ZuGyDzqMBBR3D6LrCDu0TxZBIdPBa3vIoINQG Vjh+FGCrWof+iITUU4q4bzw8qM3hA6qOLIy1BN+kCzARTDcCz3r4jx5z5M1qOd6PjKHt gos4uyo6AX29Nf8dVVQv35KZnOHiPWhyOKuJbw/dDp3wa1JVJOIyxKFo0eBBtPfeYdHW 6tyLflxCBsjsqrtNLjrSSP7SPS4QxGcce+0pUn+YAja86gKxA8ghrrHcVof3hII533Qh uY/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xlkirLsIZMObxpVgMysLgRaq8YNVzTc6KirQpgVXrl4=; b=UNUaMl6szeQqWT7ELQaNdpWfO0Clm9Q5p6Vix8RmofhCPVQACdidukUTyLSEXIQp29 kBulHX/kpb3+7tJiCya3Wyt96TWwDIjsQsgyoWNp5uUTke+xTwtlVPBSkKBSADGTjE12 0zyD66AhVKL2cUTUbzO0xEV+bwAaAbg5HidekMwMhXTKmdJU/JOyoxdJ+Yv81/L9gK/P w6GgVM1S4emCeC7QuL+IPbddzGHhrDVOuMPG721+UkCQy92ftxDFW2RKYCkxyD5vgXUc eesIVZfIM35Y9qXiVusJvJgsqc44ebbWAXLEEO189sYbN5pQzbSzg66ZVV5KgulsJ3pg 8F/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="j/PZKR7k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si440481eja.529.2020.06.29.14.08.52; Mon, 29 Jun 2020 14:09:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b="j/PZKR7k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390108AbgF2VFy (ORCPT + 99 others); Mon, 29 Jun 2020 17:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731088AbgF2TMn (ORCPT ); Mon, 29 Jun 2020 15:12:43 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48ACC08C5FD for ; Sun, 28 Jun 2020 21:53:07 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id j4so12663995wrp.10 for ; Sun, 28 Jun 2020 21:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xlkirLsIZMObxpVgMysLgRaq8YNVzTc6KirQpgVXrl4=; b=j/PZKR7k1xbX2L5QA4ostwRavWKWUK/N34oC2C8aMw8lMmmV4WnYf/amEnn5yWG6WP v5XfK2tf6vIerdnASizSZxc9nmxXFGUBQoEr8xbxqHz9ot4GDAC1Xhkk6IkuLKowEEV8 jRQ7QmthO6fUya5tSXTmdvwiv/3InniocLRyjDawgX4ZtLcTjeean32ErbKDtyMpLfCt h41wudieF4BNsc3tKAMFx3t6ihPEw+EGzk38vspi+YI7g+cfql1SYETCLdsJRtdSN33C NCAHfXe896jFf+rcPPRYrLkX6EJW+Q9RPxehYZEuMaFqEJx2ildGX4cQH642SxNm4dB5 cT5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xlkirLsIZMObxpVgMysLgRaq8YNVzTc6KirQpgVXrl4=; b=du79K/itkHhhi1n8+/dj/IJNArsyqsTD7e9m57yxVjbqp55SiWOkiUrcnaK4mYl3W2 rRUeR4sFzlcm5kJ6GnbP371fle5sWS5NKP4uG6lJxmlK4JqHJyOCyjbX5vC28hAZOdFY 2B5CKfGWTLjOAtddgxKJhtHUOtTSevIUUZMccCtsqQhNWY1Sgy5/DMk3jL/mHCXWwUh+ 4kJ4kqazTfrqiNEvHChGEYwmBR285ay97xozWMnZbKvykv+f4RiXhye4rXcfR2Ssevxe E648TCGqUuFDN8emDb1cbM/nnDbFHKnP0RV836+zWTbjIrIwZD7ILKCxKfT0gml5PHnH 5+IA== X-Gm-Message-State: AOAM531Kb4s4ZD9x1VVL2jYY5i/xKL8zl5OHZMOS/xPkWD4RNgQ3ERed wepkHenvADAoSByQO0Ea08KvxIwPQLzqIlgMJY3TWw== X-Received: by 2002:adf:de12:: with SMTP id b18mr16280822wrm.390.1593406386452; Sun, 28 Jun 2020 21:53:06 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Anup Patel Date: Mon, 29 Jun 2020 10:22:55 +0530 Message-ID: Subject: Re: [RFC PATCH 0/6] Support raw event and DT for perf on RISC-V To: Zong Li Cc: Palmer Dabbelt , Paul Walmsley , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 8:49 AM Zong Li wrote: > > This patch set adds raw event support on RISC-V. In addition, we > introduce the DT mechanism to make our perf more generic and common. > > Currently, we set the hardware events by writing the mhpmeventN CSRs, it > would raise an illegal instruction exception and trap into m-mode to > emulate event selector CSRs access. It doesn't make sense because we > shouldn't write the m-mode CSRs in s-mode. Ideally, we should set event > selector through standard SBI call or the shadow CSRs of s-mode. We have > prepared a proposal of a new SBI extension, called "PMU SBI extension", > but we also discussing the feasibility of accessing these PMU CSRs on > s-mode at the same time, such as delegation mechanism, so I was > wondering if we could use SBI calls first and make the PMU SBI extension > as legacy when s-mode access mechanism is accepted by Foundation? or > keep the current situation to see what would happen in the future. > > This patch set also introduces the DT mechanism, we don't want to add too > much platform-dependency code in perf like other architectures, so we > put the mapping of generic hardware events to DT, then we can easy to > transfer generic hardware events to vendor's own hardware events without > any platfrom-dependency stuff in our perf. Please re-write this series to have RISC-V PMU driver as a regular platform driver as drivers/perf/riscv_pmu.c. The PMU related sources will have to be removed from arch/riscv. Based on implementation of final drivers/perf/riscv_pmu.c we will come-up with drivers/perf/riscv_sbi_pmu.c driver for SBI perf counters. Regards, Anup > > Zong Li (6): > dt-bindings: riscv: Add YAML documentation for PMU > riscv: dts: sifive: Add DT support for PMU > riscv: add definition of hpmcounter CSRs > riscv: perf: Add raw event support > riscv: perf: introduce DT mechanism > riscv: remove PMU menu of Kconfig > > .../devicetree/bindings/riscv/pmu.yaml | 59 +++ > arch/riscv/Kconfig | 13 - > arch/riscv/boot/dts/sifive/fu540-c000.dtsi | 13 + > arch/riscv/include/asm/csr.h | 58 +++ > arch/riscv/include/asm/perf_event.h | 100 ++-- > arch/riscv/kernel/Makefile | 2 +- > arch/riscv/kernel/perf_event.c | 471 +++++++++++------- > 7 files changed, 471 insertions(+), 245 deletions(-) > create mode 100644 Documentation/devicetree/bindings/riscv/pmu.yaml > > -- > 2.27.0 >