From patchwork Wed Jan 31 08:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mao Jinlong X-Patchwork-Id: 194577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1749056dyb; Wed, 31 Jan 2024 00:36:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjteuXYan3BR6UGEKTv/fc0Fp7AdaGw2Q/EtnxOW77ikpO0A2da8ktRIfpEk6RjEeh04Jk X-Received: by 2002:a05:620a:2157:b0:783:35e0:e7 with SMTP id m23-20020a05620a215700b0078335e000e7mr816835qkm.51.1706690193309; Wed, 31 Jan 2024 00:36:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706690193; cv=pass; d=google.com; s=arc-20160816; b=oBuwnMVLIUlF3syCZkUBT2GDfp+WpU2RZxGrrA6YUecviusIPge3kSytE9IECY8gu0 S7AnbMZPvMHykY0SjJaozsl5Q+oLfXgEKHOIe0p+7SK0XXV79ad/reJLVArfpAfB8lOS rUfydeqrI4Fx//cjRBqLx9FCrpM6JC9BBwcNN6FYK4JAZfwNYtGdUOqq+K6US8zdE1N8 zG4XWGrrBTcsGZLXYjkIz0TTvoNqWVP8jjIUbt8jzMn4byIi+Pk1v9zq8cTUyxdB+2Q9 0BrkZKYZlhKW7EubWBat/MSn9h/OuZxiq5mz2s5VutvssVhpoDsqTJ9M3KCTJIVIiL0P ouQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=x6b9QJbN/4opz0IFJtOwxH/Vn5GmCg0lvfo4hoEWj0s=; fh=QxWkikSUgdulD3kPYMhYEFsn24LkejorvoheA4M76A8=; b=LYPOiVsr6EREx/I47Hwp35mw/QTh3pCUn09v5NEIQqEGDhBoaPEk1YETtvJO1oboTD Nze9Jf3wImD+e2IQPy3sBtrzHpRV4m5Cu+up2/2H3AebF94lBTv6J93w+KcAchx0z372 V9eT85Od/fnJnG++GiwrBKpOm/67SivYRZlACZX0c7YaFAly0DVWi7I+Ha7NNs7rlG7e Hoqk+xulPgqllNU2MiYVx8HKKlW/hghZoYXDKceWrAVyGrv+WiLW1YVRtrQ2flSS9q9d vV9TQRUesB98tUksU6vwdPlUHNSLO26d/zO1L+6UoYWWJhmO9jCTF4tIg1qGUC6CLirP IYFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SvnaHswf; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-45995-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45995-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com X-Forwarded-Encrypted: i=1; AJvYcCUZhfbEsxIuMAnzVd73u5TkPMI1dKD8y3/Oy7+PDzVdA6wH9MKB/Ijb+KFY7Sp3KRHGB77U1sGpinaz62FRDAbThn3E6A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a10-20020a05620a16ca00b00783f0a9505asi6879921qkn.283.2024.01.31.00.36.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 00:36:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-45995-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=SvnaHswf; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-45995-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-45995-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 192901C27DA6 for ; Wed, 31 Jan 2024 08:27:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 079485FF18; Wed, 31 Jan 2024 08:27:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="SvnaHswf" 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 875C4657AB; Wed, 31 Jan 2024 08:27:19 +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=1706689641; cv=none; b=uLMvTSE5NbrpaHWt6f/Kc+vZjdy6ri99qV51J+ERMPAWTJooFgxtDb6wmtVxYfL9upGKBGYrb9iKbIWcX7XM9rlRYyd1L4+rm7UKmJ0nHUej/yF7xajNWfe4DSqmm3ifhsMxA41wsqKuLXoDUUKKXcIvb9vlT6cUCeerLvJPAyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706689641; c=relaxed/simple; bh=X9YKko7TrU5gWL0cHJXiWOrEIv2uin65fLz2rxn6+Ac=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YnFnKx+bYNUxxXNQmP1cCpwGfClOlmiWK+TvdmN2KsTQXNSFwgB6s2s/KXr31mSuNht/WHm/PBrk+e2O18gz4URixRn84eZNTR6sykpqGODo/xdNU6CT2JxKnvHKidfxN14Bcg1rOJp103JnGZGYOm/xnz/DqAnKqEeVyf5SNl0= 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=SvnaHswf; 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 Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40V7fBiJ011244; Wed, 31 Jan 2024 08:26:42 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=x6b9QJbN/4opz0IFJtOwxH/Vn5GmCg0lvfo4hoEWj0s=; b=Sv naHswfoqJShvWeGhp7wbsWxHwolN1bsDD7szaPAjhJThSxX3nBVS7wgsZmiFbw6i eQkvmpnuUP0u9IZjoH3iZwDQzyPr5G8AGOVJwXWg4Um+udtnb1v3h/NyvbZYi6OU ayOtZ5TEcwI3tZjKNSsvYSByaz8PPY/NIDIn2tq9beaJPie5QDsSq2J7y5Nr8QmW FFbGp3nlxjoynLwIp4u7mVCmZ0Y43Uor9ztGsWsB6kZ9Koiz1SEC3UgPlCePRD10 EVQt8TWMpdOCzWOnpCGlPsImIQvBy//EDVWggngovbqUgLHZl4XifpPCT1bRK3lv oDjxazOSdW3DfIsY0ukw== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3vyj1483h5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 08:26:41 +0000 (GMT) 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 40V8QeOs006056 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jan 2024 08:26:40 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.1118.40; Wed, 31 Jan 2024 00:26:40 -0800 From: Mao Jinlong To: Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , Alexander Shishkin , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , "Alexandre Torgue" , Bjorn Andersson , Konrad Dybcio , "Mathieu Poirier" CC: Mao Jinlong , , , , , , , Tingwei Zhang , Yuanfang Zhang , Tao Zhang Subject: [PATCH v3 1/2] coresight: core: Add device name support Date: Wed, 31 Jan 2024 00:26:25 -0800 Message-ID: <20240131082628.6288-2-quic_jinlmao@quicinc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240131082628.6288-1-quic_jinlmao@quicinc.com> References: <20240131082628.6288-1-quic_jinlmao@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: oG6TbRR8vUUXrEvwSJ8ukAKcqMvDvyxj X-Proofpoint-ORIG-GUID: oG6TbRR8vUUXrEvwSJ8ukAKcqMvDvyxj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-31_03,2024-01-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 bulkscore=0 adultscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxlogscore=999 spamscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2401190000 definitions=main-2401310063 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789594329288428415 X-GMAIL-MSGID: 1789594376186277961 For some coresight components like CTI and TPDM, there could be numerous of them. From the node name, we can only get the type and register address of the component. We can't identify the HW or the system the component belongs to. Add the device-name support for adding the intuitive name of the device. Signed-off-by: Mao Jinlong --- drivers/hwtracing/coresight/coresight-core.c | 37 ++++++++++--------- .../hwtracing/coresight/coresight-platform.c | 31 ++++++++++++++++ include/linux/coresight.h | 3 +- 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 5dde597403b3..8e836e8f407c 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1766,33 +1766,36 @@ EXPORT_SYMBOL_GPL(coresight_loses_context_with_cpu); * duplicate indices for the same device (e.g, if we defer probing of * a device due to dependencies), in case the index is requested again. */ -char *coresight_alloc_device_name(struct coresight_dev_list *dict, +const char *coresight_alloc_device_name(struct coresight_dev_list *dict, struct device *dev) { int idx; - char *name = NULL; + const char *name = NULL; struct fwnode_handle **list; mutex_lock(&coresight_mutex); - idx = coresight_search_device_idx(dict, dev_fwnode(dev)); - if (idx < 0) { - /* Make space for the new entry */ - idx = dict->nr_idx; - list = krealloc_array(dict->fwnode_list, - idx + 1, sizeof(*dict->fwnode_list), - GFP_KERNEL); - if (ZERO_OR_NULL_PTR(list)) { - idx = -ENOMEM; - goto done; + name = coresight_get_device_name(dev); + if (!name) { + idx = coresight_search_device_idx(dict, dev_fwnode(dev)); + if (idx < 0) { + /* Make space for the new entry */ + idx = dict->nr_idx; + list = krealloc_array(dict->fwnode_list, + idx + 1, sizeof(*dict->fwnode_list), + GFP_KERNEL); + if (ZERO_OR_NULL_PTR(list)) { + idx = -ENOMEM; + goto done; + } + + list[idx] = dev_fwnode(dev); + dict->fwnode_list = list; + dict->nr_idx = idx + 1; } - list[idx] = dev_fwnode(dev); - dict->fwnode_list = list; - dict->nr_idx = idx + 1; + name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx); } - - name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx); done: mutex_unlock(&coresight_mutex); return name; diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 9d550f5697fa..c6c68fc9f787 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -183,6 +183,22 @@ static int of_coresight_get_cpu(struct device *dev) return cpu; } +static const char *of_coresight_get_device_name(struct device *dev) +{ + const char *name = NULL; + + if (!dev->of_node) + return NULL; + + /* + * Get the device name from DT. The name describes the HW or + * system the device is for. + */ + of_property_read_string(dev->of_node, "device-name", &name); + + return name; +} + /* * of_coresight_parse_endpoint : Parse the given output endpoint @ep * and fill the connection information in @pdata->out_conns @@ -315,6 +331,12 @@ static inline int of_coresight_get_cpu(struct device *dev) { return -ENODEV; } + +static inline const char *of_coresight_get_device_name(struct device *dev) +{ + return NULL; +} + #endif #ifdef CONFIG_ACPI @@ -794,6 +816,15 @@ int coresight_get_cpu(struct device *dev) } EXPORT_SYMBOL_GPL(coresight_get_cpu); +const char *coresight_get_device_name(struct device *dev) +{ + if (is_of_node(dev->fwnode)) + return of_coresight_get_device_name(dev); + else + return NULL; +} +EXPORT_SYMBOL_GPL(coresight_get_device_name); + struct coresight_platform_data * coresight_get_platform_data(struct device *dev) { diff --git a/include/linux/coresight.h b/include/linux/coresight.h index e8b6e388218c..9d50a91a3fc7 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -582,7 +582,7 @@ extern int coresight_claim_device_unlocked(struct coresight_device *csdev); extern void coresight_disclaim_device(struct coresight_device *csdev); extern void coresight_disclaim_device_unlocked(struct coresight_device *csdev); -extern char *coresight_alloc_device_name(struct coresight_dev_list *devs, +extern const char *coresight_alloc_device_name(struct coresight_dev_list *devs, struct device *dev); extern bool coresight_loses_context_with_cpu(struct device *dev); @@ -676,6 +676,7 @@ static inline void coresight_write64(struct coresight_device *csdev, u64 val, u3 #endif /* IS_ENABLED(CONFIG_CORESIGHT) */ extern int coresight_get_cpu(struct device *dev); +extern const char *coresight_get_device_name(struct device *dev); struct coresight_platform_data *coresight_get_platform_data(struct device *dev); struct coresight_connection *