Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2062182imw; Sat, 9 Jul 2022 19:21:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sa9psMNtJI0dDZsV14E5jh9IwrWFIERyKD69TykIO8EMTVt5N1T+pb6qWkPYVXea60qUa5 X-Received: by 2002:a17:907:3f88:b0:726:a6a3:750c with SMTP id hr8-20020a1709073f8800b00726a6a3750cmr11980895ejc.142.1657419667985; Sat, 09 Jul 2022 19:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657419667; cv=none; d=google.com; s=arc-20160816; b=ARrecdzufKjViJTrZglHl/KWRwfin+ypQSmmFDgJTiNKafgINjGAVFbvkFrT6tMItn ogmt2ljD6/PVMxsYJuvEvRUlv25cVgnd0S3YN4eEdkXG8FigWFW3zOqy44LtypyP1i1a Wn/0P7fO4DuJqFD/9aLbpeCYATqbrBiSSobvR2nywS85PCqbOMaCM/d6lMDTddGJQaSq yvVmPFmzOoQ00yYQruu+F6BZDiRiaM27+Q7EE1eXi0kWiQ5S5ukKm3hvcE94+Gx4sI8g DXk10oF8eRgOA4cnBMNzrqQNQDO/aeQwf4KbQYj56o67WvhRs/dJKS5udhyIXLDNQQlW fbBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bQEfM4n6TCFubmeCwxCiY1DpSUPRcPxPp5pq9eesneY=; b=Mmy+mV/H0JtfD5GDh/pMy6qoEGJNQKT9aKtHoyLk+uI9SNJvnHYoklgwj30i3zRZSE 6/XGY0ctUXPxWc9VPNqcpgvDO5rj4TE+/b9Aa24BD33hrNyHUA5sGn8pM0pRwdYyEyxd beeYKw0Z0Igrs44EqCFwQs9mEBMLT4GwyhunFTr+qfsURzWIRG8b+Viwh5YlD9qkW6LL vWC5ZBCjuLDCpnoFhBiRiZ9sLhtCGZQ24DTZj11WDcFhooIvF9beJOtObc2b+bmxhhMK eNDMZruICNJ938p4zO5Eb1DC6ezi6haJa7muWaW6KoREas+vKV2CxoxT7MRopUuWBoZL nt/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=wjwdiDmm; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a05640235cf00b0043a9b826da3si4918782edc.233.2022.07.09.19.20.43; Sat, 09 Jul 2022 19:21:07 -0700 (PDT) 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=qcdkim header.b=wjwdiDmm; 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 S229634AbiGJCLA (ORCPT + 99 others); Sat, 9 Jul 2022 22:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbiGJCK5 (ORCPT ); Sat, 9 Jul 2022 22:10:57 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6F0E1183E; Sat, 9 Jul 2022 19:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1657419057; x=1688955057; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=bQEfM4n6TCFubmeCwxCiY1DpSUPRcPxPp5pq9eesneY=; b=wjwdiDmmpgRnkLL2XVqu8fOX+MKOJQreRq4zxLGyR7WbtszTRx0vjuIE P/uclD7xcaXzhJHNeNq+D8mgO6Se1gN9Gg2Xf5r9CMbL8xzFZh9IlF0mX IoNfmfAQqKuMlbvPQbGAAMuYq/AxuadHF2JWkGVcA2vtfFK6ybCXrKb3z c=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 09 Jul 2022 19:10:56 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jul 2022 19:10:56 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Sat, 9 Jul 2022 19:10:55 -0700 Received: from jinlmao-gv.qualcomm.com (10.80.80.8) 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.22; Sat, 9 Jul 2022 19:10:51 -0700 From: Mao Jinlong To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Konrad Dybcio , Mike Leach CC: Mao Jinlong , Leo Yan , Greg Kroah-Hartman , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang , Trilok Soni , Hao Zhang , , Bjorn Andersson Subject: [PATCH v12 1/9] coresight: core: Use IDR for non-cpu bound sources' paths. Date: Sun, 10 Jul 2022 10:10:24 +0800 Message-ID: <20220710021032.27455-2-quic_jinlmao@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220710021032.27455-1-quic_jinlmao@quicinc.com> References: <20220710021032.27455-1-quic_jinlmao@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 d2b301b8a734..4d5867f87791 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 @@ -27,6 +28,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. @@ -43,14 +51,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 @@ -1048,6 +1048,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; @@ -1102,7 +1103,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 */ @@ -1126,6 +1134,7 @@ void coresight_disable(struct coresight_device *csdev) { int cpu, ret; struct list_head *path = NULL; + u32 hash; mutex_lock(&coresight_mutex); @@ -1143,14 +1152,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); -- 2.17.1