From nobody Thu Oct 2 21:55:28 2025 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 C59F92EA723 for ; Thu, 11 Sep 2025 09:37:50 +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=1757583472; cv=none; b=idrQv+16W0edHSJbw8EYdok6SembFluKBuVXt7PUP3Z1hixzLE40nNQcXZKnVza/ykJKEs+rzUgj6eK10wEuO5b0pzS++J3ktqJcExTSCvs5oNMNmqn71n5VrOE9GWMQ9/mPX9oIhTiKGjYE2gDpzVhA2ySbpwGhnjbgTnph5gE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757583472; c=relaxed/simple; bh=v23xmem2Bt+Tgm+51X3S8Idk7oSeK94L/FuNsCG9NiI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TCFswToIj1YC49+d4mFIKPlhS5/02AfUkuvrW9Ys925koQd1uxlNbQ66Ijv8x1kfLIEOIzIJ+KudiAJDb0m7eSdLjmBjRB1fPO1ONcHac5gEnz6cy+QUPWRdc9s4r1d3zfbGk4wtiRCAZ6qubYvMLMa+VJp3d6dsyPcnZwVmQJM= 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=fhj/0SiU; 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="fhj/0SiU" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58B8VUB3002820 for ; Thu, 11 Sep 2025 09:37:49 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= DP7hy6R/ajCWGii9N1NQ8UzWBIex0rIJ0tD9YQPKZFA=; b=fhj/0SiUIZgoPnck fENAT01gbp+3i9BSD0iehzs1R5I1D5khPGIkFoROj0F+D2YAXlEIQEjjrQW0L8SW iIEe6oVnqQzU8m0Ar3vLh5dmSo+cP5uoLfmB937zUxasj694fAr2tif47K9lFbbU zL4ZyB9FUd15yecvYRgYfmFEBUR9GFmrIEaefXVi7Rdo4ol+cJK3bFDSXSzQ8Jwt FbSKvlDEca4XBYe7quDtXdPfWuhveK8wpD+cTde37SrO4AflcA77hph2UflE5UQc M9qzLlU9jDxmRZN+1zxPrAcmqi+suQ7U3LEupCRLwfK1i8YUWNAy2AwNT2NfSlUy ajD5Ig== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 493tyxr6yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 11 Sep 2025 09:37:49 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b4fc06ba4c1so491577a12.1 for ; Thu, 11 Sep 2025 02:37:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757583456; x=1758188256; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DP7hy6R/ajCWGii9N1NQ8UzWBIex0rIJ0tD9YQPKZFA=; b=jcPeQiObxRpOSto1HGMfJTAlCIGUCJlpnj4apcaop3tzqPDbWtVKgn7cg4X4whjVFF OPOmdyQbFPIwN0xmr9T6jM7it+aMpGM/Q9nHiiF+HspEkUGGkuDoez1tcnRNT1c+kMoz dYBDuMqonVzcpOy9dngirmsEJwtZrtHYZz+LXu3eiWKFKK5nUu5+2Gcb2j3e4cwoAAmg /FxLxkvpE//OA/FmMrnubMo8C4amkHOrSaxVk/Lm0qLB85a73HWlpWjZLX2uQwOnUAB/ vajptntbkRaTMaztEPGobb3It5hj3HXd9SS/Jf5LK0Yb+mNpBQYDpqX+R7bVYLJC+4fq qz4Q== X-Forwarded-Encrypted: i=1; AJvYcCUQXVlthK/NHhN4KrB0mYHZSDPPtQQQTtUrDHYzNrpVlA9ujN4tHcXSvG5ct60xeuFpa2kuo8aWYixWxP8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0nSIsa98Ru3HChF5DArJ/29rJsfv0H9KSRxPBbkUvefzerR5i 5a7VZkHdqDlmlmOfsCoKZa6ONfFjBSswrGIIf3YuTMWCv4sp99QuvpXkKih71n2BfB412ri+1TV c9rp7mjnfeZtDkya6MimGZMmnWIgrev63iNRQLaTZOIdd6M4tkS9RHu+mnB2K4XTCErA= X-Gm-Gg: ASbGncu6P4HDWutgdTgI1T85DH4X094xiiSgWCFlfK4Roh+Gaa+b1YKU7QTR2EyaFm5 71dTxLftJiis0dSs03b1BD6BC8h5q7LlYc7/porR4f53Km05xJPoZAtM2LQ5zYNd/sItR8s+yD3 BlEVG9jmGoylwyiB7BcmQPtbd53D+EnUmpzslsdu8QRkgzPG6DWZsg2WGyMuzx4a6/i6srVxJY/ UuqTi35NEu7KwnGabZortS13P+C/jKAofmZfRoEEHyPEmdhrBgRlN3dfMaU8TJVCXeL0FmXkxrI TBnEpL6uaD4wG8a60yHhNbYib8T+hojzPzRQgX57yp+vOEWL9ma4Lgemo3R2aqqvkPwqRiLsYpe ILOfi3qA9SDCwdDcUL1YRcZpqc7s= X-Received: by 2002:a05:6a20:12c2:b0:24d:d206:6992 with SMTP id adf61e73a8af0-2533fab21e2mr24980710637.22.1757583455467; Thu, 11 Sep 2025 02:37:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMAT+mtv4V4eOOakGYoWzIg2DcLqJbZNqjT7jnekLGX1TDeiDnbQSIzgOPBjdtR946Xnyevw== X-Received: by 2002:a05:6a20:12c2:b0:24d:d206:6992 with SMTP id adf61e73a8af0-2533fab21e2mr24980677637.22.1757583454959; Thu, 11 Sep 2025 02:37:34 -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 d2e1a72fcca58-7760793b730sm1512930b3a.15.2025.09.11.02.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:37:34 -0700 (PDT) From: Jie Gan Date: Thu, 11 Sep 2025 17:36:57 +0800 Subject: [PATCH v2 2/3] coresight: tpdm: add static tpdm support 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: <20250911-add_static_tpdm_support-v2-2-608559d36f74@oss.qualcomm.com> References: <20250911-add_static_tpdm_support-v2-0-608559d36f74@oss.qualcomm.com> In-Reply-To: <20250911-add_static_tpdm_support-v2-0-608559d36f74@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Jinlong Mao , Tao Zhang , Alexander Shishkin , Bjorn Andersson , Konrad Dybcio Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Jie Gan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757583439; l=8786; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=v23xmem2Bt+Tgm+51X3S8Idk7oSeK94L/FuNsCG9NiI=; b=wYRgTWtOkKC5c8t1jXzCYs9vFEvjmwmgF1Oocuxz+CL/Zdyt9EbbhXGXKAsRb6w9ZflPIAQ4g YRNvTPq4vs0DnvByr9M+o7H+pfqrmNE4sCiw3Bweqfeih6AulDpGELK X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Proofpoint-ORIG-GUID: 1EjRvpBROiDedo6VpD_vHK9LlZrv3NVP X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTExMDA3NCBTYWx0ZWRfX55amFJIu7B4J ShgyLqg4Q05l0Qly5HWL6CwkWXQPb5x33+NRKb+QgxRj2jF8RJts8FejvNo+o8PmpkINKLj3pPm l7/NQ1RdSUYnqjShpLgjVCiblp/7D1OK9j8iPMhWgy2Glo7RLhtfLjfMejbKdzGPa/CcCmxtkTj aJxqXTaaP74u9/vANODKzyqemU4tgdinNuOXxtHMZkQRBCMuuKsSaapvnc2lwt2tFscjs3b83YC ilsqljuJEg4ZFDOi+quUM0WxOoqDkTwqp7yukdB2UigcwymJGzhcyJ4NtBoi0mZHvhGPB+Au4Vf Awv2nVFkh9jtglmFIMEwPUDeMWuzd07qu0MkYYmbkY7dy0W3nlwNQGY8IA2HUO7lAFl3znzDIfJ TJjbiZWt X-Authority-Analysis: v=2.4 cv=VZn3PEp9 c=1 sm=1 tr=0 ts=68c2986d cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=yJojWOMRYYMA:10 a=EUspDBNiAAAA:8 a=_wMi7B_O7ukW3LTXVV0A:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-GUID: 1EjRvpBROiDedo6VpD_vHK9LlZrv3NVP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-10_04,2025-09-11_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 adultscore=0 suspectscore=0 bulkscore=0 spamscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2509110074 The static TPDM function as a dummy source, however, it is essential to enable the port connected to the TPDA and configure the element size. Without this, the TPDA cannot correctly receive trace data from the static TPDM. Since the static TPDM does not require MMIO mapping to access its registers, a clock controller is not mandatory for its operation. Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-tpda.c | 9 ++ drivers/hwtracing/coresight/coresight-tpdm.c | 148 +++++++++++++++++++++--= ---- drivers/hwtracing/coresight/coresight-tpdm.h | 8 ++ 3 files changed, 131 insertions(+), 34 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtraci= ng/coresight/coresight-tpda.c index 333b3cb23685..4e93fa5bace4 100644 --- a/drivers/hwtracing/coresight/coresight-tpda.c +++ b/drivers/hwtracing/coresight/coresight-tpda.c @@ -68,6 +68,15 @@ static int tpdm_read_element_size(struct tpda_drvdata *d= rvdata, int rc =3D -EINVAL; struct tpdm_drvdata *tpdm_data =3D dev_get_drvdata(csdev->dev.parent); =20 + if (coresight_is_static_tpdm(csdev)) { + rc =3D fwnode_property_read_u32(dev_fwnode(csdev->dev.parent), + "qcom,dsb-element-bits", &drvdata->dsb_esize); + rc &=3D fwnode_property_read_u32(dev_fwnode(csdev->dev.parent), + "qcom,cmb-element-bits", &drvdata->cmb_esize); + + goto out; + } + if (tpdm_data->dsb) { rc =3D fwnode_property_read_u32(dev_fwnode(csdev->dev.parent), "qcom,dsb-element-bits", &drvdata->dsb_esize); diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtraci= ng/coresight/coresight-tpdm.c index 7214e65097ec..1766b0182819 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -495,7 +495,9 @@ static int tpdm_enable(struct coresight_device *csdev, = struct perf_event *event, return -EBUSY; } =20 - __tpdm_enable(drvdata); + if (!coresight_is_static_tpdm(csdev)) + __tpdm_enable(drvdata); + drvdata->enable =3D true; spin_unlock(&drvdata->spinlock); =20 @@ -551,7 +553,9 @@ static void tpdm_disable(struct coresight_device *csdev, return; } =20 - __tpdm_disable(drvdata); + if (!coresight_is_static_tpdm(csdev)) + __tpdm_disable(drvdata); + coresight_set_mode(csdev, CS_MODE_DISABLED); drvdata->enable =3D false; spin_unlock(&drvdata->spinlock); @@ -1342,10 +1346,9 @@ static const struct attribute_group *tpdm_attr_grps[= ] =3D { NULL, }; =20 -static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) +static int tpdm_probe(struct device *dev, struct resource *res) { void __iomem *base; - struct device *dev =3D &adev->dev; struct coresight_platform_data *pdata; struct tpdm_drvdata *drvdata; struct coresight_desc desc =3D { 0 }; @@ -1354,32 +1357,33 @@ static int tpdm_probe(struct amba_device *adev, con= st struct amba_id *id) pdata =3D coresight_get_platform_data(dev); if (IS_ERR(pdata)) return PTR_ERR(pdata); - adev->dev.platform_data =3D pdata; + dev->platform_data =3D pdata; =20 /* driver data*/ drvdata =3D devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; - drvdata->dev =3D &adev->dev; + drvdata->dev =3D dev; dev_set_drvdata(dev, drvdata); =20 - base =3D devm_ioremap_resource(dev, &adev->res); - if (IS_ERR(base)) - return PTR_ERR(base); + if (res) { + base =3D devm_ioremap_resource(dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); =20 - drvdata->base =3D base; + drvdata->base =3D base; + ret =3D tpdm_datasets_setup(drvdata); + if (ret) + return ret; =20 - ret =3D tpdm_datasets_setup(drvdata); - if (ret) - return ret; + if (drvdata && tpdm_has_dsb_dataset(drvdata)) + of_property_read_u32(drvdata->dev->of_node, + "qcom,dsb-msrs-num", &drvdata->dsb_msr_num); =20 - if (drvdata && tpdm_has_dsb_dataset(drvdata)) - of_property_read_u32(drvdata->dev->of_node, - "qcom,dsb-msrs-num", &drvdata->dsb_msr_num); - - if (drvdata && tpdm_has_cmb_dataset(drvdata)) - of_property_read_u32(drvdata->dev->of_node, - "qcom,cmb-msrs-num", &drvdata->cmb_msr_num); + if (drvdata && tpdm_has_cmb_dataset(drvdata)) + of_property_read_u32(drvdata->dev->of_node, + "qcom,cmb-msrs-num", &drvdata->cmb_msr_num); + } =20 /* Set up coresight component description */ desc.name =3D coresight_alloc_device_name(&tpdm_devs, dev); @@ -1388,34 +1392,51 @@ static int tpdm_probe(struct amba_device *adev, con= st struct amba_id *id) desc.type =3D CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype =3D CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM; desc.ops =3D &tpdm_cs_ops; - desc.pdata =3D adev->dev.platform_data; - desc.dev =3D &adev->dev; + desc.pdata =3D dev->platform_data; + desc.dev =3D dev; desc.access =3D CSDEV_ACCESS_IOMEM(base); - desc.groups =3D tpdm_attr_grps; + if (res) + desc.groups =3D tpdm_attr_grps; drvdata->csdev =3D coresight_register(&desc); if (IS_ERR(drvdata->csdev)) return PTR_ERR(drvdata->csdev); =20 spin_lock_init(&drvdata->spinlock); =20 - /* Decrease pm refcount when probe is done.*/ - pm_runtime_put(&adev->dev); - return 0; } =20 -static void tpdm_remove(struct amba_device *adev) +static int tpdm_remove(struct device *dev) { - struct tpdm_drvdata *drvdata =3D dev_get_drvdata(&adev->dev); + struct tpdm_drvdata *drvdata =3D dev_get_drvdata(dev); =20 coresight_unregister(drvdata->csdev); + + return 0; +} + +static int dynamic_tpdm_probe(struct amba_device *adev, + const struct amba_id *id) +{ + int ret; + + ret =3D tpdm_probe(&adev->dev, &adev->res); + if (!ret) + pm_runtime_put(&adev->dev); + + return ret; +} + +static void dynamic_tpdm_remove(struct amba_device *adev) +{ + tpdm_remove(&adev->dev); } =20 /* * Different TPDM has different periph id. * The difference is 0-7 bits' value. So ignore 0-7 bits. */ -static const struct amba_id tpdm_ids[] =3D { +static const struct amba_id dynamic_tpdm_ids[] =3D { { .id =3D 0x001f0e00, .mask =3D 0x00ffff00, @@ -1423,17 +1444,76 @@ static const struct amba_id tpdm_ids[] =3D { { 0, 0, NULL }, }; =20 -static struct amba_driver tpdm_driver =3D { +MODULE_DEVICE_TABLE(amba, dynamic_tpdm_ids); + +static struct amba_driver dynamic_tpdm_driver =3D { .drv =3D { .name =3D "coresight-tpdm", .suppress_bind_attrs =3D true, }, - .probe =3D tpdm_probe, - .id_table =3D tpdm_ids, - .remove =3D tpdm_remove, + .probe =3D dynamic_tpdm_probe, + .id_table =3D dynamic_tpdm_ids, + .remove =3D dynamic_tpdm_remove, }; =20 -module_amba_driver(tpdm_driver); +static int tpdm_platform_probe(struct platform_device *pdev) +{ + struct resource *res =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); + int ret; + + pm_runtime_get_noresume(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + + ret =3D tpdm_probe(&pdev->dev, res); + pm_runtime_put(&pdev->dev); + if (ret) + pm_runtime_disable(&pdev->dev); + + return ret; +} + +static void tpdm_platform_remove(struct platform_device *pdev) +{ + struct tpdm_drvdata *drvdata =3D dev_get_drvdata(&pdev->dev); + + if (WARN_ON(!drvdata)) + return; + + tpdm_remove(&pdev->dev); + pm_runtime_disable(&pdev->dev); +} + +static const struct of_device_id static_tpdm_match[] =3D { + {.compatible =3D "qcom,coresight-static-tpdm"}, + {} +}; + +MODULE_DEVICE_TABLE(of, static_tpdm_match); + +static struct platform_driver static_tpdm_driver =3D { + .probe =3D tpdm_platform_probe, + .remove =3D tpdm_platform_remove, + .driver =3D { + .name =3D "coresight-static-tpdm", + .of_match_table =3D static_tpdm_match, + .suppress_bind_attrs =3D true, + }, +}; + +static int __init tpdm_init(void) +{ + return coresight_init_driver("tpdm", &dynamic_tpdm_driver, &static_tpdm_d= river, + THIS_MODULE); +} + +static void __exit tpdm_exit(void) +{ + coresight_remove_driver(&dynamic_tpdm_driver, &static_tpdm_driver); +} + +module_init(tpdm_init); +module_exit(tpdm_exit); =20 MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Trace, Profiling & Diagnostic Monitor driver"); diff --git a/drivers/hwtracing/coresight/coresight-tpdm.h b/drivers/hwtraci= ng/coresight/coresight-tpdm.h index b11754389734..9f52c88ce5c1 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.h +++ b/drivers/hwtracing/coresight/coresight-tpdm.h @@ -343,4 +343,12 @@ struct tpdm_dataset_attribute { enum dataset_mem mem; u32 idx; }; + +static inline bool coresight_is_static_tpdm(struct coresight_device *csdev) +{ + struct device_node *node =3D csdev->dev.parent->of_node; + + return (csdev && + of_device_is_compatible(node, "qcom,coresight-static-tpdm")); +} #endif /* _CORESIGHT_CORESIGHT_TPDM_H */ --=20 2.34.1