From patchwork Fri Jan 6 09:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Jinlong X-Patchwork-Id: 40050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp729722wrt; Fri, 6 Jan 2023 01:27:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXv8f32YReru76IqQ9SMKHr/S7ZXyCKB9c6YPdVXsHBO96SY9ezOqC0aVUuvOQDhzZFiLdBR X-Received: by 2002:a17:907:c388:b0:849:e96f:51f4 with SMTP id tm8-20020a170907c38800b00849e96f51f4mr39151062ejc.23.1672997242512; Fri, 06 Jan 2023 01:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672997242; cv=none; d=google.com; s=arc-20160816; b=b9YmuFNX6Ewdvc8YhoF28KJYq4V2d8FJIb9D6LDUr3dz547VwAwpL4J74EiR0/PrPp qVbEWhK9wYSjesATufnKT1w1NCcnRlaZr1oEBuLywIfq8VDOn7zGTf+iYgVESkgNbnoi tdQcgzkK9ScjGlpkl+OGgTOxsLd/EA3+xkqbOxh2B15uTgHLGmoRcuHZxF05xOsz18Mn E2x9v5A3AQCueZLQgNfinFX4/DUBh1zgEbRR7jCz2ZYo9euz93Y9Q2FL+N386rmbQUD/ /Er3SNlGuaBrBnr0b/VrNCeqT4R8WU5/P/f70XqeObF0MQRUgT/q6lBXrbFbbdStYdzN V54w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V/bptrVcXVHFSDujslPeTwO4nzZz362HA58mkxTRXeE=; b=ISE7koNsOryE6/r9FZRWqQjo30Mlpya+AvW5OFjP7np0xpxDJKfeHGDcZHgXEd93I1 H4s/GdQGb6R7JleVsXBIvF2/e/Ie6YNewix2cz4XhVwRCUCCOSuBxVKM4o8squl3ulxg RWUQJG5MVLMgUYmJMoPSOQV0BAqSqVbHyUiMRWv4raU7mZJOkIjncDik4ORJukVcUak6 ws67F/GCLCKDctS6M2sk4ZvAcQpREUQG2dESU5Q4OKidswXd+/E6YuCPjffpFJygP3Dh Y8QPj0Ll8O9qg0Lj41VQUuwjcLAZVMsw8GAAM2WYZ3XASQsA5IE+Fbby0soApthbKJUS gpgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VAGQDRZb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb6-20020a170907160600b008366ae33eb6si916735ejc.580.2023.01.06.01.26.58; Fri, 06 Jan 2023 01:27:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=VAGQDRZb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233152AbjAFJ02 (ORCPT + 99 others); Fri, 6 Jan 2023 04:26:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234646AbjAFJZe (ORCPT ); Fri, 6 Jan 2023 04:25:34 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 482286C7D3; Fri, 6 Jan 2023 01:22:02 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3064rUCU028596; Fri, 6 Jan 2023 09:21:37 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 : mime-version : content-transfer-encoding : content-type; s=qcppdkim1; bh=V/bptrVcXVHFSDujslPeTwO4nzZz362HA58mkxTRXeE=; b=VAGQDRZbiM+7bVGWwOUGn/hCAeS+5wF232moBBAmEb2u7or1XRQJnqHdRHQ1m8skCN+w yL3bRSY189qJOAOnhydRYbZ+0jmplYuDdiHaw/QspnyFP3XDjqMpJlcAki39UXTREU9X KrloMGVb7Wlz53FFq1s5VHZvvm2dtl/h4ZN1RacgoT6IiiViCY5JNCnl1r6I5ScPNtFc Bd50pLuYYjrOpFulESx6oObtuju8FSPx9rSddb7wY/NTzBRihNBhocxlNv1vqi0LQYTM bZT/ykaMV5z2nGmcfIOupJycCoHksYpfuKUCPwXCVkwg6zYPznKrrZupYEUU3qi78oE4 Vg== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mwxhkabx4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 06 Jan 2023 09:21:36 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3069LaAF021122 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 6 Jan 2023 09:21:36 GMT Received: from hu-jinlmao-lv.qualcomm.com (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Fri, 6 Jan 2023 01:21:35 -0800 From: Mao Jinlong To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Konrad Dybcio , Mike Leach , Rob Herring , Krzysztof Kozlowski CC: Mao Jinlong , Leo Yan , "Greg Kroah-Hartman" , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Trilok Soni , Hao Zhang , , Bjorn Andersson Subject: [PATCH v16 1/8] coresight: core: Use IDR for non-cpu bound sources' paths. Date: Fri, 6 Jan 2023 01:21:12 -0800 Message-ID: <20230106092119.20449-2-quic_jinlmao@quicinc.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230106092119.20449-1-quic_jinlmao@quicinc.com> References: <20230106092119.20449-1-quic_jinlmao@quicinc.com> MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01b.na.qualcomm.com (10.47.209.197) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: wAp4xeBwD2nhcJrGWL_JVCisD0sBsq7W X-Proofpoint-ORIG-GUID: wAp4xeBwD2nhcJrGWL_JVCisD0sBsq7W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-06_05,2023-01-05_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=926 impostorscore=0 mlxscore=0 bulkscore=0 clxscore=1015 spamscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301060073 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754264756416924330?= X-GMAIL-MSGID: =?utf-8?q?1754264756416924330?= Except stm, there could be other sources which are not associated with cpus. Use IDR to store and search these sources' paths. Reviewed-by: Suzuki K Poulose Reviewed-by: Mike Leach Signed-off-by: Mao Jinlong --- drivers/hwtracing/coresight/coresight-core.c | 37 ++++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index ce3aa845ecc2..5eb013f49a0d 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,13 @@ static DEFINE_MUTEX(coresight_mutex); static DEFINE_PER_CPU(struct coresight_device *, csdev_sink); +/* + * Use IDR to map the hash of the source's device name + * to the pointer of path for the source. The idr is for + * the sources which aren't associated with CPU. + */ +static DEFINE_IDR(path_idr); + /** * struct coresight_node - elements of a path, from source to sink * @csdev: Address of an element. @@ -42,14 +50,6 @@ struct coresight_node { */ static DEFINE_PER_CPU(struct list_head *, tracer_path); -/* - * As of this writing only a single STM can be found in CS topologies. Since - * there is no way to know if we'll ever see more and what kind of - * configuration they will enact, for the time being only define a single path - * for STM. - */ -static struct list_head *stm_path; - /* * When losing synchronisation a new barrier packet needs to be inserted at the * beginning of the data collected in a buffer. That way the decoder knows that @@ -1075,6 +1075,7 @@ int coresight_enable(struct coresight_device *csdev) struct coresight_device *sink; struct list_head *path; enum coresight_dev_subtype_source subtype; + u32 hash; subtype = csdev->subtype.source_subtype; @@ -1129,7 +1130,14 @@ int coresight_enable(struct coresight_device *csdev) per_cpu(tracer_path, cpu) = path; break; case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE: - stm_path = path; + /* + * Use the hash of source's device name as ID + * and map the ID to the pointer of the path. + */ + hash = hashlen_hash(hashlen_string(NULL, dev_name(&csdev->dev))); + ret = idr_alloc_u32(&path_idr, path, &hash, hash, GFP_KERNEL); + if (ret) + goto err_source; break; default: /* We can't be here */ @@ -1153,6 +1161,7 @@ void coresight_disable(struct coresight_device *csdev) { int cpu, ret; struct list_head *path = NULL; + u32 hash; mutex_lock(&coresight_mutex); @@ -1170,14 +1179,20 @@ void coresight_disable(struct coresight_device *csdev) per_cpu(tracer_path, cpu) = NULL; break; case CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE: - path = stm_path; - stm_path = NULL; + hash = hashlen_hash(hashlen_string(NULL, dev_name(&csdev->dev))); + /* Find the path by the hash. */ + path = idr_find(&path_idr, hash); + if (path == NULL) { + pr_err("Path is not found for %s\n", dev_name(&csdev->dev)); + goto out; + } break; default: /* We can't be here */ break; } + idr_remove(&path_idr, hash); coresight_disable_path(path); coresight_release_path(path);