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 6A61E3033CB; Wed, 25 Feb 2026 06:25:46 +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=1772000749; cv=none; b=sx0cqfThXQYFS9L7AZi9E4jcndvW6wLPUKpYCXxPnthKkpOk9JztfvFu+yZpuZrk6T7gNOB+vocPJPhhaiqwBAmFzuySVu3knb+OVFShQyEGi/3COLXb9cDRXu4vrXv6ARP6x9wTDKCrxiQWbH7ItpQgvqYCYU9ZetYG4OGLXto= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772000749; c=relaxed/simple; bh=jacmDR5ca4HlIORwbZdByb5CPXLJ6o75hhOPcCRAnzc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=YLJg6vhNLRS2Xqi03YKj0s7+dN7v8u1BulcAmGy6lMlVh8prFKS4//87oRlL8wP8gcMRAnXbIwhnVz3vZnIwQXwe+3tMKUpefB46eOnLjlyhPRsab6QSXWESS7l1s6Z22iaQyHm7VztXlmdIEOG0qZ1crO8+BId/GwEC66KgcK4= 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=FFelbCOG; 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="FFelbCOG" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61ONodBZ4044762; Wed, 25 Feb 2026 06:25:00 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=39XkBuCd6Wzvz28IB9ZjNbuNHrPc/NSXOb/ oQSi8EbM=; b=FFelbCOGWgCEhE4IOOCeamYyQsIzHjLetFyU8OMAniQeluXCoYV JaWOAJCjleZfd5DjzIH6yUprPnl4LNDvtZTm70ADOXmycAPe+X3qwyIPRhxgy8vI Jpt6kbE4z9y+I+m1jXqGWR6Dwcw5073z/6xCKj6CY5Rqu8K6cd2PBdOCEMLcC8kQ sXf+Wx4dT6O+LDrOALch/yvYX/i35ox/Gle+HgZLEGL+4uP9qEpuWSRSXBikz/eB IG6j4Qybg2WVANsgGPbw0Kh7gwLvBiZK0oLa81e+MYJJSIDtrusDnJauHSp9kmSj r4j7pV+Up2lAKPX48yCFHA60JgQiLsSV15g== Received: from apblrppmta01.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4chexejecy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Feb 2026 06:24:59 +0000 (GMT) Received: from pps.filterd (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTP id 61P6Ot19001290; Wed, 25 Feb 2026 06:24:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4cf5sm83dx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Feb 2026 06:24:55 +0000 Received: from APBLRPPMTA01.qualcomm.com (APBLRPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 61P6OsUk001266; Wed, 25 Feb 2026 06:24:54 GMT Received: from hu-devc-blr-u24-a.qualcomm.com (hu-anuppate-blr.qualcomm.com [10.131.36.165]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 61P6Ost8001261 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Feb 2026 06:24:54 +0000 Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id AD16E235AE; Wed, 25 Feb 2026 11:54:53 +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 , Liang Kan , 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 v3 00/12] Linux RISC-V trace framework and drivers Date: Wed, 25 Feb 2026 11:54:36 +0530 Message-ID: <20260225062448.4027948-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-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI1MDA2MSBTYWx0ZWRfX+nMCPfbSQ/5K Mdk9DhaTtX7bjCEh3Zp+x2zL9pzJ3b0QrRUjVF3eu7K7WYrWz5ME0anT4JmncTH3KSJsfm56UvN xix/Qo3r2jx8HHeUEc77noO0cEmSdohdMPAj/kFQv39IVaxADi5vgFVZ6QaZjkmyy0jdYxDg/re 9wGxZxiCrduXmqn68rsml2SJfD6pMQAu54urTY33SUnqiomAzrM1Dmcr0TJXq1ICmMfVcJ/oDqy t+zbcbZN6h714WfHxIQy9LLtXFIYp7SYSPsF/o+j8sL/pHLSTEq6jQoYrqJFjliMBnxcJNV9/pB 4a6cNuqefUGe083/5w7J6h5lYsUAhv3A8nGGEvsDs4rUnNrSas9KCknRFKVddUbK4f1iVWRdh4R oRLObhQRd+UD6y1z68yeflFcHt4Hk4L5ZWImfF8kXFL/iWJnXv12uRtZPTPchd1MYijq+0HQJbC l+8kosdawuRhz3IiNPQ== X-Authority-Analysis: v=2.4 cv=V85wEOni c=1 sm=1 tr=0 ts=699e95bc cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=V1jnuoLLAAAA:20 a=NEAV23lmAAAA:8 a=p0WdMEafAAAA:8 a=utHJ6407P1UXFtj8NH4A:9 a=bA3UWDv6hWIuX7UZL3qL:22 X-Proofpoint-GUID: uMwX8avILQf8c5Z5Vh-dxZiHr3VWyUG- X-Proofpoint-ORIG-GUID: uMwX8avILQf8c5Z5Vh-dxZiHr3VWyUG- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-24_03,2026-02-23_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602250061 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 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 | 341 ++++++++ drivers/hwtracing/rvtrace/rvtrace-platform.c | 209 +++++ drivers/hwtracing/rvtrace/rvtrace-ramsink.c | 322 +++++++ 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, 2651 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