Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1887101iol; Fri, 10 Jun 2022 17:59:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzduj6+GC4AT+LahxTULfn4csf7Y7Neroe0jxydiGMXNUXUs7qh2I7poBt0BNO+2BUp0fsD X-Received: by 2002:a17:902:f70a:b0:153:88c7:774 with SMTP id h10-20020a170902f70a00b0015388c70774mr47254163plo.166.1654909140854; Fri, 10 Jun 2022 17:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654909140; cv=none; d=google.com; s=arc-20160816; b=GvD5Pey/xJbGZPky0cnVesSbVUUHDehEYZqJqZS8Sv4E7Y3YVBRyUzUcXwhsfJWPR9 8K0Hjz6qe98CjxspTXtkLyvcslICenJ1cUXefVRCQaOoEVOR5L9rSOyCwvCiYmlMmje+ JaHrnQtZJTZcKkcoqntDHiu3o5I3YNZhS29Q7X+NVBiMsT/XGNY2XDrAkHl9hLHQRm3D V1GvGF7CGwXQckcxP1vFOAQnbHKFitpPfhnbMmxdAfHq+JDAZ04rMffCrqnhWd1qXwLX ibzVbvsPhpKaoxV1x1ahuN7mMru+wrMFzxaoMWvK9e5Gi3FD4zgDNonpVDfY6r7J1KiI 9B1g== 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=k53j15Te25HMdQ8gsnbKOwZKL0zwItkm6JoC0UjVfGo=; b=adkZuOAqemnrvn8NBC3aZHE5mT2m3xls0Cx7UPYIwjP4Z7GYGTPoBwxX1ipCjq1eGX WEh5GTql2kt0AaE1+RWV15EDhuf6qQ6LUjdL/lSe2C2VocTxwM7B7OHbPkBmFgZeWFyN yZKQ6q8m9UQmgKXim7QFs5IJqnVBIl/kKp+66nYZqQ1zDpJx+U1HFn45t0B7XYAm/MOG dQcRSiWlI9YszxLBxWgJ8y6a4uBB7Jaj20QkEr1vBe371Bvc9CNvIeU/9dTkPHJBtwEQ QYm9VGKd4s2TgYGrnZtNlnI1n0G0Vlp1YIX0vyxYwg24DFQX8RjVvqa977+Nio8e6gW3 A3nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=FNiCMixf; 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 e13-20020a056a001a8d00b005108171fe28si532095pfv.162.2022.06.10.17.58.49; Fri, 10 Jun 2022 17:59:00 -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=FNiCMixf; 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 S229693AbiFKAoA (ORCPT + 99 others); Fri, 10 Jun 2022 20:44:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344260AbiFKAn4 (ORCPT ); Fri, 10 Jun 2022 20:43:56 -0400 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A99E514CA2B; Fri, 10 Jun 2022 17:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1654908235; x=1686444235; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=k53j15Te25HMdQ8gsnbKOwZKL0zwItkm6JoC0UjVfGo=; b=FNiCMixfFKNetOmY6WrquEFWKagUTK1iUHNDgts241bVqgTE0ksWtYqq Pa9GJ1rmw5Jx1rbdFmFTsKf00H2myBRTeLeP6OI8b0St6yF3CDnrKNe0+ r9+nHYg1uc3/4S7XkoNYCnAj+FKGSHE9oCV6uMPURINS0YKSqID0nrVzO Y=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 10 Jun 2022 17:43:55 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2022 17:43:55 -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; Fri, 10 Jun 2022 17:43:54 -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; Fri, 10 Jun 2022 17:43:50 -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 v10 01/10] coresight: core: Use IDR for non-cpu bound sources' paths. Date: Sat, 11 Jun 2022 08:43:22 +0800 Message-ID: <20220611004331.7343-2-quic_jinlmao@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220611004331.7343-1-quic_jinlmao@quicinc.com> References: <20220611004331.7343-1-quic_jinlmao@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: 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 bbf415c252f9..23ab16dd9b5d 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; - /* * Set up a global trace ID map. * We may need a per sink ID map in future for larger / multi sink systems. @@ -1061,6 +1061,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; @@ -1115,7 +1116,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 */ @@ -1139,6 +1147,7 @@ void coresight_disable(struct coresight_device *csdev) { int cpu, ret; struct list_head *path = NULL; + u32 hash; mutex_lock(&coresight_mutex); @@ -1156,14 +1165,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