From nobody Sat Nov 30 16:43:05 2024 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 E61D636B11; Mon, 9 Sep 2024 03:35:58 +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=1725852960; cv=none; b=MD1uE28NFJZD+0cuQVRcK0zARjFEUEK2MFhhbVpOJRwcbZraF3ebYn43Kn6RvjfhWhVVtIuzy3sWKiLpaNshrSj+54lzeqQdZJ+nA+tfrFJTT5TbWc+Q5uGI2tVqplgJtE0z9gH7CVlS/FmzdfJhoxW45ukeyiel422AFSv37Sg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725852960; c=relaxed/simple; bh=aHA0iUWPEFT3IbFR1TA1T8dPf/5fafb10xlp4mn+2Ck=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J5Hknwmvcgk4oafwplSlq3+q97L6ju+MKB0slovPtFLqa+FYK4hcu4Qf4ThhL6bvcBINk/GBFi2KCDGgByAWiFSj9AsP90WQMZAcHjMy715ChCH0tH4jR0y8vQFO01aJWR/81PKLicRlRcDZXrauwAHs2HLZqhRjGXPPENBPnTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=HVZGdhOg; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="HVZGdhOg" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4890AcMC028161; Mon, 9 Sep 2024 03:35:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Vz5/kcDxtEOju7Z676DeiXJmEA1JXEODXPhijTBJr1U=; b=HVZGdhOgrwGzX+En s2WZymbfFYc4U6mhP5AnCDWSueSsI+ufcIMsnZhmzFHeqUna8f5ifuR5Gm/3hLaQ uRkawm8NDd4b55MigWVw3wnEYaRpwVpADac0XIEnVjMU74CyUbvXMFwNqNq3tANp 9WRXbmrgoS5Dy0XXoDrgHFAAJMmpzYRO2OW2caBZErHhB+mXdbzdCJg3t79zP0yY a7jBj9MunFwB5tYWfF8u2lGFt6lj5r9F43g7xEptptnbFaP1+/Vi9wy+Dj4ZNJQh ANdT8Q7LWgtom8ix2BZ/2KF8ZLHZhAEey7KxrrFLXUMlDro4buHYD/7ZAPzfFbHU UCMr6Q== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy5r9je9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Sep 2024 03:35:25 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4893ZOx4016125 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Sep 2024 03:35:24 GMT Received: from jiegan-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 8 Sep 2024 20:35:18 -0700 From: Jie Gan To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio CC: Jinlong Mao , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Song Chai , , Subject: [PATCH v5 1/5] Coresight: Add support for new APB clock name Date: Mon, 9 Sep 2024 11:34:54 +0800 Message-ID: <20240909033458.3118238-2-quic_jiegan@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909033458.3118238-1-quic_jiegan@quicinc.com> References: <20240909033458.3118238-1-quic_jiegan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: DQtWWWpCOoDVm4lbRX-_LfktE2QTOsu1 X-Proofpoint-ORIG-GUID: DQtWWWpCOoDVm4lbRX-_LfktE2QTOsu1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 clxscore=1015 malwarescore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 mlxscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=931 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409090027 Content-Type: text/plain; charset="utf-8" Add support for new APB clock-name. If the function fails to obtain the clock with the name "apb_pclk", it will attempt to acquire the clock with the name "apb". Signed-off-by: Jie Gan --- include/linux/coresight.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/coresight.h b/include/linux/coresight.h index c13342594278..497d2206419d 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -454,8 +454,11 @@ static inline struct clk *coresight_get_enable_apb_pcl= k(struct device *dev) int ret; =20 pclk =3D clk_get(dev, "apb_pclk"); - if (IS_ERR(pclk)) - return NULL; + if (IS_ERR(pclk)) { + pclk =3D clk_get(dev, "apb"); + if (IS_ERR(pclk)) + return NULL; + } =20 ret =3D clk_prepare_enable(pclk); if (ret) { --=20 2.34.1 From nobody Sat Nov 30 16:43:05 2024 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 E3F1218AEA; Mon, 9 Sep 2024 03:35:58 +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=1725852961; cv=none; b=JNnUoL8HPi+V5DytdkSm3y1fMoLycA5BFuAXqMJY0Hz0cBoh3Em5wLtqdjE8CKmFxjKCltxtCJtxxbEX9CNtIyHzNCqRfTU5WBLankoxh2GeELvCSGnifHAnT6hZlXdxsox0bfZIvfcAtSaJhtpjTfuZKzb31bVBzxmnQhUQtkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725852961; c=relaxed/simple; bh=YzlLYgQNMQsRCYBqt2nthluRVMWYhNj8fhQIEuOvPEI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SJQB0+fk8V8S69eLZtX2L5o3wsPxRlAKhRogPqMdfo/c9eXCszUrzwaJ+3Uxn1pkOdleJmSj4sQ1G3GrqEVubFI1QBY0h342xS6E78jfVdaA8Dkbx2l5z8zSxcqz+dfTTWZgX6YM/ZFb+cjB08cOkUAvnzXXx/ms4BmQK1u72H8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=SI22xZdH; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="SI22xZdH" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 488MSefJ010982; Mon, 9 Sep 2024 03:35:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= aTAVsJNMtBUHJFJnsWQCbyFT+QeZjAsFI4J74CVPKiw=; b=SI22xZdHDqFhIC7S bn9+oHnhzeLqAeKk01Cbe2GrC6uKhgzJVhQotpE80NeQ3N3f/NRMzbXWVaNP2lJv u6Z9JVyYhtjlWFk5E8sLlaNArTyQ9q6DVUYXh7T7knxjUM3SW0pNSBbWPLS/KYM9 dDaRrfat8hkdqoCaew9G16vjBVLCp6yrr4+1IbM6/ty4AgcIlYmanfni0JuYLfro D2PVXFTtIDfCM1WgSqu8TAlc45we1DzL67TMlN7EPdEDkqDOG98XHVGaIlhjpS0h ze8uLfYZrtq15u3lZkyZHkcyYQoxqCGjdDxY1ISF6DE+gG8xrobfonexyePxBlKq +QOLOw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy8nsjk8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Sep 2024 03:35:31 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4893ZUdT001137 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Sep 2024 03:35:30 GMT Received: from jiegan-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 8 Sep 2024 20:35:24 -0700 From: Jie Gan To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio CC: Jinlong Mao , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Song Chai , , Subject: [PATCH v5 2/5] Coresight: Add trace_id function to retrieving the trace ID Date: Mon, 9 Sep 2024 11:34:55 +0800 Message-ID: <20240909033458.3118238-3-quic_jiegan@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909033458.3118238-1-quic_jiegan@quicinc.com> References: <20240909033458.3118238-1-quic_jiegan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: SmNZA01q608ELC1p4P6bX1Tu_bdlTIWd X-Proofpoint-ORIG-GUID: SmNZA01q608ELC1p4P6bX1Tu_bdlTIWd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409090027 Content-Type: text/plain; charset="utf-8" Add 'trace_id' function pointer in ops. It's responsible for retrieving the device's trace ID. Add 'struct cs_sink_data' to store the data that is needed by coresight_enable_path/coresight_disable_path. The structure will be transmitted to the helper and sink device to enable related funcationalities. Depends-on: commit 743e3154674f ("coresight: Use per-sink trace ID maps for Perf sessions") Depends-on: commit 4b5809ca2a8b ("coresight: Make CPU id map a property of a trace ID map") Depends-on: commit ef050fc3606e ("coresight: Expose map arguments in trace ID API") Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-core.c | 59 +++++++++++++++---- drivers/hwtracing/coresight/coresight-etb10.c | 3 +- .../hwtracing/coresight/coresight-etm-perf.c | 37 ++++++++++-- .../coresight/coresight-etm3x-core.c | 30 ++++++++++ .../coresight/coresight-etm4x-core.c | 29 +++++++++ drivers/hwtracing/coresight/coresight-priv.h | 13 +++- drivers/hwtracing/coresight/coresight-stm.c | 22 +++++++ drivers/hwtracing/coresight/coresight-sysfs.c | 24 +++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 3 +- .../hwtracing/coresight/coresight-tmc-etr.c | 6 +- drivers/hwtracing/coresight/coresight-tpda.c | 20 +++++++ drivers/hwtracing/coresight/coresight-trbe.c | 4 +- drivers/hwtracing/coresight/ultrasoc-smb.c | 3 +- include/linux/coresight.h | 6 ++ 14 files changed, 234 insertions(+), 25 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtraci= ng/coresight/coresight-core.c index ea38ecf26fcb..ac5dd4a43798 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -23,6 +23,7 @@ #include "coresight-etm-perf.h" #include "coresight-priv.h" #include "coresight-syscfg.h" +#include "coresight-trace-id.h" =20 /* * Mutex used to lock all sysfs enable and disable actions and loading and @@ -297,12 +298,12 @@ static int coresight_enable_helper(struct coresight_d= evice *csdev, return helper_ops(csdev)->enable(csdev, mode, data); } =20 -static void coresight_disable_helper(struct coresight_device *csdev) +static void coresight_disable_helper(struct coresight_device *csdev, void = *data) { - helper_ops(csdev)->disable(csdev, NULL); + helper_ops(csdev)->disable(csdev, data); } =20 -static void coresight_disable_helpers(struct coresight_device *csdev) +static void coresight_disable_helpers(struct coresight_device *csdev, void= *data) { int i; struct coresight_device *helper; @@ -310,7 +311,7 @@ static void coresight_disable_helpers(struct coresight_= device *csdev) for (i =3D 0; i < csdev->pdata->nr_outconns; ++i) { helper =3D csdev->pdata->out_conns[i]->dest_dev; if (helper && coresight_is_helper(helper)) - coresight_disable_helper(helper); + coresight_disable_helper(helper, data); } } =20 @@ -327,7 +328,7 @@ static void coresight_disable_helpers(struct coresight_= device *csdev) void coresight_disable_source(struct coresight_device *csdev, void *data) { source_ops(csdev)->disable(csdev, data); - coresight_disable_helpers(csdev); + coresight_disable_helpers(csdev, NULL); } EXPORT_SYMBOL_GPL(coresight_disable_source); =20 @@ -337,7 +338,8 @@ EXPORT_SYMBOL_GPL(coresight_disable_source); * disabled. */ static void coresight_disable_path_from(struct list_head *path, - struct coresight_node *nd) + struct coresight_node *nd, + void *sink_data) { u32 type; struct coresight_device *csdev, *parent, *child; @@ -382,13 +384,13 @@ static void coresight_disable_path_from(struct list_h= ead *path, } =20 /* Disable all helpers adjacent along the path last */ - coresight_disable_helpers(csdev); + coresight_disable_helpers(csdev, sink_data); } } =20 -void coresight_disable_path(struct list_head *path) +void coresight_disable_path(struct list_head *path, void *sink_data) { - coresight_disable_path_from(path, NULL); + coresight_disable_path_from(path, NULL, sink_data); } EXPORT_SYMBOL_GPL(coresight_disable_path); =20 @@ -468,10 +470,47 @@ int coresight_enable_path(struct list_head *path, enu= m cs_mode mode, out: return ret; err: - coresight_disable_path_from(path, nd); + coresight_disable_path_from(path, nd, sink_data); goto out; } =20 +int coresight_read_traceid(struct list_head *path, enum cs_mode mode, + struct coresight_trace_id_map *id_map) +{ + int trace_id, type; + struct coresight_device *csdev; + struct coresight_node *nd; + + list_for_each_entry(nd, path, link) { + csdev =3D nd->csdev; + type =3D csdev->type; + + switch (type) { + case CORESIGHT_DEV_TYPE_SOURCE: + if (source_ops(csdev)->trace_id !=3D NULL) { + trace_id =3D source_ops(csdev)->trace_id(csdev, + mode, + id_map); + if (IS_VALID_CS_TRACE_ID(trace_id)) + goto out; + } + break; + case CORESIGHT_DEV_TYPE_LINK: + if (link_ops(csdev)->trace_id !=3D NULL) { + trace_id =3D link_ops(csdev)->trace_id(csdev); + if (IS_VALID_CS_TRACE_ID(trace_id)) + goto out; + } + break; + default: + break; + } + } + return -EINVAL; +out: + return trace_id; +} + struct coresight_device *coresight_get_sink(struct list_head *path) { struct coresight_device *csdev; diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtrac= ing/coresight/coresight-etb10.c index 7edd3f1d0d46..05e620529c14 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -173,7 +173,8 @@ static int etb_enable_perf(struct coresight_device *csd= ev, void *data) pid_t pid; unsigned long flags; struct etb_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); - struct perf_output_handle *handle =3D data; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + struct perf_output_handle *handle =3D sink_data->handle; struct cs_buffers *buf =3D etm_perf_sink_config(handle); =20 spin_lock_irqsave(&drvdata->spinlock, flags); diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwt= racing/coresight/coresight-etm-perf.c index ad6a8f4b70b6..e676edd42ddc 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -459,6 +459,7 @@ static void etm_event_start(struct perf_event *event, i= nt flags) struct perf_output_handle *handle =3D &ctxt->handle; struct coresight_device *sink, *csdev =3D per_cpu(csdev_src, cpu); struct list_head *path; + struct cs_sink_data *sink_data =3D NULL; u64 hw_id; u8 trace_id; =20 @@ -498,9 +499,20 @@ static void etm_event_start(struct perf_event *event, = int flags) if (WARN_ON_ONCE(!sink)) goto fail_end_stop; =20 + sink_data =3D kzalloc(sizeof(*sink_data), GFP_KERNEL); + if (!sink_data) + goto fail_end_stop; + + sink_data->sink =3D sink; + sink_data->traceid =3D coresight_read_traceid(path, CS_MODE_PERF, + &sink->perf_sink_id_map); + sink_data->handle =3D handle; + /* Nothing will happen without a path */ - if (coresight_enable_path(path, CS_MODE_PERF, handle)) + if (coresight_enable_path(path, CS_MODE_PERF, sink_data)) { + kfree(sink_data); goto fail_end_stop; + } =20 /* Finally enable the tracer */ if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF, @@ -526,6 +538,7 @@ static void etm_event_start(struct perf_event *event, i= nt flags) perf_report_aux_output_id(event, hw_id); } =20 + kfree(sink_data); out: /* Tell the perf core the event is alive */ event->hw.state =3D 0; @@ -534,7 +547,8 @@ static void etm_event_start(struct perf_event *event, i= nt flags) return; =20 fail_disable_path: - coresight_disable_path(path); + coresight_disable_path(path, sink_data); + kfree(sink_data); fail_end_stop: /* * Check if the handle is still associated with the event, @@ -559,6 +573,7 @@ static void etm_event_stop(struct perf_event *event, in= t mode) struct perf_output_handle *handle =3D &ctxt->handle; struct etm_event_data *event_data; struct list_head *path; + struct cs_sink_data *sink_data =3D NULL; =20 /* * If we still have access to the event_data via handle, @@ -603,6 +618,10 @@ static void etm_event_stop(struct perf_event *event, i= nt mode) if (!sink) return; =20 + sink_data =3D kzalloc(sizeof(*sink_data), GFP_KERNEL); + if (!sink_data) + return; + /* stop tracer */ coresight_disable_source(csdev, event); =20 @@ -616,12 +635,16 @@ static void etm_event_stop(struct perf_event *event, = int mode) * have to do anything here. */ if (handle->event && (mode & PERF_EF_UPDATE)) { - if (WARN_ON_ONCE(handle->event !=3D event)) + if (WARN_ON_ONCE(handle->event !=3D event)) { + kfree(sink_data); return; + } =20 /* update trace information */ - if (!sink_ops(sink)->update_buffer) + if (!sink_ops(sink)->update_buffer) { + kfree(sink_data); return; + } =20 size =3D sink_ops(sink)->update_buffer(sink, handle, event_data->snk_config); @@ -642,8 +665,12 @@ static void etm_event_stop(struct perf_event *event, i= nt mode) WARN_ON(size); } =20 + sink_data->sink =3D sink; + sink_data->traceid =3D coresight_read_traceid(path, CS_MODE_PERF, + &sink->perf_sink_id_map); /* Disabling the path make its elements available to other sessions */ - coresight_disable_path(path); + coresight_disable_path(path, sink_data); + kfree(sink_data); } =20 static int etm_event_add(struct perf_event *event, int mode) diff --git a/drivers/hwtracing/coresight/coresight-etm3x-core.c b/drivers/h= wtracing/coresight/coresight-etm3x-core.c index c103f4c70f5d..0f095fab7e0a 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm3x-core.c @@ -697,10 +697,40 @@ static void etm_disable(struct coresight_device *csde= v, coresight_set_mode(csdev, CS_MODE_DISABLED); } =20 +static int etm_trace_id(struct coresight_device *csdev, + enum cs_mode mode, + struct coresight_trace_id_map *id_map) +{ + int trace_id; + struct etm_drvdata *drvdata; + + if (csdev =3D=3D NULL) + return -EINVAL; + + drvdata =3D dev_get_drvdata(csdev->dev.parent); + switch (mode) { + case CS_MODE_SYSFS: + trace_id =3D etm_read_alloc_trace_id(drvdata); + break; + case CS_MODE_PERF: + trace_id =3D coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); + if (IS_VALID_CS_TRACE_ID(trace_id)) + drvdata->traceid =3D (u8)trace_id; + break; + default: + trace_id =3D -EINVAL; + break; + } + + return trace_id; +} + + static const struct coresight_ops_source etm_source_ops =3D { .cpu_id =3D etm_cpu_id, .enable =3D etm_enable, .disable =3D etm_disable, + .trace_id =3D etm_trace_id, }; =20 static const struct coresight_ops etm_cs_ops =3D { diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/h= wtracing/coresight/coresight-etm4x-core.c index 66d44a404ad0..665611ab57a9 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -1025,10 +1025,39 @@ static void etm4_disable(struct coresight_device *c= sdev, coresight_set_mode(csdev, CS_MODE_DISABLED); } =20 +static int etm4_trace_id(struct coresight_device *csdev, + enum cs_mode mode, + struct coresight_trace_id_map *id_map) +{ + int trace_id; + struct etmv4_drvdata *drvdata; + + if (csdev =3D=3D NULL) + return -EINVAL; + + drvdata =3D dev_get_drvdata(csdev->dev.parent); + switch (mode) { + case CS_MODE_SYSFS: + trace_id =3D etm4_read_alloc_trace_id(drvdata); + break; + case CS_MODE_PERF: + trace_id =3D coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); + if (IS_VALID_CS_TRACE_ID(trace_id)) + drvdata->trcid =3D (u8)trace_id; + break; + default: + trace_id =3D -EINVAL; + break; + } + + return trace_id; +} + static const struct coresight_ops_source etm4_source_ops =3D { .cpu_id =3D etm4_cpu_id, .enable =3D etm4_enable, .disable =3D etm4_disable, + .trace_id =3D etm4_trace_id, }; =20 static const struct coresight_ops etm4_cs_ops =3D { diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtraci= ng/coresight/coresight-priv.h index 05f891ca6b5c..6a95a3ba9339 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -105,6 +105,15 @@ struct cs_buffers { void **data_pages; }; =20 +/** + * struct cs_sink_data - data used by coresight_enable_path/coresight_disa= ble_path + */ +struct cs_sink_data { + struct perf_output_handle *handle; + struct coresight_device *sink; + u8 traceid; +}; + static inline void coresight_insert_barrier_packet(void *buf) { if (buf) @@ -129,9 +138,11 @@ static inline void CS_UNLOCK(void __iomem *addr) } while (0); } =20 -void coresight_disable_path(struct list_head *path); +void coresight_disable_path(struct list_head *path, void *sink_data); int coresight_enable_path(struct list_head *path, enum cs_mode mode, void *sink_data); +int coresight_read_traceid(struct list_head *path, enum cs_mode mode, + struct coresight_trace_id_map *id_map); struct coresight_device *coresight_get_sink(struct list_head *path); struct coresight_device *coresight_get_sink_by_id(u32 id); struct coresight_device * diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracin= g/coresight/coresight-stm.c index cb3e04755c99..4975c1981f5d 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -281,9 +281,31 @@ static void stm_disable(struct coresight_device *csdev, } } =20 +static int stm_trace_id(struct coresight_device *csdev, + enum cs_mode mode, + struct coresight_trace_id_map *id_map) +{ + int trace_id; + struct stm_drvdata *drvdata; + + if (csdev =3D=3D NULL) + return -EINVAL; + + drvdata =3D dev_get_drvdata(csdev->dev.parent); + trace_id =3D drvdata->traceid; + if (!IS_VALID_CS_TRACE_ID(trace_id)) { + trace_id =3D coresight_trace_id_get_system_id(); + if (IS_VALID_CS_TRACE_ID(trace_id)) + drvdata->traceid =3D (u8)trace_id; + } + + return trace_id; +} + static const struct coresight_ops_source stm_source_ops =3D { .enable =3D stm_enable, .disable =3D stm_disable, + .trace_id =3D stm_trace_id, }; =20 static const struct coresight_ops stm_cs_ops =3D { diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtrac= ing/coresight/coresight-sysfs.c index a01c9e54e2ed..8816bccba374 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -168,6 +168,7 @@ int coresight_enable_sysfs(struct coresight_device *csd= ev) int cpu, ret =3D 0; struct coresight_device *sink; struct list_head *path; + struct cs_sink_data *sink_data; enum coresight_dev_subtype_source subtype; u32 hash; =20 @@ -209,7 +210,14 @@ int coresight_enable_sysfs(struct coresight_device *cs= dev) goto out; } =20 - ret =3D coresight_enable_path(path, CS_MODE_SYSFS, NULL); + sink_data =3D kzalloc(sizeof(*sink_data), GFP_KERNEL); + if (!sink_data) { + ret =3D -ENOMEM; + goto out; + } + sink_data->traceid =3D coresight_read_traceid(path, CS_MODE_SYSFS, NULL); + sink_data->sink =3D sink; + ret =3D coresight_enable_path(path, CS_MODE_SYSFS, sink_data); if (ret) goto err_path; =20 @@ -246,15 +254,17 @@ int coresight_enable_sysfs(struct coresight_device *c= sdev) break; } =20 + kfree(sink_data); out: mutex_unlock(&coresight_mutex); return ret; =20 err_source: - coresight_disable_path(path); + coresight_disable_path(path, sink_data); =20 err_path: coresight_release_path(path); + kfree(sink_data); goto out; } EXPORT_SYMBOL_GPL(coresight_enable_sysfs); @@ -263,6 +273,7 @@ void coresight_disable_sysfs(struct coresight_device *c= sdev) { int cpu, ret; struct list_head *path =3D NULL; + struct cs_sink_data *sink_data =3D NULL; u32 hash; =20 mutex_lock(&coresight_mutex); @@ -274,6 +285,10 @@ void coresight_disable_sysfs(struct coresight_device *= csdev) if (!coresight_disable_source_sysfs(csdev, NULL)) goto out; =20 + sink_data =3D kzalloc(sizeof(*sink_data), GFP_KERNEL); + if (!sink_data) + goto out; + switch (csdev->subtype.source_subtype) { case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC: cpu =3D source_ops(csdev)->cpu_id(csdev); @@ -297,8 +312,11 @@ void coresight_disable_sysfs(struct coresight_device *= csdev) break; } =20 - coresight_disable_path(path); + sink_data->sink =3D coresight_find_activated_sysfs_sink(csdev); + sink_data->traceid =3D coresight_read_traceid(path, CS_MODE_SYSFS, NULL); + coresight_disable_path(path, sink_data); coresight_release_path(path); + kfree(sink_data); =20 out: mutex_unlock(&coresight_mutex); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtr= acing/coresight/coresight-tmc-etf.c index d4f641cd9de6..7dc536eba3e2 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -250,7 +250,8 @@ static int tmc_enable_etf_sink_perf(struct coresight_de= vice *csdev, void *data) pid_t pid; unsigned long flags; struct tmc_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); - struct perf_output_handle *handle =3D data; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + struct perf_output_handle *handle =3D sink_data->handle; struct cs_buffers *buf =3D etm_perf_sink_config(handle); =20 spin_lock_irqsave(&drvdata->spinlock, flags); diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtr= acing/coresight/coresight-tmc-etr.c index 8962fc27d04f..73bb722e88b0 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -1254,7 +1254,8 @@ static int tmc_enable_etr_sink_sysfs(struct coresight= _device *csdev) struct etr_buf *tmc_etr_get_buffer(struct coresight_device *csdev, enum cs_mode mode, void *data) { - struct perf_output_handle *handle =3D data; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + struct perf_output_handle *handle =3D sink_data->handle; struct etr_perf_buffer *etr_perf; =20 switch (mode) { @@ -1648,7 +1649,8 @@ static int tmc_enable_etr_sink_perf(struct coresight_= device *csdev, void *data) pid_t pid; unsigned long flags; struct tmc_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); - struct perf_output_handle *handle =3D data; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + struct perf_output_handle *handle =3D sink_data->handle; struct etr_perf_buffer *etr_perf =3D etm_perf_sink_config(handle); =20 spin_lock_irqsave(&drvdata->spinlock, flags); diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtraci= ng/coresight/coresight-tpda.c index bfca103f9f84..0f47f85811f4 100644 --- a/drivers/hwtracing/coresight/coresight-tpda.c +++ b/drivers/hwtracing/coresight/coresight-tpda.c @@ -232,9 +232,29 @@ static void tpda_disable(struct coresight_device *csde= v, dev_dbg(drvdata->dev, "TPDA inport %d disabled\n", in->dest_port); } =20 +static int tpda_trace_id(struct coresight_device *csdev) +{ + int trace_id; + struct tpda_drvdata *drvdata; + + if (csdev =3D=3D NULL) + return -EINVAL; + + drvdata =3D dev_get_drvdata(csdev->dev.parent); + trace_id =3D drvdata->atid; + if (!IS_VALID_CS_TRACE_ID(trace_id)) { + trace_id =3D coresight_trace_id_get_system_id(); + if (IS_VALID_CS_TRACE_ID(trace_id)) + drvdata->atid =3D (u8)trace_id; + } + + return trace_id; +} + static const struct coresight_ops_link tpda_link_ops =3D { .enable =3D tpda_enable, .disable =3D tpda_disable, + .trace_id =3D tpda_trace_id, }; =20 static const struct coresight_ops tpda_cs_ops =3D { diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtraci= ng/coresight/coresight-trbe.c index 96a32b213669..7f4560b067a8 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -21,6 +21,7 @@ =20 #include "coresight-self-hosted-trace.h" #include "coresight-trbe.h" +#include "coresight-priv.h" =20 #define PERF_IDX2OFF(idx, buf) ((idx) % ((buf)->nr_pages << PAGE_SHIFT)) =20 @@ -1012,7 +1013,8 @@ static int arm_trbe_enable(struct coresight_device *c= sdev, enum cs_mode mode, { struct trbe_drvdata *drvdata =3D dev_get_drvdata(csdev->dev.parent); struct trbe_cpudata *cpudata =3D dev_get_drvdata(&csdev->dev); - struct perf_output_handle *handle =3D data; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + struct perf_output_handle *handle =3D sink_data->handle; struct trbe_buf *buf =3D etm_perf_sink_config(handle); =20 WARN_ON(cpudata->cpu !=3D smp_processor_id()); diff --git a/drivers/hwtracing/coresight/ultrasoc-smb.c b/drivers/hwtracing= /coresight/ultrasoc-smb.c index f9ebf20c91e6..92d8a9fb844e 100644 --- a/drivers/hwtracing/coresight/ultrasoc-smb.c +++ b/drivers/hwtracing/coresight/ultrasoc-smb.c @@ -217,7 +217,8 @@ static void smb_enable_sysfs(struct coresight_device *c= sdev) static int smb_enable_perf(struct coresight_device *csdev, void *data) { struct smb_drv_data *drvdata =3D dev_get_drvdata(csdev->dev.parent); - struct perf_output_handle *handle =3D data; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + struct perf_output_handle *handle =3D sink_data->handle; struct cs_buffers *buf =3D etm_perf_sink_config(handle); pid_t pid; =20 diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 497d2206419d..22b977908f4f 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -363,6 +363,7 @@ struct coresight_ops_sink { * Operations available for links. * @enable: enables flow between iport and oport. * @disable: disables flow between iport and oport. + * @trace_id: Collect the traceid. */ struct coresight_ops_link { int (*enable)(struct coresight_device *csdev, @@ -371,6 +372,7 @@ struct coresight_ops_link { void (*disable)(struct coresight_device *csdev, struct coresight_connection *in, struct coresight_connection *out); + int (*trace_id)(struct coresight_device *csdev); }; =20 /** @@ -380,6 +382,7 @@ struct coresight_ops_link { * is associated to. * @enable: enables tracing for a source. * @disable: disables tracing for a source. + * @trace_id: collect the traceid. */ struct coresight_ops_source { int (*cpu_id)(struct coresight_device *csdev); @@ -387,6 +390,9 @@ struct coresight_ops_source { enum cs_mode mode, struct coresight_trace_id_map *id_map); void (*disable)(struct coresight_device *csdev, struct perf_event *event); + int (*trace_id)(struct coresight_device *csdev, + enum cs_mode mode, + struct coresight_trace_id_map *id_map); }; =20 /** --=20 2.34.1 From nobody Sat Nov 30 16:43:05 2024 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 D1BAB1ACDE0; Mon, 9 Sep 2024 03:36: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=1725852962; cv=none; b=uzXIhIt1Rtgkgtg5pvmGM/mjL+eR7qENw9mhdetoHzVtNy/rtyNbI4Wfew6wQh3I+ygZkWYkWnv272GN9p2GZKrBlYJCApdlsIiaO6bS8i1LqUgS5JbSvpw4jWLA/Tn29S4FBciv7pfwqgzPLxi+wuvz4xwAPbQCARMpb/6OCUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725852962; c=relaxed/simple; bh=0ZWLle+C57j1TYiOQCo5iJEztCk7xTCz1FPwU/ne7pc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FdA6gA6i2D7RbbsxKrg9FbhAP0/OWd+5H7lfzPDkxxF0d2oBOKVDHly6eQ5x8HSKFf/+VrYFa0rvGUS90cBTEQDwqpsvd/rPTWzDz8c52CkPItZyhgBCovHwcZtsj1vufSUzv2ryEb5uyTZtpwuwIFwRqtvxoeUVIPYkcyEia5w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=mqMr6dzs; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mqMr6dzs" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4890LrvI007779; Mon, 9 Sep 2024 03:35:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= lAv+HvwlohKvnAUnYu+v3G5/3MXQD13BRoONTWtMgq0=; b=mqMr6dzslPxPiIag LGTyuyD9DXLkgR8dOKE4gar/UtVtoIIFpkfUpSUFrMshNmiz2b8eBXYi133uDbYO YJu7es+jEVNgTiePcV7mfQQW0HHN3QNlb4JS8xLJMLD0P1xezpJsQ8i+GaAzN7ca 5KulULiYyrbUg+q4DyGl2jhOJCJqMYIwXawpzq5VtgDKcWnI2g5wu75aunuY1uzN gzvfQDjwHy0XrRoZfRWmw8upxU2zAUpcByxQyiFisnkjJ0PdSGthTRG/Io7RDFoK hBk/ENP3y2eC69rSJhnWuKKeAtqKPJ2pjaDOMFzuaxIpEFSiQiACKRJTj06Yerl8 FSG9ew== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy7fhjx4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Sep 2024 03:35:37 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4893ZarQ016248 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Sep 2024 03:35:36 GMT Received: from jiegan-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 8 Sep 2024 20:35:30 -0700 From: Jie Gan To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio CC: Jinlong Mao , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Song Chai , , Subject: [PATCH v5 3/5] dt-bindings: arm: Add Coresight TMC Control Unit hardware Date: Mon, 9 Sep 2024 11:34:56 +0800 Message-ID: <20240909033458.3118238-4-quic_jiegan@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909033458.3118238-1-quic_jiegan@quicinc.com> References: <20240909033458.3118238-1-quic_jiegan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: Rvana_JGJOdSn4_U2dCDccrlEpV1Lsi8 X-Proofpoint-GUID: Rvana_JGJOdSn4_U2dCDccrlEpV1Lsi8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=1 phishscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409090027 Content-Type: text/plain; charset="utf-8" Add binding file to specify how to define a Coresight TMC Control Unit device in device tree. It is responsible for controlling the data filter function based on the source device's Trace ID for TMC ETR device. The trace data with that Trace id can get into ETR's buffer while other trace data gets ignored. Signed-off-by: Jie Gan Reviewed-by: Rob Herring (Arm) --- .../bindings/arm/qcom,coresight-ctcu.yaml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/qcom,coresight-ct= cu.yaml diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml= b/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml new file mode 100644 index 000000000000..843b52eaf872 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/qcom,coresight-ctcu.yaml @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/qcom,coresight-ctcu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CoreSight TMC Control Unit + +maintainers: + - Yuanfang Zhang + - Mao Jinlong + - Jie Gan + +description: | + The Trace Memory Controller(TMC) is used for Embedded Trace Buffer(ETB), + Embedded Trace FIFO(ETF) and Embedded Trace Router(ETR) configurations. + The configuration mode (ETB, ETF, ETR) is discovered at boot time when + the device is probed. + + The Coresight TMC Control unit controls various Coresight behaviors. + It works as a helper device when connected to TMC ETR device. + It is responsible for controlling the data filter function based on + the source device's Trace ID for TMC ETR device. The trace data with + that Trace id can get into ETR's buffer while other trace data gets + ignored. + +properties: + compatible: + enum: + - qcom,sa8775p-ctcu + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: apb + + in-ports: + $ref: /schemas/graph.yaml#/properties/ports + + patternProperties: + '^port(@[0-1])?$': + description: Input connections from CoreSight Trace bus + $ref: /schemas/graph.yaml#/properties/port + +required: + - compatible + - reg + - in-ports + +additionalProperties: false + +examples: + - | + ctcu@1001000 { + compatible =3D "qcom,sa8775p-ctcu"; + reg =3D <0x1001000 0x1000>; + + clocks =3D <&aoss_qmp>; + clock-names =3D "apb"; + + in-ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + reg =3D <0>; + ctcu_in_port0: endpoint { + remote-endpoint =3D <&etr0_out_port>; + }; + }; + + port@1 { + reg =3D <1>; + ctcu_in_port1: endpoint { + remote-endpoint =3D <&etr1_out_port>; + }; + }; + }; + }; --=20 2.34.1 From nobody Sat Nov 30 16:43:05 2024 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 E3ED7BA42; Mon, 9 Sep 2024 03:35:58 +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=1725852960; cv=none; b=rQwsiD0jlXSD+qhCngopii08SnoSuxFnelwpCFHSVeNaJXKFYKVOKz0xCuWlOAuMZ17rRhUjokCFUQKZbDObnH9OYS3PN5j2RV9xVv84Ta6oZxV/DHJquSwmRjRnCqA+f13A6r6fBKTim1x53ST468Y8oExfvdllbNAuCn57EjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725852960; c=relaxed/simple; bh=zGgBmQWbNpALuN0wVp75/rI/0Mj0dANl4fitHBXUj68=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Izz6e5n0XCLbXvnwDtzZvw1uCQHBiL3gWv+a9Pgf0i2ukc/Nox8dCpNHNHXWkhDMkrVADtEUY4c7jbh0e6W5YPm293Tw8xDuNiVFgCuHCp0R7fV9ReYBfPGDVoK3NPunb5Ip6bzqcBJ7gtwNlRfI+3pmIBRAbLk37r5vB8sXdgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=L3blAlGn; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="L3blAlGn" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 488NC9M1016372; Mon, 9 Sep 2024 03:35:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 8696fy4vlMwY0gAsSyFdqvhBE7SMUwofwED0Dm7hcMQ=; b=L3blAlGnXUfT6a8T ydinYC1VHlJjmO2MFZNq6p3d3vC7BcD74t3cUS5d+8hlnqAjPkYjnjPT3cRXa2od 1oGMGjR5J6J1cmkV4UuIdRjktNyge88OFayov33VNoRD5LEcDJWwqNlOpgmL/QVk cDZW+zIXNW4Nj2iwS+QA/jqOD0TdwuMrjKi0CzpYhc2fh88bc4YzmEpkaiOH77tA hmKYPBMste1LVdMWcBvGg6S8Erm8O6f33pTqX6bHRxzKIRPuacUkjQinl2UQsV3i 8BnNnBfmdERHLgXVeyLYh/DytQWYq/eKoVXcRUqP+b4QXeF/CjGBUFPGm7VhdOmi W/Pe8g== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy8nsjkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Sep 2024 03:35:43 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4893Zgn6001723 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Sep 2024 03:35:42 GMT Received: from jiegan-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 8 Sep 2024 20:35:36 -0700 From: Jie Gan To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio CC: Jinlong Mao , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Song Chai , , Subject: [PATCH v5 4/5] Coresight: Add Coresight TMC Control Unit driver Date: Mon, 9 Sep 2024 11:34:57 +0800 Message-ID: <20240909033458.3118238-5-quic_jiegan@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909033458.3118238-1-quic_jiegan@quicinc.com> References: <20240909033458.3118238-1-quic_jiegan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: CZMWegXXAMmdH1-4QjzzHwbesnd-NTVL X-Proofpoint-ORIG-GUID: CZMWegXXAMmdH1-4QjzzHwbesnd-NTVL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409090027 Content-Type: text/plain; charset="utf-8" The Coresight TMC Control Unit hosts miscellaneous configuration registers which control various features related to TMC ETR sink. Based on the trace ID, which is programmed in the related CTCU ATID register of a specific ETR, trace data with that trace ID gets into the ETR buffer, while other trace data gets dropped. Enabling source device sets one bit of the ATID register based on source device's trace ID. Disabling source device resets the bit according to the source device's trace ID. Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/Kconfig | 8 + drivers/hwtracing/coresight/Makefile | 1 + drivers/hwtracing/coresight/coresight-ctcu.c | 292 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-ctcu.h | 21 ++ include/linux/coresight.h | 3 +- 5 files changed, 324 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.c create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.h diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresi= ght/Kconfig index 06f0a7594169..152eab0b9b2a 100644 --- a/drivers/hwtracing/coresight/Kconfig +++ b/drivers/hwtracing/coresight/Kconfig @@ -133,6 +133,14 @@ config CORESIGHT_STM To compile this driver as a module, choose M here: the module will be called coresight-stm. =20 +config CORESIGHT_CTCU + tristate "CoreSight TMC Control Unit driver" + help + This driver provides support for CoreSight TMC Control Unit + that hosts miscellaneous configuration registers. This is + primarily used for controlling the behaviors of the TMC + ETR device. + config CORESIGHT_CPU_DEBUG tristate "CoreSight CPU Debug driver" depends on ARM || ARM64 diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/cores= ight/Makefile index 4ba478211b31..1b7869910a12 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -51,3 +51,4 @@ coresight-cti-y :=3D coresight-cti-core.o coresight-cti-p= latform.o \ coresight-cti-sysfs.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 diff --git a/drivers/hwtracing/coresight/coresight-ctcu.c b/drivers/hwtraci= ng/coresight/coresight-ctcu.c new file mode 100644 index 000000000000..e3a8259a2412 --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-ctcu.c @@ -0,0 +1,292 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "coresight-ctcu.h" +#include "coresight-priv.h" +#include "coresight-trace-id.h" + +DEFINE_CORESIGHT_DEVLIST(ctcu_devs, "ctcu"); + +#define ctcu_writel(drvdata, val, offset) __raw_writel((val), drvdata->bas= e + offset) +#define ctcu_readl(drvdata, offset) __raw_readl(drvdata->base + offset) + +/* The TMC Coresight Control Unit uses four ATID registers to control the = data filter function based + * on the trace ID for each TMC ETR sink. The length of each ATID register= is 32 bits. Therefore, + * the ETR has a related field in CTCU that is 128 bits long. Each trace I= D is represented by one + * bit in that filed. + * e.g. ETR0ATID0 layout, set bit 5 for traceid 5 + * bit5 + * ------------------------------------------------------ + * | |28| |24| |20| |16| |12| |8| 1|4| |0| + * ------------------------------------------------------ + * + * e.g. ETR0: + * 127 0 from ATID_offset for ETR0ATID0 + * ------------------------- + * |ATID3|ATID2|ATID1|ATID0| + * + */ +#define CTCU_ATID_REG_OFFSET(traceid, atid_offset) \ + ((traceid / 32) * 4 + atid_offset) + +#define CTCU_ATID_REG_BIT(traceid) (traceid % 32) +#define CTCU_ATID_REG_SIZE 0x10 + +struct ctcu_atid_config { + const int atid_offset; + const int port_num; +}; + +struct ctcu_config { + const struct ctcu_atid_config *atid_config; + int num_atid_config; +}; + +static const struct ctcu_atid_config sa8775p_atid_cfgs[] =3D { + {0xf8, 0}, + {0x108, 1}, +}; + +static const struct ctcu_config sa8775p_cfgs =3D { + .atid_config =3D sa8775p_atid_cfgs, + .num_atid_config =3D ARRAY_SIZE(sa8775p_atid_cfgs), +}; + +/* + * __ctcu_set_etr_traceid: Set bit in the ATID register based on trace ID = when enable is true. + * Reset the bit of the ATID register based on trace ID when enable is fal= se. + * + * @csdev: coresight_device struct related to the device + * @traceid: trace ID of the source tracer. + * @enable: True for set bit and false for reset bit. + * + * Returns 0 indicates success. Non-zero result means failure. + */ +static int __ctcu_set_etr_traceid(struct coresight_device *csdev, + u8 traceid, + int port_num, + bool enable) +{ + uint32_t atid_offset; + struct ctcu_drvdata *drvdata; + unsigned long flags; + uint32_t reg_offset; + int bit; + uint32_t val; + + if (!IS_VALID_CS_TRACE_ID(traceid) || port_num < 0) + return -EINVAL; + + drvdata =3D dev_get_drvdata(csdev->dev.parent); + if (IS_ERR_OR_NULL(drvdata)) + return -EINVAL; + + atid_offset =3D drvdata->atid_offset[port_num]; + if (atid_offset =3D=3D 0) + return -EINVAL; + + spin_lock_irqsave(&drvdata->spin_lock, flags); + CS_UNLOCK(drvdata->base); + + reg_offset =3D CTCU_ATID_REG_OFFSET(traceid, atid_offset); + bit =3D CTCU_ATID_REG_BIT(traceid); + if (reg_offset - atid_offset >=3D CTCU_ATID_REG_SIZE || + bit >=3D CORESIGHT_TRACE_IDS_MAX) { + CS_LOCK(drvdata); + spin_unlock_irqrestore(&drvdata->spin_lock, flags); + return -EINVAL; + } + + val =3D ctcu_readl(drvdata, reg_offset); + if (enable) + val =3D val | BIT(bit); + else + val =3D val & ~BIT(bit); + ctcu_writel(drvdata, val, reg_offset); + + CS_LOCK(drvdata->base); + spin_unlock_irqrestore(&drvdata->spin_lock, flags); + + return 0; +} + +static int ctcu_get_active_port(struct coresight_device *sink, struct core= sight_device *helper) +{ + int port, i; + + for (i =3D 0; i < sink->pdata->nr_outconns; ++i) { + if (sink->pdata->out_conns[i]->dest_dev) { + port =3D sink->pdata->out_conns[i]->dest_port; + return port; + } + } + + return -EINVAL; +} + +/* + * ctcu_set_etr_traceid: Retrieve the ATID offset and trace ID. + * + * Returns 0 indicates success. None-zero result means failure. + */ +static int ctcu_set_etr_traceid(struct coresight_device *csdev, + struct cs_sink_data *sink_data, + bool enable) +{ + int port_num; + + if (!IS_VALID_CS_TRACE_ID(sink_data->traceid) || + (csdev =3D=3D NULL) || + (sink_data->sink =3D=3D NULL)) { + dev_dbg(&csdev->dev, "Invalid parameters\n"); + return -EINVAL; + } + + port_num =3D ctcu_get_active_port(sink_data->sink, csdev); + if (port_num < 0) + return -EINVAL; + + dev_dbg(&csdev->dev, "traceid is %d\n", sink_data->traceid); + + return __ctcu_set_etr_traceid(csdev, sink_data->traceid, port_num, enable= ); +} + +static int ctcu_enable(struct coresight_device *csdev, enum cs_mode mode, + void *data) +{ + int ret =3D 0; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + + ret =3D ctcu_set_etr_traceid(csdev, sink_data, true); + if (ret) + dev_dbg(&csdev->dev, "enable data filter failed\n"); + + return 0; +} + +static int ctcu_disable(struct coresight_device *csdev, void *data) +{ + int ret =3D 0; + struct cs_sink_data *sink_data =3D (struct cs_sink_data *)data; + + ret =3D ctcu_set_etr_traceid(csdev, sink_data, false); + if (ret) + dev_dbg(&csdev->dev, "disable data filter failed\n"); + + return 0; +} + +static const struct coresight_ops_helper ctcu_helper_ops =3D { + .enable =3D ctcu_enable, + .disable =3D ctcu_disable, +}; + +static const struct coresight_ops ctcu_ops =3D { + .helper_ops =3D &ctcu_helper_ops, +}; + +static int ctcu_probe(struct platform_device *pdev) +{ + int i; + void __iomem *base; + struct device *dev =3D &pdev->dev; + struct coresight_platform_data *pdata; + struct ctcu_drvdata *drvdata; + struct coresight_desc desc =3D { 0 }; + const struct ctcu_config *cfgs; + const struct ctcu_atid_config *atid_cfg; + + desc.name =3D coresight_alloc_device_name(&ctcu_devs, dev); + if (!desc.name) + return -ENOMEM; + + drvdata =3D devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); + if (!drvdata) + return -ENOMEM; + + pdata =3D coresight_get_platform_data(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + dev->platform_data =3D pdata; + + base =3D devm_platform_get_and_ioremap_resource(pdev, 0, NULL); + if (!base) + return -ENOMEM; + + drvdata->apb_clk =3D coresight_get_enable_apb_pclk(dev); + if (IS_ERR(drvdata->apb_clk)) + return -ENODEV; + + cfgs =3D of_device_get_match_data(dev); + if (cfgs) { + if (cfgs->num_atid_config <=3D ATID_MAX_NUM) { + for (i =3D 0; i < cfgs->num_atid_config; i++) { + atid_cfg =3D &cfgs->atid_config[i]; + drvdata->atid_offset[i] =3D atid_cfg->atid_offset; + } + } + } + + drvdata->base =3D base; + drvdata->dev =3D dev; + platform_set_drvdata(pdev, drvdata); + + desc.type =3D CORESIGHT_DEV_TYPE_HELPER; + desc.subtype.helper_subtype =3D CORESIGHT_DEV_SUBTYPE_HELPER_CTCU; + desc.pdata =3D pdata; + desc.dev =3D dev; + desc.ops =3D &ctcu_ops; + + drvdata->csdev =3D coresight_register(&desc); + if (IS_ERR(drvdata->csdev)) { + if (!IS_ERR_OR_NULL(drvdata->apb_clk)) + clk_put(drvdata->apb_clk); + + return PTR_ERR(drvdata->csdev); + } + + return 0; +} + +static void ctcu_remove(struct platform_device *pdev) +{ + struct ctcu_drvdata *drvdata =3D platform_get_drvdata(pdev); + + coresight_unregister(drvdata->csdev); + if (!IS_ERR_OR_NULL(drvdata->apb_clk)) + clk_put(drvdata->apb_clk); +} + +static const struct of_device_id ctcu_match[] =3D { + {.compatible =3D "qcom,sa8775p-ctcu", .data =3D &sa8775p_cfgs}, + {} +}; + +static struct platform_driver ctcu_driver =3D { + .probe =3D ctcu_probe, + .remove =3D ctcu_remove, + .driver =3D { + .name =3D "coresight-ctcu", + .of_match_table =3D ctcu_match, + .suppress_bind_attrs =3D true, + }, +}; +module_platform_driver(ctcu_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("CoreSight TMC Control Unit driver"); diff --git a/drivers/hwtracing/coresight/coresight-ctcu.h b/drivers/hwtraci= ng/coresight/coresight-ctcu.h new file mode 100644 index 000000000000..ce5c9661623a --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-ctcu.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef _CORESIGHT_CTCU_H +#define _CORESIGHT_CTCU_H + +#define ATID_MAX_NUM 5 + +struct ctcu_drvdata { + void __iomem *base; + struct clk *apb_clk; + phys_addr_t pbase; + struct device *dev; + struct coresight_device *csdev; + spinlock_t spin_lock; + uint32_t atid_offset[ATID_MAX_NUM]; +}; + +#endif diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 22b977908f4f..d92530b3fa57 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -71,7 +71,8 @@ enum coresight_dev_subtype_source { =20 enum coresight_dev_subtype_helper { CORESIGHT_DEV_SUBTYPE_HELPER_CATU, - CORESIGHT_DEV_SUBTYPE_HELPER_ECT_CTI + CORESIGHT_DEV_SUBTYPE_HELPER_ECT_CTI, + CORESIGHT_DEV_SUBTYPE_HELPER_CTCU }; =20 /** --=20 2.34.1 From nobody Sat Nov 30 16:43:05 2024 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 CE4BE1AD9DE; Mon, 9 Sep 2024 03:36:04 +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=1725852968; cv=none; b=eN6oo/j3iTrTywV7cDS0AyIQAmqYwFiYxYR+2zl9icno23pfXgE2Kdj4qq8EShG9HK7/ruxtw5zoabkldejhgJKskfo4EVAZPKZ6eS3TDXr6K3D/dVzmTgEV88I0rwcA76JCiV6ge+1M0q/uXyjisr2btwQwIRxkKAEytiNKWVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725852968; c=relaxed/simple; bh=+4lnVmz1HkbC5gG9G3ZPV4NnrsBsSmQNOr/IMQ2D4sY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ltwm+/Fs8y3vZZRnBTydFiRGT7mR0Po7ciVukVQeCc9eXarewgwe/jZm7YPL5guKejgyF3ABDu5Lc2Xq3gnzxOsToGSQDIygakDCn2EXvvz2+/q9PdptuYIrpOgdB8aR5W8iFOoQ2oBobDjgAGctChXu2aHpd7zpofUZMsSUFW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=em0hMnqR; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="em0hMnqR" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 488NTALp023914; Mon, 9 Sep 2024 03:35:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= osMgB0mb3XqW8YTk8xRMOzQT5xdZ8ZkzCS7pK5HdoYo=; b=em0hMnqRUCGiPtzI fQFPxzDiO5uCrMxqUDNxBfC87qiUj8wcRebgZsjLMMzoQWo0f+TD/Q/x8I81bw6A cBAQvoqBOFYoau9N0Yy6Fm9HMT0gaTOwEEOYedoeb2b8mp/31+4YdkLIZaHXzfh1 z3bXXjN3imF1xj4WhX1PmpvCGih50Fmixau07nm/WL+uPGEfmiTwVBDDhGYKJr7w y8RKg8vvZWXQoC1PwPtbbQB2bAilN/fwitY2Dbe0h909MltUeBCN1o0BZbbfF4b0 YeNVFJhVvrkxKsTheZfgpL1JN9qfgapigw8FXQFR90DazGcZ6zHsujbP4NlcPl7T jrmtaw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41gy6p1jf2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Sep 2024 03:35:48 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4893ZlTN001745 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 9 Sep 2024 03:35:47 GMT Received: from jiegan-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Sun, 8 Sep 2024 20:35:42 -0700 From: Jie Gan To: Suzuki K Poulose , Mike Leach , James Clark , "Alexander Shishkin" , Maxime Coquelin , Alexandre Torgue , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Konrad Dybcio CC: Jinlong Mao , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Song Chai , , Subject: [PATCH v5 5/5] arm64: dts: qcom: Add CTCU and ETR nodes for SA8775p Date: Mon, 9 Sep 2024 11:34:58 +0800 Message-ID: <20240909033458.3118238-6-quic_jiegan@quicinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240909033458.3118238-1-quic_jiegan@quicinc.com> References: <20240909033458.3118238-1-quic_jiegan@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: jvnNOCDB0sv-W--CU1BlIuN43YUNlREz X-Proofpoint-GUID: jvnNOCDB0sv-W--CU1BlIuN43YUNlREz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 spamscore=0 phishscore=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409090027 Content-Type: text/plain; charset="utf-8" Add CTCU and ETR nodes in DT to enable related functions. Signed-off-by: Jie Gan --- arch/arm64/boot/dts/qcom/sa8775p.dtsi | 160 ++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sa8775p.dtsi b/arch/arm64/boot/dts/qc= om/sa8775p.dtsi index 23f1b2e5e624..a8b509495440 100644 --- a/arch/arm64/boot/dts/qcom/sa8775p.dtsi +++ b/arch/arm64/boot/dts/qcom/sa8775p.dtsi @@ -1664,6 +1664,35 @@ ice: crypto@1d88000 { clocks =3D <&gcc GCC_UFS_PHY_ICE_CORE_CLK>; }; =20 + ctcu@4001000 { + compatible =3D "qcom,sa8775p-ctcu"; + reg =3D <0x0 0x4001000 0x0 0x1000>; + + clocks =3D <&aoss_qmp>; + clock-names =3D "apb"; + + in-ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + reg =3D <0>; + ctcu_in0: endpoint { + remote-endpoint =3D + <&etr0_out>; + }; + }; + + port@1 { + reg =3D <1>; + ctcu_in1: endpoint { + remote-endpoint =3D + <&etr1_out>; + }; + }; + }; + }; + stm: stm@4002000 { compatible =3D "arm,coresight-stm", "arm,primecell"; reg =3D <0x0 0x4002000 0x0 0x1000>, @@ -1867,6 +1896,129 @@ qdss_funnel_in1: endpoint { }; }; =20 + replicator@4046000 { + compatible =3D "arm,coresight-dynamic-replicator", "arm,primecell"; + reg =3D <0x0 0x4046000 0x0 0x1000>; + + clocks =3D <&aoss_qmp>; + clock-names =3D "apb_pclk"; + + out-ports { + port { + qdss_rep_out0: endpoint { + remote-endpoint =3D + <&etr_rep_in>; + }; + }; + }; + + in-ports { + port { + qdss_rep_in: endpoint { + remote-endpoint =3D + <&swao_rep_out0>; + }; + }; + }; + }; + + tmc_etr: tmc@4048000 { + compatible =3D "arm,coresight-tmc", "arm,primecell"; + reg =3D <0x0 0x4048000 0x0 0x1000>; + + clocks =3D <&aoss_qmp>; + clock-names =3D "apb_pclk"; + iommus =3D <&apps_smmu 0x04c0 0x00>; + + arm,scatter-gather; + + out-ports { + port { + etr0_out: endpoint { + remote-endpoint =3D + <&ctcu_in0>; + }; + }; + }; + + in-ports { + port { + etr0_in: endpoint { + remote-endpoint =3D + <&etr_rep_out0>; + }; + }; + }; + }; + + replicator@404e000 { + compatible =3D "arm,coresight-dynamic-replicator", "arm,primecell"; + reg =3D <0x0 0x404e000 0x0 0x1000>; + + clocks =3D <&aoss_qmp>; + clock-names =3D "apb_pclk"; + + out-ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@0 { + reg =3D <0>; + etr_rep_out0: endpoint { + remote-endpoint =3D + <&etr0_in>; + }; + }; + + port@1 { + reg =3D <1>; + etr_rep_out1: endpoint { + remote-endpoint =3D + <&etr1_in>; + }; + }; + }; + + in-ports { + port { + etr_rep_in: endpoint { + remote-endpoint =3D + <&qdss_rep_out0>; + }; + }; + }; + }; + + tmc_etr1: tmc@404f000 { + compatible =3D "arm,coresight-tmc", "arm,primecell"; + reg =3D <0x0 0x404f000 0x0 0x1000>; + + clocks =3D <&aoss_qmp>; + clock-names =3D "apb_pclk"; + iommus =3D <&apps_smmu 0x04a0 0x40>; + + arm,scatter-gather; + arm,buffer-size =3D <0x400000>; + + out-ports { + port { + etr1_out: endpoint { + remote-endpoint =3D + <&ctcu_in1>; + }; + }; + }; + + in-ports { + port { + etr1_in: endpoint { + remote-endpoint =3D + <&etr_rep_out1>; + }; + }; + }; + }; + funnel@4b04000 { compatible =3D "arm,coresight-dynamic-funnel", "arm,primecell"; reg =3D <0x0 0x4b04000 0x0 0x1000>; @@ -1942,6 +2094,14 @@ out-ports { #address-cells =3D <1>; #size-cells =3D <0>; =20 + port@0 { + reg =3D <0>; + swao_rep_out0: endpoint { + remote-endpoint =3D + <&qdss_rep_in>; + }; + }; + port@1 { reg =3D <1>; swao_rep_out1: endpoint { --=20 2.34.1