From nobody Wed Apr 8 19:15:29 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 D3B3E2FF65B; Wed, 25 Feb 2026 06:25:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772000754; cv=none; b=gJlmjpI5JI80SjfTB42EV3ZZmPAfxXEyxO9t5knpEjz1v7k9Y5wXyLmmpYVLHUJJnblp61fSF3wom4oxmJ8HqWud/tZb9wd90VTw+IjrOhyYvXWzPAFD9umi7xI+zBVW+iHB+YqRZ3ZnrRY2nI7sNqHWXayYrxjHlnLyfqCDdPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772000754; c=relaxed/simple; bh=3fjiR1OLUKEW3wYA7hZz7rAGXNWjm2SfZk7UVWmb9xw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ge5dWoUd2QxZ+3hLwC5ulZqltmGfzscWoa+w8NmqaP/s0eYH1IXLeBPO20/l2eFr5YauyOzQv5Sq8fCh1TNv/TQf8KIhhaa1dkuUnD/rAkZSVI3VrJlX6vPbOvAZJcsNBrfjwdDQXSss6gsNyfSzim1sHAGs1lobNf9vaFGDkwQ= 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=Nx0qnNNW; arc=none smtp.client-ip=205.220.168.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="Nx0qnNNW" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61P2J7h72334677; 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:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=whc2xuE7mjG PrFhJLcfcyz207KCnXeQQirLtWYIG99E=; b=Nx0qnNNWFuRK0bpKS+dfDOWU2HC V6ZotrThg+WI5zYZu4Ab0bpvLVveA+qjlGKg+CfWOr8dT+9LRdemry8a6r8xlF86 8sFSlsqcLGpq6RMKUtOQuYP6gXqzfrKcU8kfe/oUVP+DNHW85pKKmlYdrbF3FqGe 0qW5sMQbSfI8Cn2B5CF0UTVr2/ASMxffm8W6tKbC4qWJ/NijVF98/s7Wo0YLC1pG /jPOpS+8VcFBxB+pJNUUwKY1iv2BY0kiSITxgqA+TxxqESuWpzqClnZx5qS6UB4q 3cW0H9RGu7mqho1c/tOpD2llmitSUsLiOq+KOjuS8gDzAuGVs6qqJHh3Bxg== 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 4chg37t698-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 61P6OtoA001344; Wed, 25 Feb 2026 06:24:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APBLRPPMTA01.qualcomm.com (PPS) with ESMTPS id 4cf5sm83ev-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Feb 2026 06:24:56 +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 61P6OtgR001315; Wed, 25 Feb 2026 06:24:55 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 61P6Ot0r001303 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 Feb 2026 06:24:55 +0000 Received: by hu-devc-blr-u24-a.qualcomm.com (Postfix, from userid 486687) id E06862574B; 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, Mayuresh Chitale , Anup Patel Subject: [PATCH v3 11/12] perf tools: Initial support for RISC-V trace decoder Date: Wed, 25 Feb 2026 11:54:47 +0530 Message-ID: <20260225062448.4027948-12-anup.patel@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260225062448.4027948-1-anup.patel@oss.qualcomm.com> References: <20260225062448.4027948-1-anup.patel@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Authority-Analysis: v=2.4 cv=br1BxUai c=1 sm=1 tr=0 ts=699e95bb cx=c_pps a=Ou0eQOY4+eZoSc0qltEV5Q==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=b95MOGMN5JXeKaQ3w7sA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI1MDA2MSBTYWx0ZWRfXytCZ2TOdUZVW igJwoMAZWB+od35QbVOZ5RKjPWCDjhMg7n9mKrhDEAYPdmTB93EwGl7db8vdp4KaibkHX0CTfEa esYwvjb7hvddYZfNFVMiyA5DGqsgl/ofA4dZyVR7sggecPKiYfc15PamUOriOK4VAxSlVF+71dq +qxR0CYCKxE1OxY1osq67gEK6RXQn5eWAFA97XTQfW5ptjVZOIePKlmNtUaZ1gRB9ngKFmZIuHA RSXXL2rvQL3qzrmXPrxK8JU/5lrJ6T346FP3H5J1PgebWo5hci2W4mvSm5PoIJq/+/MRK3iNO7b KWmH5342JOnPXVT5nQ11ElXPra1oSPFPtUxmeD+oWbpWdwxTzjuS8vJvgAA/vEfwEUz99YwyucN IzV3BLU9NhhAst1S/tF6z4izy7bJ58QZwY7KdVPDJgAfwhuw/xY89ujkccs2scM5+sd3D5duVX9 Fhcju0ZMQK+N7Fos8Vw== X-Proofpoint-ORIG-GUID: S24LmRNr1STx8rNAqM9fQIHSskUYYuPN X-Proofpoint-GUID: S24LmRNr1STx8rNAqM9fQIHSskUYYuPN 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 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 impostorscore=0 adultscore=0 bulkscore=0 phishscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602250061 Content-Type: text/plain; charset="utf-8" From: Mayuresh Chitale Add bare bones support for RISC-V trace decoder so that the data received from the hardware by the RISC-V trace perf driver can be written to the perf record output file. Co-developed-by: Anup Patel Signed-off-by: Anup Patel Signed-off-by: Mayuresh Chitale --- tools/perf/util/Build | 1 + tools/perf/util/auxtrace.c | 3 + tools/perf/util/rvtrace-decoder.c | 91 +++++++++++++++++++++++++++++++ tools/perf/util/rvtrace.h | 1 + 4 files changed, 96 insertions(+) create mode 100644 tools/perf/util/rvtrace-decoder.c diff --git a/tools/perf/util/Build b/tools/perf/util/Build index bcccad7487a9..4cb5a6c61bf7 100644 --- a/tools/perf/util/Build +++ b/tools/perf/util/Build @@ -147,6 +147,7 @@ perf-util-y +=3D cs-etm.o perf-util-y +=3D cs-etm-decoder/ endif perf-util-y +=3D cs-etm-base.o +perf-util-y +=3D rvtrace-decoder.o =20 perf-util-y +=3D parse-branch-options.o perf-util-y +=3D dump-insn.o diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c index 944a43d48739..c6bd6642ce05 100644 --- a/tools/perf/util/auxtrace.c +++ b/tools/perf/util/auxtrace.c @@ -54,6 +54,7 @@ #include "arm-spe.h" #include "hisi-ptt.h" #include "s390-cpumsf.h" +#include "rvtrace.h" #include "util/mmap.h" #include "powerpc-vpadtl.h" =20 @@ -1412,6 +1413,8 @@ int perf_event__process_auxtrace_info(const struct pe= rf_tool *tool __maybe_unuse err =3D powerpc_vpadtl_process_auxtrace_info(event, session); break; case PERF_AUXTRACE_RISCV_TRACE: + err =3D rvtrace__process_auxtrace_info(event, session); + break; case PERF_AUXTRACE_UNKNOWN: default: return -EINVAL; diff --git a/tools/perf/util/rvtrace-decoder.c b/tools/perf/util/rvtrace-de= coder.c new file mode 100644 index 000000000000..58db5ca62c1a --- /dev/null +++ b/tools/perf/util/rvtrace-decoder.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * RISC-V trace Decoder + */ + +#include +#include +#include "evlist.h" +#include +#include "rvtrace.h" + +struct rvtrace_decoder { + struct auxtrace auxtrace; + u32 auxtrace_type; + struct perf_session *session; + struct machine *machine; + u32 pmu_type; +}; + +static int rvtrace_process_event(struct perf_session *session __maybe_unus= ed, + union perf_event *event __maybe_unused, + struct perf_sample *sample __maybe_unused, + const struct perf_tool *tool __maybe_unused) +{ + return 0; +} + +static int rvtrace_process_auxtrace_event(struct perf_session *session __m= aybe_unused, + union perf_event *event __maybe_unused, + const struct perf_tool *tool __maybe_unused) +{ + return 0; +} + +static int rvtrace_flush(struct perf_session *session __maybe_unused, + const struct perf_tool *tool __maybe_unused) +{ + return 0; +} + +static void rvtrace_free_events(struct perf_session *session __maybe_unuse= d) +{ +} + +static void rvtrace_free(struct perf_session *session) +{ + struct rvtrace_decoder *ptr =3D container_of(session->auxtrace, struct rv= trace_decoder, + auxtrace); + + session->auxtrace =3D NULL; + free(ptr); +} + +static bool rvtrace_evsel_is_auxtrace(struct perf_session *session, + struct evsel *evsel) +{ + struct rvtrace_decoder *ptr =3D container_of(session->auxtrace, + struct rvtrace_decoder, auxtrace); + + return evsel->core.attr.type =3D=3D ptr->pmu_type; +} + +int rvtrace__process_auxtrace_info(union perf_event *event, + struct perf_session *session) +{ + struct perf_record_auxtrace_info *auxtrace_info =3D &event->auxtrace_info; + struct rvtrace_decoder *ptr; + + if (auxtrace_info->header.size < RVTRACE_AUXTRACE_PRIV_SIZE + + sizeof(struct perf_record_auxtrace_info)) + return -EINVAL; + + ptr =3D zalloc(sizeof(*ptr)); + if (!ptr) + return -ENOMEM; + + ptr->session =3D session; + ptr->machine =3D &session->machines.host; + ptr->auxtrace_type =3D auxtrace_info->type; + ptr->pmu_type =3D auxtrace_info->priv[0]; + + ptr->auxtrace.process_event =3D rvtrace_process_event; + ptr->auxtrace.process_auxtrace_event =3D rvtrace_process_auxtrace_event; + ptr->auxtrace.flush_events =3D rvtrace_flush; + ptr->auxtrace.free_events =3D rvtrace_free_events; + ptr->auxtrace.free =3D rvtrace_free; + ptr->auxtrace.evsel_is_auxtrace =3D rvtrace_evsel_is_auxtrace; + session->auxtrace =3D &ptr->auxtrace; + + return 0; +} diff --git a/tools/perf/util/rvtrace.h b/tools/perf/util/rvtrace.h index 24b32947fb4c..8e3eb4d681a7 100644 --- a/tools/perf/util/rvtrace.h +++ b/tools/perf/util/rvtrace.h @@ -15,4 +15,5 @@ =20 #define RVTRACE_AUXTRACE_PRIV_SIZE sizeof(u64) =20 +int rvtrace__process_auxtrace_info(union perf_event *event, struct perf_se= ssion *session); #endif --=20 2.43.0