From nobody Wed Feb 11 10:35:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09923C7618D for ; Thu, 16 Mar 2023 03:26:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229886AbjCPD0u (ORCPT ); Wed, 15 Mar 2023 23:26:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjCPD0X (ORCPT ); Wed, 15 Mar 2023 23:26:23 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5809A8832; Wed, 15 Mar 2023 20:24:37 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32G2qaWM030232; Thu, 16 Mar 2023 03:20:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=qcppdkim1; bh=AZfr8iUqFAQKPj5UxBH4iMO+y0HoGZiTkfSP+9OXdOE=; b=j1Oz52FY2qhtKRCmbaXsYKPGssDamWtTJ0fs48m2qNNzUbbyrUygDv87LL25u/+bl6wG 3b404IMHdIeYA0qkoTCcEUH4X7qwGam9elyfCjGOOqXTZuBZzVxS54/4Ya30UykpskH3 LuhWzHFMkNmGkCQc7ADxeXjKE1fsxxvCbK4PfHh4WkBhZGjIR75lNY2i1WAU4BxDZJ/Z vo4o6pOCWtfPC3EDicl5zXiVdivKX0Pnq9uB3+yaTlxEx15R2is2VNqx8JZ+dypfNatp QHNWZvA3q03XpemowK2HBo/1NibWgYbo97LbeHbNGcsuk9gdyCdkqmplCjyKmi9s9TcT 7A== Received: from aptaippmta01.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com [103.229.16.4]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pbpyd0gps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Mar 2023 03:20:22 +0000 Received: from pps.filterd (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTP id 32G3KI4q006432; Thu, 16 Mar 2023 03:20:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 3p8jqmenmm-1; Thu, 16 Mar 2023 03:20:18 +0000 Received: from APTAIPPMTA01.qualcomm.com (APTAIPPMTA01.qualcomm.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32G3KI9j006427; Thu, 16 Mar 2023 03:20:18 GMT Received: from hazha-gv.ap.qualcomm.com (hazha-gv.qualcomm.com [10.239.105.144]) by APTAIPPMTA01.qualcomm.com (PPS) with ESMTP id 32G3KIIk006425; Thu, 16 Mar 2023 03:20:18 +0000 Received: by hazha-gv.ap.qualcomm.com (Postfix, from userid 4083943) id 724EB1200077; Thu, 16 Mar 2023 11:20:17 +0800 (CST) From: Hao Zhang To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Konrad Dybcio , Mike Leach , Rob Herring , Krzysztof Kozlowski , Andy Gross , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jonathan Corbet Cc: Hao Zhang , Leo Yan , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Tingwei Zhang , Jinlong Mao , Yuanfang Zhang , Tao Zhang , Trilok Soni , linux-arm-msm@vger.kernel.org, Bjorn Andersson , linux-doc@vger.kernel.org Subject: [PATCH v1 1/3] Coresight: Add coresight dummy driver Date: Thu, 16 Mar 2023 11:20:03 +0800 Message-Id: <20230316032005.6509-2-quic_hazha@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230316032005.6509-1-quic_hazha@quicinc.com> References: <20230316032005.6509-1-quic_hazha@quicinc.com> X-QCInternal: smtphost X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: UmtQsPWuSk_d_bcFzhtl3XWlN__Fj9Y9 X-Proofpoint-ORIG-GUID: UmtQsPWuSk_d_bcFzhtl3XWlN__Fj9Y9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-16_02,2023-03-15_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 priorityscore=1501 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303160028 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some Coresight devices that HLOS don't have permission to access or configure. Such as Coresight sink EUD, some TPDMs etc. So there need driver to register dummy devices as Coresight devices. Provide Coresight API for dummy device operations, such as enabling and disabling dummy devices. Build the Coresight path for dummy sink or dummy source for debugging. Signed-off-by: Hao Zhang --- drivers/hwtracing/coresight/Kconfig | 11 ++ drivers/hwtracing/coresight/Makefile | 1 + drivers/hwtracing/coresight/coresight-dummy.c | 176 ++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 drivers/hwtracing/coresight/coresight-dummy.c diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresi= ght/Kconfig index 2b5bbfffbc4f..06f0a7594169 100644 --- a/drivers/hwtracing/coresight/Kconfig +++ b/drivers/hwtracing/coresight/Kconfig @@ -236,4 +236,15 @@ config CORESIGHT_TPDA =20 To compile this driver as a module, choose M here: the module will be called coresight-tpda. + +config CORESIGHT_DUMMY + tristate "Dummy driver support" + help + Enables support for dummy driver. Dummy driver can be used for + CoreSight sources/sinks that are owned and configured by some + other subsystem and use Linux drivers to configure rest of trace + path. + + To compile this driver as a module, choose M here: the module will be + called coresight-dummy. endif diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/cores= ight/Makefile index 33bcc3f7b8ae..995d3b2c76df 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -30,3 +30,4 @@ obj-$(CONFIG_CORESIGHT_TPDA) +=3D coresight-tpda.o coresight-cti-y :=3D coresight-cti-core.o coresight-cti-platform.o \ coresight-cti-sysfs.o obj-$(CONFIG_ULTRASOC_SMB) +=3D ultrasoc-smb.o +obj-$(CONFIG_CORESIGHT_DUMMY) +=3D coresight-dummy.o diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtrac= ing/coresight/coresight-dummy.c new file mode 100644 index 000000000000..d06baafb77da --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-dummy.c @@ -0,0 +1,176 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include "coresight-priv.h" +#include "coresight-trace-id.h" + +struct dummy_drvdata { + struct device *dev; + struct coresight_device *csdev; + int traceid; +}; + +DEFINE_CORESIGHT_DEVLIST(dummy_devs, "dummy"); + +static int dummy_source_enable(struct coresight_device *csdev, + struct perf_event *event, u32 mode) +{ + struct dummy_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); + + dev_info(drvdata->dev, "Dummy source enabled\n"); + + return 0; +} + +static void dummy_source_disable(struct coresight_device *csdev, + struct perf_event *event) +{ + struct dummy_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); + + dev_info(drvdata->dev, "Dummy source disabled\n"); +} + +static int dummy_sink_enable(struct coresight_device *csdev, u32 mode, + void *data) +{ + struct dummy_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); + + dev_info(drvdata->dev, "Dummy sink enabled\n"); + + return 0; +} + +static int dummy_sink_disable(struct coresight_device *csdev) +{ + struct dummy_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); + + dev_info(drvdata->dev, "Dummy sink disabled\n"); + + return 0; +} + +static const struct coresight_ops_source dummy_source_ops =3D { + .enable =3D dummy_source_enable, + .disable =3D dummy_source_disable, +}; + +static const struct coresight_ops_sink dummy_sink_ops =3D { + .enable =3D dummy_sink_enable, + .disable =3D dummy_sink_disable, +}; + +static const struct coresight_ops dummy_cs_ops =3D { + .source_ops =3D &dummy_source_ops, + .sink_ops =3D &dummy_sink_ops, +}; + +static int dummy_probe(struct platform_device *pdev) +{ + int ret, trace_id; + struct device *dev =3D &pdev->dev; + struct coresight_platform_data *pdata; + struct dummy_drvdata *drvdata; + struct coresight_desc desc =3D { 0 }; + + desc.name =3D coresight_alloc_device_name(&dummy_devs, dev); + if (!desc.name) + return -ENOMEM; + + pdata =3D coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + pdev->dev.platform_data =3D pdata; + + drvdata =3D devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + drvdata->dev =3D &pdev->dev; + platform_set_drvdata(pdev, drvdata); + + if (of_property_read_bool(pdev->dev.of_node, "qcom,dummy-source")) { + desc.type =3D CORESIGHT_DEV_TYPE_SOURCE; + desc.subtype.source_subtype =3D + CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS; + } else if (of_property_read_bool(pdev->dev.of_node, + "qcom,dummy-sink")) { + desc.type =3D CORESIGHT_DEV_TYPE_SINK; + desc.subtype.sink_subtype =3D CORESIGHT_DEV_SUBTYPE_SINK_BUFFER; + } else { + dev_info(dev, "Device type not set\n"); + return -EINVAL; + } + + desc.ops =3D &dummy_cs_ops; + desc.pdata =3D pdev->dev.platform_data; + desc.dev =3D &pdev->dev; + drvdata->csdev =3D coresight_register(&desc); + if (IS_ERR(drvdata->csdev)) + return PTR_ERR(drvdata->csdev); + + trace_id =3D coresight_trace_id_get_system_id(); + if (trace_id < 0) { + ret =3D trace_id; + goto cs_unregister; + } + drvdata->traceid =3D (u8)trace_id; + + pm_runtime_enable(dev); + dev_info(dev, "Dummy device initialized\n"); + + return 0; + +cs_unregister: + coresight_unregister(drvdata->csdev); + + return ret; +} + +static int dummy_remove(struct platform_device *pdev) +{ + struct dummy_drvdata *drvdata =3D platform_get_drvdata(pdev); + struct device *dev =3D &pdev->dev; + + coresight_trace_id_put_system_id(drvdata->traceid); + pm_runtime_disable(dev); + coresight_unregister(drvdata->csdev); + return 0; +} + +static const struct of_device_id dummy_match[] =3D { + {.compatible =3D "qcom,coresight-dummy"}, + {}, +}; + +static struct platform_driver dummy_driver =3D { + .probe =3D dummy_probe, + .remove =3D dummy_remove, + .driver =3D { + .name =3D "coresight-dummy", + .of_match_table =3D dummy_match, + }, +}; + +int __init dummy_init(void) +{ + return platform_driver_register(&dummy_driver); +} +module_init(dummy_init); + +void __exit dummy_exit(void) +{ + platform_driver_unregister(&dummy_driver); +} +module_exit(dummy_exit); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("CoreSight dummy source driver"); --=20 2.17.1