Message ID | 1682586037-25973-3-git-send-email-quic_taozha@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp134858vqo; Thu, 27 Apr 2023 02:12:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7JiF5PcufMeNQL/7Dflb6JmWP9H02sQInS6JKg3r5+G76/NOM/GpmaxiJ6dEZzR3HuaXC4 X-Received: by 2002:a05:6a20:4321:b0:da:501:55e with SMTP id h33-20020a056a20432100b000da0501055emr1160284pzk.40.1682586721758; Thu, 27 Apr 2023 02:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682586721; cv=none; d=google.com; s=arc-20160816; b=KHyml7nYsBWMEOI7wuzCM47S7yi9tlXnpCOv9/Mn1E58/et5gtf5M5OunmBv8HCnIa +FYY6eMgEB3eepbu0GDaVuhkZev51tuPlEhrlYRRZHGm/mq2yGmVLj7/QHoqofs4oG41 0hizfvNs5xp/CGdvpOIn4hE5zKQTQ/vBi/L1Xv2MChfMmt6aGML3MYRJhr9gaCPttW5t tTmc3il8Tz7i+GHxy/41JnPol6XoRzktPSzV0P32Ca8w86wL6jXVtYoaC8Lt2uhQErFD fEjqRQvtBilEn5MHf7sImJjGkO7KoH2epAOjg+ojRttuJ4HJGTk5stlzWnuHKhJwru1P R7IQ== 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=FhAHcwDtUysj4PzwFxSKRxXkvGWqT9EdqmRXLEk4igc=; b=Ozvg1MMwt7QzBpVpRy4Fxd9CYZ42LW6yFNWpwYKjn95ENvXvgwOgqer0aWHoGIf9iM N5fXVDuh+D2EA1KE3NfFw2psmxg9+nvgU42t0NdgofiX9zHJXJqAikm6U71WnN4NOGb7 nc2hBhXUQHk1CkxE3VYIqFrtapXHGOkCnzOx+ha7jD+LaJzdwTjXACskEIc+jISrh/hG D+n1e/XSlP7bfeiQnR8L9Eh5GqzdzJGDFRjt58Oli6TKymVtvztH73//OIC2Zkt8Iv/3 AYaMTZjWsuF7gav5cPRDktHYmXrGoY8U0KqZkBgigMzzDxhb1ME5EXGAum52Gg1/ayjT 09+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=nRS1td6B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a655945000000b0051418f75569si17829459pgu.425.2023.04.27.02.11.46; Thu, 27 Apr 2023 02:12:01 -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=qcppdkim1 header.b=nRS1td6B; 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 S243072AbjD0JBt (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Thu, 27 Apr 2023 05:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243245AbjD0JBo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 27 Apr 2023 05:01:44 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8224F4C39; Thu, 27 Apr 2023 02:01:25 -0700 (PDT) Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33R7DQZ1011869; Thu, 27 Apr 2023 09:01:07 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-type; s=qcppdkim1; bh=FhAHcwDtUysj4PzwFxSKRxXkvGWqT9EdqmRXLEk4igc=; b=nRS1td6BvzjWJALU2LQopjIpLzAzA4rFvhK/QrGPhDn6ooDUvvjpDtn1l9w4uMIA8+Lo jmDiUoQeXi8TSa6kFd/Op8ivewPwM8Z6aoc+BbcQ4b6s8st9M8k5fN3YaKUlbYvrAnLG 4P+Hp7eHQBrWQg+ZqdTfqQg+1dViQqnKuK6dUIoAAVxX3xxmlTUwT4CXBDZcM9tqlz+Z twRQjArqW16zZcaBOl9e+EzKZ3jxfDk+FTjMqDIBTBF7o/xGPceLRvjmM7g83/sbRZh1 Z2V30Fyle5vYrYjsHyp8qiH4Iak8BLGY6b43tGynU1tPcECfqzJHs7A0AkHLo7El/TUx 9Q== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3q7mfj0819-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Apr 2023 09:01:07 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 33R916i3013335 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 27 Apr 2023 09:01:06 GMT Received: from taozha-gv.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.42; Thu, 27 Apr 2023 02:01:00 -0700 From: Tao Zhang <quic_taozha@quicinc.com> To: Mathieu Poirier <mathieu.poirier@linaro.org>, Suzuki K Poulose <suzuki.poulose@arm.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Konrad Dybcio <konradybcio@gmail.com>, Mike Leach <mike.leach@linaro.org>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org> CC: Tao Zhang <quic_taozha@quicinc.com>, Jinlong Mao <quic_jinlmao@quicinc.com>, Leo Yan <leo.yan@linaro.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <coresight@lists.linaro.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>, Tingwei Zhang <quic_tingweiz@quicinc.com>, Yuanfang Zhang <quic_yuanfang@quicinc.com>, Trilok Soni <quic_tsoni@quicinc.com>, Hao Zhang <quic_hazha@quicinc.com>, <linux-arm-msm@vger.kernel.org>, <andersson@kernel.org> Subject: [PATCH v4 02/11] coresight-tpda: Add DSB dataset support Date: Thu, 27 Apr 2023 17:00:28 +0800 Message-ID: <1682586037-25973-3-git-send-email-quic_taozha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1682586037-25973-1-git-send-email-quic_taozha@quicinc.com> References: <1682586037-25973-1-git-send-email-quic_taozha@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 nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: han4fXjtulkgY-vpE-sLrXSmeHBs7NSe X-Proofpoint-ORIG-GUID: han4fXjtulkgY-vpE-sLrXSmeHBs7NSe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-27_06,2023-04-26_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 mlxscore=0 bulkscore=0 clxscore=1015 spamscore=0 impostorscore=0 phishscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304270078 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764320053895261371?= X-GMAIL-MSGID: =?utf-8?q?1764320053895261371?= |
Series |
Add support to configure TPDM DSB subunit
|
|
Commit Message
Tao Zhang
April 27, 2023, 9 a.m. UTC
Read the DSB element size from the device tree. Set the register
bit that controls the DSB element size of the corresponding port.
Signed-off-by: Tao Zhang <quic_taozha@quicinc.com>
---
drivers/hwtracing/coresight/coresight-core.c | 1 +
drivers/hwtracing/coresight/coresight-tpda.c | 92 +++++++++++++++++++++++++---
drivers/hwtracing/coresight/coresight-tpda.h | 4 ++
drivers/hwtracing/coresight/coresight-tpdm.c | 2 +-
include/linux/coresight.h | 1 +
5 files changed, 90 insertions(+), 10 deletions(-)
Comments
On 27/04/2023 10:00, Tao Zhang wrote: > Read the DSB element size from the device tree. Set the register > bit that controls the DSB element size of the corresponding port. > > Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> > --- > drivers/hwtracing/coresight/coresight-core.c | 1 + > drivers/hwtracing/coresight/coresight-tpda.c | 92 +++++++++++++++++++++++++--- > drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ > drivers/hwtracing/coresight/coresight-tpdm.c | 2 +- > include/linux/coresight.h | 1 + > 5 files changed, 90 insertions(+), 10 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c > index 2af416b..f1eacbb 100644 > --- a/drivers/hwtracing/coresight/coresight-core.c > +++ b/drivers/hwtracing/coresight/coresight-core.c > @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct coresight_device *csdev, > > if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && > subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && > + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && > subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { > dev_err(&csdev->dev, "wrong device subtype in %s\n", function); > return -EINVAL; Please see the comment at the bottom. > diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c > index 8d2b9d2..af9c72f 100644 > --- a/drivers/hwtracing/coresight/coresight-tpda.c > +++ b/drivers/hwtracing/coresight/coresight-tpda.c > @@ -21,6 +21,56 @@ > > DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); > > +/* Search and read element data size from the TPDM node in > + * the devicetree. Each input port of TPDA is connected to > + * a TPDM. Different TPDM supports different types of dataset, > + * and some may support more than one type of dataset. > + * Parameter "inport" is used to pass in the input port number > + * of TPDA, and it is set to 0 in the recursize call. > + * Parameter "parent" is used to pass in the original call. > + */ > +static int tpda_set_element_size(struct tpda_drvdata *drvdata, > + struct coresight_device *csdev, int inport, bool parent) > +{ > + static int nr_inport; > + int i; > + static bool tpdm_found; > + struct coresight_device *in_csdev; > + > + if (inport > (TPDA_MAX_INPORTS - 1)) > + return -EINVAL; > + > + if (parent) { > + nr_inport = inport; > + tpdm_found = false; > + } > + > + for (i = 0; i < csdev->pdata->nr_inconns; i++) { > + in_csdev = csdev->pdata->in_conns[i]->src_dev; > + if (!in_csdev) > + break; > + > + if (parent) > + if (csdev->pdata->in_conns[i]->dest_port != inport) > + continue; > + > + if (in_csdev->subtype.source_subtype We must match the in_csdev->type to be SOURCE && the subtype. > + == CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM) { > + of_property_read_u8(in_csdev->dev.parent->of_node, > + "qcom,dsb-element-size", &drvdata->dsb_esize[nr_inport]); > + if (!tpdm_found) > + tpdm_found = true; > + else > + dev_warn(drvdata->dev, > + "More than one TPDM is mapped to the TPDA input port %d.\n", > + nr_inport); When we know, we have found a source device, we don't need to recurse down and could simply 'continue' to the next one in the list and skip the call below. > + } > + tpda_set_element_size(drvdata, in_csdev, 0, false); > + } > + > + return 0; > +} > + > /* Settings pre enabling port control register */ > static void tpda_enable_pre_port(struct tpda_drvdata *drvdata) > { > @@ -32,26 +82,43 @@ static void tpda_enable_pre_port(struct tpda_drvdata *drvdata) > writel_relaxed(val, drvdata->base + TPDA_CR); > } > > -static void tpda_enable_port(struct tpda_drvdata *drvdata, int port) > +static int tpda_enable_port(struct tpda_drvdata *drvdata, int port) > { > u32 val; > > val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); > + /* > + * Configure aggregator port n DSB data set element size > + * Set the bit to 0 if the size is 32 > + * Set the bit to 1 if the size is 64 > + */ > + if (drvdata->dsb_esize[port] == 32) > + val &= ~TPDA_Pn_CR_DSBSIZE; > + else if (drvdata->dsb_esize[port] == 64) > + val |= TPDA_Pn_CR_DSBSIZE; > + else > + return -EINVAL; > + > /* Enable the port */ > val |= TPDA_Pn_CR_ENA; > writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); > + > + return 0; > } > > -static void __tpda_enable(struct tpda_drvdata *drvdata, int port) > +static int __tpda_enable(struct tpda_drvdata *drvdata, int port) > { > + int ret; > + > CS_UNLOCK(drvdata->base); > > if (!drvdata->csdev->enable) > tpda_enable_pre_port(drvdata); > > - tpda_enable_port(drvdata, port); > - > + ret = tpda_enable_port(drvdata, port); > CS_LOCK(drvdata->base); > + > + return ret; > } > > static int tpda_enable(struct coresight_device *csdev, > @@ -59,16 +126,23 @@ static int tpda_enable(struct coresight_device *csdev, > struct coresight_connection *out) > { > struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); > + int ret; > + > + ret = tpda_set_element_size(drvdata, csdev, in->dest_port, true); > + if (ret) > + return ret; > > spin_lock(&drvdata->spinlock); > - if (atomic_read(&in->dest_refcnt) == 0) > + if (atomic_read(&in->dest_refcnt) == 0) { > __tpda_enable(drvdata, in->dest_port); ret = ... ? > + if (!ret) { > + atomic_inc(&in->dest_refcnt); > + dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); > + } > + } > > - atomic_inc(&in->dest_refcnt); This seems wrong, as we may fail to hold additional refcounts for the additional sessions ? > spin_unlock(&drvdata->spinlock); > - > - dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); > - return 0; > + return ret; > } > > static void __tpda_disable(struct tpda_drvdata *drvdata, int port) > diff --git a/drivers/hwtracing/coresight/coresight-tpda.h b/drivers/hwtracing/coresight/coresight-tpda.h > index 0399678..7332e9c 100644 > --- a/drivers/hwtracing/coresight/coresight-tpda.h > +++ b/drivers/hwtracing/coresight/coresight-tpda.h > @@ -10,6 +10,8 @@ > #define TPDA_Pn_CR(n) (0x004 + (n * 4)) > /* Aggregator port enable bit */ > #define TPDA_Pn_CR_ENA BIT(0) > +/* Aggregator port DSB data set element size bit */ > +#define TPDA_Pn_CR_DSBSIZE BIT(8) > > #define TPDA_MAX_INPORTS 32 > > @@ -23,6 +25,7 @@ > * @csdev: component vitals needed by the framework. > * @spinlock: lock for the drvdata value. > * @enable: enable status of the component. > + * @dsb_esize: DSB element size, it must be 32 or 64. minor nit: DSB element size for each inport, it must be 32 or 64 > */ > struct tpda_drvdata { > void __iomem *base; > @@ -30,6 +33,7 @@ struct tpda_drvdata { > struct coresight_device *csdev; > spinlock_t spinlock; > u8 atid; > + u8 dsb_esize[TPDA_MAX_INPORTS]; > }; > > #endif /* _CORESIGHT_CORESIGHT_TPDA_H */ > diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c > index f4854af..ba1867f 100644 > --- a/drivers/hwtracing/coresight/coresight-tpdm.c > +++ b/drivers/hwtracing/coresight/coresight-tpdm.c > @@ -205,7 +205,7 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) > if (!desc.name) > return -ENOMEM; > desc.type = CORESIGHT_DEV_TYPE_SOURCE; > - desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS; > + desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM; > desc.ops = &tpdm_cs_ops; > desc.pdata = adev->dev.platform_data; > desc.dev = &adev->dev; Please could you split this change, i.e., introduction of SUBTYPE_SOURCE_TPDM and using this in TPDM driver, in a separate patch before this change. > diff --git a/include/linux/coresight.h b/include/linux/coresight.h > index 225a5fa..6563896 100644 > --- a/include/linux/coresight.h > +++ b/include/linux/coresight.h > @@ -60,6 +60,7 @@ enum coresight_dev_subtype_source { > CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, > CORESIGHT_DEV_SUBTYPE_SOURCE_BUS, > CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, > + CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM, > CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS, > }; >
On 23/05/2023 11:07, Suzuki K Poulose wrote: > On 27/04/2023 10:00, Tao Zhang wrote: >> Read the DSB element size from the device tree. Set the register >> bit that controls the DSB element size of the corresponding port. >> >> Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> >> --- >> drivers/hwtracing/coresight/coresight-core.c | 1 + >> drivers/hwtracing/coresight/coresight-tpda.c | 92 >> +++++++++++++++++++++++++--- >> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >> drivers/hwtracing/coresight/coresight-tpdm.c | 2 +- >> include/linux/coresight.h | 1 + >> 5 files changed, 90 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-core.c >> b/drivers/hwtracing/coresight/coresight-core.c >> index 2af416b..f1eacbb 100644 >> --- a/drivers/hwtracing/coresight/coresight-core.c >> +++ b/drivers/hwtracing/coresight/coresight-core.c >> @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct >> coresight_device *csdev, >> if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && >> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && >> + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && >> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { >> dev_err(&csdev->dev, "wrong device subtype in %s\n", function); >> return -EINVAL; > > Please see the comment at the bottom. > >> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >> b/drivers/hwtracing/coresight/coresight-tpda.c >> index 8d2b9d2..af9c72f 100644 >> --- a/drivers/hwtracing/coresight/coresight-tpda.c >> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >> @@ -21,6 +21,56 @@ >> DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); >> +/* Search and read element data size from the TPDM node in >> + * the devicetree. Each input port of TPDA is connected to >> + * a TPDM. Different TPDM supports different types of dataset, >> + * and some may support more than one type of dataset. >> + * Parameter "inport" is used to pass in the input port number >> + * of TPDA, and it is set to 0 in the recursize call. >> + * Parameter "parent" is used to pass in the original call. >> + */ >> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >> + struct coresight_device *csdev, int inport, bool parent) The name parent is a bit confusing. It could imply parent device ? That is kind of inverse ? because, parent = true, indicates the parent device of tpda, which is not true. Could we simply say bool match_inport => When true, the dest_port of the connection from the csdev must match the inport ? And ... >> +{ >> + static int nr_inport; >> + int i; >> + static bool tpdm_found; >> + struct coresight_device *in_csdev; >> + >> + if (inport > (TPDA_MAX_INPORTS - 1)) >> + return -EINVAL; >> + >> + if (parent) { >> + nr_inport = inport; >> + tpdm_found = false; >> + } >> + >> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >> + in_csdev = csdev->pdata->in_conns[i]->src_dev; >> + if (!in_csdev) >> + break; >> + >> + if (parent) >> + if (csdev->pdata->in_conns[i]->dest_port != inport) >> + continue; The above can become : if (match_inport && csdev->pdata->in_conns[i]->dest_port != inport) continue; Suzuki
On 5/23/2023 6:07 PM, Suzuki K Poulose wrote: > On 27/04/2023 10:00, Tao Zhang wrote: >> Read the DSB element size from the device tree. Set the register >> bit that controls the DSB element size of the corresponding port. >> >> Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> >> --- >> drivers/hwtracing/coresight/coresight-core.c | 1 + >> drivers/hwtracing/coresight/coresight-tpda.c | 92 >> +++++++++++++++++++++++++--- >> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >> drivers/hwtracing/coresight/coresight-tpdm.c | 2 +- >> include/linux/coresight.h | 1 + >> 5 files changed, 90 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/hwtracing/coresight/coresight-core.c >> b/drivers/hwtracing/coresight/coresight-core.c >> index 2af416b..f1eacbb 100644 >> --- a/drivers/hwtracing/coresight/coresight-core.c >> +++ b/drivers/hwtracing/coresight/coresight-core.c >> @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct >> coresight_device *csdev, >> if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && >> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && >> + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && >> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { >> dev_err(&csdev->dev, "wrong device subtype in %s\n", >> function); >> return -EINVAL; > > Please see the comment at the bottom. > >> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >> b/drivers/hwtracing/coresight/coresight-tpda.c >> index 8d2b9d2..af9c72f 100644 >> --- a/drivers/hwtracing/coresight/coresight-tpda.c >> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >> @@ -21,6 +21,56 @@ >> DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); >> +/* Search and read element data size from the TPDM node in >> + * the devicetree. Each input port of TPDA is connected to >> + * a TPDM. Different TPDM supports different types of dataset, >> + * and some may support more than one type of dataset. >> + * Parameter "inport" is used to pass in the input port number >> + * of TPDA, and it is set to 0 in the recursize call. >> + * Parameter "parent" is used to pass in the original call. >> + */ >> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >> + struct coresight_device *csdev, int inport, bool parent) >> +{ >> + static int nr_inport; >> + int i; >> + static bool tpdm_found; >> + struct coresight_device *in_csdev; >> + >> + if (inport > (TPDA_MAX_INPORTS - 1)) >> + return -EINVAL; >> + >> + if (parent) { >> + nr_inport = inport; >> + tpdm_found = false; >> + } >> + >> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >> + in_csdev = csdev->pdata->in_conns[i]->src_dev; >> + if (!in_csdev) >> + break; >> + >> + if (parent) >> + if (csdev->pdata->in_conns[i]->dest_port != inport) >> + continue; >> + >> + if (in_csdev->subtype.source_subtype > > We must match the in_csdev->type to be SOURCE && the subtype. Sure, I will update it in the next patch series. > >> + == CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM) { >> + of_property_read_u8(in_csdev->dev.parent->of_node, >> + "qcom,dsb-element-size", >> &drvdata->dsb_esize[nr_inport]); >> + if (!tpdm_found) >> + tpdm_found = true; >> + else >> + dev_warn(drvdata->dev, >> + "More than one TPDM is mapped to the TPDA input >> port %d.\n", >> + nr_inport); > > When we know, we have found a source device, we don't need to recurse > down and could simply 'continue' to the next one in the list and skip > the call below. Actually, one input port on TPDA only can connect to one TPDM. In the current design, it will find out all the TPDMs on one input port and warn the users all the TPDMs it found. If we replace 'recurse down' as 'continue' here, it may not find some TPDMs that might be connected incorrectly. > >> + } >> + tpda_set_element_size(drvdata, in_csdev, 0, false); >> + } >> + >> + return 0; >> +} >> + >> /* Settings pre enabling port control register */ >> static void tpda_enable_pre_port(struct tpda_drvdata *drvdata) >> { >> @@ -32,26 +82,43 @@ static void tpda_enable_pre_port(struct >> tpda_drvdata *drvdata) >> writel_relaxed(val, drvdata->base + TPDA_CR); >> } >> -static void tpda_enable_port(struct tpda_drvdata *drvdata, int port) >> +static int tpda_enable_port(struct tpda_drvdata *drvdata, int port) >> { >> u32 val; >> val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); >> + /* >> + * Configure aggregator port n DSB data set element size >> + * Set the bit to 0 if the size is 32 >> + * Set the bit to 1 if the size is 64 >> + */ >> + if (drvdata->dsb_esize[port] == 32) >> + val &= ~TPDA_Pn_CR_DSBSIZE; >> + else if (drvdata->dsb_esize[port] == 64) >> + val |= TPDA_Pn_CR_DSBSIZE; >> + else >> + return -EINVAL; >> + >> /* Enable the port */ >> val |= TPDA_Pn_CR_ENA; >> writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); >> + >> + return 0; >> } >> -static void __tpda_enable(struct tpda_drvdata *drvdata, int port) >> +static int __tpda_enable(struct tpda_drvdata *drvdata, int port) >> { >> + int ret; >> + >> CS_UNLOCK(drvdata->base); >> if (!drvdata->csdev->enable) >> tpda_enable_pre_port(drvdata); >> - tpda_enable_port(drvdata, port); >> - >> + ret = tpda_enable_port(drvdata, port); >> CS_LOCK(drvdata->base); >> + >> + return ret; >> } >> static int tpda_enable(struct coresight_device *csdev, >> @@ -59,16 +126,23 @@ static int tpda_enable(struct coresight_device >> *csdev, >> struct coresight_connection *out) >> { >> struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); >> + int ret; >> + >> + ret = tpda_set_element_size(drvdata, csdev, in->dest_port, true); >> + if (ret) >> + return ret; >> spin_lock(&drvdata->spinlock); >> - if (atomic_read(&in->dest_refcnt) == 0) >> + if (atomic_read(&in->dest_refcnt) == 0) { >> __tpda_enable(drvdata, in->dest_port); > > ret = ... ? Sure, I will update it in the next patch series. > >> + if (!ret) { > > > >> + atomic_inc(&in->dest_refcnt); >> + dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", >> in->dest_port); >> + } >> + } > >> - atomic_inc(&in->dest_refcnt); > > This seems wrong, as we may fail to hold additional refcounts for the > additional sessions ? In the current design, if the TPDA is enabled successfully, it will run "atomic_inc(&in->dest_refcnt);" Otherwise, it will not run "atomic_inc(&in->dest_refcnt);" to avoid additional refcounts. Is it right? > >> spin_unlock(&drvdata->spinlock); >> - >> - dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); >> - return 0; >> + return ret; >> } >> static void __tpda_disable(struct tpda_drvdata *drvdata, int port) >> diff --git a/drivers/hwtracing/coresight/coresight-tpda.h >> b/drivers/hwtracing/coresight/coresight-tpda.h >> index 0399678..7332e9c 100644 >> --- a/drivers/hwtracing/coresight/coresight-tpda.h >> +++ b/drivers/hwtracing/coresight/coresight-tpda.h >> @@ -10,6 +10,8 @@ >> #define TPDA_Pn_CR(n) (0x004 + (n * 4)) >> /* Aggregator port enable bit */ >> #define TPDA_Pn_CR_ENA BIT(0) >> +/* Aggregator port DSB data set element size bit */ >> +#define TPDA_Pn_CR_DSBSIZE BIT(8) >> #define TPDA_MAX_INPORTS 32 >> @@ -23,6 +25,7 @@ >> * @csdev: component vitals needed by the framework. >> * @spinlock: lock for the drvdata value. >> * @enable: enable status of the component. >> + * @dsb_esize: DSB element size, it must be 32 or 64. > > minor nit: > > DSB element size for each inport, it must be 32 or 64 Sure, I will update it in the next patch series. > >> */ >> struct tpda_drvdata { >> void __iomem *base; >> @@ -30,6 +33,7 @@ struct tpda_drvdata { >> struct coresight_device *csdev; >> spinlock_t spinlock; >> u8 atid; >> + u8 dsb_esize[TPDA_MAX_INPORTS]; >> }; >> #endif /* _CORESIGHT_CORESIGHT_TPDA_H */ >> diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c >> b/drivers/hwtracing/coresight/coresight-tpdm.c >> index f4854af..ba1867f 100644 >> --- a/drivers/hwtracing/coresight/coresight-tpdm.c >> +++ b/drivers/hwtracing/coresight/coresight-tpdm.c >> @@ -205,7 +205,7 @@ static int tpdm_probe(struct amba_device *adev, >> const struct amba_id *id) >> if (!desc.name) >> return -ENOMEM; >> desc.type = CORESIGHT_DEV_TYPE_SOURCE; >> - desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS; >> + desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM; >> desc.ops = &tpdm_cs_ops; >> desc.pdata = adev->dev.platform_data; >> desc.dev = &adev->dev; > > Please could you split this change, i.e., introduction of > SUBTYPE_SOURCE_TPDM and using this in TPDM driver, > in a separate patch before this change. Sure, I will update it in the next patch series. Best, Tao > >> diff --git a/include/linux/coresight.h b/include/linux/coresight.h >> index 225a5fa..6563896 100644 >> --- a/include/linux/coresight.h >> +++ b/include/linux/coresight.h >> @@ -60,6 +60,7 @@ enum coresight_dev_subtype_source { >> CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, >> CORESIGHT_DEV_SUBTYPE_SOURCE_BUS, >> CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, >> + CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM, >> CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS, >> }; >
On 5/23/2023 10:48 PM, Suzuki K Poulose wrote: > On 23/05/2023 11:07, Suzuki K Poulose wrote: >> On 27/04/2023 10:00, Tao Zhang wrote: >>> Read the DSB element size from the device tree. Set the register >>> bit that controls the DSB element size of the corresponding port. >>> >>> Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> >>> --- >>> drivers/hwtracing/coresight/coresight-core.c | 1 + >>> drivers/hwtracing/coresight/coresight-tpda.c | 92 >>> +++++++++++++++++++++++++--- >>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>> drivers/hwtracing/coresight/coresight-tpdm.c | 2 +- >>> include/linux/coresight.h | 1 + >>> 5 files changed, 90 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-core.c >>> b/drivers/hwtracing/coresight/coresight-core.c >>> index 2af416b..f1eacbb 100644 >>> --- a/drivers/hwtracing/coresight/coresight-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-core.c >>> @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct >>> coresight_device *csdev, >>> if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && >>> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && >>> + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && >>> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { >>> dev_err(&csdev->dev, "wrong device subtype in %s\n", >>> function); >>> return -EINVAL; >> >> Please see the comment at the bottom. >> >>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>> b/drivers/hwtracing/coresight/coresight-tpda.c >>> index 8d2b9d2..af9c72f 100644 >>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>> @@ -21,6 +21,56 @@ >>> DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); >>> +/* Search and read element data size from the TPDM node in >>> + * the devicetree. Each input port of TPDA is connected to >>> + * a TPDM. Different TPDM supports different types of dataset, >>> + * and some may support more than one type of dataset. >>> + * Parameter "inport" is used to pass in the input port number >>> + * of TPDA, and it is set to 0 in the recursize call. >>> + * Parameter "parent" is used to pass in the original call. >>> + */ >>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>> + struct coresight_device *csdev, int inport, bool >>> parent) > > The name parent is a bit confusing. It could imply parent device ? That > is kind of inverse ? because, parent = true, indicates the parent device > of tpda, which is not true. Could we simply say > > bool match_inport => When true, the dest_port of the connection from the > csdev must match the inport ? And ... > Sure, I will update this in the next patch series. >>> +{ >>> + static int nr_inport; >>> + int i; >>> + static bool tpdm_found; >>> + struct coresight_device *in_csdev; >>> + >>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>> + return -EINVAL; >>> + >>> + if (parent) { >>> + nr_inport = inport; >>> + tpdm_found = false; >>> + } >>> + >>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>> + in_csdev = csdev->pdata->in_conns[i]->src_dev; >>> + if (!in_csdev) >>> + break; >>> + >>> + if (parent) >>> + if (csdev->pdata->in_conns[i]->dest_port != inport) >>> + continue; > > The above can become : > > if (match_inport && > csdev->pdata->in_conns[i]->dest_port != inport) > continue; Sure, I will update this in the next patch series. Best, Tao > > Suzuki >
On 25/05/2023 08:16, Tao Zhang wrote: > > On 5/23/2023 6:07 PM, Suzuki K Poulose wrote: >> On 27/04/2023 10:00, Tao Zhang wrote: >>> Read the DSB element size from the device tree. Set the register >>> bit that controls the DSB element size of the corresponding port. >>> >>> Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> >>> --- >>> drivers/hwtracing/coresight/coresight-core.c | 1 + >>> drivers/hwtracing/coresight/coresight-tpda.c | 92 >>> +++++++++++++++++++++++++--- >>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>> drivers/hwtracing/coresight/coresight-tpdm.c | 2 +- >>> include/linux/coresight.h | 1 + >>> 5 files changed, 90 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-core.c >>> b/drivers/hwtracing/coresight/coresight-core.c >>> index 2af416b..f1eacbb 100644 >>> --- a/drivers/hwtracing/coresight/coresight-core.c >>> +++ b/drivers/hwtracing/coresight/coresight-core.c >>> @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct >>> coresight_device *csdev, >>> if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && >>> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && >>> + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && >>> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { >>> dev_err(&csdev->dev, "wrong device subtype in %s\n", >>> function); >>> return -EINVAL; >> >> Please see the comment at the bottom. >> >>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>> b/drivers/hwtracing/coresight/coresight-tpda.c >>> index 8d2b9d2..af9c72f 100644 >>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>> @@ -21,6 +21,56 @@ >>> DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); >>> +/* Search and read element data size from the TPDM node in >>> + * the devicetree. Each input port of TPDA is connected to >>> + * a TPDM. Different TPDM supports different types of dataset, >>> + * and some may support more than one type of dataset. >>> + * Parameter "inport" is used to pass in the input port number >>> + * of TPDA, and it is set to 0 in the recursize call. >>> + * Parameter "parent" is used to pass in the original call. >>> + */ >>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>> + struct coresight_device *csdev, int inport, bool parent) >>> +{ >>> + static int nr_inport; >>> + int i; >>> + static bool tpdm_found; >>> + struct coresight_device *in_csdev; >>> + >>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>> + return -EINVAL; >>> + >>> + if (parent) { >>> + nr_inport = inport; >>> + tpdm_found = false; >>> + } >>> + >>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>> + in_csdev = csdev->pdata->in_conns[i]->src_dev; >>> + if (!in_csdev) >>> + break; >>> + >>> + if (parent) >>> + if (csdev->pdata->in_conns[i]->dest_port != inport) >>> + continue; >>> + >>> + if (in_csdev->subtype.source_subtype >> >> We must match the in_csdev->type to be SOURCE && the subtype. > Sure, I will update it in the next patch series. >> >>> + == CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM) { >>> + of_property_read_u8(in_csdev->dev.parent->of_node, >>> + "qcom,dsb-element-size", >>> &drvdata->dsb_esize[nr_inport]); >>> + if (!tpdm_found) >>> + tpdm_found = true; >>> + else >>> + dev_warn(drvdata->dev, >>> + "More than one TPDM is mapped to the TPDA input >>> port %d.\n", >>> + nr_inport); >> >> When we know, we have found a source device, we don't need to recurse >> down and could simply 'continue' to the next one in the list and skip >> the call below. > > Actually, one input port on TPDA only can connect to one TPDM. In the > current design, it will > > find out all the TPDMs on one input port and warn the users all the > TPDMs it found. If we > > replace 'recurse down' as 'continue' here, it may not find some TPDMs > that might be connected > > incorrectly. What do you mean ? When you enter the if () above, the in_csdev is a source and it is TPDM. There must be no input connections TPDM, i.e. in_csdev, so no need to go further up the connection chain looking at the in_csdev. The loop will continue to analyse this device (where we found one TPDM already) and detect any further duplicate TPDMs connected. Suzuki
On 5/25/2023 5:08 PM, Suzuki K Poulose wrote: > On 25/05/2023 08:16, Tao Zhang wrote: >> >> On 5/23/2023 6:07 PM, Suzuki K Poulose wrote: >>> On 27/04/2023 10:00, Tao Zhang wrote: >>>> Read the DSB element size from the device tree. Set the register >>>> bit that controls the DSB element size of the corresponding port. >>>> >>>> Signed-off-by: Tao Zhang <quic_taozha@quicinc.com> >>>> --- >>>> drivers/hwtracing/coresight/coresight-core.c | 1 + >>>> drivers/hwtracing/coresight/coresight-tpda.c | 92 >>>> +++++++++++++++++++++++++--- >>>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>>> drivers/hwtracing/coresight/coresight-tpdm.c | 2 +- >>>> include/linux/coresight.h | 1 + >>>> 5 files changed, 90 insertions(+), 10 deletions(-) >>>> >>>> diff --git a/drivers/hwtracing/coresight/coresight-core.c >>>> b/drivers/hwtracing/coresight/coresight-core.c >>>> index 2af416b..f1eacbb 100644 >>>> --- a/drivers/hwtracing/coresight/coresight-core.c >>>> +++ b/drivers/hwtracing/coresight/coresight-core.c >>>> @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct >>>> coresight_device *csdev, >>>> if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && >>>> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && >>>> + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && >>>> subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { >>>> dev_err(&csdev->dev, "wrong device subtype in %s\n", >>>> function); >>>> return -EINVAL; >>> >>> Please see the comment at the bottom. >>> >>>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>>> b/drivers/hwtracing/coresight/coresight-tpda.c >>>> index 8d2b9d2..af9c72f 100644 >>>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>>> @@ -21,6 +21,56 @@ >>>> DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); >>>> +/* Search and read element data size from the TPDM node in >>>> + * the devicetree. Each input port of TPDA is connected to >>>> + * a TPDM. Different TPDM supports different types of dataset, >>>> + * and some may support more than one type of dataset. >>>> + * Parameter "inport" is used to pass in the input port number >>>> + * of TPDA, and it is set to 0 in the recursize call. >>>> + * Parameter "parent" is used to pass in the original call. >>>> + */ >>>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>>> + struct coresight_device *csdev, int inport, bool >>>> parent) >>>> +{ >>>> + static int nr_inport; >>>> + int i; >>>> + static bool tpdm_found; >>>> + struct coresight_device *in_csdev; >>>> + >>>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>>> + return -EINVAL; >>>> + >>>> + if (parent) { >>>> + nr_inport = inport; >>>> + tpdm_found = false; >>>> + } >>>> + >>>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>>> + in_csdev = csdev->pdata->in_conns[i]->src_dev; >>>> + if (!in_csdev) >>>> + break; >>>> + >>>> + if (parent) >>>> + if (csdev->pdata->in_conns[i]->dest_port != inport) >>>> + continue; >>>> + >>>> + if (in_csdev->subtype.source_subtype >>> >>> We must match the in_csdev->type to be SOURCE && the subtype. >> Sure, I will update it in the next patch series. >>> >>>> + == CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM) { >>>> + of_property_read_u8(in_csdev->dev.parent->of_node, >>>> + "qcom,dsb-element-size", >>>> &drvdata->dsb_esize[nr_inport]); >>>> + if (!tpdm_found) >>>> + tpdm_found = true; >>>> + else >>>> + dev_warn(drvdata->dev, >>>> + "More than one TPDM is mapped to the TPDA >>>> input port %d.\n", >>>> + nr_inport); >>> >>> When we know, we have found a source device, we don't need to recurse >>> down and could simply 'continue' to the next one in the list and skip >>> the call below. >> >> Actually, one input port on TPDA only can connect to one TPDM. In the >> current design, it will >> >> find out all the TPDMs on one input port and warn the users all the >> TPDMs it found. If we >> >> replace 'recurse down' as 'continue' here, it may not find some TPDMs >> that might be connected >> >> incorrectly. > > > What do you mean ? When you enter the if () above, the in_csdev is a > source and it is TPDM. There must be no input connections TPDM, i.e. > in_csdev, so no need to go further up the connection chain looking at > the in_csdev. The loop will continue to analyse this device (where we > found one TPDM already) and detect any further duplicate TPDMs > connected. Got it. You're right. I will update this in the next patch series as well. > > Suzuki > >
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 2af416b..f1eacbb 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct coresight_device *csdev, if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC && subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE && + subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM && subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) { dev_err(&csdev->dev, "wrong device subtype in %s\n", function); return -EINVAL; diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c index 8d2b9d2..af9c72f 100644 --- a/drivers/hwtracing/coresight/coresight-tpda.c +++ b/drivers/hwtracing/coresight/coresight-tpda.c @@ -21,6 +21,56 @@ DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda"); +/* Search and read element data size from the TPDM node in + * the devicetree. Each input port of TPDA is connected to + * a TPDM. Different TPDM supports different types of dataset, + * and some may support more than one type of dataset. + * Parameter "inport" is used to pass in the input port number + * of TPDA, and it is set to 0 in the recursize call. + * Parameter "parent" is used to pass in the original call. + */ +static int tpda_set_element_size(struct tpda_drvdata *drvdata, + struct coresight_device *csdev, int inport, bool parent) +{ + static int nr_inport; + int i; + static bool tpdm_found; + struct coresight_device *in_csdev; + + if (inport > (TPDA_MAX_INPORTS - 1)) + return -EINVAL; + + if (parent) { + nr_inport = inport; + tpdm_found = false; + } + + for (i = 0; i < csdev->pdata->nr_inconns; i++) { + in_csdev = csdev->pdata->in_conns[i]->src_dev; + if (!in_csdev) + break; + + if (parent) + if (csdev->pdata->in_conns[i]->dest_port != inport) + continue; + + if (in_csdev->subtype.source_subtype + == CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM) { + of_property_read_u8(in_csdev->dev.parent->of_node, + "qcom,dsb-element-size", &drvdata->dsb_esize[nr_inport]); + if (!tpdm_found) + tpdm_found = true; + else + dev_warn(drvdata->dev, + "More than one TPDM is mapped to the TPDA input port %d.\n", + nr_inport); + } + tpda_set_element_size(drvdata, in_csdev, 0, false); + } + + return 0; +} + /* Settings pre enabling port control register */ static void tpda_enable_pre_port(struct tpda_drvdata *drvdata) { @@ -32,26 +82,43 @@ static void tpda_enable_pre_port(struct tpda_drvdata *drvdata) writel_relaxed(val, drvdata->base + TPDA_CR); } -static void tpda_enable_port(struct tpda_drvdata *drvdata, int port) +static int tpda_enable_port(struct tpda_drvdata *drvdata, int port) { u32 val; val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port)); + /* + * Configure aggregator port n DSB data set element size + * Set the bit to 0 if the size is 32 + * Set the bit to 1 if the size is 64 + */ + if (drvdata->dsb_esize[port] == 32) + val &= ~TPDA_Pn_CR_DSBSIZE; + else if (drvdata->dsb_esize[port] == 64) + val |= TPDA_Pn_CR_DSBSIZE; + else + return -EINVAL; + /* Enable the port */ val |= TPDA_Pn_CR_ENA; writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); + + return 0; } -static void __tpda_enable(struct tpda_drvdata *drvdata, int port) +static int __tpda_enable(struct tpda_drvdata *drvdata, int port) { + int ret; + CS_UNLOCK(drvdata->base); if (!drvdata->csdev->enable) tpda_enable_pre_port(drvdata); - tpda_enable_port(drvdata, port); - + ret = tpda_enable_port(drvdata, port); CS_LOCK(drvdata->base); + + return ret; } static int tpda_enable(struct coresight_device *csdev, @@ -59,16 +126,23 @@ static int tpda_enable(struct coresight_device *csdev, struct coresight_connection *out) { struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + int ret; + + ret = tpda_set_element_size(drvdata, csdev, in->dest_port, true); + if (ret) + return ret; spin_lock(&drvdata->spinlock); - if (atomic_read(&in->dest_refcnt) == 0) + if (atomic_read(&in->dest_refcnt) == 0) { __tpda_enable(drvdata, in->dest_port); + if (!ret) { + atomic_inc(&in->dest_refcnt); + dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); + } + } - atomic_inc(&in->dest_refcnt); spin_unlock(&drvdata->spinlock); - - dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port); - return 0; + return ret; } static void __tpda_disable(struct tpda_drvdata *drvdata, int port) diff --git a/drivers/hwtracing/coresight/coresight-tpda.h b/drivers/hwtracing/coresight/coresight-tpda.h index 0399678..7332e9c 100644 --- a/drivers/hwtracing/coresight/coresight-tpda.h +++ b/drivers/hwtracing/coresight/coresight-tpda.h @@ -10,6 +10,8 @@ #define TPDA_Pn_CR(n) (0x004 + (n * 4)) /* Aggregator port enable bit */ #define TPDA_Pn_CR_ENA BIT(0) +/* Aggregator port DSB data set element size bit */ +#define TPDA_Pn_CR_DSBSIZE BIT(8) #define TPDA_MAX_INPORTS 32 @@ -23,6 +25,7 @@ * @csdev: component vitals needed by the framework. * @spinlock: lock for the drvdata value. * @enable: enable status of the component. + * @dsb_esize: DSB element size, it must be 32 or 64. */ struct tpda_drvdata { void __iomem *base; @@ -30,6 +33,7 @@ struct tpda_drvdata { struct coresight_device *csdev; spinlock_t spinlock; u8 atid; + u8 dsb_esize[TPDA_MAX_INPORTS]; }; #endif /* _CORESIGHT_CORESIGHT_TPDA_H */ diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index f4854af..ba1867f 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -205,7 +205,7 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) if (!desc.name) return -ENOMEM; desc.type = CORESIGHT_DEV_TYPE_SOURCE; - desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS; + desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM; desc.ops = &tpdm_cs_ops; desc.pdata = adev->dev.platform_data; desc.dev = &adev->dev; diff --git a/include/linux/coresight.h b/include/linux/coresight.h index 225a5fa..6563896 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -60,6 +60,7 @@ enum coresight_dev_subtype_source { CORESIGHT_DEV_SUBTYPE_SOURCE_PROC, CORESIGHT_DEV_SUBTYPE_SOURCE_BUS, CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE, + CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM, CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS, };