Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2441850ybt; Sun, 28 Jun 2020 20:23:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyRW3qlgYHWRiwQgdZrR/YzlIZnw+pMzVxIl4YvK3OYYDMup//6xqT5ccv62AxwJBDFnf3 X-Received: by 2002:a05:6402:b9b:: with SMTP id cf27mr12952693edb.84.1593401033155; Sun, 28 Jun 2020 20:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593401033; cv=none; d=google.com; s=arc-20160816; b=YqttMrHix9Ls3L4VFud9z/eRUfVzmRDyxKQNSkcOUB/ck8k4G6rQl20bvAHjlpxcfF JlYGsUUaU3a6gMREz9zcoqf9bWtNOQ1IpQY+CJUXorSdEVcSsDnPzzjDrqW3hUufsEMF nz8az1KSqei7gI0DnIfNkCHIpx2Q0R6W3ALLNgzW8IKpMAkYfA5vccvijUfRKbG4RTBK HTbPq2CPzWOPIUUZviZq7sbLzhra+eQLe8HnboRnzSC7g/mikTnIeyt+1mY0OPaJYwY9 PKfXfucGG9tTxton0W/LrUJLyRgyoFLgo6xMxjShAtpyO9Rc95OGDyINEkMltta5cyei eqSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=MX1npRs6E1BJMvrT9omJsOQIQGUgSUPJQrW7wHX73nA=; b=ZqMBYBvfRxwfMmx9MrjAQO4MaCXIHFJSKIWjQiA0rTPTnP21aZqdsEf2BHLGO28P3s zSKXDKH6O0xUtvuunpezxx2W2zKkagz07M0zmMreUb+0X4OlJ83b5btbPALA/PXpetRF 8S1/zDRKpL2ZHsVedasnrMM85TRmW5BCzuHjhCOoiwgRx1By+LYTadqmx5VLzvo49FFd n8Ue1Cc4MW755bJTb8ORJbsRZiiFDzq6Da7trnqYbC6T7dmNTM5wBrYTx5O/ln2zYcGe MuaUSm1hYS0f+Fs4wJWQQqsj0f+ZDFtPgcOYBG2FfxRU4HveaHu0mUNmGmORbxCqH8gc zdjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=DjjLcbwY; 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 a8si330770eds.491.2020.06.28.20.23.30; Sun, 28 Jun 2020 20:23:53 -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=@sifive.com header.s=google header.b=DjjLcbwY; 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 S1726019AbgF2DTV (ORCPT + 99 others); Sun, 28 Jun 2020 23:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgF2DTV (ORCPT ); Sun, 28 Jun 2020 23:19:21 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E520C03E979 for ; Sun, 28 Jun 2020 20:19:21 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id 35so6548571ple.0 for ; Sun, 28 Jun 2020 20:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MX1npRs6E1BJMvrT9omJsOQIQGUgSUPJQrW7wHX73nA=; b=DjjLcbwY5BLsHDucAiJGHAt3gNsHaOg6PiLoaWZxOGruFvSbZQF4RW1hATXG1HnaWO pcZRJWshtmAxSLaRi/JtjxHj7PxLej/B40u2BarfoutSjccAyDxw2hcUwpex99gqqQb2 9O3yqMDejj0DMYOFaiMYErhmu/2Fez6uwhyw8wgwxXrcc1yRNEkmuc8yM1x5s63g+AiZ enfWSmp4cHLHLk6qJkgylXKWsIYPPMmEsWXpb0kiUrlFJ7M5Cf/meUzPO5Kim1q1/NrW AQSaf1wD/krSAdzXwK7sbRUfAlua4GNPn5T1oGK4hVGstQcy3UrdJk7pyl0BaJ07C+f1 ss4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MX1npRs6E1BJMvrT9omJsOQIQGUgSUPJQrW7wHX73nA=; b=Lvy3PvJc5WCfxiP0ZUX7jOhHWRKezj7l4m5k+qUvETHpd9DSzYlISTlPrtz92zfLfB 89TIYd0X+Y7dxRt1HkGFF3Qu4zxKOxH0uqXS+MrZW4r7pV4ea+BavmulcHM2Xu7uq6Km c37S5hwVu7OUBd/bilTF7fD0e3k8Khv4fsrqIM/PKCzN/U2VHierRX+KkyQrnmM0xAXT vGAs0vOkWAjKCxkDhz1o80rFh1ixUotTrcYwDXkDy0NjwQ23V1Hd3qKXpZck5MLJEXzr 3rJyBexXXg/ZCCDi/oN4stgkHAy8yYZu+9OCXcOMNlHoyYYpH3KZr40XY7VtHHd40arC 35aA== X-Gm-Message-State: AOAM532UPOGmV0mnd2syltXcKImGo5MfesKGetnTtJ+dtjxNUnzhbFLg 0vKyv7cBTRtWbCOAKEC3GAB6XQ== X-Received: by 2002:a17:90a:20ad:: with SMTP id f42mr5130595pjg.96.1593400760594; Sun, 28 Jun 2020 20:19:20 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id j70sm12876254pfd.208.2020.06.28.20.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jun 2020 20:19:20 -0700 (PDT) From: Zong Li To: palmer@dabbelt.com, paul.walmsley@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Zong Li Subject: [RFC PATCH 0/6] Support raw event and DT for perf on RISC-V Date: Mon, 29 Jun 2020 11:19:09 +0800 Message-Id: X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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