Message ID | 20231228093321.5522-1-quic_jinlmao@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-12535-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1891965dyb; Thu, 28 Dec 2023 01:35:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNXFeMbCbTTmfDsdvOLtg/iFlwEwIGXWphSjzYcip1cGJwOYO5RsEK+pWD1daPsJVv6r1l X-Received: by 2002:a17:906:74c2:b0:a23:339f:3313 with SMTP id z2-20020a17090674c200b00a23339f3313mr4884740ejl.55.1703756105177; Thu, 28 Dec 2023 01:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703756105; cv=none; d=google.com; s=arc-20160816; b=SDMTV6Qoa4D/ulpCqOzmX1ssEVvtwBvbakW6ELy99JDiGCkLYjsoSlZwtarKgmJBR5 QzdjiPCx1qah452ccg7wBWqg0x6yLFF8nlitUAtOG7jEPfcfrH14VmlT4zSHdpS0kFAC 4DfzFOs1Axk7wvwsV0eWzbORcLXB3YoWs0R3xaZMt+px4pc/goXghWoBOfbF3gPctC9l QcvHd5Ixfm9ffXsgGv9HZVt80e8NiMrSCrAnp132fo7ArCzbiUb2lKcnvoFwVVPae/lU be8EhTHqKiJr8VYVrtyu1FJv0+hOJSkLwmtUA7vQj7zLQKFRV52deVNbLXmRJIL5VOEe F9AQ== ARC-Message-Signature: i=1; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=3V3kSOAOwccGH7vwGx91DHobrSy3nxlzWo29d0Rsq1w=; fh=UYtvLCUEIUbgvSnlzYB+C7Aof+n3bbLIEmv8+X+BSBY=; b=Lmtcyp5o2Hbe5ObQC03X0NXMyjCaJlRBkhaYsBgj1SmHvbHvGlxePgzCEJCMp54YMo qoeQwRZp6mgAOQJSuYzKl4v6S3+j7Hz2kHtxIYgxhmRKE88Qt9i1OgZf9ZtzwVbxeKpi lcG/gkew3gOMwqTliiqBql6qPLrjg2/npgyeBx2mtXbUabdZIPUFUJXN0y3GZicbMPYu 38y+r57/w5cKQwMAHw5zSpchxxfiiO8oSNbRUAJBh8KimirVN+pxyUYvNHbpYwzOyD1k W5aiqkEl46zuujUFMHmI2pZNFAGI4HAdy2RZDY51NrFVfy12rTNcYx3yuBLObPRIGv34 IsLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eENMT9lE; spf=pass (google.com: domain of linux-kernel+bounces-12535-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12535-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 28-20020a170906101c00b00a1db94ef722si6814990ejm.199.2023.12.28.01.35.04 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 01:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12535-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=eENMT9lE; spf=pass (google.com: domain of linux-kernel+bounces-12535-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12535-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 9F04D1F22740 for <ouuuleilei@gmail.com>; Thu, 28 Dec 2023 09:35:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 218466FA1; Thu, 28 Dec 2023 09:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="eENMT9lE" X-Original-To: linux-kernel@vger.kernel.org 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 C2AD363B6; Thu, 28 Dec 2023 09:34:44 +0000 (UTC) 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 (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BS9XYdX005402; Thu, 28 Dec 2023 09:33:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=3V3kSOA OwccGH7vwGx91DHobrSy3nxlzWo29d0Rsq1w=; b=eENMT9lET+jKLILcfCbrDZu KjAQHhKWuy+KTuGsDuIcUScMPfv6DE4vtabpGEJtF7qCgWsh6RJLRy/snkBhOHYY ANgYwTHOrabuV+LEcsqG/mPPzROLrZmXjLwso0V9iED7+FdbqfIQ+Kk1q5IT3k5U iErHUtT7MpSVZqVTfQQDTBKLEfBBHQONtQtiDdsvuowQ/3LkM36hnHi4S9wiRX0R vJfKfM2/TTQKxoFE1tGqEJ6n7anr2JNMhacsREh3CtZ+H/z5dd9L2nklLNf/BtB3 iiE8peHWTAkB0fSZcpu7ya/QXfVEB5803Fl+hN6uVOFhVnDzPystF4As9QvPVQg= = Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v8hbgaa5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Dec 2023 09:33:34 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BS9XX1Z007595 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Dec 2023 09:33:33 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; Thu, 28 Dec 2023 01:33:33 -0800 From: Mao Jinlong <quic_jinlmao@quicinc.com> To: Suzuki K Poulose <suzuki.poulose@arm.com>, Mike Leach <mike.leach@linaro.org>, James Clark <james.clark@arm.com>, Leo Yan <leo.yan@linaro.org>, Alexander Shishkin <alexander.shishkin@linux.intel.com> CC: Mao Jinlong <quic_jinlmao@quicinc.com>, <coresight@lists.linaro.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>, Tingwei Zhang <quic_tingweiz@quicinc.com>, Yuanfang Zhang <quic_yuanfang@quicinc.com>, Tao Zhang <quic_taozha@quicinc.com> Subject: [PATCH] coresight: Add coresight name support Date: Thu, 28 Dec 2023 01:33:19 -0800 Message-ID: <20231228093321.5522-1-quic_jinlmao@quicinc.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) 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-ORIG-GUID: 1vrc7teFwwSHAcIFVZv_acjCvHve53-h X-Proofpoint-GUID: 1vrc7teFwwSHAcIFVZv_acjCvHve53-h X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 mlxscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312280076 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786517761506230608 X-GMAIL-MSGID: 1786517761506230608 |
Series |
coresight: Add coresight name support
|
|
Commit Message
Mao Jinlong
Dec. 28, 2023, 9:33 a.m. UTC
Add coresight name support for custom names which will be
easy to identify the device by the name.
Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
---
.../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------
drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++---
.../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++
drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++---
include/linux/coresight.h | 1 +
5 files changed, 53 insertions(+), 15 deletions(-)
Comments
On 28/12/2023 09:33, Mao Jinlong wrote: > Add coresight name support for custom names which will be > easy to identify the device by the name. > I suppose this is more of a V2 because the subject is the same as the one sent earlier this year. But it looks like the discussion on the previous one wasn't resolved. With the main issues to solve being: * It would be nice to use the existing root node name instead of adding a new property. But at the same time DT nodes are supposed to have generic names. * This only works for DT and not ACPI To me it seems like adding the new property is just a "cheat" to get around not being allowed to have a specific name for the root node. But if we admit that we need a name I don't see the benefit of not putting the name where the node is already named. Using the root node name at this point would also undo the hard coded per-cpu naming of the CTI and ETM devices, so maybe it would be nice, but it's just too late. That means that a new field is necessary. Although that field could be a boolean like "use-root-name-for-display" or something like that. In the end it probably doesn't really make a difference whether it's that or a name string. And maybe the answer to the ACPI question is just that if anyone needs it, they can add it in the future. It doesn't seem like it would conflict with anything we do here. > Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> > --- > .../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------ > drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++--- > .../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++ > drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++--- > include/linux/coresight.h | 1 + > 5 files changed, 53 insertions(+), 15 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c > index 3999d0a2cb60..60a1e76064a9 100644 > --- a/drivers/hwtracing/coresight/coresight-cti-core.c > +++ b/drivers/hwtracing/coresight/coresight-cti-core.c > @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id) > /* default to powered - could change on PM notifications */ > drvdata->config.hw_powered = true; > > - /* set up device name - will depend if cpu bound or otherwise */ > - if (drvdata->ctidev.cpu >= 0) > - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", > - drvdata->ctidev.cpu); > - else > - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); Can we put the new name stuff inside coresight_alloc_device_name()? Then it happens by default for every device. I know Suzuki said previously to do it per-device, but the new DT property is just "coresight-name", so it's generic. Rather than being specific like "cti-name". So I don't see the benefit of duplicating the code at this point if we do decide to do it. > - if (!cti_desc.name) > - return -ENOMEM; > + cti_desc.name = coresight_get_device_name(dev); > + if (!cti_desc.name) { > + /* set up device name - will depend if cpu bound or otherwise */ > + if (drvdata->ctidev.cpu >= 0) > + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", > + drvdata->ctidev.cpu); > + else { > + cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); > + if (!cti_desc.name) > + return -ENOMEM; > + } > + } > > /* setup CPU power management handling for CPU bound CTI devices. */ > ret = cti_pm_setup(drvdata); > diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c > index e4deafae7bc2..b19cd400df79 100644 > --- a/drivers/hwtracing/coresight/coresight-dummy.c > +++ b/drivers/hwtracing/coresight/coresight-dummy.c > @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) > struct coresight_desc desc = { 0 }; > > if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { > - > - desc.name = coresight_alloc_device_name(&source_devs, dev); > - if (!desc.name) > - return -ENOMEM; > + desc.name = coresight_get_device_name(dev); > + if (!desc.name) { > + desc.name = coresight_alloc_device_name(&source_devs, dev); > + if (!desc.name) > + return -ENOMEM; > + } > > desc.type = CORESIGHT_DEV_TYPE_SOURCE; > desc.subtype.source_subtype = > diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c > index 9d550f5697fa..284aa22a06b7 100644 > --- a/drivers/hwtracing/coresight/coresight-platform.c > +++ b/drivers/hwtracing/coresight/coresight-platform.c > @@ -183,6 +183,18 @@ 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; > + > + of_property_read_string(dev->of_node, "coresight-name", &name); Do you need to update the binding docs with this new property? Also a minor nit: Maybe "display-name" is better? "Coresight" is implied, and the node is already named, although that node name isn't used for display purposes, but this one is. Thanks James
As James mentions this is clearly a V2 of a previous patch - please mark as such in future. Adding to what James has already said:- 1) Mapping between the canonical names used in the drivers and the information as to the precise device is as easy as running 'ls' on /sys/bus/coresight/devices:- root@linaro-developer:/home/linaro/cs-mods# ls -al /sys/bus/coresight/devices/ total 0 drwxr-xr-x 2 root root 0 Jan 2 11:27 . drwxr-xr-x 4 root root 0 Jan 2 11:27 .. lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu0 -> ../../../devices/platform/soc@0/858000.cti/cti_cpu0 lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu1 -> ../../../devices/platform/soc@0/859000.cti/cti_cpu1 lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu2 -> ../../../devices/platform/soc@0/85a000.cti/cti_cpu2 lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu3 -> ../../../devices/platform/soc@0/85b000.cti/cti_cpu3 lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys0 -> ../../../devices/platform/soc@0/810000.cti/cti_sys0 lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys1 -> ../../../devices/platform/soc@0/811000.cti/cti_sys1 lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm0 -> ../../../devices/platform/soc@0/85c000.etm/etm0 lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm1 -> ../../../devices/platform/soc@0/85d000.etm/etm1 lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm2 -> ../../../devices/platform/soc@0/85e000.etm/etm2 lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm3 -> ../../../devices/platform/soc@0/85f000.etm/etm3 lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel0 -> ../../../devices/platform/soc@0/821000.funnel/funnel0 lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel1 -> ../../../devices/platform/soc@0/841000.funnel/funnel1 lrwxrwxrwx 1 root root 0 Jan 2 11:42 replicator0 -> ../../../devices/platform/soc@0/824000.replicator/replicator0 lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etf0 -> ../../../devices/platform/soc@0/825000.etf/tmc_etf0 lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etr0 -> ../../../devices/platform/soc@0/826000.etr/tmc_etr0 2) The patch set must contain the usage and specification in the .yaml file(s) of the property used. However, there was a standard property called 'name' which is deprecated - see https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html section 2.3.11. I do not believe that adding another 'name' property would be accepted by the DT maintainers. 3) the 'device_node' structure has a 'name' field that contains the node name in the DT approved "node-name@unit-address" format.This contains whatever node names you used in the dt. Why not use this if a change has to be made and find some conditional to activate it. However, given point 1) above, the problem is solved and the patch adds no new information not already available. Regards Mike On Thu, 28 Dec 2023 at 11:26, James Clark <james.clark@arm.com> wrote: > > > > On 28/12/2023 09:33, Mao Jinlong wrote: > > Add coresight name support for custom names which will be > > easy to identify the device by the name. > > > > I suppose this is more of a V2 because the subject is the same as the > one sent earlier this year. But it looks like the discussion on the > previous one wasn't resolved. > > With the main issues to solve being: > > * It would be nice to use the existing root node name instead of adding > a new property. But at the same time DT nodes are supposed to have > generic names. > > * This only works for DT and not ACPI > > To me it seems like adding the new property is just a "cheat" to get > around not being allowed to have a specific name for the root node. But > if we admit that we need a name I don't see the benefit of not putting > the name where the node is already named. > > Using the root node name at this point would also undo the hard coded > per-cpu naming of the CTI and ETM devices, so maybe it would be nice, > but it's just too late. That means that a new field is necessary. > Although that field could be a boolean like "use-root-name-for-display" > or something like that. In the end it probably doesn't really make a > difference whether it's that or a name string. > > And maybe the answer to the ACPI question is just that if anyone needs > it, they can add it in the future. It doesn't seem like it would > conflict with anything we do here. > > > Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> > > --- > > .../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------ > > drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++--- > > .../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++ > > drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++--- > > include/linux/coresight.h | 1 + > > 5 files changed, 53 insertions(+), 15 deletions(-) > > > > diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c > > index 3999d0a2cb60..60a1e76064a9 100644 > > --- a/drivers/hwtracing/coresight/coresight-cti-core.c > > +++ b/drivers/hwtracing/coresight/coresight-cti-core.c > > @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id) > > /* default to powered - could change on PM notifications */ > > drvdata->config.hw_powered = true; > > > > - /* set up device name - will depend if cpu bound or otherwise */ > > - if (drvdata->ctidev.cpu >= 0) > > - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", > > - drvdata->ctidev.cpu); > > - else > > - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); > > Can we put the new name stuff inside coresight_alloc_device_name()? Then > it happens by default for every device. > > I know Suzuki said previously to do it per-device, but the new DT > property is just "coresight-name", so it's generic. Rather than being > specific like "cti-name". So I don't see the benefit of duplicating the > code at this point if we do decide to do it. > > > - if (!cti_desc.name) > > - return -ENOMEM; > > + cti_desc.name = coresight_get_device_name(dev); > > + if (!cti_desc.name) { > > + /* set up device name - will depend if cpu bound or otherwise */ > > + if (drvdata->ctidev.cpu >= 0) > > + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", > > + drvdata->ctidev.cpu); > > + else { > > + cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); > > + if (!cti_desc.name) > > + return -ENOMEM; > > + } > > + } > > > > > /* setup CPU power management handling for CPU bound CTI devices. */ > > ret = cti_pm_setup(drvdata); > > diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c > > index e4deafae7bc2..b19cd400df79 100644 > > --- a/drivers/hwtracing/coresight/coresight-dummy.c > > +++ b/drivers/hwtracing/coresight/coresight-dummy.c > > @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) > > struct coresight_desc desc = { 0 }; > > > > if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { > > - > > - desc.name = coresight_alloc_device_name(&source_devs, dev); > > - if (!desc.name) > > - return -ENOMEM; > > + desc.name = coresight_get_device_name(dev); > > + if (!desc.name) { > > + desc.name = coresight_alloc_device_name(&source_devs, dev); > > + if (!desc.name) > > + return -ENOMEM; > > + } > > > > desc.type = CORESIGHT_DEV_TYPE_SOURCE; > > desc.subtype.source_subtype = > > diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c > > index 9d550f5697fa..284aa22a06b7 100644 > > --- a/drivers/hwtracing/coresight/coresight-platform.c > > +++ b/drivers/hwtracing/coresight/coresight-platform.c > > @@ -183,6 +183,18 @@ 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; > > + > > + of_property_read_string(dev->of_node, "coresight-name", &name); > > Do you need to update the binding docs with this new property? > > Also a minor nit: Maybe "display-name" is better? "Coresight" is > implied, and the node is already named, although that node name isn't > used for display purposes, but this one is. > > Thanks > James
On 28/12/2023 11:26, James Clark wrote: > > > On 28/12/2023 09:33, Mao Jinlong wrote: >> Add coresight name support for custom names which will be >> easy to identify the device by the name. >> > > I suppose this is more of a V2 because the subject is the same as the > one sent earlier this year. But it looks like the discussion on the > previous one wasn't resolved. > > With the main issues to solve being: > > * It would be nice to use the existing root node name instead of adding > a new property. But at the same time DT nodes are supposed to have > generic names. > > * This only works for DT and not ACPI > > To me it seems like adding the new property is just a "cheat" to get > around not being allowed to have a specific name for the root node. But > if we admit that we need a name I don't see the benefit of not putting > the name where the node is already named. > > Using the root node name at this point would also undo the hard coded > per-cpu naming of the CTI and ETM devices, so maybe it would be nice, > but it's just too late. That means that a new field is necessary. The CTI and ETM can be handled as special cases, like they are already done and fall back to the nodename for the rest ? But, I thought the node names must be generic (e.g, cti) and doesn't really solve the naming requirements for naming CTIs. (e.g, <device>_tpda, etr_cti). Is there something I missed ? > Although that field could be a boolean like "use-root-name-for-display" > or something like that. In the end it probably doesn't really make a > difference whether it's that or a name string. > > And maybe the answer to the ACPI question is just that if anyone needs > it, they can add it in the future. It doesn't seem like it would > conflict with anything we do here. > >> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> >> --- >> .../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------ >> drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++--- >> .../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++ >> drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++--- >> include/linux/coresight.h | 1 + >> 5 files changed, 53 insertions(+), 15 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c >> index 3999d0a2cb60..60a1e76064a9 100644 >> --- a/drivers/hwtracing/coresight/coresight-cti-core.c >> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c >> @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id) >> /* default to powered - could change on PM notifications */ >> drvdata->config.hw_powered = true; >> >> - /* set up device name - will depend if cpu bound or otherwise */ >> - if (drvdata->ctidev.cpu >= 0) >> - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >> - drvdata->ctidev.cpu); >> - else >> - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); > > Can we put the new name stuff inside coresight_alloc_device_name()? Then > it happens by default for every device. +1 > > I know Suzuki said previously to do it per-device, but the new DT > property is just "coresight-name", so it's generic. Rather than being > specific like "cti-name". So I don't see the benefit of duplicating the > code at this point if we do decide to do it. My suggestion was to name the device based on the specific device rather than following a generic rule for all device. e.g., A TPDM connected to modem, could be named as such based on the platform information. It could be any means, for e.g., tpdm nodes are always children nodes of the devices they are connected to ? or could have a phandle to point to the device they are monitoring etc. And the name could be created from the "monitoring device name" + tpdm. Also, we do this for CPU bound CTI and ETMs already, where we name them based on the CPU. But then the "nodename" is something we explored and it looks like may not be an option. > >> - if (!cti_desc.name) >> - return -ENOMEM; >> + cti_desc.name = coresight_get_device_name(dev); >> + if (!cti_desc.name) { >> + /* set up device name - will depend if cpu bound or otherwise */ >> + if (drvdata->ctidev.cpu >= 0) >> + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >> + drvdata->ctidev.cpu); >> + else { >> + cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); >> + if (!cti_desc.name) >> + return -ENOMEM; >> + } >> + } For these special cases, i.e., CPU bound, we should handle them with priority. if (drvdata->ctidev.cpu >= 0) name = devm_kasprintf(... "cti_cpu%d", .. cpu); else name = coresight_alloc_device_name(...); > >> >> /* setup CPU power management handling for CPU bound CTI devices. */ >> ret = cti_pm_setup(drvdata); >> diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c >> index e4deafae7bc2..b19cd400df79 100644 >> --- a/drivers/hwtracing/coresight/coresight-dummy.c >> +++ b/drivers/hwtracing/coresight/coresight-dummy.c >> @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) >> struct coresight_desc desc = { 0 }; >> >> if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { >> - >> - desc.name = coresight_alloc_device_name(&source_devs, dev); >> - if (!desc.name) >> - return -ENOMEM; >> + desc.name = coresight_get_device_name(dev); >> + if (!desc.name) { >> + desc.name = coresight_alloc_device_name(&source_devs, dev); >> + if (!desc.name) >> + return -ENOMEM; >> + } >> >> desc.type = CORESIGHT_DEV_TYPE_SOURCE; >> desc.subtype.source_subtype = >> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c >> index 9d550f5697fa..284aa22a06b7 100644 >> --- a/drivers/hwtracing/coresight/coresight-platform.c >> +++ b/drivers/hwtracing/coresight/coresight-platform.c >> @@ -183,6 +183,18 @@ 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; >> + >> + of_property_read_string(dev->of_node, "coresight-name", &name); > > Do you need to update the binding docs with this new property? > > Also a minor nit: Maybe "display-name" is better? "Coresight" is > implied, and the node is already named, although that node name isn't > used for display purposes, but this one is. On that front, the name is used as a "device" name and not simply display. So, even "device-name" sounds more appropriate. Suzuki > > Thanks > James
On Tue, Jan 2, 2024 at 5:05 AM Mike Leach <mike.leach@linaro.org> wrote: > > As James mentions this is clearly a V2 of a previous patch - please > mark as such in future. > > Adding to what James has already said:- > > 1) Mapping between the canonical names used in the drivers and the > information as to the precise device is as easy as running 'ls' on > /sys/bus/coresight/devices:- > > root@linaro-developer:/home/linaro/cs-mods# ls -al /sys/bus/coresight/devices/ > total 0 > drwxr-xr-x 2 root root 0 Jan 2 11:27 . > drwxr-xr-x 4 root root 0 Jan 2 11:27 .. > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu0 -> > ../../../devices/platform/soc@0/858000.cti/cti_cpu0 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu1 -> > ../../../devices/platform/soc@0/859000.cti/cti_cpu1 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu2 -> > ../../../devices/platform/soc@0/85a000.cti/cti_cpu2 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu3 -> > ../../../devices/platform/soc@0/85b000.cti/cti_cpu3 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys0 -> > ../../../devices/platform/soc@0/810000.cti/cti_sys0 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys1 -> > ../../../devices/platform/soc@0/811000.cti/cti_sys1 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm0 -> > ../../../devices/platform/soc@0/85c000.etm/etm0 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm1 -> > ../../../devices/platform/soc@0/85d000.etm/etm1 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm2 -> > ../../../devices/platform/soc@0/85e000.etm/etm2 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm3 -> > ../../../devices/platform/soc@0/85f000.etm/etm3 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel0 -> > ../../../devices/platform/soc@0/821000.funnel/funnel0 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel1 -> > ../../../devices/platform/soc@0/841000.funnel/funnel1 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 replicator0 -> > ../../../devices/platform/soc@0/824000.replicator/replicator0 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etf0 -> > ../../../devices/platform/soc@0/825000.etf/tmc_etf0 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etr0 -> > ../../../devices/platform/soc@0/826000.etr/tmc_etr0 > > > 2) The patch set must contain the usage and specification in the .yaml > file(s) of the property used. For the record, I don't like "coresight-name". I don't have another suggestion because "easy" is not sufficient reasoning for why this is needed. > However, there was a standard property called 'name' which is > deprecated - see > https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html > section 2.3.11. I do not believe that adding another 'name' property > would be accepted by the DT maintainers. "name" is just the node name for anything in the last 15 years. They used to be separate, but would still mostly be the same. The only case I found with them different was old PowerPC Macs. > 3) the 'device_node' structure has a 'name' field that contains the > node name in the DT approved "node-name@unit-address" format. Actually, it is without the unit-address. full_name is with the unit-address. > This > contains whatever node names you used in the dt. Why not use this if > a change has to be made and find some conditional to activate it. Don't go accessing "name" or "full_name" directly. I intend to get rid of "name" and generate it from full_name. So use the accessors and printk specifiers if you need node names. Rob
On 12/28/2023 7:26 PM, James Clark wrote: > > > On 28/12/2023 09:33, Mao Jinlong wrote: >> Add coresight name support for custom names which will be >> easy to identify the device by the name. >> > > I suppose this is more of a V2 because the subject is the same as the > one sent earlier this year. But it looks like the discussion on the > previous one wasn't resolved. I will make next patch as V2 > > With the main issues to solve being: > > * It would be nice to use the existing root node name instead of adding > a new property. But at the same time DT nodes are supposed to have > generic names. > > * This only works for DT and not ACPI > > To me it seems like adding the new property is just a "cheat" to get > around not being allowed to have a specific name for the root node. But > if we admit that we need a name I don't see the benefit of not putting > the name where the node is already named. > > Using the root node name at this point would also undo the hard coded > per-cpu naming of the CTI and ETM devices, so maybe it would be nice, > but it's just too late. That means that a new field is necessary. > Although that field could be a boolean like "use-root-name-for-display" > or something like that. In the end it probably doesn't really make a > difference whether it's that or a name string. > > And maybe the answer to the ACPI question is just that if anyone needs > it, they can add it in the future. It doesn't seem like it would > conflict with anything we do here. > >> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> >> --- >> .../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------ >> drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++--- >> .../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++ >> drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++--- >> include/linux/coresight.h | 1 + >> 5 files changed, 53 insertions(+), 15 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c >> index 3999d0a2cb60..60a1e76064a9 100644 >> --- a/drivers/hwtracing/coresight/coresight-cti-core.c >> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c >> @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id) >> /* default to powered - could change on PM notifications */ >> drvdata->config.hw_powered = true; >> >> - /* set up device name - will depend if cpu bound or otherwise */ >> - if (drvdata->ctidev.cpu >= 0) >> - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >> - drvdata->ctidev.cpu); >> - else >> - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); > > Can we put the new name stuff inside coresight_alloc_device_name()? Then > it happens by default for every device. > > I know Suzuki said previously to do it per-device, but the new DT > property is just "coresight-name", so it's generic. Rather than being > specific like "cti-name". So I don't see the benefit of duplicating the > code at this point if we do decide to do it. I will add it inside the coresight_alloc_device_name. > >> - if (!cti_desc.name) >> - return -ENOMEM; >> + cti_desc.name = coresight_get_device_name(dev); >> + if (!cti_desc.name) { >> + /* set up device name - will depend if cpu bound or otherwise */ >> + if (drvdata->ctidev.cpu >= 0) >> + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >> + drvdata->ctidev.cpu); >> + else { >> + cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); >> + if (!cti_desc.name) >> + return -ENOMEM; >> + } >> + } > >> >> /* setup CPU power management handling for CPU bound CTI devices. */ >> ret = cti_pm_setup(drvdata); >> diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c >> index e4deafae7bc2..b19cd400df79 100644 >> --- a/drivers/hwtracing/coresight/coresight-dummy.c >> +++ b/drivers/hwtracing/coresight/coresight-dummy.c >> @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) >> struct coresight_desc desc = { 0 }; >> >> if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { >> - >> - desc.name = coresight_alloc_device_name(&source_devs, dev); >> - if (!desc.name) >> - return -ENOMEM; >> + desc.name = coresight_get_device_name(dev); >> + if (!desc.name) { >> + desc.name = coresight_alloc_device_name(&source_devs, dev); >> + if (!desc.name) >> + return -ENOMEM; >> + } >> >> desc.type = CORESIGHT_DEV_TYPE_SOURCE; >> desc.subtype.source_subtype = >> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c >> index 9d550f5697fa..284aa22a06b7 100644 >> --- a/drivers/hwtracing/coresight/coresight-platform.c >> +++ b/drivers/hwtracing/coresight/coresight-platform.c >> @@ -183,6 +183,18 @@ 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; >> + >> + of_property_read_string(dev->of_node, "coresight-name", &name); > > Do you need to update the binding docs with this new property? Yes. I will update the binding doc. > > Also a minor nit: Maybe "display-name" is better? "Coresight" is > implied, and the node is already named, although that node name isn't > used for display purposes, but this one is. From Suzuki's comments, "device-name" should be better. What do you think ? Thanks Jinlong Mao
On 1/2/2024 8:04 PM, Mike Leach wrote: > As James mentions this is clearly a V2 of a previous patch - please > mark as such in future. > > Adding to what James has already said:- > > 1) Mapping between the canonical names used in the drivers and the > information as to the precise device is as easy as running 'ls' on > /sys/bus/coresight/devices:- For the components bounded with CPU, we can easily identify them by the number in the name. But for other components, we can only get the component type and registers address of it. We can't identify which system it belongs to from current name. lrwxrwxrwx 1 root 0 0 Jan 1 00:01 cti_sys0 -> ./../../devices/platform/soc@0/138f0000.cti/cti_sys0 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 cti_sys1 -> ./../../devices/platform/soc@0/13900000.cti/cti_sys1 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 tpdm0 -> ./../../devices/platform/soc@0/10b0d000.tpdm/tpdm0 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 tpdm1 -> ./../../devices/platform/soc@0/10c28000.tpdm/tpdm1 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 tpdm2 -> ./../../devices/platform/soc@0/10c29000.tpdm/tpdm2 > > root@linaro-developer:/home/linaro/cs-mods# ls -al /sys/bus/coresight/devices/ > total 0 > drwxr-xr-x 2 root root 0 Jan 2 11:27 . > drwxr-xr-x 4 root root 0 Jan 2 11:27 .. > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu0 -> > ../../../devices/platform/soc@0/858000.cti/cti_cpu0 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu1 -> > ../../../devices/platform/soc@0/859000.cti/cti_cpu1 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu2 -> > ../../../devices/platform/soc@0/85a000.cti/cti_cpu2 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu3 -> > ../../../devices/platform/soc@0/85b000.cti/cti_cpu3 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys0 -> > ../../../devices/platform/soc@0/810000.cti/cti_sys0 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys1 -> > ../../../devices/platform/soc@0/811000.cti/cti_sys1 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm0 -> > ../../../devices/platform/soc@0/85c000.etm/etm0 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm1 -> > ../../../devices/platform/soc@0/85d000.etm/etm1 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm2 -> > ../../../devices/platform/soc@0/85e000.etm/etm2 > lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm3 -> > ../../../devices/platform/soc@0/85f000.etm/etm3 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel0 -> > ../../../devices/platform/soc@0/821000.funnel/funnel0 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel1 -> > ../../../devices/platform/soc@0/841000.funnel/funnel1 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 replicator0 -> > ../../../devices/platform/soc@0/824000.replicator/replicator0 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etf0 -> > ../../../devices/platform/soc@0/825000.etf/tmc_etf0 > lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etr0 -> > ../../../devices/platform/soc@0/826000.etr/tmc_etr0 > > > 2) The patch set must contain the usage and specification in the .yaml > file(s) of the property used. > I will add the usage in yaml. > However, there was a standard property called 'name' which is > deprecated - see > https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html > section 2.3.11. I do not believe that adding another 'name' property > would be accepted by the DT maintainers. > > 3) the 'device_node' structure has a 'name' field that contains the > node name in the DT approved "node-name@unit-address" format.This > contains whatever node names you used in the dt. Why not use this if > a change has to be made and find some conditional to activate it. > > However, given point 1) above, the problem is solved and the patch > adds no new information not already available. > The name in the DT only has the general class of device and registers address. It can't describe the subsystem it belongs to. Thanks Jinlong Mao > Regards > > Mike > > On Thu, 28 Dec 2023 at 11:26, James Clark <james.clark@arm.com> wrote: >> >> >> >> On 28/12/2023 09:33, Mao Jinlong wrote: >>> Add coresight name support for custom names which will be >>> easy to identify the device by the name. >>> >> >> I suppose this is more of a V2 because the subject is the same as the >> one sent earlier this year. But it looks like the discussion on the >> previous one wasn't resolved. >> >> With the main issues to solve being: >> >> * It would be nice to use the existing root node name instead of adding >> a new property. But at the same time DT nodes are supposed to have >> generic names. >> >> * This only works for DT and not ACPI >> >> To me it seems like adding the new property is just a "cheat" to get >> around not being allowed to have a specific name for the root node. But >> if we admit that we need a name I don't see the benefit of not putting >> the name where the node is already named. >> >> Using the root node name at this point would also undo the hard coded >> per-cpu naming of the CTI and ETM devices, so maybe it would be nice, >> but it's just too late. That means that a new field is necessary. >> Although that field could be a boolean like "use-root-name-for-display" >> or something like that. In the end it probably doesn't really make a >> difference whether it's that or a name string. >> >> And maybe the answer to the ACPI question is just that if anyone needs >> it, they can add it in the future. It doesn't seem like it would >> conflict with anything we do here. >> >>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> >>> --- >>> .../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------ >>> drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++--- >>> .../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++ >>> drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++--- >>> include/linux/coresight.h | 1 + >>> 5 files changed, 53 insertions(+), 15 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c >>> index 3999d0a2cb60..60a1e76064a9 100644 >>> --- a/drivers/hwtracing/coresight/coresight-cti-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c >>> @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id) >>> /* default to powered - could change on PM notifications */ >>> drvdata->config.hw_powered = true; >>> >>> - /* set up device name - will depend if cpu bound or otherwise */ >>> - if (drvdata->ctidev.cpu >= 0) >>> - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >>> - drvdata->ctidev.cpu); >>> - else >>> - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); >> >> Can we put the new name stuff inside coresight_alloc_device_name()? Then >> it happens by default for every device. >> >> I know Suzuki said previously to do it per-device, but the new DT >> property is just "coresight-name", so it's generic. Rather than being >> specific like "cti-name". So I don't see the benefit of duplicating the >> code at this point if we do decide to do it. >> >>> - if (!cti_desc.name) >>> - return -ENOMEM; >>> + cti_desc.name = coresight_get_device_name(dev); >>> + if (!cti_desc.name) { >>> + /* set up device name - will depend if cpu bound or otherwise */ >>> + if (drvdata->ctidev.cpu >= 0) >>> + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >>> + drvdata->ctidev.cpu); >>> + else { >>> + cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); >>> + if (!cti_desc.name) >>> + return -ENOMEM; >>> + } >>> + } >> >>> >>> /* setup CPU power management handling for CPU bound CTI devices. */ >>> ret = cti_pm_setup(drvdata); >>> diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c >>> index e4deafae7bc2..b19cd400df79 100644 >>> --- a/drivers/hwtracing/coresight/coresight-dummy.c >>> +++ b/drivers/hwtracing/coresight/coresight-dummy.c >>> @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) >>> struct coresight_desc desc = { 0 }; >>> >>> if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { >>> - >>> - desc.name = coresight_alloc_device_name(&source_devs, dev); >>> - if (!desc.name) >>> - return -ENOMEM; >>> + desc.name = coresight_get_device_name(dev); >>> + if (!desc.name) { >>> + desc.name = coresight_alloc_device_name(&source_devs, dev); >>> + if (!desc.name) >>> + return -ENOMEM; >>> + } >>> >>> desc.type = CORESIGHT_DEV_TYPE_SOURCE; >>> desc.subtype.source_subtype = >>> diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c >>> index 9d550f5697fa..284aa22a06b7 100644 >>> --- a/drivers/hwtracing/coresight/coresight-platform.c >>> +++ b/drivers/hwtracing/coresight/coresight-platform.c >>> @@ -183,6 +183,18 @@ 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; >>> + >>> + of_property_read_string(dev->of_node, "coresight-name", &name); >> >> Do you need to update the binding docs with this new property? >> >> Also a minor nit: Maybe "display-name" is better? "Coresight" is >> implied, and the node is already named, although that node name isn't >> used for display purposes, but this one is. >> >> Thanks >> James > > >
On 1/3/2024 7:33 PM, Suzuki K Poulose wrote: > On 28/12/2023 11:26, James Clark wrote: >> >> >> On 28/12/2023 09:33, Mao Jinlong wrote: >>> Add coresight name support for custom names which will be >>> easy to identify the device by the name. >>> >> >> I suppose this is more of a V2 because the subject is the same as the >> one sent earlier this year. But it looks like the discussion on the >> previous one wasn't resolved. >> >> With the main issues to solve being: >> >> * It would be nice to use the existing root node name instead of adding >> a new property. But at the same time DT nodes are supposed to have >> generic names. >> >> * This only works for DT and not ACPI >> >> To me it seems like adding the new property is just a "cheat" to get >> around not being allowed to have a specific name for the root node. But >> if we admit that we need a name I don't see the benefit of not putting >> the name where the node is already named. >> >> Using the root node name at this point would also undo the hard coded >> per-cpu naming of the CTI and ETM devices, so maybe it would be nice, >> but it's just too late. That means that a new field is necessary. > > The CTI and ETM can be handled as special cases, like they are > already done and fall back to the nodename for the rest ? > But, I thought the node names must be generic (e.g, cti) and doesn't > really solve the naming requirements for naming CTIs. (e.g, > <device>_tpda, etr_cti). Is there something I missed ? > >> Although that field could be a boolean like "use-root-name-for-display" >> or something like that. In the end it probably doesn't really make a >> difference whether it's that or a name string. > >> And maybe the answer to the ACPI question is just that if anyone needs >> it, they can add it in the future. It doesn't seem like it would >> conflict with anything we do here. >> >>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com> >>> --- >>> .../hwtracing/coresight/coresight-cti-core.c | 20 ++++++++------ >>> drivers/hwtracing/coresight/coresight-dummy.c | 10 ++++--- >>> .../hwtracing/coresight/coresight-platform.c | 27 +++++++++++++++++++ >>> drivers/hwtracing/coresight/coresight-tpdm.c | 10 ++++--- >>> include/linux/coresight.h | 1 + >>> 5 files changed, 53 insertions(+), 15 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c >>> b/drivers/hwtracing/coresight/coresight-cti-core.c >>> index 3999d0a2cb60..60a1e76064a9 100644 >>> --- a/drivers/hwtracing/coresight/coresight-cti-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-cti-core.c >>> @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, >>> const struct amba_id *id) >>> /* default to powered - could change on PM notifications */ >>> drvdata->config.hw_powered = true; >>> - /* set up device name - will depend if cpu bound or otherwise */ >>> - if (drvdata->ctidev.cpu >= 0) >>> - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", >>> - drvdata->ctidev.cpu); >>> - else >>> - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, >>> dev); >> >> Can we put the new name stuff inside coresight_alloc_device_name()? Then >> it happens by default for every device. > > +1 > >> >> I know Suzuki said previously to do it per-device, but the new DT >> property is just "coresight-name", so it's generic. Rather than being >> specific like "cti-name". So I don't see the benefit of duplicating the >> code at this point if we do decide to do it. > > My suggestion was to name the device based on the specific device rather > than following a generic rule for all device. e.g., A TPDM connected to > modem, could be named as such based on the platform information. It > could be any means, for e.g., tpdm nodes are always children nodes of > the devices they are connected to ? or could have a phandle to point to > the device they are monitoring etc. And the name could be created from > the "monitoring device name" + tpdm. Also, we do this for CPU bound CTI > and ETMs already, where we name them based on the CPU. TPDM can only connect to the funnel or TPDA. The system TPDM is monitoring may not have the device node in DT. > > But then the "nodename" is something we explored and it looks like > may not be an option. > >> >>> - if (!cti_desc.name) >>> - return -ENOMEM; >>> + cti_desc.name = coresight_get_device_name(dev); >>> + if (!cti_desc.name) { >>> + /* set up device name - will depend if cpu bound or >>> otherwise */ >>> + if (drvdata->ctidev.cpu >= 0) >>> + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, >>> "cti_cpu%d", >>> + drvdata->ctidev.cpu); >>> + else { >>> + cti_desc.name = >>> coresight_alloc_device_name(&cti_sys_devs, dev); >>> + if (!cti_desc.name) >>> + return -ENOMEM; >>> + } >>> + } > > For these special cases, i.e., CPU bound, we should handle them with > priority. > > if (drvdata->ctidev.cpu >= 0) > name = devm_kasprintf(... "cti_cpu%d", .. cpu); > else > name = coresight_alloc_device_name(...); > >> >>> /* setup CPU power management handling for CPU bound CTI >>> devices. */ >>> ret = cti_pm_setup(drvdata); >>> diff --git a/drivers/hwtracing/coresight/coresight-dummy.c >>> b/drivers/hwtracing/coresight/coresight-dummy.c >>> index e4deafae7bc2..b19cd400df79 100644 >>> --- a/drivers/hwtracing/coresight/coresight-dummy.c >>> +++ b/drivers/hwtracing/coresight/coresight-dummy.c >>> @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) >>> struct coresight_desc desc = { 0 }; >>> if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { >>> - >>> - desc.name = coresight_alloc_device_name(&source_devs, dev); >>> - if (!desc.name) >>> - return -ENOMEM; >>> + desc.name = coresight_get_device_name(dev); >>> + if (!desc.name) { >>> + desc.name = coresight_alloc_device_name(&source_devs, dev); >>> + if (!desc.name) >>> + return -ENOMEM; >>> + } >>> desc.type = CORESIGHT_DEV_TYPE_SOURCE; >>> desc.subtype.source_subtype = >>> diff --git a/drivers/hwtracing/coresight/coresight-platform.c >>> b/drivers/hwtracing/coresight/coresight-platform.c >>> index 9d550f5697fa..284aa22a06b7 100644 >>> --- a/drivers/hwtracing/coresight/coresight-platform.c >>> +++ b/drivers/hwtracing/coresight/coresight-platform.c >>> @@ -183,6 +183,18 @@ 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; >>> + >>> + of_property_read_string(dev->of_node, "coresight-name", &name); >> >> Do you need to update the binding docs with this new property? >> >> Also a minor nit: Maybe "display-name" is better? "Coresight" is >> implied, and the node is already named, although that node name isn't >> used for display purposes, but this one is. > > On that front, the name is used as a "device" name and not simply > display. So, even "device-name" sounds more appropriate. > I will use the device-name. Thanks Jinlong Mao > Suzuki > >> >> Thanks >> James >
On 1/3/2024 11:32 PM, Rob Herring wrote: > On Tue, Jan 2, 2024 at 5:05 AM Mike Leach <mike.leach@linaro.org> wrote: >> >> As James mentions this is clearly a V2 of a previous patch - please >> mark as such in future. >> >> Adding to what James has already said:- >> >> 1) Mapping between the canonical names used in the drivers and the >> information as to the precise device is as easy as running 'ls' on >> /sys/bus/coresight/devices:- >> >> root@linaro-developer:/home/linaro/cs-mods# ls -al /sys/bus/coresight/devices/ >> total 0 >> drwxr-xr-x 2 root root 0 Jan 2 11:27 . >> drwxr-xr-x 4 root root 0 Jan 2 11:27 .. >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu0 -> >> ../../../devices/platform/soc@0/858000.cti/cti_cpu0 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu1 -> >> ../../../devices/platform/soc@0/859000.cti/cti_cpu1 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu2 -> >> ../../../devices/platform/soc@0/85a000.cti/cti_cpu2 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_cpu3 -> >> ../../../devices/platform/soc@0/85b000.cti/cti_cpu3 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys0 -> >> ../../../devices/platform/soc@0/810000.cti/cti_sys0 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 cti_sys1 -> >> ../../../devices/platform/soc@0/811000.cti/cti_sys1 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm0 -> >> ../../../devices/platform/soc@0/85c000.etm/etm0 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm1 -> >> ../../../devices/platform/soc@0/85d000.etm/etm1 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm2 -> >> ../../../devices/platform/soc@0/85e000.etm/etm2 >> lrwxrwxrwx 1 root root 0 Jan 2 11:27 etm3 -> >> ../../../devices/platform/soc@0/85f000.etm/etm3 >> lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel0 -> >> ../../../devices/platform/soc@0/821000.funnel/funnel0 >> lrwxrwxrwx 1 root root 0 Jan 2 11:42 funnel1 -> >> ../../../devices/platform/soc@0/841000.funnel/funnel1 >> lrwxrwxrwx 1 root root 0 Jan 2 11:42 replicator0 -> >> ../../../devices/platform/soc@0/824000.replicator/replicator0 >> lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etf0 -> >> ../../../devices/platform/soc@0/825000.etf/tmc_etf0 >> lrwxrwxrwx 1 root root 0 Jan 2 11:42 tmc_etr0 -> >> ../../../devices/platform/soc@0/826000.etr/tmc_etr0 >> >> >> 2) The patch set must contain the usage and specification in the .yaml >> file(s) of the property used. > > For the record, I don't like "coresight-name". I don't have another > suggestion because "easy" is not sufficient reasoning for why this is > needed. For example, if we want to configure the trigger and HW events for modem, we can't know which cti or TPDM is for modem from current names. lrwxrwxrwx 1 root 0 0 Jan 1 00:01 cti_sys0 -> ./../../devices/platform/soc@0/138f0000.cti/cti_sys0 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 cti_sys1 -> ./../../devices/platform/soc@0/13900000.cti/cti_sys1 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 tpdm0 -> ./../../devices/platform/soc@0/10b0d000.tpdm/tpdm0 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 tpdm1 -> ./../../devices/platform/soc@0/10c28000.tpdm/tpdm1 lrwxrwxrwx 1 root 0 0 Jan 1 00:01 tpdm2 -> ./../../devices/platform/soc@0/10c29000.tpdm/tpdm2 Thanks Jinlong Mao > >> However, there was a standard property called 'name' which is >> deprecated - see >> https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html >> section 2.3.11. I do not believe that adding another 'name' property >> would be accepted by the DT maintainers. > > "name" is just the node name for anything in the last 15 years. They > used to be separate, but would still mostly be the same. The only case > I found with them different was old PowerPC Macs. > >> 3) the 'device_node' structure has a 'name' field that contains the >> node name in the DT approved "node-name@unit-address" format. > > Actually, it is without the unit-address. full_name is with the unit-address. > >> This >> contains whatever node names you used in the dt. Why not use this if >> a change has to be made and find some conditional to activate it. > > Don't go accessing "name" or "full_name" directly. I intend to get rid > of "name" and generate it from full_name. So use the accessors and > printk specifiers if you need node names. > > Rob
diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c index 3999d0a2cb60..60a1e76064a9 100644 --- a/drivers/hwtracing/coresight/coresight-cti-core.c +++ b/drivers/hwtracing/coresight/coresight-cti-core.c @@ -902,14 +902,18 @@ static int cti_probe(struct amba_device *adev, const struct amba_id *id) /* default to powered - could change on PM notifications */ drvdata->config.hw_powered = true; - /* set up device name - will depend if cpu bound or otherwise */ - if (drvdata->ctidev.cpu >= 0) - cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", - drvdata->ctidev.cpu); - else - cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); - if (!cti_desc.name) - return -ENOMEM; + cti_desc.name = coresight_get_device_name(dev); + if (!cti_desc.name) { + /* set up device name - will depend if cpu bound or otherwise */ + if (drvdata->ctidev.cpu >= 0) + cti_desc.name = devm_kasprintf(dev, GFP_KERNEL, "cti_cpu%d", + drvdata->ctidev.cpu); + else { + cti_desc.name = coresight_alloc_device_name(&cti_sys_devs, dev); + if (!cti_desc.name) + return -ENOMEM; + } + } /* setup CPU power management handling for CPU bound CTI devices. */ ret = cti_pm_setup(drvdata); diff --git a/drivers/hwtracing/coresight/coresight-dummy.c b/drivers/hwtracing/coresight/coresight-dummy.c index e4deafae7bc2..b19cd400df79 100644 --- a/drivers/hwtracing/coresight/coresight-dummy.c +++ b/drivers/hwtracing/coresight/coresight-dummy.c @@ -76,10 +76,12 @@ static int dummy_probe(struct platform_device *pdev) struct coresight_desc desc = { 0 }; if (of_device_is_compatible(node, "arm,coresight-dummy-source")) { - - desc.name = coresight_alloc_device_name(&source_devs, dev); - if (!desc.name) - return -ENOMEM; + desc.name = coresight_get_device_name(dev); + if (!desc.name) { + desc.name = coresight_alloc_device_name(&source_devs, dev); + if (!desc.name) + return -ENOMEM; + } desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index 9d550f5697fa..284aa22a06b7 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -183,6 +183,18 @@ 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; + + of_property_read_string(dev->of_node, "coresight-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 +327,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 +812,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/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index f4854af0431e..7735ff18c48e 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -201,9 +201,13 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) drvdata->base = base; /* Set up coresight component description */ - desc.name = coresight_alloc_device_name(&tpdm_devs, dev); - if (!desc.name) - return -ENOMEM; + desc.name = coresight_get_device_name(dev); + if (!desc.name) { + desc.name = coresight_alloc_device_name(&tpdm_devs, dev); + if (!desc.name) + return -ENOMEM; + } + desc.type = CORESIGHT_DEV_TYPE_SOURCE; desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS; desc.ops = &tpdm_cs_ops; diff --git a/include/linux/coresight.h b/include/linux/coresight.h index a269fffaf991..caa17c8af865 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -675,6 +675,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 *