From mboxrd@z Thu Jan 1 00:00:00 1970 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 52AE01E2312 for ; Mon, 8 Sep 2025 02:02:38 +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=1757296960; cv=none; b=qjvRXusdP51ToqkTatRNhDNF/7LfmSZqW0NjjHB10D6HjVYgZ/BgLSY87WZOtoR1XRRzzToiv0q+3vv07+NLzDILzXecgYWREDKAjPrBoW7RnSOge+0WxgOD3auXdI7hXtZsQhJz69ASSocyCPjxHb3Un7YJ/1B4Pca/j1bhmt4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757296960; c=relaxed/simple; bh=QFpFMOUZf/2SBDLxhrsEj1Eto2xysYNZ7RxKlu5EyYo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aek5gSzvRvDuMFvQ1UFlNzRM3ldL0Au2WpYz/usanMjGlqlW8cBSfJLfoJr8+RbiRC5yH4WOmQDK11VDyjegcClh02I6U0NPqFK7b4h8V7k7iZozyLwGjcefkhPQ8Bb0Fxw9w1ICzcpv1WZP1+vflxLMVRuqhXRU+oesPhKFVRI= 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=SAbt/Bc2; 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="SAbt/Bc2" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5880TsU9004353 for ; Mon, 8 Sep 2025 02:02:37 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= mmrEmFTMxg84eXRvylgPXjTGj2u1nEfxmypzMMZc/rM=; b=SAbt/Bc2JoIaPY45 59j0UsyvnCnYOylZEbH2gVACRNpOPn+Tj0yk8AuBs9qpG/tgFtNpjQhTFvIdte2b OFuME9rCEkfqQp3bRQiR1cpy/4Rw5I4bee29vRnMm11R7YdwBceeR2DQ6aKm/n78 BJWDW/XS72Gz1xG7ofwGyT4sj3FceVqPV8Bao0F7SOyCK+lbY5r0HJjJ2hL7Fox7 Y7GylWa2V+3O7W9kvxUrAmOORulAB3EBskwYknoB07jfE4CJA/Hy0c2UwDIVGfnB 2/zXAUGasCYRnEoZfyTp4A9H/6MiruSYRKNWTYKVS94ZKkreuoOJuKy9WSvwNoLq 1oz67A== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 490e4ktu61-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 08 Sep 2025 02:02:37 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7725b4273acso8322258b3a.1 for ; Sun, 07 Sep 2025 19:02:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757296956; x=1757901756; 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=mmrEmFTMxg84eXRvylgPXjTGj2u1nEfxmypzMMZc/rM=; b=ImMzNLhhavkuE/jVO+Nu22ytmnw2oXZTRpHlZo5dLMy9xbfT7WtC4z4Fcstit7cu2Z xuwDJl9LhcsBBzJf31doYL/ed5fWF+eFJXqF++zclXJDzpvitXA4N68vuTl6kbB2ldnm 9rcQWKtjP/GH4wbCSuD8FLsBUs50edhyxejdNMAhGau09V44TDVhFzskgtCBEM3yn2nL G3pDJ68rbrgZw3HEtZ2634MFNcdZioFKkk8QYgkKETo5tTJHjmTz5f8t33RWh3uVtxOZ CcTLVChvaTUqB+jMFO8JYkmDNmud4fuuwPuAE5UT4eGjpX9cteC8ZI9dUkEdLogChs/d NB8g== X-Forwarded-Encrypted: i=1; AJvYcCXstyINRdElJBtvDBc+PGGYbWgZD1tGJCc1vkvX/JM2AC8IVhmchCwyOf23WgTsqijUr9wdKzjckRj0@vger.kernel.org X-Gm-Message-State: AOJu0YxS4SSFAvAdb0sB9Tjm5GnwmpdjznbH+y6h7owQAi78LCjA5qrc xe6elr5y+hK/eLSY4EQkBAslqWVv7B2ctOHWwSAiGvtwy4sMzQHt7YZAK9eFttELQpohc/tZNOk owdJ7GrFoMbST2EtXhTTa/eAAt52GE7KjUYkxKufmmVaQXFQ0//pEaWstROIFv/uBRE7ZTSvbb9 k= X-Gm-Gg: ASbGncukeRi7id8gXYF17yr7B/eGOky36hileMD6QKd0nyaSKbN1OK8SXJQE8/iX/t7 R0KqVwXCEzMnxZiwJrrMXFJBLGktQwvRBy6Yj8qQSLFDEgfpnzEKlNKst7857bfwM4hRBxJ8iZJ m0W7q+H6wFiDDPDG4pyBCTknFB/W7ucTO7YglstSE+mu22yzA1EwJ7YHn3WeZpKhzxY73rJNehS cE/tf8Od3QVgfZsIxuQJWnezJvwvd7w+tRc3kG8Th4s2RT4GxIev2btgsFEnffUCm5U5Ttw3O5j RShRPTwhnJv7c1fNfhfN7QcO8Pulsgunuh8xE4azDfL38VJ0X9mzLq0roJdusUzUL3jjGQJRRqk TSIiKJA/pG0liHMgYNbg5xrxMzBQ= X-Received: by 2002:a05:6a20:939e:b0:243:78a:82a7 with SMTP id adf61e73a8af0-25345579b43mr7587415637.47.1757296956471; Sun, 07 Sep 2025 19:02:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpz91qpajdyoSqIcc47npMEE1FkO9LwTqg9ZWKouQV8RyNp0nC1V+LGbeoE3r4URiIgPkNgw== X-Received: by 2002:a05:6a20:939e:b0:243:78a:82a7 with SMTP id adf61e73a8af0-25345579b43mr7587375637.47.1757296955935; Sun, 07 Sep 2025 19:02:35 -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-7723f4858e6sm24285076b3a.4.2025.09.07.19.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Sep 2025 19:02:35 -0700 (PDT) From: Jie Gan Date: Mon, 08 Sep 2025 10:01:54 +0800 Subject: [PATCH v6 2/9] coresight: core: add a new API to retrieve the helper device Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250908-enable-byte-cntr-for-tmc-v6-2-1db9e621441a@oss.qualcomm.com> References: <20250908-enable-byte-cntr-for-tmc-v6-0-1db9e621441a@oss.qualcomm.com> In-Reply-To: <20250908-enable-byte-cntr-for-tmc-v6-0-1db9e621441a@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Tingwei Zhang , Jinlong Mao , 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=1757296940; l=2649; i=jie.gan@oss.qualcomm.com; s=20240927; h=from:subject:message-id; bh=QFpFMOUZf/2SBDLxhrsEj1Eto2xysYNZ7RxKlu5EyYo=; b=bi+tUi3A8/0GEEoeIWtWZ7na0uNDvTr9BROFOck5sTnvMXnTbiYnJxMCb3pPyOarEUn1dR8Kj rl4N7CvjIGgDyH59hczXqMiQtklb4wJquhOR2XH0lTt3flB7xAbZl2K X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=OZh7JyRifqJh4xmrcGgmwa8/LCS8O11Q+mtx4aZGmi4= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTA2MDAzOCBTYWx0ZWRfX1tmjs4DVB5Qh u27N2xmKChicPuStyhoaGWscV2Pm6Pf8jaPNd8TPvxmqfuyWQm/LBRLGsciFvhjxoZ2wc/urCDD akY7uuhxkdL9ytjXXIno2rMGnfJema5wP0ZHAdHqc2fEv6pxgaRZipqYz/FfofgH8RLQjSsZrXW IfLkciCgIN+GKwNdAjDA5UKbPIgI4/rI5RtsPdsRoMRk0L7WyjUdzkZqoFnqpNheSHQJiw5C4vM X3S6hLYEPeYK5+kOTane+CtXDMwsfnYYniDqYBbdSAQtssOfV3IRc7VoHu5kMcDdoIMrUL2sEY9 ZsbPDPs5gf00w2lLj9KXMZErlqMoHCTjl/43e1J6GjSTgH18nSGBophhYahwF76yMLhoHTXEQd2 bnLvK6Cn X-Authority-Analysis: v=2.4 cv=J66q7BnS c=1 sm=1 tr=0 ts=68be393d cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=yJojWOMRYYMA:10 a=KKAkSRfTAAAA:8 a=EUspDBNiAAAA:8 a=WErVAGsNQcrMbPXGsVkA:9 a=QEXdDO2ut3YA:10 a=zc0IvFSfCIW2DFIPzwfm:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: WJwIjyzorqdU3olHZGIzRsn0w2reV7T4 X-Proofpoint-ORIG-GUID: WJwIjyzorqdU3olHZGIzRsn0w2reV7T4 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-07_10,2025-09-04_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 clxscore=1015 spamscore=0 phishscore=0 adultscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2507300000 definitions=main-2509060038 Retrieving the helper device of the specific coresight device based on its helper_subtype because a single coresight device may has multiple types of the helper devices. Reviewed-by: Mike Leach Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-core.c | 35 ++++++++++++++++++++++++++++ drivers/hwtracing/coresight/coresight-priv.h | 2 ++ 2 files changed, 37 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 042c4fa39e55..018b1119c48a 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -580,6 +580,41 @@ struct coresight_device *coresight_get_sink(struct coresight_path *path) } EXPORT_SYMBOL_GPL(coresight_get_sink); +/** + * coresight_get_helper: find the helper device of the assigned csdev. + * + * @csdev: The csdev the helper device is conntected to. + * @type: helper_subtype of the expected helper device. + * + * Retrieve the helper device for the specific csdev based on its + * helper_subtype. + * + * Return: the helper's csdev upon success or NULL for fail. + */ +struct coresight_device *coresight_get_helper(struct coresight_device *csdev, + int type) +{ + int i; + struct coresight_device *helper; + + /* protect the connections */ + mutex_lock(&coresight_mutex); + for (i = 0; i < csdev->pdata->nr_outconns; ++i) { + helper = csdev->pdata->out_conns[i]->dest_dev; + if (!helper || !coresight_is_helper(helper)) + continue; + + if (helper->subtype.helper_subtype == type) { + mutex_unlock(&coresight_mutex); + return helper; + } + } + mutex_unlock(&coresight_mutex); + + return NULL; +} +EXPORT_SYMBOL_GPL(coresight_get_helper); + /** * coresight_get_in_port_dest: get the in-port number of the dest device * that is connected to the src device. diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index e51b22b8ebde..f80122827934 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -158,6 +158,8 @@ void coresight_path_assign_trace_id(struct coresight_path *path, enum cs_mode mode); int coresight_get_in_port_dest(struct coresight_device *src, struct coresight_device *dest); +struct coresight_device *coresight_get_helper(struct coresight_device *csdev, + int type); #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X) int etm_readl_cp14(u32 off, unsigned int *val); -- 2.34.1