From nobody Thu Apr 2 06:31:58 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 40D76387590 for ; Mon, 23 Mar 2026 09:49:56 +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=1774259397; cv=none; b=hC6zwKdfP3V69Ds3MZcu9QvKJKnePz7H9xY/wWK+j1zbulFmgfD6ln0yZ/D22/vY75NHmF3sKRuabP2SS7M3ocg9R2xbAAP+VhN4AxEGyChKOD4KemrXupfXmY2zKK3ZlzuznGAENnVLdfyaK8bqJi71cIRoVaii7DRJ8mkm/fM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259397; c=relaxed/simple; bh=ckf80wWUcb1qnI0v7q/6ZqqYr3nuJh7ROL35EVLOH7w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sqeHxTgpfYIUAEqtNrWx0sHtSOP4hNMdmlfb1gH48+9zDPgusFu82itBrD8ALHHyYTOdHVrGvcK30STHOE+NV/mDbj8HZBK0hgresoo0tHYdYZnokViXMjBqB/7NOGBESr9cFGyG1Kh7jWbXqR8RBnCTApiBddP957GxPYlB1oA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Mn7WVtAN; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=kgFAvpZm; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Mn7WVtAN"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="kgFAvpZm" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7tMFS2291969 for ; Mon, 23 Mar 2026 09:49:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= aOdpdbZJkeNi3c6n6qEjoFu015+pEeWRTwmOxcPblaY=; b=Mn7WVtANdLkIu+8d ykBDn7KOR2vtBgKonqxOg0r0blLWFH8TBhoKkUME5Bk0NcZySln1ruTj4QQn0pQW rEpWrqmMGi0rM5PveuriqY7HMp9LzXugw1t0AombowwSCleZ0sKJE5z/Avk+Qv7t Qv0mDQY7c/kK0WKeeaxvAtA/5r/qFZ9WF8Zl3ChMXON2hT+w5DejOeycpqwhXWrI VZLRzQl8IplW2b9MS+w1SmIHavZfa9mQpxLEEj7C+TeNcgv06Rp+kBYgWrwFL82/ DXHD/nRVrXZrmvbzB1ryz48TcnUCNynZVBCNUspOI2oAPfTnPWvWI/eVhCSykXXX DN4KEQ== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d31j70cyy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:49:55 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-35bea322389so1349961a91.1 for ; Mon, 23 Mar 2026 02:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259395; x=1774864195; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aOdpdbZJkeNi3c6n6qEjoFu015+pEeWRTwmOxcPblaY=; b=kgFAvpZmVSzAQqXc3K8grVmwyFog8rDnkztt4dYxTC7NGrcM0l0Yyn8+LH+yakIzct wNr5QeQgT43GSlefYSG+Oy5vrOst9eGcTUTtRfiHmxZylOUOEgoOZCwPtdliCtsHlZg6 RIFdhsfY0/PE/Zy5uN+mBWuEC8C5dvMB2fhu9le2YMnUEqsuMYGSPFbBr86VF60jF96R ypW5xOKG8Iit6seKoESyOiaXSzydcVBYcHkKKhgn2dEySOV+u1OCK8IWn4Zm77xt9p5h Rr7ODbJ4nxLRC2x0LBV9we0VrFIM+z8jhF7PsXxtnTFNEd3qMf9obMDPriE9nNFpLUNj M5Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259395; x=1774864195; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=aOdpdbZJkeNi3c6n6qEjoFu015+pEeWRTwmOxcPblaY=; b=cv9WVVwobNAgwOibzlSId30H/6uv7pfLoBWhTZKjWSpZYFv5c54crAkwyCs/InQSDu q/kbs4bUT6fvXiqvlqTPLk+y4igPJ4UvQSPZd62F6jYtucTMBvD1SCbb3fRPm3/sy3iL nloXnORJgjgrYUEFk0z3ocpagohbTmSC6wZmPcRgOPWGdnINDzMD5zviejDWhga6sd6i 9w+Z1kvQ+pNfb21UrIO6TbSmrUtDFj8g1COylmjTuEhERVOs7Le7gmA4O2JDrk/5mPR9 42T5ayN2sIX6ukDft7/2JH7TWLi1OkXvQ0xeeRg+XWKHoEMIZr/GqzhChDJ1C3mBv3wD Gf9g== X-Forwarded-Encrypted: i=1; AJvYcCUVb1LnvqSx4VzOZJiFXOVjNdzWexCfNlX1mMkIAzdS4zhorwZ09/mFsRLkqoVWNO94wHRhIVU9dEDXtjY=@vger.kernel.org X-Gm-Message-State: AOJu0Yxv3wZ2TgX7wN7XZPaJLYzCp26SC3zTX8qtvcXCf4ursI4g2n6Z 2Q5WAcNL5Q+/dWd2tfmySvvOC2RQnj1Y8jMQodwaxmSqAEFghybJ1K3IdEoqxINt+0Ciai+J03g ZWf5zOJDESzH51UDPY7l+Xm2tGQn/ynFRQ5XZDPJd6bPIH7hIVrh46hWOmxf6XJz6YGY= X-Gm-Gg: ATEYQzzmubbHQeuHhSBu1S0pKUX4w01aFFfyH7D2pdirFxtTEAcHj7L+m4QTbP/GZlV QHsu+jW4je88xeZ34baqCi6r/hh05HT4PPa/ePgfm3QCgXcOoUTtC2sy4eZlqIRkRww+lrSEVHf nepvk4hQx8b4BvHh5i5QJM4+8p69eBJDKb7LAblKFkOrCbUYrPOupBfhdBH8Ocz6IuiGe1LOE3x 1J4V5vFHNiNt3NC6mzD+Tr9rXKV/DVI6KKPm/HYgcPS+1kknS0M9PTDff32TIQPVftgWvC/A4jY zx86SoX8VJdqWThLJm0ykFaLOjuvOBQv+ei9UzA4AdGKkNURjYyUCmFnAWybB2FE7W1cnNiX99c FcVz+a/BZxwuvC713UpSCesC5wCIId3saSV3dWHB0x6EbaRDflxK7wchyL7xWBUkVLTPef0jd/s wroHLp/8Sc X-Received: by 2002:a17:902:f545:b0:2ae:5655:b16 with SMTP id d9443c01a7336-2b0827556bfmr114909045ad.21.1774259394754; Mon, 23 Mar 2026 02:49:54 -0700 (PDT) X-Received: by 2002:a17:902:f545:b0:2ae:5655:b16 with SMTP id d9443c01a7336-2b0827556bfmr114908795ad.21.1774259394276; Mon, 23 Mar 2026 02:49:54 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:49:53 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:26 +0800 Subject: [PATCH v16 1/7] coresight: core: refactor ctcu_get_active_port and make it generic Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-1-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan , Mike Leach X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259383; l=3771; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=ckf80wWUcb1qnI0v7q/6ZqqYr3nuJh7ROL35EVLOH7w=; b=w8ZILQOnGTMowRbpwWpLUHa5OOF+7MJT/Ml5rl4sI+DJZQpFY3JY/QPQdMZL7gqB50X0CQjcF Ld7n0gX3kSYAOt22Gbfx3Q5bQ5n5sDS6wUCigNYTrtUhtb2T00rpytb X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Authority-Analysis: v=2.4 cv=ArXjHe9P c=1 sm=1 tr=0 ts=69c10cc3 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=KKAkSRfTAAAA:8 a=EUspDBNiAAAA:8 a=qQZ2XtAyJf2dEkEvaVsA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: FzPVAtmkHtEmVdmGCv-u3LNqe4raNRj3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfXzmEXMoFzwbIW zq+vz8H6vQ4eeHnGwlk/tLii7xiqdydw58V6ZvdSOM0kLUB0YwYRluNY7wBodFsNL0lD8f35/oL aA7cT0NONroO4dwIwgiL3MIKKL0uTjSkNnZPeDuefkK0yxmPKYGPIY6ZnN8ryWl/snQs2UatU9o s6Sce7k92GoO8DnjvRJaU+aQxFl/veY6s5pWYtAmsEp3mD7BQCNQx0B0R3VDHNQajPbFq3jyKuz zogAn69Ta05g1YuW0GKKAiZB6e0W0PCYHhYTiYuwY7L/gvvr15LSppSaEpt08+whd9pzDk5TxCd a1zjkttxcEBB26M18otTlywtxps1rzOrH1rqDsD2Vt+zg4Oh99yktrRV5+hs9TwVyEb9XA61PkO ityDfeLMtL+7enmEe2lXGH/Lv8v+CJgAF1HLyWofMxj0mQil06c3FGXDvg8eR+ON1my3YGuoCgn QXibizEJOebh9tHwwqQ== X-Proofpoint-GUID: FzPVAtmkHtEmVdmGCv-u3LNqe4raNRj3 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 Remove ctcu_get_active_port from CTCU module and add it to the core framework. The port number is crucial for the CTCU device to identify which ETR it serves. With the port number we can correctly get required parameters of the CTCU device in TMC module. Reviewed-by: Mike Leach Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-core.c | 24 +++++++++++++++++++= ++++ drivers/hwtracing/coresight/coresight-ctcu-core.c | 19 +----------------- drivers/hwtracing/coresight/coresight-priv.h | 2 ++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index 46f247f73cf6..221de57ca57b 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -588,6 +588,30 @@ struct coresight_device *coresight_get_sink(struct cor= esight_path *path) } EXPORT_SYMBOL_GPL(coresight_get_sink); =20 +/** + * coresight_get_in_port: Find the input port number at @remote where the = @csdev + * device is connected to. + * + * @csdev: csdev of the device. + * @remote: csdev of the remote device which is connected to @csdev. + * + * Return: port number upon success or -EINVAL for fail. + */ +int coresight_get_in_port(struct coresight_device *csdev, + struct coresight_device *remote) +{ + struct coresight_platform_data *pdata =3D remote->pdata; + int i; + + for (i =3D 0; i < pdata->nr_inconns; ++i) { + if (pdata->in_conns[i]->src_dev =3D=3D csdev) + return pdata->in_conns[i]->dest_port; + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(coresight_get_in_port); + u32 coresight_get_sink_id(struct coresight_device *csdev) { if (!csdev->ea) diff --git a/drivers/hwtracing/coresight/coresight-ctcu-core.c b/drivers/hw= tracing/coresight/coresight-ctcu-core.c index 9043cad42f01..e8720026c9e3 100644 --- a/drivers/hwtracing/coresight/coresight-ctcu-core.c +++ b/drivers/hwtracing/coresight/coresight-ctcu-core.c @@ -116,23 +116,6 @@ static int __ctcu_set_etr_traceid(struct coresight_dev= ice *csdev, u8 traceid, in return 0; } =20 -/* - * Searching the sink device from helper's view in case there are multiple= helper devices - * connected to the sink device. - */ -static int ctcu_get_active_port(struct coresight_device *sink, struct core= sight_device *helper) -{ - struct coresight_platform_data *pdata =3D helper->pdata; - int i; - - for (i =3D 0; i < pdata->nr_inconns; ++i) { - if (pdata->in_conns[i]->src_dev =3D=3D sink) - return pdata->in_conns[i]->dest_port; - } - - return -EINVAL; -} - static int ctcu_set_etr_traceid(struct coresight_device *csdev, struct cor= esight_path *path, bool enable) { @@ -145,7 +128,7 @@ static int ctcu_set_etr_traceid(struct coresight_device= *csdev, struct coresight return -EINVAL; } =20 - port_num =3D ctcu_get_active_port(sink, csdev); + port_num =3D coresight_get_in_port(sink, csdev); if (port_num < 0) return -EINVAL; =20 diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtraci= ng/coresight/coresight-priv.h index 1ea882dffd70..5532ec82e82c 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -155,6 +155,8 @@ void coresight_remove_links(struct coresight_device *or= ig, u32 coresight_get_sink_id(struct coresight_device *csdev); void coresight_path_assign_trace_id(struct coresight_path *path, enum cs_mode mode); +int coresight_get_in_port(struct coresight_device *csdev, + struct coresight_device *remote); =20 #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X) int etm_readl_cp14(u32 off, unsigned int *val); --=20 2.34.1 From nobody Thu Apr 2 06:31:58 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 023ED387585 for ; Mon, 23 Mar 2026 09:50:00 +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=1774259402; cv=none; b=ity7BNvaZCDGH5C+4ea6ajWZlg0E3N9NwdSfzDc8b8cfTS1qMx5CKKnSDiGzfWAAictnPu35Z72IEgLlJRBomsYXSXTApefEqXpK8hXca6Fhd7IKcmFfg4ocEtcSrOlPrKv70OcWXSgJS9pjtrhBx0YHgZYOsewOJRAgM6PLURo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259402; c=relaxed/simple; bh=FFceOaqM6wu7CDdoDhopkNKARk15nwOEHek364eGNLA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q1SpfngfjrRqzCkjXcI6X1C2xiqAnu2REWEtFwEu/Fv2PabD0ZrsG+XUROlHZIGnZ7L4J8N6kgMbdREYzstSa+AmbgIUO0FGLqSe4jqB7XZ7KbtRqQ/olqwtWP30QT3c4w6llCENXH50tOt0AVK3Iirl61S3ILBOCE/WHNLaGqQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=F/v5HfO7; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Dp/O4fWx; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="F/v5HfO7"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Dp/O4fWx" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7tAQ92291139 for ; Mon, 23 Mar 2026 09:50:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= aTJDJgY9ATjCAHRG1W16e0NWqYe38EB68qyE9RQn52c=; b=F/v5HfO705xH/vJB SbtOD/UJD6A0luaLs8qQTTMKjZK1pZymr3FST00FbGEerxLOcogUuB589xEbPphy hrAzmP6O6dDKAMp3OcGbsxNmhBpF0YLOi4upryTxgS2vcq2d/Osa8xVHsXOC4/g5 R5XnMphB3DXKvtFYtNAViMlOsDexgm4/EdVWfbetedbeKkGvA6GFsBJrj0lPySmn pNThk9WcWGCKOdX0ZOom/OxX9TYiOAuoD5XNaxfA1JcEbAEoTs1GpKbXTLn0l3yU sf+OLw8kG+lDgrbj0jr+niLuH9wr8xliur61mwAbQ5VVGzFxIBYE9+W1Xcjtbvew jm0H3w== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d31j70d0f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:50:00 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-35b901d542bso3753962a91.3 for ; Mon, 23 Mar 2026 02:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259400; x=1774864200; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aTJDJgY9ATjCAHRG1W16e0NWqYe38EB68qyE9RQn52c=; b=Dp/O4fWx2DnGVDRs5IKFLRZUpVXeakcisK8LdU4ohaklkeqxaoen89Ivp0ME3elx+8 79IETGf4LtPBLfDSnJjPAFwiBRiWjDwhxSdubktaaM69vmIAe1sZLj4YpDkIFvUKmMdR dZpoiV6wur3xRKVNA/x14hW92dwg1q8TvGwURuhi38pJl9M0VifeXjASeT19BT4yLkN9 Uq+0IFKYPVWxW0CFJq6oAtq1GEqnmn/lnVmtiQiu9g+F7LdABKe7wiL2YK6fp3woNwHh D93bJnZRbfL0e0Ju9uhiHbo3s4XbvSwOaPBu3lDR5urizPvRN+98rz3Qj6/fwAY7vqlu /XTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259400; x=1774864200; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=aTJDJgY9ATjCAHRG1W16e0NWqYe38EB68qyE9RQn52c=; b=DV1BZ2aCvWwUsTngXfddBYMrZYHdn80TLiBM4gggEGlUHs0u1XdfTvxHN0/YZSGORC bOrPtYwL26yA9G7c9JGxgJVmhjNeQs52rixqLAYPHW4E2op7E1+GjkPoneDEiRXqYbmy RTSzFPEmkeUXPyi/bcmoDLcSF/tH2p6gl0/MmM/lWbhqnCIFp5cpK6r9z0+eJSuem9yv A3DaIEMAqO9WgqBd6vv5oGb5P0W6F3TzZ1rRoVkTMUTGrTvJaCdLYQ38EEr7BxwBRj0t /bpzYZuwjti0R38eGBAHNPwbzkqa35Jw0+cueu6p/4s45m2gKfGgd3hV1d4fkE1O2D9x t2+A== X-Forwarded-Encrypted: i=1; AJvYcCWz8q3LKsR+MzNsQCyduTsL1CvUY/VKY4hsbSa4GtecLP69c4UTmekpe+rwaQ3LlKxW4VREuisJZAySJZU=@vger.kernel.org X-Gm-Message-State: AOJu0YySFJlSBS5FpN5lJyPymcsvOb2oRhYsZ/Cv7HMo6dJ1t8r6z5id rJok7os9Q2uiKmNGhhyBnCEGMnL/TLmJRcIKUANnMFrA38QPOrJd2RFvqSIODua4verm0/lc/mS ohCn9uiTY6Ys/BsAG9TGCm95EE00Gw8q9ctG2AT1qFs73CSupt7O+ZXpH0eyw5oAo+Eo= X-Gm-Gg: ATEYQzxpy9ZW97mMT9X1pvKAEQiL1n96vZ4V0bwTE+kpjwcSBIXCqknwfO6eout9Jr3 1ktFs1IUafPNdFL6jD2auf+ZnyiSq4bXsqdvCV1Bf4vFCBUQrbgCP05+qNmfUkGqyi061+xrVNy kCi0WxU61cGgIW7ce5tOtQaXJ2WIpkKwD+oWftbHX61y5UpvKR0imTIY+5K0XvEAxOl6SUP1prY 9f8vF9Xbx9jlDc3mkTqK55W+7tLMZXGU6E6/P/aRTFXOaNHfEv6Dy5SGwllpjMDUL+A7rXVGGkM Op/C/tyRwWKOhL+NyEX5O0zEQYIS0RFuQvkRdgKhfnQadRjInONuThkWwlln/wNTPJBn2tkbG// 6ZyJwB/23qOSY8lTcGl7o5nL6tIz2JSgmJUW+mjf59TJ43by+GyX1eqXETkoraFGR/OkD6rAgK3 aJ8zZwdCmr X-Received: by 2002:a17:90b:4a84:b0:359:ff8a:ee4f with SMTP id 98e67ed59e1d1-35bd2bd8b5cmr10355265a91.7.1774259399440; Mon, 23 Mar 2026 02:49:59 -0700 (PDT) X-Received: by 2002:a17:90b:4a84:b0:359:ff8a:ee4f with SMTP id 98e67ed59e1d1-35bd2bd8b5cmr10355240a91.7.1774259398986; Mon, 23 Mar 2026 02:49:58 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:49:58 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:27 +0800 Subject: [PATCH v16 2/7] coresight: tmc: add create/clean functions for etr_buf_list Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-2-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan , Mike Leach X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259383; l=6204; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=FFceOaqM6wu7CDdoDhopkNKARk15nwOEHek364eGNLA=; b=IxYt/7EWVEDsCF4b7tnmVPQ9RVLcT/lR15WOFzdR6hqbCMhYuQEXRluud+4FVD3Lk5YXocrsX oWbe/GW9qWtB6KsrbrOt6MFOi22gzWTP6IOOljrd0am8sPMzK69IDG0 X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Authority-Analysis: v=2.4 cv=ArXjHe9P c=1 sm=1 tr=0 ts=69c10cc8 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=KKAkSRfTAAAA:8 a=EUspDBNiAAAA:8 a=AScg1gZdVb1XvqdcXssA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: b7A0eFZXGol93X4H9LUL7w2vW24a1myd X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfX8omAzUw41+gd qLjtzV4kZO4sN/ECwFZ6YPNeLvQHktuFlcfd9ip65Jcz6x7UyXG2hYlPSVyKXdKBofQ84Kv9Yfy 6NZx2VHNF0mtz+4y0bwppH+6sXEo+5lJwSWOhfs8eQeFQERM8s40Kz61TljrTBUFBjHUiMhOk+k 82OdBhQtfKuI7rEbOUafEalkVN1VzTbdd43fltpioV8UUh+FPXcTa5O0DYKPlN1WwwGhVGN47yE XlSTqJA/tTZNPhIZMNv0Qviuu6EpMds7ygfNgXUC+Ped+IboTxpuy86qxiIcS5kvQUbH9gbpyNP Rwjbd9+E7v/r9fH0KV58s0uE82bedvbwsi67EXfoGI/Lpl53mi5HLNxIyLjreS5bolut8gJH5Qn MKXwAhLinnuOsWBlDFiK0qrWaLvJfKdyrwOVMKnQhHsJbRH5BWv0ez/einqddtxXez2TZSrJwIi ytiLjqmcAdaRA5OAb3w== X-Proofpoint-GUID: b7A0eFZXGol93X4H9LUL7w2vW24a1myd 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 Introduce functions for creating and inserting or removing the etr_buf_node to/from the etr_buf_list. The byte-cntr functionality requires two etr_buf to receive trace data. The active etr_buf collects the trace data from source device, while the byte-cntr reading function accesses the deactivated etr_buf after is has been filled and synced, transferring data to the userspace. Reviewed-by: Mike Leach Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-tmc-core.c | 1 + drivers/hwtracing/coresight/coresight-tmc-etr.c | 98 ++++++++++++++++++++= ++++ drivers/hwtracing/coresight/coresight-tmc.h | 17 ++++ 3 files changed, 116 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwt= racing/coresight/coresight-tmc-core.c index c89fe996af23..bac3278ef4dd 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-core.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -835,6 +835,7 @@ static int __tmc_probe(struct device *dev, struct resou= rce *res) idr_init(&drvdata->idr); mutex_init(&drvdata->idr_mutex); dev_list =3D "tmc_etr"; + INIT_LIST_HEAD(&drvdata->etr_buf_list); break; case TMC_CONFIG_TYPE_ETF: desc.groups =3D coresight_etf_groups; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index 4dc1defe27a5..306982e88dbb 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1918,6 +1918,104 @@ const struct coresight_ops tmc_etr_cs_ops =3D { .panic_ops =3D &tmc_etr_sync_ops, }; =20 +/** + * tmc_clean_etr_buf_list - clean the etr_buf_list. + * @drvdata: driver data of the TMC device. + * + * Remove unused buffers from @drvdata->etr_buf_list and free them. + */ +void tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata) +{ + struct etr_buf_node *nd, *next; + + list_for_each_entry_safe(nd, next, &drvdata->etr_buf_list, link) { + if (nd->sysfs_buf =3D=3D drvdata->sysfs_buf) { + if (coresight_get_mode(drvdata->csdev) !=3D CS_MODE_DISABLED) { + /* + * Dont free the sysfs_buf, just remove it from the list. + * drvdata->sysfs_buf will hold the buffer and free it later. + */ + nd->sysfs_buf =3D NULL; + list_del(&nd->link); + kfree(nd); + continue; + } + /* Free the sysfs_buf in coming steps through nd->sysfs_buf */ + drvdata->sysfs_buf =3D NULL; + } + /* Free allocated buffers which are not utilized by ETR */ + tmc_etr_free_sysfs_buf(nd->sysfs_buf); + nd->sysfs_buf =3D NULL; + list_del(&nd->link); + kfree(nd); + } +} +EXPORT_SYMBOL_GPL(tmc_clean_etr_buf_list); + +/** + * tmc_create_etr_buf_list - create a list to manage the etr_buf_node. + * @drvdata: driver data of the TMC device. + * @num_nodes: number of nodes want to create with the list. + * + * Return 0 upon success and return the error number if fail. + */ +int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes) +{ + struct etr_buf_node *new_node; + struct etr_buf *sysfs_buf; + int i =3D 0, ret =3D 0; + + /* We dont need a list if there is only one node */ + if (num_nodes < 2) + return -EINVAL; + + /* We expect that sysfs_buf in drvdata has already been allocated. */ + if (drvdata->sysfs_buf) { + /* Directly insert the allocated sysfs_buf into the list first */ + new_node =3D kzalloc_obj(*new_node, GFP_KERNEL); + if (!new_node) + return -ENOMEM; + + new_node->sysfs_buf =3D drvdata->sysfs_buf; + new_node->is_free =3D false; + list_add(&new_node->link, &drvdata->etr_buf_list); + i++; + } + + while (i < num_nodes) { + new_node =3D kzalloc_obj(*new_node, GFP_KERNEL); + if (!new_node) { + ret =3D -ENOMEM; + break; + } + + sysfs_buf =3D tmc_alloc_etr_buf(drvdata, drvdata->size, 0, cpu_to_node(0= ), NULL); + if (!sysfs_buf) { + kfree(new_node); + ret =3D -ENOMEM; + break; + } + + /* We dont have a available sysfs_buf in drvdata, setup one */ + if (!drvdata->sysfs_buf) { + drvdata->sysfs_buf =3D sysfs_buf; + new_node->is_free =3D false; + } else + new_node->is_free =3D true; + + new_node->sysfs_buf =3D sysfs_buf; + list_add_tail(&new_node->link, &drvdata->etr_buf_list); + i++; + } + + /* Clean the list if there is an error */ + if (ret) + tmc_clean_etr_buf_list(drvdata); + + return ret; +} +EXPORT_SYMBOL_GPL(tmc_create_etr_buf_list); + int tmc_read_prepare_etr(struct tmc_drvdata *drvdata) { int ret =3D 0; diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracin= g/coresight/coresight-tmc.h index 319a354ede9f..6e994678f926 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -208,6 +208,19 @@ struct tmc_resrv_buf { s64 len; }; =20 +/** + * @sysfs_buf: Allocated sysfs_buf. + * @is_free: Indicates whether the buffer is free to choose. + * @pos: Offset to the start of the buffer. + * @link: list_head of the node. + */ +struct etr_buf_node { + struct etr_buf *sysfs_buf; + bool is_free; + loff_t pos; + struct list_head link; +}; + /** * struct tmc_drvdata - specifics associated to an TMC component * @atclk: optional clock for the core parts of the TMC. @@ -245,6 +258,7 @@ struct tmc_resrv_buf { * (after crash) by default. * @crash_mdata: Reserved memory for storing tmc crash metadata. * Used by ETR/ETF. + * @etr_buf_list: List that is used to manage allocated etr_buf. */ struct tmc_drvdata { struct clk *atclk; @@ -275,6 +289,7 @@ struct tmc_drvdata { struct etr_buf *perf_buf; struct tmc_resrv_buf resrv_buf; struct tmc_resrv_buf crash_mdata; + struct list_head etr_buf_list; }; =20 struct etr_buf_operations { @@ -447,5 +462,7 @@ struct etr_buf *tmc_etr_get_buffer(struct coresight_dev= ice *csdev, enum cs_mode mode, struct coresight_path *path); extern const struct attribute_group coresight_etr_group; +void tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata); +int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes); =20 #endif --=20 2.34.1 From nobody Thu Apr 2 06:31:58 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 BB4743876AB for ; Mon, 23 Mar 2026 09:50:05 +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=1774259407; cv=none; b=Srfe+jtWsYvNJfRNn0FldnbE+kPjm8+HRAbKMKZSTLYAr3BYaJXI5O3Vj+UMQkFnj5K1mEVhvdKNjWEHvOcJDGP2iMAGwHNnszWGL21wmP7bul4PUo87Dok5GacCUQDMEBrrEwF47EOaNbh+ha3HsD0EtenPFqAcCpV3Q5QGv8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259407; c=relaxed/simple; bh=0THtAIFi5jelKh7Fknxn2c5M5CE76ThTcdKm3o+68rg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wj36Zro+3oxj47gxuNi71dG8pO+1iJofheSpWW0QbCb8XUm0vZy8rS/WK+pMohLTMivgxwW/AgvWWjTdWSuKyYPrvLrqJBwoUFZwktEGhPfC+9A1W8zXJyA5Vq+qsMtrLW+CT6iw0tquKPn6LnNpkzPfWV6YOeQziudda86TdaM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=bk0WrT8e; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=VGTNvID3; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="bk0WrT8e"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="VGTNvID3" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7560l199272 for ; Mon, 23 Mar 2026 09:50:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= +1wWjC7fh+aHAvyftVm0FHkxDiI5MU51E2SCcX00kUs=; b=bk0WrT8eGYhDHQ/8 kTp58Qqov/XMKk5Qvbh/+vkZ3MFovJvBlCrkXh/ssLFW79GgxvDhVT3pk55DEPn6 87/pTCPXxC5naCzh+wB+wmFwDZvvW20cZAv/iYk38QTkqrj4knQI7DcD82MPz9Xh UE1Pir65UHTM2AyCaPy64Ag7yftkpSO/jLBjY3wYU7T8lADXS1iUqvuyoTd0n8zo KYlYUQVbehLFaIruIdjYQm391XRKZe5jueXGOvaPvFH/CIwyTsE0K5DnA2d5kzEh RCpYmZztnZcjZnS3TTopX0jMShQU+tYHGTUDG0QHsvTJ9HmSy7yi6ilqLNu1i1N7 1vzN5Q== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d1h1e4xc1-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:50:04 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-35ba237d2e0so3038919a91.2 for ; Mon, 23 Mar 2026 02:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259404; x=1774864204; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+1wWjC7fh+aHAvyftVm0FHkxDiI5MU51E2SCcX00kUs=; b=VGTNvID3+Wt6dm0sFUsx61s+l1OzXRhofzUU/WE0SlMe11onVG3tvQY5Wz6tQ2PxQD tL9RsSlwGeGx6zLXN1nVnkWyUzXXnp0IBpvWMG6TjnodErcIve/SF/N5G9VPDyGCA2R9 XWk8fZDVbgiU1seZxtLdAScY1V2mCoxttWOEsGRMLHL+FV+BF3nHU4xZPGta67SxfEbn VBnDP570yF9lUHJYfNbF4ACqo+OGmal1d2KsxCZjxzqMj8z7v0UQoxhWOKIBS+EZlhtF 4vPcj09OTAIBJC+8NpEzIJj5Lixp3UZGKiJMmrN8IP/5jll5t8euHp7QrJzUBLCFAF74 FTag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259404; x=1774864204; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+1wWjC7fh+aHAvyftVm0FHkxDiI5MU51E2SCcX00kUs=; b=bDrkSO6wpMWFRHM59gjCSecuKUKaGcivVEZXRTkPFMIHn1x6HZMAM9yD/trsj3Kxgz /2SJE72SWoIK+ImRF9GnRCJlcRq05CmkbFkX1Wpnuf1MUNY33/w9+FH6A3zyuYtsfuFT 1hS0kIdgg8n/ZPp+z+MAojlLE3g8e8LI8CLRERLbI1pk3AjGz28pFQWzjmiO8ILPEPmF w7OlWW6FRrR9AEn+s7sYVBaoyNsjFsfn4VXPd0zTl+EXbisdhM2Y+iguF8r2PwWltXgf u4/xe5cUepNzvZTboFnSadamMUHvJQ0CgqbGMWKCAGjh97JMHTWS4P4yUznQvtrT5OBO LMfw== X-Forwarded-Encrypted: i=1; AJvYcCXDcYwuMDXtIeyEzLVNi5+Wr9JiDFkeAnytWN92NheryF8R/Q41ZdJQoJ61pGLwzYIxYREL1wjcgVy3sSk=@vger.kernel.org X-Gm-Message-State: AOJu0YxCm0nFncbYpDAvn7nNz0ZpJiFw1hvz1A3IWcHeI3fIeA8bceRM QqmlOvjTFiFK2HKzE/0D/7uLjfuPXEFCwfQJG8udWIgS1uhBxpDOhFuLj/IutaUbkexrFiveNLO sxQ0JFFEy2dhsJD6xDclPNjtHo9hWY7xA+yhPB6//sj70U0d1Tz4OB525ePFPCe9eDsw= X-Gm-Gg: ATEYQzwB8kSlJGybccuoqGvfgeZFzrqtW0D65zbf/cCUUvBUR1vavI+aJN0JCFhmlmF g+U7AazSPISgcK162O//JXrEXIdgu4YWQqnJ3o8afKDN5sCLQKKhnRsbEEyTfJxYK6zOj5Gsj5Q KKoL7o/cCxL6ygQMGk87+Z0Jr9WF+e3k3eB41ybe7L+HD5FxmKVhLNDUV9JOLn9fmYsXd7OBOuM LnvRuJEozqAjdYiV8Izt4GCVwT3wHLa/GsJHEYhcg6k7t4UpZVFhzef0pa8YzbY0Pe/X+a+RNyK cB1jUTwpqwOrIWm4q3Uiw8EdFuf1vQbwRh74cEoLXoVLUOckg9kJUpjKhQmQHgrWCPp62ZVKhNR M73rpnizhXhV3s5KCECRjWvxIbY5wbvQpZt/S4FZCSm7JqWwZ8uv7evBvZ5jZbwOsWmzova2su6 SibEMVtzof X-Received: by 2002:a05:6a20:7f9f:b0:398:7765:29 with SMTP id adf61e73a8af0-39bceb4772bmr9781610637.34.1774259404262; Mon, 23 Mar 2026 02:50:04 -0700 (PDT) X-Received: by 2002:a05:6a20:7f9f:b0:398:7765:29 with SMTP id adf61e73a8af0-39bceb4772bmr9781586637.34.1774259403738; Mon, 23 Mar 2026 02:50:03 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:50:03 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:28 +0800 Subject: [PATCH v16 3/7] coresight: tmc: introduce tmc_sysfs_ops to wrap sysfs read operations Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-3-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan , Mike Leach X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259384; l=5200; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=0THtAIFi5jelKh7Fknxn2c5M5CE76ThTcdKm3o+68rg=; b=wvKikvtR4w0c8IuBLQ6hNVCfOt4BETo1zTmLsmCQTrdtpNZ9EdNhVWueFq/22fodFb/JLm6r2 a+mh0krKnULB0lmLnSI0Gdnj7S5cJ3qWLCjkDmSIZa5e8x1rjkIgcmT X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Proofpoint-ORIG-GUID: NbpLMsxTKmrlyR-xEGhHo2sUOgn-_HOS X-Authority-Analysis: v=2.4 cv=epXSD4pX c=1 sm=1 tr=0 ts=69c10ccc cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=KKAkSRfTAAAA:8 a=EUspDBNiAAAA:8 a=ia3uihG--C1vaqsH_ucA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfX+5ZSZ2CRuO0q 85kmRCSXpPx+oTH7yCCgyI5BfYv8ExdiTtOy9fcildJQheYv4xJSczxWLS0Nl2NV06p1kQLj4JP SkPrpKJzvtqGjf/nYqlX48zCM8O1ULq3aIbZchTfazdOi9qS6NzyKifa8OeJ5LrPd9DfF+XQN2o CebMXkonT8fw7koIS4DNO+VXCtzBa8nbb83gI3TBDPGq1zEoeXym2uZilj3EBRE1YxoEKaRUca6 ku2een5Qi4K7h7e7gR0nonsPq2jOzbhD1Jij76358FxxsebtvEGx7WrnssziHQkcJKRc2cx0k9r FMWS/dJyszSDaKMEhDjrvQlt7a9Nc+RGSm8T1hnn7hMOu8ahTrnZPs0OCb9WHcZ2Qz/1GH1GXnN IHjHQ272V19koLr8rBFHRHuw4gejK5mKfeyY1QzpWuMk5UfZ7EaFh2qjJR1Nhf/e87cA5WfNvtO VY/ETvZ9ywdpF4NVt2w== X-Proofpoint-GUID: NbpLMsxTKmrlyR-xEGhHo2sUOgn-_HOS 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 spamscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 Introduce tmc_sysfs_ops as a wrapper, wrap sysfs read operations, for reading trace data from the TMC buffer. Reviewed-by: Mike Leach Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-tmc-core.c | 51 ++++++++++----------= ---- drivers/hwtracing/coresight/coresight-tmc.h | 15 +++++++ 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwt= racing/coresight/coresight-tmc-core.c index bac3278ef4dd..110eedde077f 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-core.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -228,17 +228,10 @@ static int tmc_read_prepare(struct tmc_drvdata *drvda= ta) { int ret =3D 0; =20 - switch (drvdata->config_type) { - case TMC_CONFIG_TYPE_ETB: - case TMC_CONFIG_TYPE_ETF: - ret =3D tmc_read_prepare_etb(drvdata); - break; - case TMC_CONFIG_TYPE_ETR: - ret =3D tmc_read_prepare_etr(drvdata); - break; - default: + if (drvdata->sysfs_ops) + ret =3D drvdata->sysfs_ops->read_prepare(drvdata); + else ret =3D -EINVAL; - } =20 if (!ret) dev_dbg(&drvdata->csdev->dev, "TMC read start\n"); @@ -250,17 +243,10 @@ static int tmc_read_unprepare(struct tmc_drvdata *drv= data) { int ret =3D 0; =20 - switch (drvdata->config_type) { - case TMC_CONFIG_TYPE_ETB: - case TMC_CONFIG_TYPE_ETF: - ret =3D tmc_read_unprepare_etb(drvdata); - break; - case TMC_CONFIG_TYPE_ETR: - ret =3D tmc_read_unprepare_etr(drvdata); - break; - default: + if (drvdata->sysfs_ops) + ret =3D drvdata->sysfs_ops->read_unprepare(drvdata); + else ret =3D -EINVAL; - } =20 if (!ret) dev_dbg(&drvdata->csdev->dev, "TMC read end\n"); @@ -287,15 +273,7 @@ static int tmc_open(struct inode *inode, struct file *= file) static ssize_t tmc_get_sysfs_trace(struct tmc_drvdata *drvdata, loff_t pos= , size_t len, char **bufpp) { - switch (drvdata->config_type) { - case TMC_CONFIG_TYPE_ETB: - case TMC_CONFIG_TYPE_ETF: - return tmc_etb_get_sysfs_trace(drvdata, pos, len, bufpp); - case TMC_CONFIG_TYPE_ETR: - return tmc_etr_get_sysfs_trace(drvdata, pos, len, bufpp); - } - - return -EINVAL; + return drvdata->sysfs_ops->get_trace_data(drvdata, pos, len, bufpp); } =20 static ssize_t tmc_read(struct file *file, char __user *data, size_t len, @@ -764,6 +742,18 @@ static void register_crash_dev_interface(struct tmc_dr= vdata *drvdata, "Valid crash tracedata found\n"); } =20 +static const struct tmc_sysfs_ops etb_sysfs_ops =3D { + .read_prepare =3D tmc_read_prepare_etb, + .read_unprepare =3D tmc_read_unprepare_etb, + .get_trace_data =3D tmc_etb_get_sysfs_trace, +}; + +static const struct tmc_sysfs_ops etr_sysfs_ops =3D { + .read_prepare =3D tmc_read_prepare_etr, + .read_unprepare =3D tmc_read_unprepare_etr, + .get_trace_data =3D tmc_etr_get_sysfs_trace, +}; + static int __tmc_probe(struct device *dev, struct resource *res) { int ret =3D 0; @@ -823,6 +813,7 @@ static int __tmc_probe(struct device *dev, struct resou= rce *res) desc.subtype.sink_subtype =3D CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; desc.ops =3D &tmc_etb_cs_ops; dev_list =3D "tmc_etb"; + drvdata->sysfs_ops =3D &etb_sysfs_ops; break; case TMC_CONFIG_TYPE_ETR: desc.groups =3D coresight_etr_groups; @@ -835,6 +826,7 @@ static int __tmc_probe(struct device *dev, struct resou= rce *res) idr_init(&drvdata->idr); mutex_init(&drvdata->idr_mutex); dev_list =3D "tmc_etr"; + drvdata->sysfs_ops =3D &etr_sysfs_ops; INIT_LIST_HEAD(&drvdata->etr_buf_list); break; case TMC_CONFIG_TYPE_ETF: @@ -844,6 +836,7 @@ static int __tmc_probe(struct device *dev, struct resou= rce *res) desc.subtype.link_subtype =3D CORESIGHT_DEV_SUBTYPE_LINK_FIFO; desc.ops =3D &tmc_etf_cs_ops; dev_list =3D "tmc_etf"; + drvdata->sysfs_ops =3D &etb_sysfs_ops; break; default: pr_err("%s: Unsupported TMC config\n", desc.name); diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracin= g/coresight/coresight-tmc.h index 6e994678f926..a14645b04624 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -259,6 +259,7 @@ struct etr_buf_node { * @crash_mdata: Reserved memory for storing tmc crash metadata. * Used by ETR/ETF. * @etr_buf_list: List that is used to manage allocated etr_buf. + * @sysfs_ops: Read operations for the sysfs mode. */ struct tmc_drvdata { struct clk *atclk; @@ -290,6 +291,20 @@ struct tmc_drvdata { struct tmc_resrv_buf resrv_buf; struct tmc_resrv_buf crash_mdata; struct list_head etr_buf_list; + const struct tmc_sysfs_ops *sysfs_ops; +}; + +/** + * struct tmc_sysfs_ops - read operations for TMC and its helper devices + * @read_prepare: prepare operation. + * @read_unprepare: unprepare operation. + * @get_trace_data: read operation. + */ +struct tmc_sysfs_ops { + int (*read_prepare)(struct tmc_drvdata *drvdata); + int (*read_unprepare)(struct tmc_drvdata *drvdata); + ssize_t (*get_trace_data)(struct tmc_drvdata *drvdata, loff_t pos, + size_t len, char **bufpp); }; =20 struct etr_buf_operations { --=20 2.34.1 From nobody Thu Apr 2 06:31:58 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 7D50E3876B7 for ; Mon, 23 Mar 2026 09:50:10 +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=1774259411; cv=none; b=fXcgpyNm+DAbfQxWUbFfmN+zichXo+Icbsi2i+i0UL8mgM+SCvANe26ZJXfR397FedK1XPSqyvxfQ0Woi/dxk6WRe+NzZESgM/BC/BNqbvQxmLO1ltGWYixVd8vZo7mC9zFPExSrt7nMBwoGHJzFQOC/xukXAIZaLUkoKDMTVTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259411; c=relaxed/simple; bh=QjBBWW3nZNJQ7dW86dG4Ar+IGXRSYDsLrfUfjlg4xNQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tisiU3pSBLdkPaXiwmnmfD0v2xVs0AhqzVzRrBYXFD8uBjlOH5pdTBsIj8Sv+wjRBs0hibOj43hglzsbezc9g+hreyy/pKbVJN9hxzXktY1K+En9cl4SYZUBCIkqliM3BkFUFJUn9NIzSyVCHrRkfJY+spXP43lvK1F3/ZoyZVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=OM7em+d9; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Z1EnM2Sa; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="OM7em+d9"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Z1EnM2Sa" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7trrj3468141 for ; Mon, 23 Mar 2026 09:50:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= XNFnCKRlYseUEtoxCTko5eEC5pQQo7W92i+zQLuCE1k=; b=OM7em+d9dFVzcj10 BE9dEBV/Ch9Z7m5LogiYs8z2jp+aiRvhNsVZhNDeoU0GolWGLQcXeZ12dQJW8hPr WJE0BWMXv/72GzSyFsVRZpfkAE6y7A0ed7F1Dw++MwUCm6fuIosfuc88Bskztva4 gFMlzKvfYndbVfYJI2tEkaIZ9QRjwP4cUe3Oh69r1NUclcUwVREwaAlAYFarLYpA Dbbmw3s/+1N4D1n4OcU2o2czOWY4iHJvKsTZVZ/RPuZ3SOKl99Ureo5UMDCwuZX7 b+LMbwi1J1cbJEuv7q/lAz+Ml089Ph4P8G9ajUlgB4uG9GiBjWJNc4lRXrVuTTqA RDzNtQ== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d31jggdst-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:50:09 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-35be4ea8292so1512837a91.1 for ; Mon, 23 Mar 2026 02:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259409; x=1774864209; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XNFnCKRlYseUEtoxCTko5eEC5pQQo7W92i+zQLuCE1k=; b=Z1EnM2SanCMsKWPIoXhtMeS0KJwZGcqLpMXWhQiqQOCVBHSgYDQUooC9YqXDKovrFj v8ULa6U6wKqNHFwRc+U8wdzRYYdqrvd5VG3cEsjny7Dxo7UjbJWxRw3Kd4Sn68R5ewng 4IxEYbIuc9M5Jh82zE5ITx0ab4Se1+Z/yVwhhtDakyMtM9gIEUcLacdxin2OPdqa3Y9K Vu0WeQrU7z5DpXjBTWN7gas8D/ZTSwQhxic7KtQabqVDCVGTROD8wltFSZGpV4ckMkQs 9gl8C7cBh7YHphKhXFMtBuhKfrLhILH8fecf3ux4zeCWsUurmcZMS3xBUn2GdW+ScKiS dYMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259409; x=1774864209; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=XNFnCKRlYseUEtoxCTko5eEC5pQQo7W92i+zQLuCE1k=; b=eoOfKrufS9laRUACuaG5+nADwBF/vZ4hvB67BoQUm7qbYaXWgVClztGKwA35Hkc3XS 7lE2BFNGTgXlC3OKWtV+Sev/UNZZ7GCYpxmJfPKmqT/pazd3Lj+2/le9CEgRXa80wi1k UGOWLuTcrcZGI3VZiEy3ELEKHqC8a6paQVrKV1PyEZsBgkwvNXvbTNDQN4OuCutpHJuI KDVjQnlS/RJj3RG8y3zCyKUE6irf4wwZ2wp09JrGY3mZLsaM/N0euPY7IgvG+PDOgrPp FuH0lMGem8DIS0kbiMW+1KJm/5sc3JriduFa8D10Hhd6T4mitWh8cNRZZNrvfP1GyeKO VRYw== X-Forwarded-Encrypted: i=1; AJvYcCX9RF6ye1UcuuHp/es4vUbSV5EUkKpGkQZfsM+1WBs/Ufl69TAQjqZ2obd3Dlfw/JeFQyF/lcWJVkZjSi0=@vger.kernel.org X-Gm-Message-State: AOJu0YxgMGHYLqckGMy/DU2qXNBXhZR4SFgA5C6MCoSoyKHgOcSJORoa Z0G8ak73wCp+HjbTMuArNomjI6MZNZnollhOo6E2DDRyC4jiMClSTfWMpcdk5ehFJCAdsvyuLj4 em+GY2wjJCeic62m/k0JIzTKX1Lh8Jv9iReN8M2Lok8UjgreI+KhRCbSgcvl/aXvHe8o= X-Gm-Gg: ATEYQzw/GOMnGi+0gNSRBQF7SEH6jQOV/LrZYLudkX73t7YcvoIV/41KZhFOJpgti/K D2hseP0l1j78fndIvvparmGP2UN5+ro4UNCGOlCPHtZtNd0cfJ0uTbdq+hnPNAnkSbZpI/h2JTE wJQWtOKfAEJJUQ3YQtaW3t5UF+1nYZAAv1ZGzo38QuushKb2AEEq5I7IhWqWr5+rWg9cMNMoBod PK4Ay8eFOUhuRzvMoqTb3ZLLwxrcU9hT4ywuDR9S1SzOIQAvjFj6PCtPfS2ysuF1BFpgFRvyPTg xYo3oX2WKz3wufiPI3/IWFFYPAZC0c/K9WE5D0wZL3W07Xm8Z9Sgfcr2b/+Q4y2KucXVEWNBBnZ VEtuOOa3XUWBkACz5/1Y2qFCGywDvgcMQhi2lUnwbEk8ilBhJ1lpzNBKfFDPZTOBl1IKPLuVD8H P6UX7B6rcH X-Received: by 2002:a17:90b:510b:b0:35a:1b43:dff1 with SMTP id 98e67ed59e1d1-35bd2bf7926mr9813876a91.12.1774259409074; Mon, 23 Mar 2026 02:50:09 -0700 (PDT) X-Received: by 2002:a17:90b:510b:b0:35a:1b43:dff1 with SMTP id 98e67ed59e1d1-35bd2bf7926mr9813857a91.12.1774259408597; Mon, 23 Mar 2026 02:50:08 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:50:08 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:29 +0800 Subject: [PATCH v16 4/7] coresight: etr: add a new function to retrieve the CTCU device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-4-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259384; l=2348; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=QjBBWW3nZNJQ7dW86dG4Ar+IGXRSYDsLrfUfjlg4xNQ=; b=/ND2nS44mbInVi4eNYBq/svnHomprXsHoRCmcKSXJZJjvVzmC7pJzBR0bMBaeQMxxQlzQqux1 UeemwW4IB24AXbcIycNxDxrs8HgNvFJRGYIm+DAEvI3VmliTw9r+tCV X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Proofpoint-GUID: SUKu5WSvir3ZgMpAh-NQ-_RbtNFmm1Vi X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfX55tmSw2RfLsZ frAg5Wu2f6e/mNzEbGZr16AfiiuMeZR+b5r9mrsZzsJDdyXNpcUPwjcJuP0pNYdApNb0I2Fp1gc XjIjyk3tW+m0DK64cTM1K3fnDI3dkKx+m7nGw7dLJgp7D/EnhW7dvpwIZ939277wVlKpqi8WTmD bh4up7x4xGkRT14w8QOkN2QfhkRF3Q7ZofvZL2ClQ4iO8981Z1wGFZ2r4VKMqFCp0XzopDPydvd 2QDhaDIq5h2lnLBPTv+RGqzuudc9ZhalL2s93f7ThqzBPEq6de4cbvH7Ij2V+Stzjb1arXj6lob UGZWnkF52e8I0VDRvvbLABnVerz+OnoZX55nkVeg5uAD/zmwQUiq3gLfCwSSRu7d6yVQ3Ra1/gl z+oM9428T6dGiF0zn8H5pk9XH2Y6ohYEDIY2FCiQFYoRDpxwJ5ZfEaOWlN+xamYVh/x9WMKC+Nk 7UHHaQNoChlQ4Hj5MZw== X-Authority-Analysis: v=2.4 cv=CMInnBrD c=1 sm=1 tr=0 ts=69c10cd1 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=FuIWbRVyn4pKkvqW11oA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-ORIG-GUID: SUKu5WSvir3ZgMpAh-NQ-_RbtNFmm1Vi 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 phishscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 Add tmc_etr_get_ctcu_device function to find the ptr of the coresight_device of the CTCU device if the CTCU device is connected to the TMC ETR device. Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-tmc-etr.c | 24 +++++++++++++++++++++= +++ drivers/hwtracing/coresight/coresight-tmc.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index 306982e88dbb..d4a99c77dd90 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -865,6 +865,30 @@ tmc_etr_get_catu_device(struct tmc_drvdata *drvdata) } EXPORT_SYMBOL_GPL(tmc_etr_get_catu_device); =20 +/* + * TMC ETR could be connected to a CTCU device, which can provide ATID fil= ter + * and byte-cntr service. This is represented by the output port of the TMC + * (ETR) connected to the input port of the CTCU. + * + * Returns : coresight_device ptr for the CTCU device if a CTCU is found. + * : NULL otherwise. + */ +struct coresight_device * +tmc_etr_get_ctcu_device(struct tmc_drvdata *drvdata) +{ + struct coresight_device *etr =3D drvdata->csdev; + union coresight_dev_subtype ctcu_subtype =3D { + .helper_subtype =3D CORESIGHT_DEV_SUBTYPE_HELPER_CTCU + }; + + if (!IS_ENABLED(CONFIG_CORESIGHT_CTCU)) + return NULL; + + return coresight_find_output_type(etr->pdata, CORESIGHT_DEV_TYPE_HELPER, + ctcu_subtype); +} +EXPORT_SYMBOL_GPL(tmc_etr_get_ctcu_device); + static const struct etr_buf_operations *etr_buf_ops[] =3D { [ETR_MODE_FLAT] =3D &etr_flat_buf_ops, [ETR_MODE_ETR_SG] =3D &etr_sg_buf_ops, diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracin= g/coresight/coresight-tmc.h index a14645b04624..fbb015079872 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -470,6 +470,7 @@ static inline uint32_t find_crash_tracedata_crc(struct = tmc_drvdata *drvdata, } =20 struct coresight_device *tmc_etr_get_catu_device(struct tmc_drvdata *drvda= ta); +struct coresight_device *tmc_etr_get_ctcu_device(struct tmc_drvdata *drvda= ta); =20 void tmc_etr_set_catu_ops(const struct etr_buf_operations *catu); void tmc_etr_remove_catu_ops(void); --=20 2.34.1 From nobody Thu Apr 2 06:31:58 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 05D063876C4 for ; Mon, 23 Mar 2026 09:50:15 +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=1774259417; cv=none; b=Jie7p7X3mE8VNkjDa83U+CzK/3FKYlnIXW7exHkTiix+NFOOJjzTO01Dt8iIBfm2hfkd/WeSodqOOhPWhqIx7bLwzLpBDc/Eyi/HKWGYEOWhw0CzrIBmsYYMXxaKqGF+ruzMa9n1zBUcRlcd9pG7t48ReU++YGZetdrHUpdgteY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259417; c=relaxed/simple; bh=DsL6kcYT3hY1q2jvZSOp/rxfO6RBNAUHqHA9yEMzJAk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HG+xCod0csbW8XlSMaM/8G4DXOHvxG15rcFrpz2FM5UAZ97NQ+Zf7ibmBMu6lKxeBwD/ZS2VRDCrrrDKgtAFTa+M1FNtoxWoK5WYG8Fy/HpKMCZdw7t4lUw1UkOf9nc7a/TQYCQXqpDgRX0uYwQe0uRLlKGMlDRIlvpRNESYn8Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=RGk1ATWi; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RpVeCYuz; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="RGk1ATWi"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RpVeCYuz" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7tMFa2291969 for ; Mon, 23 Mar 2026 09:50:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 5AiUjeizRXgIt0pWaEk9wGXXVAIJo5RCeKWJBfIhvcE=; b=RGk1ATWijn46n4dV /PPjXcUanGIl+j9qtviAsZLIdftayoF+99Mdx43vPdb87MJrSUYcEX2CfRPJi+wn lQXZYd/0EXGyy/NuKJPL1Lj/c3q1nVy6HLApo6D88QGmw0OBH3dyTEjAGH/yD9Fx QlT3bkC+IRgfFC92aQul4OUBaJGMr7C0pQT9tWI652l4R2AUh0Z+P83Mck3HJ6US +M8p3UNkUbiW9UnsvePoDNwAcaV33RoAwnvXLtfUM9xSNvzJedCqlbyoknSbLKRL 8RTynxj/9swi+fOKEyHj5LcG0bdY0fqr53TcphtaUO9QKETT2MlCBcivqJJqRfWO FWE8Xw== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d31j70d26-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:50:15 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-354c44bf176so3337572a91.0 for ; Mon, 23 Mar 2026 02:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259414; x=1774864214; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=5AiUjeizRXgIt0pWaEk9wGXXVAIJo5RCeKWJBfIhvcE=; b=RpVeCYuzx4jPHAUpmtCHxkpPA/D0uH8kvboBmhCLelcQgT1LmM9olGDbb+lsNWS8/s 6QXg7fR/vQod8sAGHCeSEAPCy/ErHUGPVn+1x7Z+UTyNi9wK8PDZ114JMawDT2YmJLUa SHOAnGP7BNsdNPKqBLZ6tBHPPYLt4dxL8NrERKW/scOSgMOPVdQFrN///oDGakRm9c8u EHeeLdc+6ypdXqBINZL1L8JTP+00G6VHdpvAzIA5kX8l3bZweO/KqjrTyAewBXRtjqCe z1g5Y7sGaoKnc2CQLmHbV2uZ3BmEwI74lklqCvYMWB+mNCzzHJt/YJ/PgyoVugFv/vq8 yjdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259414; x=1774864214; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=5AiUjeizRXgIt0pWaEk9wGXXVAIJo5RCeKWJBfIhvcE=; b=FNjqMA0QavJdutDYzvCP/FLgnllFIjN2WYxmRgtbGSiwj3znTboWaMYaZOkWGlQqB4 6UwYLhqbY5U3B4NzURI3+ncNEpPOmA2SdMfpbACtNsaTPdtlcnrC6vpR7kjdJltUKvhf B12YLi0wLSq4+IndmvoB98wh07fJkZCBe81fm5d1OZ7yGZ+wBv3MTNjMz9mluJoVI19a 4ZLG0rC/DqQkbCl11ta8JcmoEut7oc7uf7hXhYkoICletkoW9n0jLVq/qAnQBPOKaD7S vU+R2mVtFxR6RvPjKR8OMW0xvUpzMYcGFoVIalDXOk1wo0/cB/a3O/LEWI941Po4SINg sHJA== X-Forwarded-Encrypted: i=1; AJvYcCWLBBuDCSdtJAEGz3+JEFcAVlwhoPhL/vGn9iGogh1fWbF0Oito/T4jXz9ZXe8MqrGcxS996vE6lZ5P/IE=@vger.kernel.org X-Gm-Message-State: AOJu0YxGVjOgqISLR662obffb3b5/QRhQLJIxBw5rVaCrMKZBj9kLvgD ACQxE0BaTr/+iocgZKknvoPLNCki1yw7MBUUGaTBRFCwk0KojC55mlEJIwOLN15Zzx+JNk4bPAw lZgvw3dSyKJHjME0jtes7eh6AslQ5jbYtxw65MyklXbywriDhgHNZJ9rduneEdS5ZAsA= X-Gm-Gg: ATEYQzxFYmX3DhJKAG5H7GboZN4e8y6Zqqm8jTZvVXWIBorhWzQoh17WF1ytz8fdjDt QNleEtJwKK4ezB6HqdJ4oGO/UVknmHfFVbdO7Fe69YEIt/5zUpRcMwW1QL7sZ+oLiBzOTWPfuit F5VNiJfrSUUEmywiasdFx44hTm+NVYJ2fzW2CE/JW7y05BPHZuo0B3IVdRO80hI9QNMioDR4GeK PIfiKH1+CcQc3NgbO3+MVj7pRTua2kvd294K0si7fWaV8gRvz/jJA2lOs6h2NZ9v7OZGVxjZh7o DS0e+rgR0c8odeUivkrzNAAhCH1g+h+RwRXfhPXvxVEfD3fKr++OmoXk5eJ7oKMjKWAdT10GzYX 2eoG12w+qFb9DKnyMUcFgdYICY16nAbhUgnDniutmD/u8ZRT1dI0XNUqWeR87iINXv5E3e4LAN+ SkvvzwlCHY X-Received: by 2002:a17:90b:35c3:b0:35b:9c97:3d18 with SMTP id 98e67ed59e1d1-35bd2be82e6mr9172199a91.12.1774259414369; Mon, 23 Mar 2026 02:50:14 -0700 (PDT) X-Received: by 2002:a17:90b:35c3:b0:35b:9c97:3d18 with SMTP id 98e67ed59e1d1-35bd2be82e6mr9172173a91.12.1774259413891; Mon, 23 Mar 2026 02:50:13 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:50:13 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:30 +0800 Subject: [PATCH v16 5/7] dt-bindings: arm: add an interrupt property for Coresight CTCU Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-5-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan , Krzysztof Kozlowski , Mike Leach X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259384; l=1751; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=DsL6kcYT3hY1q2jvZSOp/rxfO6RBNAUHqHA9yEMzJAk=; b=QEOSRZFfoBp0jud88kuJhTiDDDkzmK/bBgbOz82nCMck9HgEPLrVRoJ18aRIKgPGe2aUeK3vm mjSYkANIMw7DhV+ZtEsVnee9wwsAtCeKdfPHe8nFQfIwEfwpDdh67OI X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Authority-Analysis: v=2.4 cv=ArXjHe9P c=1 sm=1 tr=0 ts=69c10cd7 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=KKAkSRfTAAAA:8 a=EUspDBNiAAAA:8 a=gSyxy6DGYGa4b6s9XCEA:9 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-ORIG-GUID: IBB7DJZgwOd7MTgChJojl6YNxivCb6b5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfXwXpmEn73raEq OHwz84q2tl+MlKapn/IJl88g3dvu8XvTjai+ZT2lez9/K2plGaH+KpUFN8xJnpimEnc76ndgYEg 9kXhMkA9k2guhXFQNruSVbxAo/rqxlNx7Q+JB81l5xAUHslCtx0+IDy4SRpDi61CO9s6/fc7Vv/ t0hw+uJOa6VSPGGksVCgEEZDueTvbj+BIcvOA9qtOwIt/A6/+Adu5GxdX7wcsBpp2aiGUpzSf6y EcjR0DViSPz04xyJGkCg0nWO9ulLwtF+it6Z9bC5ahJV+UHz8vEiGUsTBKbRTDvYv4RqIliPKib /rUA2wSr+WLbZdRJ8+eFO7bZnmLadB/VTVr1CLaWLVslXvuvIQwnavi4+xnnM46ju+LiRkk5+Bm uZmw6J8j17cfzaWAMeDTEDI2hQn7ddH4kUjxsg82YnV+WmQ79uGfiv47xFMPbE/1oGEgMxhU5WD jgbdP2pdBkoHUpKox/Q== X-Proofpoint-GUID: IBB7DJZgwOd7MTgChJojl6YNxivCb6b5 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 Add an interrupt property to CTCU device. The interrupt will be triggered when the data size in the ETR buffer exceeds the threshold of the BYTECNTRVAL register. Programming a threshold in the BYTECNTRVAL register of CTCU device will enable the interrupt. Acked-by: Krzysztof Kozlowski Reviewed-by: Mike Leach Signed-off-by: Jie Gan --- Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml | 10 ++++++= ++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml= b/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml index e002f87361ad..2981001a7d7f 100644 --- a/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml +++ b/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml @@ -44,6 +44,11 @@ properties: items: - const: apb =20 + interrupts: + items: + - description: Interrupt for the ETR device connected to in-port0. + - description: Interrupt for the ETR device connected to in-port1. + label: description: Description of a coresight device. @@ -65,6 +70,8 @@ additionalProperties: false =20 examples: - | + #include + ctcu@1001000 { compatible =3D "qcom,sa8775p-ctcu"; reg =3D <0x1001000 0x1000>; @@ -72,6 +79,9 @@ examples: clocks =3D <&aoss_qmp>; clock-names =3D "apb"; =20 + interrupts =3D , + ; + in-ports { #address-cells =3D <1>; #size-cells =3D <0>; --=20 2.34.1 From nobody Thu Apr 2 06:31:59 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 CE90D3876B8 for ; Mon, 23 Mar 2026 09:50:21 +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=1774259425; cv=none; b=K+RbMGhh9ET740TZoicNABegmGNoLQoukWZWeFs5usNPswoOpCVMFCU/1voboagp3uDzp2nUKeyDkfmmEiOWWM6+4NjTOlIAuRzEnAAmNO86DEzNCG410DrqEFnNNPpmA3u1KYdbZ7qWY2CXLI5Zk3Fe6i23k46ejTy5RdEMRAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259425; c=relaxed/simple; bh=97xtlmAyciUIO+o5gGzxUuH3GqS+Adj0culUAy5SXTg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cyd57zKvVeD8OBqdssi2nJY3gjjSDXGCgv/bZMegmxde1bYVTxl0CLgRz0toIw6c4OeHwDUUE6GqmILl/Q/ymXt3YZ9VKSewS9evxdWCYMg3KMLMnE1h+L7gJlvTpQ2FLDj0MpuImCdJJuD+/ydGgjYHyQBHuqRo3BvLxd2M48Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=B7RrgLtp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KdjnFPD/; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="B7RrgLtp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KdjnFPD/" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7tC4Y2291198 for ; Mon, 23 Mar 2026 09:50:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ooMDE0MSw4v3f3lHr2nkChYE4mhaevB7FL7QtnRSlMY=; b=B7RrgLtpAaPd4zc3 5uvsiHj9kTycKRiQgylN89YRP+NpN6EeQ8caYv7wA5rE9lJ/5Ehn+nvq0q/H9GEq W4Co6tFqBMIc3EwiiMo4cXOfXJNDV/YFKVg8gPodN35GZVCy00fISOGzfbCemk1c A+HKSezpQGbCuUzMZk769VdtKbF1qv5JlmAPRDdVm6jegZeZELMz1jW8kbx8Wqjy upakyIhjp4pu0+a8/Sw+Q7TTgE0XFC3d4qeM7xjxOnCd5qY0Bpsk7cSXavbNBXLZ fUOK855euWbwn5ekEQluXFouEkAMdtHv7Zzn790Mnj/7+LwcEDU3x0Or8LKaqvqY m/chUw== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d31j70d2n-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:50:20 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2aecfe69196so53082235ad.1 for ; Mon, 23 Mar 2026 02:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259420; x=1774864220; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ooMDE0MSw4v3f3lHr2nkChYE4mhaevB7FL7QtnRSlMY=; b=KdjnFPD/qcKFetZWeFliBw+V2Yq7VfIHcTnkivpZ1BlEbvFQnH+7nkS1ugw20x50HS s/9YLP7YGguLBXMOyIC9x+Wtlt+tM8JJJ9J5WhvEPBvqM8Ht9oDvVn70KBmU7cGOyToj Z+bqUCJHpZ3t26qHIxvAw99FD1rd/kvuEK7l4BHSHiRMdjBri9f5U0cJjg2wlDoUy34t jijRN7VGEodT1IidunDWVa2V0wIdDvuA+7F5bw49Ogm4EIM3VHWYCVsFv6L65DS1zsgL HitmPIdJHDi4XjMpiaeehgHCAppiKM9qcrgyyNdRKqUxdrv3bOAfx5g1B5c5mIRG/aVl fB1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259420; x=1774864220; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ooMDE0MSw4v3f3lHr2nkChYE4mhaevB7FL7QtnRSlMY=; b=PcDdNmILw8jpPed8Y6swjQQWMo3y7CwjJ24igaCHTOTkNgXAbAMzi4HrgNzYaqW28F qAKkJPZUjUslYe2FNNvJT7Ebd8N8J1YG4mWa44v0WhUYKBX7/UH2bKw6cFnDz6MW0OKI /FEQWEaplTORARcAB9JMbetlX69LtXUhMbfg0ElMPXZeP5+yGq2vPTBReAzSU803HtO4 QkpE+ndwTYOk88ndlyNUXeKi3dDIziZL6Sa0tlSfH187vOIbKITsoOAbm5SdXf/L0+T2 yNbZBX+Skw5yyK7rAOPwJGUlFwZRDbmq4ltP3zejQ2MX758EkSX/OftT7p9cz7rbkKS+ Z5Kw== X-Forwarded-Encrypted: i=1; AJvYcCVuHAvfGlOSqb62ktVLleKU4MpNFsmMavKf/lHAnrHAqlt5j4Q8sVq2pRV65zHkoxoevaBo5kfDYMJCKiU=@vger.kernel.org X-Gm-Message-State: AOJu0YzAGAO8Gl8ueFI7KMF8iPsTtIYXMxjShRkWgF8ysEcRELFs4u26 TJ3MevirxzS70LqlnomeaMs62DxmFImXi5CyRT7bE3EAULmywAQMGSqP6BKv32qOdRWu6NaQDrV dHMbsF4rkXNm6eXwRlkO/nH6rOzfJjFQaNOUOl026xcARSuv3Zg9abkmwKdB5wu4rd8g= X-Gm-Gg: ATEYQzz2BtnGDUAKSmJ9Z6H47FWda5aVAQwp/HDU3aELkTPU34Bh4A/M0m4j/O6Zhsc KWR6WDQPnm6MGEaZ012MYofCIKHnRy/PuchiFsWkcM5/XGOaV1Z4ekG5N5WsL86dNiMkZ0dcxPv Tceq3gZxvM6zcDepup0kjrZSTaR8BZiQSkQkLqqVIreACVxeyTteKJdHRzfB3K8I6C+n/t/vzBk iMS4UTQWOhsGQuY3CUsFAsI+1LnpFedQdcAkfOz23AxVoSE8yJJNzBRF2WybFojg7njc/CmHFxO f77N9fAxM4DK+gvrh/VrPnKssLzB8uOX6fv9WNUb0jvez2GDVh8cattxbOm7uJmQz4o0QQxbNRd TKFAPQDhVMTDpEzk3dTZa3PX03Ces1PjDfK9KXq/1C2lOEvs97oiZpKcIDgiE6Etwot7yW32Se/ aPDyERgd/t X-Received: by 2002:a05:6a20:958e:b0:398:962e:83d7 with SMTP id adf61e73a8af0-39bceb41a77mr10141403637.43.1774259419602; Mon, 23 Mar 2026 02:50:19 -0700 (PDT) X-Received: by 2002:a05:6a20:958e:b0:398:962e:83d7 with SMTP id adf61e73a8af0-39bceb41a77mr10141364637.43.1774259418957; Mon, 23 Mar 2026 02:50:18 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:50:18 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:31 +0800 Subject: [PATCH v16 6/7] coresight: ctcu: enable byte-cntr for TMC ETR devices Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-6-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259384; l=28288; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=97xtlmAyciUIO+o5gGzxUuH3GqS+Adj0culUAy5SXTg=; b=H7N0kXtUc1uxp2l06qKtER4tk3EOFUeTXWI430ArfuuwzdzPhBgn1/KIa5YdGw/X0NT95b1C8 xDPylGpbnJeAukHd73Z0jstsyEERUOL2/42a6kI21n/qZxc8OIOhjPU X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Authority-Analysis: v=2.4 cv=ArXjHe9P c=1 sm=1 tr=0 ts=69c10cdc cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=6MhHx5wqrWBboxSnaDoA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-ORIG-GUID: YiXyj-MRd8U5htw_zRicD-oh1HKi_nmv X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfX5BWlCftYchFB jj0jCYzA7b7ORLd0lLMMdFCHqaUgoK6dPNt5PwxzTcQuTGtsPKclVjwEg5oALRzUJaOdXwmdcpW CVEzzZC9t6fFjz/HTbUZDuqUAcJy3SH8RkUsVMiSWCso93iwmrmPuSmbrQGozANCQHjD3BPgze5 E+i16LQlg6KqCWsEv1NclUGWNBC42hgpn//9ItXVEBmwhIji7H8ylY3TpPMwVvtWLlGnR5qs9z7 P+xdjOSuYHWZiOBjZZE994/zDlJ5Zgg0zSMF4tqelxwJ3j4KJ7lX5Z8ShI/eRsEOJxeoJKxy6xM LRLojPj0reQVu4IwTB1yTNkoIf6xJh0K9fhZwlhuOfeSpFWuwlU2Thz2EH8VBbuRB16LzMJgo2k Oqw+bAPzG9MPDsnSkF45n2VCX5w7t1G3tL0UOSf8UEZoVYgDVV0GwxHtJIOgxl2hOvwLwOd8qSf m/eTB6ITwLZbdf7EwZA== X-Proofpoint-GUID: YiXyj-MRd8U5htw_zRicD-oh1HKi_nmv 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 adultscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 The byte-cntr function provided by the CTCU device is used to transfer data from the ETR buffer to the userspace. An interrupt is triggered if the data size exceeds the threshold set in the BYTECNTRVAL register. The interrupt handler counts the number of triggered interruptions and the read function will read the data from the synced ETR buffer. Switching the sysfs_buf when current buffer is full or the timeout is triggered and resets rrp and rwp registers after switched the buffer. The synced buffer will become available for reading after the switch. Byte-cntr workflow: start -> ctcu_enable(ctcu_byte_cntr_start) -> tmc_enable_etr_sink -> tmc_read_prepare_etr(jump to tmc_read_prepare_byte_cntr) -> tmc_etr_get_sysfs_trace(jump to tmc_byte_cntr_get_data) -> tmc_disable_etr_sink -> ctcu_disable(ctcu_byte_cntr_stop) -> tmc_read_unprepare_etr(jump to tmc_read_unprepare_byte_cntr) -> finish Signed-off-by: Jie Gan --- .../ABI/testing/sysfs-bus-coresight-devices-ctcu | 9 + drivers/hwtracing/coresight/Makefile | 2 +- .../hwtracing/coresight/coresight-ctcu-byte-cntr.c | 286 +++++++++++++++++= ++++ drivers/hwtracing/coresight/coresight-ctcu-core.c | 104 +++++++- drivers/hwtracing/coresight/coresight-ctcu.h | 79 +++++- drivers/hwtracing/coresight/coresight-tmc-core.c | 3 +- drivers/hwtracing/coresight/coresight-tmc-etr.c | 104 +++++++- drivers/hwtracing/coresight/coresight-tmc.h | 9 + 8 files changed, 571 insertions(+), 25 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-coresight-devices-ctcu b/D= ocumentation/ABI/testing/sysfs-bus-coresight-devices-ctcu new file mode 100644 index 000000000000..f17a6c0382c8 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-coresight-devices-ctcu @@ -0,0 +1,9 @@ +What: /sys/bus/coresight/devices//irq_enabled[0:1] +Date: March 2026 +KernelVersion: 7.1 +Contact: Tingwei Zhang ; Jinlong Ma= o ; Jie Gan +Description: + (RW) Configure the flag to enable interrupt to count data during CTCU en= ablement. + An interrupt is generated when the data size exceeds the value set in th= e IRQ register. + 0 : disable + 1 : enable diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/cores= ight/Makefile index ab16d06783a5..821a1b06b20c 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -55,5 +55,5 @@ coresight-cti-y :=3D coresight-cti-core.o coresight-cti-p= latform.o \ obj-$(CONFIG_ULTRASOC_SMB) +=3D ultrasoc-smb.o obj-$(CONFIG_CORESIGHT_DUMMY) +=3D coresight-dummy.o obj-$(CONFIG_CORESIGHT_CTCU) +=3D coresight-ctcu.o -coresight-ctcu-y :=3D coresight-ctcu-core.o +coresight-ctcu-y :=3D coresight-ctcu-core.o coresight-ctcu-byte-cntr.o obj-$(CONFIG_CORESIGHT_KUNIT_TESTS) +=3D coresight-kunit-tests.o diff --git a/drivers/hwtracing/coresight/coresight-ctcu-byte-cntr.c b/drive= rs/hwtracing/coresight/coresight-ctcu-byte-cntr.c new file mode 100644 index 000000000000..a73b7a346d04 --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-ctcu-byte-cntr.c @@ -0,0 +1,286 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#include +#include +#include +#include +#include +#include + +#include "coresight-ctcu.h" +#include "coresight-priv.h" +#include "coresight-tmc.h" + +static irqreturn_t byte_cntr_handler(int irq, void *data) +{ + struct ctcu_byte_cntr *byte_cntr_data =3D data; + + atomic_inc(&byte_cntr_data->irq_cnt); + wake_up(&byte_cntr_data->wq); + + return IRQ_HANDLED; +} + +static void ctcu_cfg_byte_cntr_reg(struct ctcu_drvdata *drvdata, u32 val, + u32 offset) +{ + /* A one value for IRQCTRL register represents 8 bytes */ + ctcu_program_register(drvdata, val / 8, offset); +} + +static struct ctcu_byte_cntr *ctcu_get_byte_cntr(struct coresight_device *= ctcu, + struct coresight_device *etr) +{ + struct ctcu_drvdata *drvdata =3D dev_get_drvdata(ctcu->dev.parent); + int port; + + port =3D coresight_get_in_port(etr, ctcu); + if (port < 0 || port > 1) + return NULL; + + return &drvdata->byte_cntr_data[port]; +} + +static bool ctcu_byte_cntr_switch_buffer(struct tmc_drvdata *etr_drvdata, + struct ctcu_byte_cntr *byte_cntr_data) +{ + struct etr_buf_node *nd, *next, *curr_node =3D NULL, *picked_node =3D NUL= L; + struct etr_buf *curr_buf =3D etr_drvdata->sysfs_buf; + bool found_free_buf =3D false; + + if (WARN_ON(!etr_drvdata || !byte_cntr_data)) + return false; + + /* Stop the ETR before initiating the switch */ + if (coresight_get_mode(etr_drvdata->csdev) !=3D CS_MODE_DISABLED) + tmc_etr_enable_disable_hw(etr_drvdata, false); + + list_for_each_entry_safe(nd, next, &etr_drvdata->etr_buf_list, link) { + /* curr_buf is free for next round */ + if (nd->sysfs_buf =3D=3D curr_buf) { + nd->is_free =3D true; + curr_node =3D nd; + } else if (!found_free_buf && nd->is_free) { + picked_node =3D nd; + found_free_buf =3D true; + } + } + + if (found_free_buf) { + curr_node->pos =3D 0; + curr_node->reading =3D true; + byte_cntr_data->buf_node =3D curr_node; + etr_drvdata->sysfs_buf =3D picked_node->sysfs_buf; + etr_drvdata->etr_buf =3D picked_node->sysfs_buf; + picked_node->is_free =3D false; + /* Reset irq_cnt for next etr_buf */ + atomic_set(&byte_cntr_data->irq_cnt, 0); + /* Restart the ETR once a free buffer is available */ + if (coresight_get_mode(etr_drvdata->csdev) !=3D CS_MODE_DISABLED) + tmc_etr_enable_disable_hw(etr_drvdata, true); + } + + return found_free_buf; +} + +/* + * ctcu_byte_cntr_get_data() - reads data from the deactivated and filled = buffer. + * The byte-cntr reading work reads data from the deactivated and filled b= uffer. + * The read operation waits for a buffer to become available, either fille= d or + * upon timeout, and then reads trace data from the synced buffer. + */ +static ssize_t tmc_byte_cntr_get_data(struct tmc_drvdata *etr_drvdata, lof= f_t pos, + size_t len, char **bufpp) +{ + struct coresight_device *ctcu =3D tmc_etr_get_ctcu_device(etr_drvdata); + struct device *dev =3D &etr_drvdata->csdev->dev; + struct ctcu_byte_cntr *byte_cntr_data; + struct etr_buf *sysfs_buf; + atomic_t *irq_cnt; + ssize_t actual; + int ret; + + byte_cntr_data =3D ctcu_get_byte_cntr(ctcu, etr_drvdata->csdev); + if (!byte_cntr_data || !byte_cntr_data->irq_enabled) + return -EINVAL; + + irq_cnt =3D &byte_cntr_data->irq_cnt; + +wait_buffer: + if (!byte_cntr_data->buf_node) { + ret =3D wait_event_interruptible_timeout(byte_cntr_data->wq, + (atomic_read(irq_cnt) >=3D MAX_IRQ_CNT - 1) || + !byte_cntr_data->enable, + BYTE_CNTR_TIMEOUT); + if (ret < 0) + return ret; + /* + * The current etr_buf is almost full or timeout is triggered, + * so switch the buffer and mark the switched buffer as reading. + */ + if (byte_cntr_data->enable) { + if (!ctcu_byte_cntr_switch_buffer(etr_drvdata, byte_cntr_data)) { + dev_err(dev, "Switch buffer failed for the byte-cntr\n"); + return -ENOMEM; + } + } else { + /* Exit byte-cntr reading */ + return 0; + } + } + + /* Check the status of current etr_buf */ + if (atomic_read(irq_cnt) >=3D MAX_IRQ_CNT) + dev_warn(dev, "Data overwrite happened\n"); + + pos =3D byte_cntr_data->buf_node->pos; + sysfs_buf =3D byte_cntr_data->buf_node->sysfs_buf; + actual =3D tmc_etr_read_sysfs_buf(sysfs_buf, pos, len, bufpp); + if (actual <=3D 0) { + /* Reset buf_node upon reading is finished or failed */ + byte_cntr_data->buf_node->reading =3D false; + byte_cntr_data->buf_node =3D NULL; + + /* + * Nothing in the buffer, waiting for the next buffer + * to be filled. + */ + if (actual =3D=3D 0) + goto wait_buffer; + } + + return actual; +} + +static int tmc_read_prepare_byte_cntr(struct tmc_drvdata *etr_drvdata) +{ + struct coresight_device *ctcu =3D tmc_etr_get_ctcu_device(etr_drvdata); + struct ctcu_byte_cntr *byte_cntr_data; + int ret =3D 0; + + /* byte-cntr is operating with SYSFS mode being enabled only */ + if (coresight_get_mode(etr_drvdata->csdev) !=3D CS_MODE_SYSFS) + return -EINVAL; + + byte_cntr_data =3D ctcu_get_byte_cntr(ctcu, etr_drvdata->csdev); + if (!byte_cntr_data || !byte_cntr_data->irq_enabled) + return -EINVAL; + + if (byte_cntr_data->reading) + return -EBUSY; + + /* Setup an available etr_buf_list for byte-cntr */ + ret =3D tmc_create_etr_buf_list(etr_drvdata, 2); + if (ret) + return ret; + + guard(raw_spinlock_irqsave)(&byte_cntr_data->spin_lock); + atomic_set(&byte_cntr_data->irq_cnt, 0); + /* + * Configure the byte-cntr register to enable IRQ. The configured + * size is 5% of the buffer_size. + */ + ctcu_cfg_byte_cntr_reg(byte_cntr_data->ctcu_drvdata, + etr_drvdata->size / MAX_IRQ_CNT, + byte_cntr_data->irq_ctrl_offset); + enable_irq_wake(byte_cntr_data->irq); + byte_cntr_data->buf_node =3D NULL; + byte_cntr_data->reading =3D true; + + return 0; +} + +static int tmc_read_unprepare_byte_cntr(struct tmc_drvdata *etr_drvdata) +{ + struct coresight_device *ctcu =3D tmc_etr_get_ctcu_device(etr_drvdata); + struct ctcu_byte_cntr *byte_cntr_data; + + byte_cntr_data =3D ctcu_get_byte_cntr(ctcu, etr_drvdata->csdev); + if (!byte_cntr_data || !byte_cntr_data->irq_enabled) + return -EINVAL; + + tmc_clean_etr_buf_list(etr_drvdata); + guard(raw_spinlock_irqsave)(&byte_cntr_data->spin_lock); + /* Configure the byte-cntr register to disable IRQ */ + ctcu_cfg_byte_cntr_reg(byte_cntr_data->ctcu_drvdata, 0, + byte_cntr_data->irq_ctrl_offset); + disable_irq_wake(byte_cntr_data->irq); + byte_cntr_data->buf_node =3D NULL; + byte_cntr_data->reading =3D false; + + return 0; +} + +const struct tmc_sysfs_ops byte_cntr_sysfs_ops =3D { + .read_prepare =3D tmc_read_prepare_byte_cntr, + .read_unprepare =3D tmc_read_unprepare_byte_cntr, + .get_trace_data =3D tmc_byte_cntr_get_data, +}; + +/* Start the byte-cntr function when the path is enabled. */ +void ctcu_byte_cntr_start(struct coresight_device *csdev, struct coresight= _path *path) +{ + struct coresight_device *sink =3D coresight_get_sink(path); + struct ctcu_byte_cntr *byte_cntr_data; + + byte_cntr_data =3D ctcu_get_byte_cntr(csdev, sink); + if (!byte_cntr_data) + return; + + /* Don't start byte-cntr function when irq_enabled is not set. */ + if (!byte_cntr_data->irq_enabled || byte_cntr_data->enable) + return; + + guard(raw_spinlock_irqsave)(&byte_cntr_data->spin_lock); + byte_cntr_data->enable =3D true; +} + +/* Stop the byte-cntr function when the path is disabled. */ +void ctcu_byte_cntr_stop(struct coresight_device *csdev, struct coresight_= path *path) +{ + struct coresight_device *sink =3D coresight_get_sink(path); + struct ctcu_byte_cntr *byte_cntr_data; + + if (coresight_get_mode(sink) =3D=3D CS_MODE_SYSFS) + return; + + byte_cntr_data =3D ctcu_get_byte_cntr(csdev, sink); + if (!byte_cntr_data) + return; + + guard(raw_spinlock_irqsave)(&byte_cntr_data->spin_lock); + byte_cntr_data->enable =3D false; +} + +void ctcu_byte_cntr_init(struct device *dev, struct ctcu_drvdata *drvdata,= int etr_num) +{ + struct ctcu_byte_cntr *byte_cntr_data; + struct device_node *nd =3D dev->of_node; + int irq_num, ret, i; + + tmc_etr_set_byte_cntr_sysfs_ops(&byte_cntr_sysfs_ops); + for (i =3D 0; i < etr_num; i++) { + byte_cntr_data =3D &drvdata->byte_cntr_data[i]; + irq_num =3D of_irq_get(nd, i); + if (irq_num < 0) { + dev_err(dev, "Failed to get IRQ from DT for port%d\n", i); + continue; + } + + ret =3D devm_request_irq(dev, irq_num, byte_cntr_handler, + IRQF_TRIGGER_RISING | IRQF_SHARED, + dev_name(dev), byte_cntr_data); + if (ret) { + dev_err(dev, "Failed to register IRQ for port%d\n", i); + continue; + } + + byte_cntr_data->irq =3D irq_num; + byte_cntr_data->ctcu_drvdata =3D drvdata; + init_waitqueue_head(&byte_cntr_data->wq); + raw_spin_lock_init(&byte_cntr_data->spin_lock); + } +} diff --git a/drivers/hwtracing/coresight/coresight-ctcu-core.c b/drivers/hw= tracing/coresight/coresight-ctcu-core.c index e8720026c9e3..56590f22ad79 100644 --- a/drivers/hwtracing/coresight/coresight-ctcu-core.c +++ b/drivers/hwtracing/coresight/coresight-ctcu-core.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights res= erved. + * Copyright (c) 2024-2026 Qualcomm Innovation Center, Inc. All rights res= erved. + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. */ =20 #include @@ -18,6 +19,7 @@ =20 #include "coresight-ctcu.h" #include "coresight-priv.h" +#include "coresight-tmc.h" =20 #define ctcu_writel(drvdata, val, offset) __raw_writel((val), drvdata->bas= e + offset) #define ctcu_readl(drvdata, offset) __raw_readl(drvdata->base + offset) @@ -43,17 +45,21 @@ =20 #define CTCU_ATID_REG_BIT(traceid) (traceid % 32) #define CTCU_ATID_REG_SIZE 0x10 +#define CTCU_ETR0_IRQCTRL 0x6c +#define CTCU_ETR1_IRQCTRL 0x70 #define CTCU_ETR0_ATID0 0xf8 #define CTCU_ETR1_ATID0 0x108 =20 static const struct ctcu_etr_config sa8775p_etr_cfgs[] =3D { { - .atid_offset =3D CTCU_ETR0_ATID0, - .port_num =3D 0, + .atid_offset =3D CTCU_ETR0_ATID0, + .irq_ctrl_offset =3D CTCU_ETR0_IRQCTRL, + .port_num =3D 0, }, { - .atid_offset =3D CTCU_ETR1_ATID0, - .port_num =3D 1, + .atid_offset =3D CTCU_ETR1_ATID0, + .irq_ctrl_offset =3D CTCU_ETR1_IRQCTRL, + .port_num =3D 1, }, }; =20 @@ -62,6 +68,85 @@ static const struct ctcu_config sa8775p_cfgs =3D { .num_etr_config =3D ARRAY_SIZE(sa8775p_etr_cfgs), }; =20 +void ctcu_program_register(struct ctcu_drvdata *drvdata, u32 val, u32 offs= et) +{ + CS_UNLOCK(drvdata->base); + ctcu_writel(drvdata, val, offset); + CS_LOCK(drvdata->base); +} + +static ssize_t irq_enabled_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct ctcu_byte_cntr_irq_attribute *irq_attr =3D + container_of(attr, struct ctcu_byte_cntr_irq_attribute, attr); + struct ctcu_drvdata *drvdata =3D dev_get_drvdata(dev->parent); + u8 port =3D irq_attr->port; + + if (!drvdata->byte_cntr_data[port].irq_ctrl_offset) + return -EINVAL; + + return sysfs_emit(buf, "%u\n", + (unsigned int)drvdata->byte_cntr_data[port].irq_enabled); +} + +static ssize_t irq_enabled_store(struct device *dev, + struct device_attribute *attr, + const char *buf, + size_t size) +{ + struct ctcu_byte_cntr_irq_attribute *irq_attr =3D + container_of(attr, struct ctcu_byte_cntr_irq_attribute, attr); + struct ctcu_drvdata *drvdata =3D dev_get_drvdata(dev->parent); + u8 port =3D irq_attr->port; + unsigned long val; + + if (kstrtoul(buf, 0, &val)) + return -EINVAL; + + guard(raw_spinlock_irqsave)(&drvdata->spin_lock); + if (drvdata->byte_cntr_data[port].reading) + return -EBUSY; + else if (drvdata->byte_cntr_data[port].irq_ctrl_offset) + drvdata->byte_cntr_data[port].irq_enabled =3D !!val; + + return size; +} + +static umode_t irq_enabled_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + struct device_attribute *dev_attr =3D + container_of(attr, struct device_attribute, attr); + struct ctcu_byte_cntr_irq_attribute *irq_attr =3D + container_of(dev_attr, struct ctcu_byte_cntr_irq_attribute, attr); + struct device *dev =3D kobj_to_dev(kobj); + struct ctcu_drvdata *drvdata =3D dev_get_drvdata(dev->parent); + u8 port =3D irq_attr->port; + + if (drvdata && drvdata->byte_cntr_data[port].irq_ctrl_offset) + return attr->mode; + + return 0; +} + +static struct attribute *ctcu_attrs[] =3D { + ctcu_byte_cntr_irq_rw(0), + ctcu_byte_cntr_irq_rw(1), + NULL, +}; + +static struct attribute_group ctcu_attr_grp =3D { + .attrs =3D ctcu_attrs, + .is_visible =3D irq_enabled_is_visible, +}; + +static const struct attribute_group *ctcu_attr_grps[] =3D { + &ctcu_attr_grp, + NULL, +}; + static void ctcu_program_atid_register(struct ctcu_drvdata *drvdata, u32 r= eg_offset, u8 bit, bool enable) { @@ -140,11 +225,15 @@ static int ctcu_set_etr_traceid(struct coresight_devi= ce *csdev, struct coresight static int ctcu_enable(struct coresight_device *csdev, enum cs_mode mode, struct coresight_path *path) { + ctcu_byte_cntr_start(csdev, path); + return ctcu_set_etr_traceid(csdev, path, true); } =20 static int ctcu_disable(struct coresight_device *csdev, struct coresight_p= ath *path) { + ctcu_byte_cntr_stop(csdev, path); + return ctcu_set_etr_traceid(csdev, path, false); } =20 @@ -195,7 +284,10 @@ static int ctcu_probe(struct platform_device *pdev) for (i =3D 0; i < cfgs->num_etr_config; i++) { etr_cfg =3D &cfgs->etr_cfgs[i]; drvdata->atid_offset[i] =3D etr_cfg->atid_offset; + drvdata->byte_cntr_data[i].irq_ctrl_offset =3D + etr_cfg->irq_ctrl_offset; } + ctcu_byte_cntr_init(dev, drvdata, cfgs->num_etr_config); } } =20 @@ -209,6 +301,7 @@ static int ctcu_probe(struct platform_device *pdev) desc.dev =3D dev; desc.ops =3D &ctcu_ops; desc.access =3D CSDEV_ACCESS_IOMEM(base); + desc.groups =3D ctcu_attr_grps; raw_spin_lock_init(&drvdata->spin_lock); =20 drvdata->csdev =3D coresight_register(&desc); @@ -248,6 +341,7 @@ static void ctcu_platform_remove(struct platform_device= *pdev) if (WARN_ON(!drvdata)) return; =20 + tmc_etr_reset_byte_cntr_sysfs_ops(); ctcu_remove(pdev); pm_runtime_disable(&pdev->dev); } diff --git a/drivers/hwtracing/coresight/coresight-ctcu.h b/drivers/hwtraci= ng/coresight/coresight-ctcu.h index e9594c38dd91..a2ae0a0d91d0 100644 --- a/drivers/hwtracing/coresight/coresight-ctcu.h +++ b/drivers/hwtracing/coresight/coresight-ctcu.h @@ -1,23 +1,31 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2024-2025 Qualcomm Innovation Center, Inc. All rights res= erved. + * Copyright (c) 2024-2026 Qualcomm Innovation Center, Inc. All rights res= erved. + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. */ =20 #ifndef _CORESIGHT_CTCU_H #define _CORESIGHT_CTCU_H + +#include #include "coresight-trace-id.h" =20 /* Maximum number of supported ETR devices for a single CTCU. */ #define ETR_MAX_NUM 2 =20 +#define BYTE_CNTR_TIMEOUT (3 * HZ) +#define MAX_IRQ_CNT 20 + /** * struct ctcu_etr_config * @atid_offset: offset to the ATID0 Register. - * @port_num: in-port number of CTCU device that connected to ETR. + * @port_num: in-port number of the CTCU device that connected to ETR. + * @irq_ctrl_offset: offset to the BYTECNTRVAL register. */ struct ctcu_etr_config { const u32 atid_offset; const u32 port_num; + const u32 irq_ctrl_offset; }; =20 struct ctcu_config { @@ -25,15 +33,68 @@ struct ctcu_config { int num_etr_config; }; =20 -struct ctcu_drvdata { - void __iomem *base; - struct clk *apb_clk; - struct device *dev; - struct coresight_device *csdev; +/** + * struct ctcu_byte_cntr + * @enable: indicates that byte_cntr function is enabled or not. + * @irq_enabled: indicates that the interruption is enabled. + * @reading: indicates that byte_cntr is reading. + * @irq: allocated number of the IRQ. + * @irq_cnt: IRQ count number of the triggered interruptions. + * @wq: waitqueue for reading data from ETR buffer. + * @spin_lock: spinlock of the byte_cntr_data. + * @irq_ctrl_offset: offset to the BYTECNTVAL Register. + * @ctcu_drvdata: drvdata of the CTCU device. + * @buf_node: etr_buf_node for reading. + */ +struct ctcu_byte_cntr { + bool enable; + bool irq_enabled; + bool reading; + int irq; + atomic_t irq_cnt; + wait_queue_head_t wq; raw_spinlock_t spin_lock; - u32 atid_offset[ETR_MAX_NUM]; + u32 irq_ctrl_offset; + struct ctcu_drvdata *ctcu_drvdata; + struct etr_buf_node *buf_node; +}; + +struct ctcu_drvdata { + void __iomem *base; + struct clk *apb_clk; + struct device *dev; + struct coresight_device *csdev; + struct ctcu_byte_cntr byte_cntr_data[ETR_MAX_NUM]; + raw_spinlock_t spin_lock; + u32 atid_offset[ETR_MAX_NUM]; /* refcnt for each traceid of each sink */ - u8 traceid_refcnt[ETR_MAX_NUM][CORESIGHT_TRACE_ID_RES_TOP]; + u8 traceid_refcnt[ETR_MAX_NUM][CORESIGHT_TRACE_ID_RES_TOP]; }; =20 +/** + * struct ctcu_byte_cntr_irq_attribute + * @attr: The device attribute. + * @port: port number. + */ +struct ctcu_byte_cntr_irq_attribute { + struct device_attribute attr; + u8 port; +}; + +#define ctcu_byte_cntr_irq_rw(port) \ + (&((struct ctcu_byte_cntr_irq_attribute[]) { \ + { \ + __ATTR(irq_enabled##port, 0644, irq_enabled_show, \ + irq_enabled_store), \ + port, \ + } \ + })[0].attr.attr) + +void ctcu_program_register(struct ctcu_drvdata *drvdata, u32 val, u32 offs= et); + +/* Byte-cntr functions */ +void ctcu_byte_cntr_start(struct coresight_device *csdev, struct coresight= _path *path); +void ctcu_byte_cntr_stop(struct coresight_device *csdev, struct coresight_= path *path); +void ctcu_byte_cntr_init(struct device *dev, struct ctcu_drvdata *drvdata,= int port_num); + #endif diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwt= racing/coresight/coresight-tmc-core.c index 110eedde077f..9f4fd86e8c32 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-core.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -293,7 +293,8 @@ static ssize_t tmc_read(struct file *file, char __user = *data, size_t len, return -EFAULT; } =20 - *ppos +=3D actual; + if (!tmc_etr_update_buf_node_pos(drvdata, actual)) + *ppos +=3D actual; dev_dbg(&drvdata->csdev->dev, "%zu bytes copied\n", actual); =20 return actual; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index d4a99c77dd90..3253964d1ce7 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1168,6 +1168,8 @@ static int tmc_etr_enable_hw(struct tmc_drvdata *drvd= ata, return rc; } =20 +static const struct tmc_sysfs_ops *byte_cntr_sysfs_ops; + /* * Return the available trace data in the buffer (starts at etr_buf->offse= t, * limited by etr_buf->len) from @pos, with a maximum limit of @len, @@ -1178,23 +1180,39 @@ static int tmc_etr_enable_hw(struct tmc_drvdata *dr= vdata, * We are protected here by drvdata->reading !=3D 0, which ensures the * sysfs_buf stays alive. */ -ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata, - loff_t pos, size_t len, char **bufpp) +ssize_t tmc_etr_read_sysfs_buf(struct etr_buf *sysfs_buf, loff_t pos, + size_t len, char **bufpp) { s64 offset; ssize_t actual =3D len; - struct etr_buf *etr_buf =3D drvdata->sysfs_buf; =20 - if (pos + actual > etr_buf->len) - actual =3D etr_buf->len - pos; + if (pos + actual > sysfs_buf->len) + actual =3D sysfs_buf->len - pos; if (actual <=3D 0) return actual; =20 /* Compute the offset from which we read the data */ - offset =3D etr_buf->offset + pos; - if (offset >=3D etr_buf->size) - offset -=3D etr_buf->size; - return tmc_etr_buf_get_data(etr_buf, offset, actual, bufpp); + offset =3D sysfs_buf->offset + pos; + if (offset >=3D sysfs_buf->size) + offset -=3D sysfs_buf->size; + return tmc_etr_buf_get_data(sysfs_buf, offset, actual, bufpp); +} +EXPORT_SYMBOL_GPL(tmc_etr_read_sysfs_buf); + +ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata, + loff_t pos, size_t len, char **bufpp) +{ + ssize_t ret; + + if (byte_cntr_sysfs_ops) { + ret =3D byte_cntr_sysfs_ops->get_trace_data(drvdata, pos, + len, bufpp); + /* Return the filled buffer */ + if (ret > 0 || ret =3D=3D -ENOMEM) + return ret; + } + + return tmc_etr_read_sysfs_buf(drvdata->sysfs_buf, pos, len, bufpp); } =20 static struct etr_buf * @@ -1248,6 +1266,33 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata = *drvdata) =20 } =20 +static void tmc_etr_reset_sysfs_buf(struct tmc_drvdata *drvdata) +{ + u32 sts; + + CS_UNLOCK(drvdata->base); + tmc_write_rrp(drvdata, drvdata->sysfs_buf->hwaddr); + tmc_write_rwp(drvdata, drvdata->sysfs_buf->hwaddr); + sts =3D readl_relaxed(drvdata->base + TMC_STS) & ~TMC_STS_FULL; + writel_relaxed(sts, drvdata->base + TMC_STS); + CS_LOCK(drvdata->base); +} + +/** + * tmc_etr_enable_disable_hw - enable/disable the ETR hw. + * @drvdata: drvdata of the TMC device. + * @enable: indicates enable/disable. + */ +void tmc_etr_enable_disable_hw(struct tmc_drvdata *drvdata, bool enable) +{ + if (enable) { + tmc_etr_reset_sysfs_buf(drvdata); + __tmc_etr_enable_hw(drvdata); + } else + __tmc_etr_disable_hw(drvdata); +} +EXPORT_SYMBOL_GPL(tmc_etr_enable_disable_hw); + void tmc_etr_disable_hw(struct tmc_drvdata *drvdata) { __tmc_etr_disable_hw(drvdata); @@ -2040,6 +2085,35 @@ int tmc_create_etr_buf_list(struct tmc_drvdata *drvd= ata, int num_nodes) } EXPORT_SYMBOL_GPL(tmc_create_etr_buf_list); =20 +void tmc_etr_set_byte_cntr_sysfs_ops(const struct tmc_sysfs_ops *sysfs_ops) +{ + byte_cntr_sysfs_ops =3D sysfs_ops; +} +EXPORT_SYMBOL_GPL(tmc_etr_set_byte_cntr_sysfs_ops); + +void tmc_etr_reset_byte_cntr_sysfs_ops(void) +{ + byte_cntr_sysfs_ops =3D NULL; +} +EXPORT_SYMBOL_GPL(tmc_etr_reset_byte_cntr_sysfs_ops); + +bool tmc_etr_update_buf_node_pos(struct tmc_drvdata *drvdata, ssize_t size) +{ + struct etr_buf_node *nd, *next; + + if (drvdata->config_type !=3D TMC_CONFIG_TYPE_ETR) + return false; + + list_for_each_entry_safe(nd, next, &drvdata->etr_buf_list, link) { + if (nd && nd->reading) { + nd->pos +=3D size; + return true; + } + } + + return false; +} + int tmc_read_prepare_etr(struct tmc_drvdata *drvdata) { int ret =3D 0; @@ -2049,6 +2123,14 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata) if (WARN_ON_ONCE(drvdata->config_type !=3D TMC_CONFIG_TYPE_ETR)) return -EINVAL; =20 + if (byte_cntr_sysfs_ops) { + ret =3D byte_cntr_sysfs_ops->read_prepare(drvdata); + if (!ret || ret =3D=3D -EBUSY) + return ret; + + ret =3D 0; + } + raw_spin_lock_irqsave(&drvdata->spinlock, flags); if (drvdata->reading) { ret =3D -EBUSY; @@ -2085,6 +2167,10 @@ int tmc_read_unprepare_etr(struct tmc_drvdata *drvda= ta) if (WARN_ON_ONCE(drvdata->config_type !=3D TMC_CONFIG_TYPE_ETR)) return -EINVAL; =20 + if (byte_cntr_sysfs_ops) + if (!byte_cntr_sysfs_ops->read_unprepare(drvdata)) + return 0; + raw_spin_lock_irqsave(&drvdata->spinlock, flags); =20 /* RE-enable the TMC if need be */ diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracin= g/coresight/coresight-tmc.h index fbb015079872..a15e2f93f16a 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -211,12 +211,15 @@ struct tmc_resrv_buf { /** * @sysfs_buf: Allocated sysfs_buf. * @is_free: Indicates whether the buffer is free to choose. + * @reading: Indicates byte_cntr is reading the buffer attached to + * the node. * @pos: Offset to the start of the buffer. * @link: list_head of the node. */ struct etr_buf_node { struct etr_buf *sysfs_buf; bool is_free; + bool reading; loff_t pos; struct list_head link; }; @@ -480,5 +483,11 @@ struct etr_buf *tmc_etr_get_buffer(struct coresight_de= vice *csdev, extern const struct attribute_group coresight_etr_group; void tmc_clean_etr_buf_list(struct tmc_drvdata *drvdata); int tmc_create_etr_buf_list(struct tmc_drvdata *drvdata, int num_nodes); +void tmc_etr_set_byte_cntr_sysfs_ops(const struct tmc_sysfs_ops *sysfs_ops= ); +void tmc_etr_reset_byte_cntr_sysfs_ops(void); +void tmc_etr_enable_disable_hw(struct tmc_drvdata *drvdata, bool enable); +bool tmc_etr_update_buf_node_pos(struct tmc_drvdata *drvdata, ssize_t size= ); +ssize_t tmc_etr_read_sysfs_buf(struct etr_buf *sysfs_buf, loff_t pos, + size_t len, char **bufpp); =20 #endif --=20 2.34.1 From nobody Thu Apr 2 06:31:59 2026 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 8FCFA388389 for ; Mon, 23 Mar 2026 09:50:26 +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=1774259428; cv=none; b=GOPsVo6ksCfPzgNjAxk5qZxx5HyjlJSYZG5ilr0wXyZfg31eEXLzLXCpb7pAud/R1OpHFrfvRRSLGFtZ/66afHRyOYfIJShcE1TIM8/y4hb+Gz7SHVFUAAU+3cCJmpueXO3s7BMMjEpjpJCn1iBjxJyCTRvW4/YyhzdxtmNrkD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774259428; c=relaxed/simple; bh=0MADiRxGeDkPQDc+D4cOyR9YpPfqVXFTQN8hJDo+rxc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m0UM+KntQGAawmAuyZ4LwOhF0PLcBGdZ6v7Jtpr/Jkf5ijgkn9DoNVAtrFbP5A+mq4kcZ05whM97h1C6QHgpbLU9ddvzaZ7BWSKpa3BKLSuOVGhWKrosZStVae1BoySJkSrzT9zR4qgiPG4dMODnYWx1rQveaWUZx+AmRjmN42o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=bCE01tvS; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=d/kKQSHb; 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=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="bCE01tvS"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="d/kKQSHb" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62N7UP4Y424216 for ; Mon, 23 Mar 2026 09:50:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Q+6sbBvItLVDaaK2nVoqlOqVJ4lF02bwo0WaOVku2Og=; b=bCE01tvSrWvcPg6l QuWF1UhU6fkcPrb2rKKR2EyuZkD4TsQAcY9qe2Yha37rHrs5yUofLu8DkCiEvm9D dpq/HOeVA3/pGFXTpbZabPu1ne3iJCZaMq88hau2VCY/41xPdzuvvQACaiEyjF0v 5AP1YjbsHd1KLBaQGtPyVs8dWduEk7k5CbRooViVNu65UXnGj65y1NbGOAr5WjhQ Mv1cGL5UWu1zlKcAzMIuAqyakBqTnuaI+s7Qloi0oj0YKazRT8pPjQkTO1SzVKB/ 05t+3ZEjxQmuoj+0J8YrODDp5CVEdmEmz0eLNY0GCfUKxjysUrmxs2pGeNIkzGZw w+EYnA== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d1jwvmtw4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Mar 2026 09:50:25 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c7380305a9aso3315114a12.1 for ; Mon, 23 Mar 2026 02:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1774259425; x=1774864225; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q+6sbBvItLVDaaK2nVoqlOqVJ4lF02bwo0WaOVku2Og=; b=d/kKQSHbG/2x3i1Zj6oESE8AuKVhtVS3CVhTmaCpuRLllgOb0yDRkc9U5ETL226vSI tBLBwjyu0sXkJpVV4ugSCx2Bh+p3mt5RnjX4/whPuuDZBmeoNWl3v3hrFid9t8nIc8h3 X/GQj5WG5DDpkRVnEZ6GuNmYV49A5fIqtOCgHn+yFd3dN0YiSpFPfBh/30c14/iKHwmu FnuprMd0Hxjj46+oX7jlgsyB0MOEJdtnFB14UbYeTBwJTawEHkKKajJK47I1dbpS4ir4 k6RWicc1Cn20EosJq7/kRaoKNq1sulMHEncSIHmMa8jGJRfCeKTLPoXFlcKhEGUm46Rn EDPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774259425; x=1774864225; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q+6sbBvItLVDaaK2nVoqlOqVJ4lF02bwo0WaOVku2Og=; b=ZT+q9BYRDeF6OFKFtkeGmA9X/3NivnRHCvJ9su6AonpMeFE7EBTnuBWc8PheWrCVlX 0Uz4JOjyNuTLH9AHxlDZLvwX+W8qK/WwTfpHPDPUwdARCrUHF4nYfviwrnkygvkdOrsH ZWykr37zTz0LEo5N1IRdIJO/M/L6QY/c1do6VHxtHggvwZ0vzFhGXCIcYYlxB2lklIvK 6Vvoo9YbskOnkMCBlas6sJh0RvofJ4x7gCXhvoJRy4SWBccNZoEGPqKbkswpiHiZ725m zlYHAkom2A45lbDSPsuNi9HNZ5ivU7BLM/lnJgU8kj3Lf7dfHKxtg1i7g7ZRDGzFrKup KkMQ== X-Forwarded-Encrypted: i=1; AJvYcCUTb5Ts03Dca3w2azEBcryRGvjXCYxnIAsDDqtB7RPxC2YVWXFeWyiTZc1315VTd0Sik2dFm10Y2dzIjZw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6qVc2uBW5it0AdxJodITwblUzAakPCqzlALOGiYgffFYEnyE7 rq4cJa535LAqLX49TCVFCrj3EbGc+pCHEYoq40LPmpioCFKQc4jazJywZh0TNIHJPpH33zc7PBa OB03IfrsQAj6ASAo6OiDQu6ND6M3hbH1PL9LvfxZw73NINttnrn3IgZTE3cE7kgBAPYU= X-Gm-Gg: ATEYQzxJ/6/l5cmH5U40ctnjHngBsXhCw1IXIIezc9CfVIVXJD1CWtNtnOBXEr9X3r2 n85aWXuIvVWOwjxwPscIl28BpF9iG8WNxqn4QgleiOzI31aNrHuihLJAE9UM/sWgmkartGHSJ0a W+kiYulGRex/0C7l+k4zvo+h/jaO7hylkpcKe09PGDV+x9X0NCGxppDVTlYehn9li++nQ9JF3/+ /Xob9MJzsTSXRqvzDwwYR5c4UH8YSNSyo0R3b4YapeMpMKhC5zRBCcFKq1+S0Z+jpeC0QftawTb aTXOFCEutK4JaOUTs5ambdKn6Ed+DqKXQFMMmrkr5EXKHULGft904OYKdUFfG1HSM8ZlflrCYEv OL0x3wGCNI/FQPzhtl7xEotaa6YrvLSUuJS9I6fceNQ+2E+U50xlHX7/RyX8XIRsGojmUYHQX2w cKvsGBONrE X-Received: by 2002:a05:6a21:e082:b0:398:71f2:59dd with SMTP id adf61e73a8af0-39bcf0df18emr9614583637.9.1774259424622; Mon, 23 Mar 2026 02:50:24 -0700 (PDT) X-Received: by 2002:a05:6a21:e082:b0:398:71f2:59dd with SMTP id adf61e73a8af0-39bcf0df18emr9614550637.9.1774259424127; Mon, 23 Mar 2026 02:50:24 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c743a939af0sm6591935a12.16.2026.03.23.02.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 02:50:23 -0700 (PDT) From: Jie Gan Date: Mon, 23 Mar 2026 17:49:32 +0800 Subject: [PATCH v16 7/7] arm64: dts: qcom: lemans: add interrupts to CTCU device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260323-enable-byte-cntr-for-ctcu-v16-7-7a413d211b8d@oss.qualcomm.com> References: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> In-Reply-To: <20260323-enable-byte-cntr-for-ctcu-v16-0-7a413d211b8d@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, Jie Gan , Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1774259384; l=769; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=0MADiRxGeDkPQDc+D4cOyR9YpPfqVXFTQN8hJDo+rxc=; b=kKXIWKhLADAUr9KJy3p82eIWtpxUIV/8MOu6/roEzWF1+EwFIeX1+5C+emzLimc1QIZOOYu3/ wo7Qb6HSAkUDKSzCHF9Nr51Q9mEUiuWPLEJIqUF/83MMsnHZX5bNQgP X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzIzMDA3NSBTYWx0ZWRfXxM5C55ZfYbWx Bk6diE2r2MBJ4cOq2UR5ptUhO/OgoV9iJ6vUx8Jif6U1x6+K5seKXvB/7bBWT8K0M1QzzqAyQVi AnAbs0E0cYVi3620GA7wxP1KiOPc5thmqTWsAiJYNuXwoJqQBbI/MxA/gB7dhFxIIyLniUWjiTg rOVMnKlahVFYp6wNgLq7o99KlFlZ83g0SeHjrxre1DbPimTK+E6ZwRy5z9lfdei7PVPIytAKNfd vBlHqeC9V+JZWlgggX4y+8izkKM0zMsWPTGCFtYxbu+NB0SrxYViuMFH3habSNUdN1R4vOcJ50Z gSBJPIIwl01tYods/RjCFOa/eXGGF7DU6pbkp72Y9g8lpFdWED6ta17+fmCHpN4Rxlu42b0gEci ZgXM56qy9VYVZhBnMqke1nP9uSh2zjFtuBAhqB6RRJ1zP/iBV8Y7RssZ/2Rw+krIDBl7C/Mq2H6 Yb2axEL33gsg5Cwvr4w== X-Authority-Analysis: v=2.4 cv=bcdmkePB c=1 sm=1 tr=0 ts=69c10ce1 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=gBkj9RZkAcI1HbXH1KoA:9 a=QEXdDO2ut3YA:10 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-ORIG-GUID: aln-XiM-aFXddQm0ygWqzmFX0bDhuPgV X-Proofpoint-GUID: aln-XiM-aFXddQm0ygWqzmFX0bDhuPgV 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-03-23_03,2026-03-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 impostorscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603230075 Add interrupts to enable byte-cntr function for TMC ETR devices. Reviewed-by: Konrad Dybcio Signed-off-by: Jie Gan --- arch/arm64/boot/dts/qcom/lemans.dtsi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/lemans.dtsi b/arch/arm64/boot/dts/qco= m/lemans.dtsi index 808827b83553..e8a20789cd58 100644 --- a/arch/arm64/boot/dts/qcom/lemans.dtsi +++ b/arch/arm64/boot/dts/qcom/lemans.dtsi @@ -2800,6 +2800,9 @@ ctcu@4001000 { clocks =3D <&aoss_qmp>; clock-names =3D "apb"; =20 + interrupts =3D , + ; + in-ports { #address-cells =3D <1>; #size-cells =3D <0>; --=20 2.34.1