From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80C183F54C5; Wed, 29 Apr 2026 12:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777467135; cv=none; b=UdBnBf8QwcGzdZPAiwCoQCbqobAYTelMix+DWZNoh4DfRosU0krajY/CF/kiB4mVi2e7lrnkuqjf5UT9H7DPv5ZpGGUkjfUfEHOrNBUU9Yy9I/yFkvGUPpsRGjhb2tujUD33fPaJ8r+EUM+RoFqa8Df8xpaGIlgDRNx6pYbVnLo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777467135; c=relaxed/simple; bh=R6NK+k8ZNjgQeXfEqDRJFmobQO1th4diTIab92ehWT4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CWaOEdefYU2e13KEVgIkEvKVjDs5X8soxmAa3ZNFzcb94qFV7ywkyk9/O12GbT932DDS8gd4FUed21PtLD+3YQRAwvGHzZ+xyyfYjXIfgcpNqO6MDfDFqvCmvx3NMI4VhV3oYx0zDGqAgOidiisLh0kxLj+UaqhE3jxzKM2Swdw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=mYnCKVRs; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="mYnCKVRs" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63T8plvC3752353; Wed, 29 Apr 2026 12:51:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=bYXYwzQuclEQ/6LXNdmF4xIW3tfTCncolOW eQi146eA=; b=mYnCKVRs0FiMVGo8kF5LQMcNtscJxJrdUQfbVEB+oeaaK+Wp3uo F2/aw9Pj9B3TGeFiww/igE/OkMbEUYbrbEL7/7GywrpMze0UGHvcJPGvJkNRmKkF 29qpyWvNl4rGeBPK2PYZ7jotrl6Rgpt+9erhucCvTmTSzP6cG6hCxYBHNMWj2ZWg OjLRN1r81C1RQz0Vp7SCaouBVsP/+nC9OfYZTnnNM8gGtF8bFBoxpmKHHtj0VYK3 uLDVvUtwdf4kKBl2ydsBlf3LNEYqEcmZlHDkBsUe1IZY5mR8HY3BCEvt3lFkZzba orwBBWTHThXk9PkRzgadtexsqC8culRFkWg== Received: from apblrppmta02.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4duch1hjah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:51:41 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (8.18.1.7/8.18.1.7) with ESMTP id 63TCpb5N010777; Wed, 29 Apr 2026 12:51:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 4ds65fvr0t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:51:37 +0000 (GMT) Received: from APBLRPPMTA02.qualcomm.com (APBLRPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63TCpbD3010748; Wed, 29 Apr 2026 12:51:37 GMT Received: from hu-devc-blr-u24-a.qualcomm.com (hu-anuppate-blr.qualcomm.com [10.131.36.165]) by APBLRPPMTA02.qualcomm.com (PPS) with ESMTPS id 63TCpbtG010743 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Apr 2026 12:51:37 +0000 (GMT) Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id AE9DF215BA; Wed, 29 Apr 2026 18:21:36 +0530 (+0530) From: Anup Patel To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Palmer Dabbelt , Paul Walmsley , Greg KH , Alexander Shishkin , Ian Rogers Cc: Alexandre Ghiti , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Mark Rutland , Jiri Olsa , Adrian Hunter , Mayuresh Chitale , Anup Patel , Atish Patra , Andrew Jones , Sunil V L , linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v4 00/12] Linux RISC-V trace framework and drivers Date: Wed, 29 Apr 2026 18:21:23 +0530 Message-ID: <20260429125135.1983498-1-anup.patel@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QCInternal: smtphost X-QCInternal: smtphost X-Authority-Analysis: v=2.4 cv=arGCzyZV c=1 sm=1 tr=0 ts=69f1fedd cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=V1jnuoLLAAAA:20 a=NEAV23lmAAAA:8 a=p0WdMEafAAAA:8 a=utHJ6407P1UXFtj8NH4A:9 a=bA3UWDv6hWIuX7UZL3qL:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI5MDEzMCBTYWx0ZWRfX1ddY+Uv1MfCk mtgHPJEUX4rbEWeUp2B19CYQ3091zpQgg/Jdo+/Vwln6gBeZxOZ/sM2fXz5em+TYL4bBzXj7xW5 aGOTxX/Ynfd4iArNtV8BOQbuuPRNt7wYqGS3gfEdHMYmRDqhGkFdgT6rfxvp5TBqbg+fPdBTbi/ 0IKQ40VGjgDVjHFPVYmURCDvYBZdJzK822rdDyutKvzareLYSVots2dB8wcZ0jGtEymg1d/1Ddl p7kWxt3Rw8K/q9z0cD4KzjovbfCkA7h8ayxXNwry5Qo6CNc6RNhxCuss5wQ1/zezdwdYMsF9hFK unrgaPn9ZjjvyFD7IaIcfWUxT2q7mEaq/af4JxTsDbjz2MKzkYrklGBAzl9kr5EqtkirQ8c/ziU JQrcbWHZF2HuXTldwMCRs2m8/fy+G57Wa+ENIByrDHfOD+MpXkxtbJNcgHCZuCgYuQEpHRcN49d O2pglWF68ODzFywKX7w== X-Proofpoint-GUID: tBDwjlniXAo1fUUr1Yveh4tp_yAhg-BI X-Proofpoint-ORIG-GUID: tBDwjlniXAo1fUUr1Yveh4tp_yAhg-BI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-28_05,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 clxscore=1015 adultscore=0 impostorscore=0 spamscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604290130 This series adds initial support for RISC-V trace framework and drivers. The RISC-V trace v1.0 specification is already ratified and can be found at: https://github.com/riscv-non-isa/e-trace-encap/releases/tag/v1.0.0-ratified https://github.com/riscv-non-isa/tg-nexus-trace/releases/tag/1.0_Ratified The RISC-V trace framework and drivers are designed to be agnostic to the underlying trace protocol hence both RISC-V E-trace and RISC-V N-trace should work fine. The discovery of trace protocl parameters are left to user-space trace decoder. In ther future, there will be subsequent series adding: 1) Sysfs support 2) ACPI support 3) More trace drivers (such as funnel, ATB, etc) 4) Support for upcoming self-hosted trace specification 5) ... and more ... These patches can also be found in the riscv_trace_support_v3 branch at: https://github.com/avpatel/linux.git To test the patches, we need QEMU virt machine with RISC-V trace support which can be found in rv-etrace branch at: https://gitlab.com/danielhb/qemu.git To capture rvtrace data using perf on QEMU virt machine do the following: 1) Launch QEMU virt machine $ qemu-system-riscv64 -nographic -M virt -smp 2 -bios fw_dynamic.bin \ -kernel Image -append "root=/dev/vda rw console=ttyS0 earlycon=sbi" \ -drive file=/path/to/rootfs.img,id=disk1,if=none,format=raw \ -device virtio-blk-device,drive=disk1 2) Run perf record to capture rvtrace data $ perf record --all-cpus -e rvtrace/event=0x1/ 3) The step2 would create a perf.data file which has the rvtrace data. Now run perf report -D and look for PERF_RECORD_AUXTRACE event section(s) which point(s) to the actual rvtrace data offset. Changes since v3: - Rebased on Linux-7.1-rc1 - Use kzalloc_obj() in-place of kzalloc() in PATCH2, PATCH3 and PATCH9 - Improved PATCH7 to save the previous WP value Changes since v2: - Rebased on Linux-7.0-rc1 - Addressed Rob's comments on DT bindings in PATCH1 - Addressed ref-count related issues in rvtrace_of_parse_outconns() of PATCH2 - Made RVtrace framework more generic by avoiding implicit access to component registers in PATCH2 - More improvements in trRamStart/Limit/WP programming and other improvments in PATCH7 - Removed RVTRACE_BUF_LEN from PATCH9 - Removed redundant page_size from PATCH10 - Renamed found_etm in PATCH10 - Removed rvtrace_recording_init() declaration from header in PATCH11 Changes since v1: - Rebased on Linux-6.18-rc3 - Addressed Rob's comments in dt-bindings added by PATCH1 - Get reference of conn->dest_fwnode and add missing break in rvtrace_of_parse_outconns() of rvtrace-platform drivers added by PATCH2 - Added new inline function rvtrace_comp_is_empty() in PATCH2 and used it in rvtrace_encoder_stop() added by PATCH5 - Fixed trRamWPLow usage in PATCH7 - Determine RAM sink buffer size based on component implementation ID and reduce default RAM sink buffer size to 1MB - Add new PATCH8 to enable DMA_RESTRICTED_POOL in RISC-V defconfig so that implementations with RAM sink address restrictions can be handled. Anup Patel (6): dt-bindings: Add RISC-V trace component bindings rvtrace: Initial implementation of driver framework rvtrace: Add functions to create/destroy a trace component path rvtrace: Add function to copy into perf AUX buffer riscv: Enable DMA_RESTRICTED_POOL in defconfig MAINTAINERS: Add entry for RISC-V trace framework Mayuresh Chitale (6): rvtrace: Add functions to start/stop tracing on a component path rvtrace: Add trace encoder driver rvtrace: Add trace ramsink driver rvtrace: Add perf driver for tracing using perf tool perf tools: Add RISC-V trace PMU record capabilities perf tools: Initial support for RISC-V trace decoder .../bindings/riscv/riscv,trace-component.yaml | 120 +++ MAINTAINERS | 11 + arch/riscv/configs/defconfig | 1 + drivers/Makefile | 1 + drivers/hwtracing/Kconfig | 2 + drivers/hwtracing/rvtrace/Kconfig | 33 + drivers/hwtracing/rvtrace/Makefile | 6 + drivers/hwtracing/rvtrace/rvtrace-core.c | 787 ++++++++++++++++++ drivers/hwtracing/rvtrace/rvtrace-encoder.c | 130 +++ drivers/hwtracing/rvtrace/rvtrace-perf.c | 345 ++++++++ drivers/hwtracing/rvtrace/rvtrace-platform.c | 209 +++++ drivers/hwtracing/rvtrace/rvtrace-ramsink.c | 338 ++++++++ include/linux/rvtrace.h | 352 ++++++++ tools/perf/arch/riscv/util/Build | 1 + tools/perf/arch/riscv/util/auxtrace.c | 219 +++++ tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 4 + tools/perf/util/auxtrace.h | 1 + tools/perf/util/rvtrace-decoder.c | 91 ++ tools/perf/util/rvtrace.h | 19 + 20 files changed, 2671 insertions(+) create mode 100644 Documentation/devicetree/bindings/riscv/riscv,trace-component.yaml create mode 100644 drivers/hwtracing/rvtrace/Kconfig create mode 100644 drivers/hwtracing/rvtrace/Makefile create mode 100644 drivers/hwtracing/rvtrace/rvtrace-core.c create mode 100644 drivers/hwtracing/rvtrace/rvtrace-encoder.c create mode 100644 drivers/hwtracing/rvtrace/rvtrace-perf.c create mode 100644 drivers/hwtracing/rvtrace/rvtrace-platform.c create mode 100644 drivers/hwtracing/rvtrace/rvtrace-ramsink.c create mode 100644 include/linux/rvtrace.h create mode 100644 tools/perf/arch/riscv/util/auxtrace.c create mode 100644 tools/perf/util/rvtrace-decoder.c create mode 100644 tools/perf/util/rvtrace.h -- 2.43.0