Message ID | 1679551448-19160-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:a5d:604a:0:0:0:0:0 with SMTP id j10csp2747073wrt; Wed, 22 Mar 2023 23:21:56 -0700 (PDT) X-Google-Smtp-Source: AK7set+EMHY5rwoqJtCon+HSFMVTymFCgXBGLmMUxre2UsM2ptTzBtFm35gDHBIxOdY5+DWv/zEs X-Received: by 2002:a17:903:410b:b0:1a1:bff4:4a06 with SMTP id r11-20020a170903410b00b001a1bff44a06mr4751738pld.24.1679552516193; Wed, 22 Mar 2023 23:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679552516; cv=none; d=google.com; s=arc-20160816; b=zD8UDEieCHqz03pKfNFAO/VJUKY3YIqRRrlkLLJotU7cXIy9iMyLfZYnNUKf+iiUKQ ri6aIDcTGRcDiZVPk1N8VONaoc+uecTM+nDN3mgzcqFSphMtBWMLjf+jyrWIRGPiYwzu Se980BqHvKdkHcPMvCNGC6+4PaD0dwYw3D6dhnJmy/QrsfwcYKyQ3RgicevHWiDTgXpS 1TTuIbZb3nXpuFdhrjIQktHoBEyhc8czwsjyunTtgb42Fg7BxK8VxSgmYW5KHITy7lWO YzGjPheQt8HGspk4Gj2UhTLxMDa9w5BbkF+BQcy+TvSF6/qfa71PDX9dLrlKrzuAM5Vl HDNQ== 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=a0KJ2Ixr7wCyt3Sz77Gt0PUj6x8JwmpHQa7jNGesVvU=; b=NfwIJHrSDHGGMpu3MXAocORDILyDQO6mtZi/uH9eh9P8IOeKOQCrH9HNh0DkM3JUYA e4oaRNobHKn/ajzxHB2LgJghQX/e6NJJt3sa6sVkN4wLJwlou4nzMJTJEm0cF4GA0oRD 5d1g6y3hwORFZromWllnee3HYcKB+X3k0t49EtMLw/QoHS6tSVimWtQZM3yjz/OoNThf fU2pACMKJ4He9PnAeibl0eK4biDaYY8l71GMi28nyhSsN9dhHU0aE9NYQfLr9NtUKgx0 F+Fpm74j551gLyO2paAdtzwb6NN6J028tjj7QXWaVdByguXFoIDUmfO3tTsWOCW7EQfL lElw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AQcPh6lf; 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 s6-20020a63ff46000000b005030a59a81dsi17659482pgk.159.2023.03.22.23.21.43; Wed, 22 Mar 2023 23:21:56 -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=AQcPh6lf; 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 S230467AbjCWGFV (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Thu, 23 Mar 2023 02:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjCWGFM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 23 Mar 2023 02:05:12 -0400 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C7A226C0E; Wed, 22 Mar 2023 23:05:07 -0700 (PDT) Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32N5h18O029123; Thu, 23 Mar 2023 06:04:46 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=a0KJ2Ixr7wCyt3Sz77Gt0PUj6x8JwmpHQa7jNGesVvU=; b=AQcPh6lf2/GJzeVi5kC+wgv5qHIE9iKUjGUJUYn5WotTyYNtJQEceM7ePjI5Ty+eZb1s d3JPpF+wZJ7gqG7muK7hTU0LvJ4aBIkLtjvtH/d6EcUEMNMsizNIcHpr6Tz7RnTrsXFs 8bKMKVPYgsBHr4yoiG6WK96x5iMS3a0vJElrOdwj/UD3zgk/U3qRQ+W+J4PsluFfCGoq 9kx8GX558r1LBBexzeYF1yWUbod+u0/bbvSkQN7aklFWb4mAT+uWiG6WcoD0kc3Wxh++ RtHdvY2rGiqB2zK70OzGnl6I8c8wAnTAU31f8ATfjDzaRh/seRBUOpVuALBAOEihHnHe 0A== Received: from nalasppmta05.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3pgghj0288-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Mar 2023 06:04:45 +0000 Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA05.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 32N64iTu031817 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Mar 2023 06:04:44 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.41; Wed, 22 Mar 2023 23:04:39 -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>, <bjorn.andersson@linaro.org> Subject: [PATCH v3 02/11] coresight-tpda: Add DSB dataset support Date: Thu, 23 Mar 2023 14:03:59 +0800 Message-ID: <1679551448-19160-3-git-send-email-quic_taozha@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1679551448-19160-1-git-send-email-quic_taozha@quicinc.com> References: <1679551448-19160-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: nasanex01a.na.qualcomm.com (10.52.223.231) 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: G7pz1sAOCTkxq7USSSZxWOxHBJ0q1YgW X-Proofpoint-ORIG-GUID: G7pz1sAOCTkxq7USSSZxWOxHBJ0q1YgW 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-03-22_21,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303230045 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761138459471932924?= X-GMAIL-MSGID: =?utf-8?q?1761138459471932924?= |
Series |
Add support to configure TPDM DSB subunit
|
|
Commit Message
Tao Zhang
March 23, 2023, 6:03 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-tpda.c | 58 ++++++++++++++++++++++++++++
drivers/hwtracing/coresight/coresight-tpda.h | 4 ++
2 files changed, 62 insertions(+)
Comments
On 23/03/2023 06:03, 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-tpda.c | 58 ++++++++++++++++++++++++++++ > drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ > 2 files changed, 62 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c > index f712e11..8dcfc4a 100644 > --- a/drivers/hwtracing/coresight/coresight-tpda.c > +++ b/drivers/hwtracing/coresight/coresight-tpda.c > @@ -21,6 +21,47 @@ > > 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. > + */ I am still not clear why we need to do this recursively ? > +static int tpda_set_element_size(struct tpda_drvdata *drvdata, > + struct coresight_device *csdev, int inport, bool parent) Please could we renamse csdev => tpda_dev > +{ > + static int nr_inport; > + int i; > + struct coresight_device *in_csdev; similarly tpdm_dev ? Could we not add a check here to see if the dsb_esize[inport] is already set and then bail out, reading this over and over ? > + > + if (inport > (TPDA_MAX_INPORTS - 1)) > + return -EINVAL; > + > + if (parent) > + nr_inport = inport; > + > + for (i = 0; i < csdev->pdata->nr_inconns; i++) { > + in_csdev = csdev->pdata->in_conns[i].remote_dev; Please note, the names of the structure field might change in the next version of James' series > + if (!in_csdev) > + break; > + > + if (parent) > + if (csdev->pdata->in_conns[i].port != inport) > + continue; > + > + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { Isn't there a better way to distinguish a device to be TPDM ? May be we could even add a source_sub_type - SOURCE_TPDM instead of using SOURCE_OTHERS ? Do you expect other sources to be connected to TPDA? e.g., STMs ? > + of_property_read_u32(in_csdev->dev.parent->of_node, > + "qcom,dsb-element-size", &drvdata->dsb_esize[nr_inport]); > + break; > + } > + tpda_set_element_size(drvdata, in_csdev, 0, false); What is the point of this ? Is this for covering the a TPDA connected to another TPDA ? e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? And you want to figure out the DSB size of TPDM0 when you want to enable TPDA1 ? How do you choose between that size of TPDM0 vs TPDM1 ? Please add a proper documentation for this function ? If TPDA0 is in the the path, it should have been enabled before you reach TPDA1. Thus, the dsb_esize array must have been initialised for TPDA0 and thus, you could simply read it from the dsb_esize[] of TPDA0. You could always look at the device_type and sub_type to detect a TPDA{0} connected into TPDA{1} > + } > + > + return 0; > +} > + > /* Settings pre enabling port control register */ > static void tpda_enable_pre_port(struct tpda_drvdata *drvdata) > { > @@ -37,6 +78,18 @@ static void 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 > + dev_err(drvdata->dev, > + "DSB data size input from port[%d] is invalid\n", port); WARN_ON_ONCE() and abort the enable opration ? Or say, "fallback to 32bit or 64bit" if one of them is a safer option ? Please don't leave it unknown. > /* Enable the port */ > val |= TPDA_Pn_CR_ENA; > writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); > @@ -57,6 +110,11 @@ static void __tpda_enable(struct tpda_drvdata *drvdata, int port) > static int tpda_enable(struct coresight_device *csdev, int inport, int outport) > { > struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); > + int ret; > + > + ret = tpda_set_element_size(drvdata, csdev, inport, true); > + if (ret) > + return ret; > > spin_lock(&drvdata->spinlock); > if (atomic_read(&csdev->refcnt[inport]) == 0) > diff --git a/drivers/hwtracing/coresight/coresight-tpda.h b/drivers/hwtracing/coresight/coresight-tpda.h > index 0399678..9ec5870 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 Please state, 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; > + u32 dsb_esize[TPDA_MAX_INPORTS]; Couldn't this be u8 ? Suzuki > }; > > #endif /* _CORESIGHT_CORESIGHT_TPDA_H */
On 24/03/2023 14:58, Tao Zhang wrote: > Hi Suzuki, > > 在 3/23/2023 7:51 PM, Suzuki K Poulose 写道: >> On 23/03/2023 06:03, 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-tpda.c | 58 >>> ++++++++++++++++++++++++++++ >>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>> 2 files changed, 62 insertions(+) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>> b/drivers/hwtracing/coresight/coresight-tpda.c >>> index f712e11..8dcfc4a 100644 >>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>> @@ -21,6 +21,47 @@ >>> 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. >>> + */ >> >> I am still not clear why we need to do this recursively ? > > Some TPDMs are not directly output connected to the TPDAs. So here I > > use a recursive method to check from the TPDA input port until I find > > the connected TPDM. > > Do you have a better suggestion besides a recursive method? > >> >>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>> + struct coresight_device *csdev, int inport, bool parent) >> >> Please could we renamse csdev => tpda_dev > > Since this is a recursively called function, this Coresight device is not > > necessarily TPDA, it can be other Coresight device. > >> >>> +{ >>> + static int nr_inport; >>> + int i; >>> + struct coresight_device *in_csdev; >> >> similarly tpdm_dev ? > Same as above, this variable may not necessarily be a TPDM. >> >> Could we not add a check here to see if the dsb_esize[inport] is already >> set and then bail out, reading this over and over ? >> > I will update this in the next patch series. >>> + >>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>> + return -EINVAL; >>> + >>> + if (parent) >>> + nr_inport = inport; >>> + >>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>> + in_csdev = csdev->pdata->in_conns[i].remote_dev; >> >> Please note, the names of the structure field might change in the >> next version of James' series > Got it. I will keep an eye out for the James' patch series. >> >>> + if (!in_csdev) >>> + break; >>> + >>> + if (parent) >>> + if (csdev->pdata->in_conns[i].port != inport) >>> + continue; >>> + >>> + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { >> >> Isn't there a better way to distinguish a device to be TPDM ? May be we >> could even add a source_sub_type - SOURCE_TPDM instead of using >> SOURCE_OTHERS ? Do you expect other sources to be connected to TPDA? >> e.g., STMs ? > > I can add "SOURCE_TPDM" as a source_sub_type, but SOURCE_OTHERS needs > > to be kept since the other Coresight component we will upstream later may > > need it. > >> >>> + of_property_read_u32(in_csdev->dev.parent->of_node, >>> + "qcom,dsb-element-size", >>> &drvdata->dsb_esize[nr_inport]); >>> + break; >>> + } >>> + tpda_set_element_size(drvdata, in_csdev, 0, false); >> >> What is the point of this ? Is this for covering the a TPDA connected to >> another TPDA ? >> >> e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? > > A TPDM may not connect to the TPDA directly, for example, > > TPDM0 ->FUNNEL0->FUNNEL1->TPDA0 > > And many TPDMs can connect to one TPDA, one input port on TPDA only has > > one TPDM connected. Therefore, we use a recursive method to find the TPDM > > corresponding to the input port of TPDA. How do you find out decide what to choose, if there are multiple TPDMs connected to FUNNEL0 or even FUNNEL1 ? e.g TPDM0->FUNNEL0->FUNNEL1->TPDA0 / TPDM1 Suzuki
On 3/26/2023 3:31 AM, Suzuki K Poulose wrote: > On 24/03/2023 14:58, Tao Zhang wrote: >> Hi Suzuki, >> >> 在 3/23/2023 7:51 PM, Suzuki K Poulose 写道: >>> On 23/03/2023 06:03, 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-tpda.c | 58 >>>> ++++++++++++++++++++++++++++ >>>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>>> 2 files changed, 62 insertions(+) >>>> >>>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>>> b/drivers/hwtracing/coresight/coresight-tpda.c >>>> index f712e11..8dcfc4a 100644 >>>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>>> @@ -21,6 +21,47 @@ >>>> 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. >>>> + */ >>> >>> I am still not clear why we need to do this recursively ? >> >> Some TPDMs are not directly output connected to the TPDAs. So here I >> >> use a recursive method to check from the TPDA input port until I find >> >> the connected TPDM. >> >> Do you have a better suggestion besides a recursive method? >> >>> >>>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>>> + struct coresight_device *csdev, int inport, bool >>>> parent) >>> >>> Please could we renamse csdev => tpda_dev >> >> Since this is a recursively called function, this Coresight device is >> not >> >> necessarily TPDA, it can be other Coresight device. >> >>> >>>> +{ >>>> + static int nr_inport; >>>> + int i; >>>> + struct coresight_device *in_csdev; >>> >>> similarly tpdm_dev ? >> Same as above, this variable may not necessarily be a TPDM. >>> >>> Could we not add a check here to see if the dsb_esize[inport] is >>> already >>> set and then bail out, reading this over and over ? >>> >> I will update this in the next patch series. >>>> + >>>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>>> + return -EINVAL; >>>> + >>>> + if (parent) >>>> + nr_inport = inport; >>>> + >>>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>>> + in_csdev = csdev->pdata->in_conns[i].remote_dev; >>> >>> Please note, the names of the structure field might change in the >>> next version of James' series >> Got it. I will keep an eye out for the James' patch series. >>> >>>> + if (!in_csdev) >>>> + break; >>>> + >>>> + if (parent) >>>> + if (csdev->pdata->in_conns[i].port != inport) >>>> + continue; >>>> + >>>> + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { >>> >>> Isn't there a better way to distinguish a device to be TPDM ? May be we >>> could even add a source_sub_type - SOURCE_TPDM instead of using >>> SOURCE_OTHERS ? Do you expect other sources to be connected to TPDA? >>> e.g., STMs ? >> >> I can add "SOURCE_TPDM" as a source_sub_type, but SOURCE_OTHERS needs >> >> to be kept since the other Coresight component we will upstream later >> may >> >> need it. >> >>> >>>> + of_property_read_u32(in_csdev->dev.parent->of_node, >>>> + "qcom,dsb-element-size", >>>> &drvdata->dsb_esize[nr_inport]); >>>> + break; >>>> + } >>>> + tpda_set_element_size(drvdata, in_csdev, 0, false); >>> >>> What is the point of this ? Is this for covering the a TPDA >>> connected to >>> another TPDA ? >>> >>> e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? >> >> A TPDM may not connect to the TPDA directly, for example, >> >> TPDM0 ->FUNNEL0->FUNNEL1->TPDA0 >> >> And many TPDMs can connect to one TPDA, one input port on TPDA only has >> >> one TPDM connected. Therefore, we use a recursive method to find the >> TPDM >> >> corresponding to the input port of TPDA. > > How do you find out decide what to choose, if there are multiple TPDMs > connected to FUNNEL0 or even FUNNEL1 ? > > e.g > > TPDM0->FUNNEL0->FUNNEL1->TPDA0 > / > TPDM1 We can find out the corresponding TPDM by the input port number of TPDA. Each input port is connected to a TPDM. So we have an input port number in the input parameter of the recursive lookup function "tpda_set_element_size". > Suzuki > >
On 27/03/2023 04:31, Tao Zhang wrote: > > On 3/26/2023 3:31 AM, Suzuki K Poulose wrote: >> On 24/03/2023 14:58, Tao Zhang wrote: >>> Hi Suzuki, >>> >>> 在 3/23/2023 7:51 PM, Suzuki K Poulose 写道: >>>> On 23/03/2023 06:03, 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-tpda.c | 58 >>>>> ++++++++++++++++++++++++++++ >>>>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>>>> 2 files changed, 62 insertions(+) >>>>> >>>>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>>>> b/drivers/hwtracing/coresight/coresight-tpda.c >>>>> index f712e11..8dcfc4a 100644 >>>>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>>>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>>>> @@ -21,6 +21,47 @@ >>>>> 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. >>>>> + */ >>>> >>>> I am still not clear why we need to do this recursively ? >>> >>> Some TPDMs are not directly output connected to the TPDAs. So here I >>> >>> use a recursive method to check from the TPDA input port until I find >>> >>> the connected TPDM. >>> >>> Do you have a better suggestion besides a recursive method? >>> >>>> >>>>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>>>> + struct coresight_device *csdev, int inport, bool >>>>> parent) >>>> >>>> Please could we renamse csdev => tpda_dev >>> >>> Since this is a recursively called function, this Coresight device is >>> not >>> >>> necessarily TPDA, it can be other Coresight device. >>> >>>> >>>>> +{ >>>>> + static int nr_inport; >>>>> + int i; >>>>> + struct coresight_device *in_csdev; >>>> >>>> similarly tpdm_dev ? >>> Same as above, this variable may not necessarily be a TPDM. >>>> >>>> Could we not add a check here to see if the dsb_esize[inport] is >>>> already >>>> set and then bail out, reading this over and over ? >>>> >>> I will update this in the next patch series. >>>>> + >>>>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>>>> + return -EINVAL; >>>>> + >>>>> + if (parent) >>>>> + nr_inport = inport; >>>>> + >>>>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>>>> + in_csdev = csdev->pdata->in_conns[i].remote_dev; >>>> >>>> Please note, the names of the structure field might change in the >>>> next version of James' series >>> Got it. I will keep an eye out for the James' patch series. >>>> >>>>> + if (!in_csdev) >>>>> + break; >>>>> + >>>>> + if (parent) >>>>> + if (csdev->pdata->in_conns[i].port != inport) >>>>> + continue; >>>>> + >>>>> + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { >>>> >>>> Isn't there a better way to distinguish a device to be TPDM ? May be we >>>> could even add a source_sub_type - SOURCE_TPDM instead of using >>>> SOURCE_OTHERS ? Do you expect other sources to be connected to TPDA? >>>> e.g., STMs ? >>> >>> I can add "SOURCE_TPDM" as a source_sub_type, but SOURCE_OTHERS needs >>> >>> to be kept since the other Coresight component we will upstream later >>> may >>> >>> need it. >>> >>>> >>>>> + of_property_read_u32(in_csdev->dev.parent->of_node, >>>>> + "qcom,dsb-element-size", >>>>> &drvdata->dsb_esize[nr_inport]); >>>>> + break; >>>>> + } >>>>> + tpda_set_element_size(drvdata, in_csdev, 0, false); >>>> >>>> What is the point of this ? Is this for covering the a TPDA >>>> connected to >>>> another TPDA ? >>>> >>>> e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? >>> >>> A TPDM may not connect to the TPDA directly, for example, >>> >>> TPDM0 ->FUNNEL0->FUNNEL1->TPDA0 >>> >>> And many TPDMs can connect to one TPDA, one input port on TPDA only has >>> >>> one TPDM connected. Therefore, we use a recursive method to find the >>> TPDM >>> >>> corresponding to the input port of TPDA. >> >> How do you find out decide what to choose, if there are multiple TPDMs >> connected to FUNNEL0 or even FUNNEL1 ? >> >> e.g >> >> TPDM0->FUNNEL0->FUNNEL1->TPDA0 >> / >> TPDM1 > > We can find out the corresponding TPDM by the input port number of TPDA. > > Each input port is connected to a TPDM. So we have an input port number in > > the input parameter of the recursive lookup function > "tpda_set_element_size". I don't understand, how you would figure out, in the above situation. i.e., FUNNEL1 is connected to TPDA0, but there are two TPDMs that could be pumping the trace. They both arrive via FUNNEL1. So, how does that solve your problem ? Suzuki > >> Suzuki >> >>
Hi Suzuki, On 3/27/2023 5:43 PM, Suzuki K Poulose wrote: > On 27/03/2023 04:31, Tao Zhang wrote: >> >> On 3/26/2023 3:31 AM, Suzuki K Poulose wrote: >>> On 24/03/2023 14:58, Tao Zhang wrote: >>>> Hi Suzuki, >>>> >>>> 在 3/23/2023 7:51 PM, Suzuki K Poulose 写道: >>>>> On 23/03/2023 06:03, 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-tpda.c | 58 >>>>>> ++++++++++++++++++++++++++++ >>>>>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>>>>> 2 files changed, 62 insertions(+) >>>>>> >>>>>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>>>>> b/drivers/hwtracing/coresight/coresight-tpda.c >>>>>> index f712e11..8dcfc4a 100644 >>>>>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>>>>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>>>>> @@ -21,6 +21,47 @@ >>>>>> 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. >>>>>> + */ >>>>> >>>>> I am still not clear why we need to do this recursively ? >>>> >>>> Some TPDMs are not directly output connected to the TPDAs. So here I >>>> >>>> use a recursive method to check from the TPDA input port until I find >>>> >>>> the connected TPDM. >>>> >>>> Do you have a better suggestion besides a recursive method? >>>> >>>>> >>>>>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>>>>> + struct coresight_device *csdev, int inport, bool >>>>>> parent) >>>>> >>>>> Please could we renamse csdev => tpda_dev >>>> >>>> Since this is a recursively called function, this Coresight device >>>> is not >>>> >>>> necessarily TPDA, it can be other Coresight device. >>>> >>>>> >>>>>> +{ >>>>>> + static int nr_inport; >>>>>> + int i; >>>>>> + struct coresight_device *in_csdev; >>>>> >>>>> similarly tpdm_dev ? >>>> Same as above, this variable may not necessarily be a TPDM. >>>>> >>>>> Could we not add a check here to see if the dsb_esize[inport] is >>>>> already >>>>> set and then bail out, reading this over and over ? >>>>> >>>> I will update this in the next patch series. >>>>>> + >>>>>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>>>>> + return -EINVAL; >>>>>> + >>>>>> + if (parent) >>>>>> + nr_inport = inport; >>>>>> + >>>>>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>>>>> + in_csdev = csdev->pdata->in_conns[i].remote_dev; >>>>> >>>>> Please note, the names of the structure field might change in the >>>>> next version of James' series >>>> Got it. I will keep an eye out for the James' patch series. >>>>> >>>>>> + if (!in_csdev) >>>>>> + break; >>>>>> + >>>>>> + if (parent) >>>>>> + if (csdev->pdata->in_conns[i].port != inport) >>>>>> + continue; >>>>>> + >>>>>> + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { >>>>> >>>>> Isn't there a better way to distinguish a device to be TPDM ? May >>>>> be we >>>>> could even add a source_sub_type - SOURCE_TPDM instead of using >>>>> SOURCE_OTHERS ? Do you expect other sources to be connected to TPDA? >>>>> e.g., STMs ? >>>> >>>> I can add "SOURCE_TPDM" as a source_sub_type, but SOURCE_OTHERS needs >>>> >>>> to be kept since the other Coresight component we will upstream >>>> later may >>>> >>>> need it. >>>> >>>>> >>>>>> + of_property_read_u32(in_csdev->dev.parent->of_node, >>>>>> + "qcom,dsb-element-size", >>>>>> &drvdata->dsb_esize[nr_inport]); >>>>>> + break; >>>>>> + } >>>>>> + tpda_set_element_size(drvdata, in_csdev, 0, false); >>>>> >>>>> What is the point of this ? Is this for covering the a TPDA >>>>> connected to >>>>> another TPDA ? >>>>> >>>>> e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? >>>> >>>> A TPDM may not connect to the TPDA directly, for example, >>>> >>>> TPDM0 ->FUNNEL0->FUNNEL1->TPDA0 >>>> >>>> And many TPDMs can connect to one TPDA, one input port on TPDA only >>>> has >>>> >>>> one TPDM connected. Therefore, we use a recursive method to find >>>> the TPDM >>>> >>>> corresponding to the input port of TPDA. >>> >>> How do you find out decide what to choose, if there are multiple TPDMs >>> connected to FUNNEL0 or even FUNNEL1 ? >>> >>> e.g >>> >>> TPDM0->FUNNEL0->FUNNEL1->TPDA0 >>> / >>> TPDM1 >> >> We can find out the corresponding TPDM by the input port number of TPDA. >> >> Each input port is connected to a TPDM. So we have an input port >> number in >> >> the input parameter of the recursive lookup function >> "tpda_set_element_size". > > I don't understand, how you would figure out, in the above situation. > i.e., FUNNEL1 is connected to TPDA0, but there are two TPDMs that could > be pumping the trace. They both arrive via FUNNEL1. So, how does that > solve your problem ? In our HW design, the input ports of TPDA and TPDM are one-one-one corresponding. Only one TPDM can be found connected from one TPDA's input port. The path to a TPDA input port doesn't connect more than one TPDM. It's by HW design. Tao > > Suzuki > > >> >>> Suzuki >>> >>> >
On 28/03/2023 12:31, Tao Zhang wrote: > Hi Suzuki, > > On 3/27/2023 5:43 PM, Suzuki K Poulose wrote: >> On 27/03/2023 04:31, Tao Zhang wrote: >>> >>> On 3/26/2023 3:31 AM, Suzuki K Poulose wrote: >>>> On 24/03/2023 14:58, Tao Zhang wrote: >>>>> Hi Suzuki, >>>>> >>>>> 在 3/23/2023 7:51 PM, Suzuki K Poulose 写道: >>>>>> On 23/03/2023 06:03, 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-tpda.c | 58 >>>>>>> ++++++++++++++++++++++++++++ >>>>>>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>>>>>> 2 files changed, 62 insertions(+) >>>>>>> >>>>>>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>> b/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>> index f712e11..8dcfc4a 100644 >>>>>>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>> @@ -21,6 +21,47 @@ >>>>>>> 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. >>>>>>> + */ >>>>>> >>>>>> I am still not clear why we need to do this recursively ? >>>>> >>>>> Some TPDMs are not directly output connected to the TPDAs. So here I >>>>> >>>>> use a recursive method to check from the TPDA input port until I find >>>>> >>>>> the connected TPDM. >>>>> >>>>> Do you have a better suggestion besides a recursive method? >>>>> >>>>>> >>>>>>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>>>>>> + struct coresight_device *csdev, int inport, bool >>>>>>> parent) >>>>>> >>>>>> Please could we renamse csdev => tpda_dev >>>>> >>>>> Since this is a recursively called function, this Coresight device >>>>> is not >>>>> >>>>> necessarily TPDA, it can be other Coresight device. >>>>> >>>>>> >>>>>>> +{ >>>>>>> + static int nr_inport; >>>>>>> + int i; >>>>>>> + struct coresight_device *in_csdev; >>>>>> >>>>>> similarly tpdm_dev ? >>>>> Same as above, this variable may not necessarily be a TPDM. >>>>>> >>>>>> Could we not add a check here to see if the dsb_esize[inport] is >>>>>> already >>>>>> set and then bail out, reading this over and over ? >>>>>> >>>>> I will update this in the next patch series. >>>>>>> + >>>>>>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>>>>>> + return -EINVAL; >>>>>>> + >>>>>>> + if (parent) >>>>>>> + nr_inport = inport; >>>>>>> + >>>>>>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>>>>>> + in_csdev = csdev->pdata->in_conns[i].remote_dev; >>>>>> >>>>>> Please note, the names of the structure field might change in the >>>>>> next version of James' series >>>>> Got it. I will keep an eye out for the James' patch series. >>>>>> >>>>>>> + if (!in_csdev) >>>>>>> + break; >>>>>>> + >>>>>>> + if (parent) >>>>>>> + if (csdev->pdata->in_conns[i].port != inport) >>>>>>> + continue; >>>>>>> + >>>>>>> + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { >>>>>> >>>>>> Isn't there a better way to distinguish a device to be TPDM ? May >>>>>> be we >>>>>> could even add a source_sub_type - SOURCE_TPDM instead of using >>>>>> SOURCE_OTHERS ? Do you expect other sources to be connected to TPDA? >>>>>> e.g., STMs ? >>>>> >>>>> I can add "SOURCE_TPDM" as a source_sub_type, but SOURCE_OTHERS needs >>>>> >>>>> to be kept since the other Coresight component we will upstream >>>>> later may >>>>> >>>>> need it. >>>>> >>>>>> >>>>>>> + of_property_read_u32(in_csdev->dev.parent->of_node, >>>>>>> + "qcom,dsb-element-size", >>>>>>> &drvdata->dsb_esize[nr_inport]); >>>>>>> + break; >>>>>>> + } >>>>>>> + tpda_set_element_size(drvdata, in_csdev, 0, false); >>>>>> >>>>>> What is the point of this ? Is this for covering the a TPDA >>>>>> connected to >>>>>> another TPDA ? >>>>>> >>>>>> e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? >>>>> >>>>> A TPDM may not connect to the TPDA directly, for example, >>>>> >>>>> TPDM0 ->FUNNEL0->FUNNEL1->TPDA0 >>>>> >>>>> And many TPDMs can connect to one TPDA, one input port on TPDA only >>>>> has >>>>> >>>>> one TPDM connected. Therefore, we use a recursive method to find >>>>> the TPDM >>>>> >>>>> corresponding to the input port of TPDA. >>>> >>>> How do you find out decide what to choose, if there are multiple TPDMs >>>> connected to FUNNEL0 or even FUNNEL1 ? >>>> >>>> e.g >>>> >>>> TPDM0->FUNNEL0->FUNNEL1->TPDA0 >>>> / >>>> TPDM1 >>> >>> We can find out the corresponding TPDM by the input port number of TPDA. >>> >>> Each input port is connected to a TPDM. So we have an input port >>> number in >>> >>> the input parameter of the recursive lookup function >>> "tpda_set_element_size". >> >> I don't understand, how you would figure out, in the above situation. >> i.e., FUNNEL1 is connected to TPDA0, but there are two TPDMs that could >> be pumping the trace. They both arrive via FUNNEL1. So, how does that >> solve your problem ? > > In our HW design, the input ports of TPDA and TPDM are one-one-one > corresponding. Only one > > TPDM can be found connected from one TPDA's input port. The path to a > TPDA input port doesn't > > connect more than one TPDM. It's by HW design. Your current designs may be like that. But as far as the driver is concerned, I would like to add in extra measures to ensure that it encounters a variation from the above on a future platform. So, please could you add a check to detect this case and add a WARNING ? Suzuki > > > Tao > >> >> Suzuki >> >> >>> >>>> Suzuki >>>> >>>> >>
Hi Suzuki, On 3/28/2023 8:33 PM, Suzuki K Poulose wrote: > On 28/03/2023 12:31, Tao Zhang wrote: >> Hi Suzuki, >> >> On 3/27/2023 5:43 PM, Suzuki K Poulose wrote: >>> On 27/03/2023 04:31, Tao Zhang wrote: >>>> >>>> On 3/26/2023 3:31 AM, Suzuki K Poulose wrote: >>>>> On 24/03/2023 14:58, Tao Zhang wrote: >>>>>> Hi Suzuki, >>>>>> >>>>>> 在 3/23/2023 7:51 PM, Suzuki K Poulose 写道: >>>>>>> On 23/03/2023 06:03, 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-tpda.c | 58 >>>>>>>> ++++++++++++++++++++++++++++ >>>>>>>> drivers/hwtracing/coresight/coresight-tpda.h | 4 ++ >>>>>>>> 2 files changed, 62 insertions(+) >>>>>>>> >>>>>>>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>>> b/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>>> index f712e11..8dcfc4a 100644 >>>>>>>> --- a/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c >>>>>>>> @@ -21,6 +21,47 @@ >>>>>>>> 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. >>>>>>>> + */ >>>>>>> >>>>>>> I am still not clear why we need to do this recursively ? >>>>>> >>>>>> Some TPDMs are not directly output connected to the TPDAs. So here I >>>>>> >>>>>> use a recursive method to check from the TPDA input port until I >>>>>> find >>>>>> >>>>>> the connected TPDM. >>>>>> >>>>>> Do you have a better suggestion besides a recursive method? >>>>>> >>>>>>> >>>>>>>> +static int tpda_set_element_size(struct tpda_drvdata *drvdata, >>>>>>>> + struct coresight_device *csdev, int inport, >>>>>>>> bool parent) >>>>>>> >>>>>>> Please could we renamse csdev => tpda_dev >>>>>> >>>>>> Since this is a recursively called function, this Coresight >>>>>> device is not >>>>>> >>>>>> necessarily TPDA, it can be other Coresight device. >>>>>> >>>>>>> >>>>>>>> +{ >>>>>>>> + static int nr_inport; >>>>>>>> + int i; >>>>>>>> + struct coresight_device *in_csdev; >>>>>>> >>>>>>> similarly tpdm_dev ? >>>>>> Same as above, this variable may not necessarily be a TPDM. >>>>>>> >>>>>>> Could we not add a check here to see if the dsb_esize[inport] is >>>>>>> already >>>>>>> set and then bail out, reading this over and over ? >>>>>>> >>>>>> I will update this in the next patch series. >>>>>>>> + >>>>>>>> + if (inport > (TPDA_MAX_INPORTS - 1)) >>>>>>>> + return -EINVAL; >>>>>>>> + >>>>>>>> + if (parent) >>>>>>>> + nr_inport = inport; >>>>>>>> + >>>>>>>> + for (i = 0; i < csdev->pdata->nr_inconns; i++) { >>>>>>>> + in_csdev = csdev->pdata->in_conns[i].remote_dev; >>>>>>> >>>>>>> Please note, the names of the structure field might change in the >>>>>>> next version of James' series >>>>>> Got it. I will keep an eye out for the James' patch series. >>>>>>> >>>>>>>> + if (!in_csdev) >>>>>>>> + break; >>>>>>>> + >>>>>>>> + if (parent) >>>>>>>> + if (csdev->pdata->in_conns[i].port != inport) >>>>>>>> + continue; >>>>>>>> + >>>>>>>> + if (in_csdev && strstr(dev_name(&in_csdev->dev), >>>>>>>> "tpdm")) { >>>>>>> >>>>>>> Isn't there a better way to distinguish a device to be TPDM ? >>>>>>> May be we >>>>>>> could even add a source_sub_type - SOURCE_TPDM instead of using >>>>>>> SOURCE_OTHERS ? Do you expect other sources to be connected to >>>>>>> TPDA? >>>>>>> e.g., STMs ? >>>>>> >>>>>> I can add "SOURCE_TPDM" as a source_sub_type, but SOURCE_OTHERS >>>>>> needs >>>>>> >>>>>> to be kept since the other Coresight component we will upstream >>>>>> later may >>>>>> >>>>>> need it. >>>>>> >>>>>>> >>>>>>>> + of_property_read_u32(in_csdev->dev.parent->of_node, >>>>>>>> + "qcom,dsb-element-size", >>>>>>>> &drvdata->dsb_esize[nr_inport]); >>>>>>>> + break; >>>>>>>> + } >>>>>>>> + tpda_set_element_size(drvdata, in_csdev, 0, false); >>>>>>> >>>>>>> What is the point of this ? Is this for covering the a TPDA >>>>>>> connected to >>>>>>> another TPDA ? >>>>>>> >>>>>>> e.g., { TPDM0, TPDM1 } -> TPDA0 -> TPDA1 ? >>>>>> >>>>>> A TPDM may not connect to the TPDA directly, for example, >>>>>> >>>>>> TPDM0 ->FUNNEL0->FUNNEL1->TPDA0 >>>>>> >>>>>> And many TPDMs can connect to one TPDA, one input port on TPDA >>>>>> only has >>>>>> >>>>>> one TPDM connected. Therefore, we use a recursive method to find >>>>>> the TPDM >>>>>> >>>>>> corresponding to the input port of TPDA. >>>>> >>>>> How do you find out decide what to choose, if there are multiple >>>>> TPDMs >>>>> connected to FUNNEL0 or even FUNNEL1 ? >>>>> >>>>> e.g >>>>> >>>>> TPDM0->FUNNEL0->FUNNEL1->TPDA0 >>>>> / >>>>> TPDM1 >>>> >>>> We can find out the corresponding TPDM by the input port number of >>>> TPDA. >>>> >>>> Each input port is connected to a TPDM. So we have an input port >>>> number in >>>> >>>> the input parameter of the recursive lookup function >>>> "tpda_set_element_size". >>> >>> I don't understand, how you would figure out, in the above situation. >>> i.e., FUNNEL1 is connected to TPDA0, but there are two TPDMs that could >>> be pumping the trace. They both arrive via FUNNEL1. So, how does that >>> solve your problem ? >> >> In our HW design, the input ports of TPDA and TPDM are one-one-one >> corresponding. Only one >> >> TPDM can be found connected from one TPDA's input port. The path to a >> TPDA input port doesn't >> >> connect more than one TPDM. It's by HW design. > > Your current designs may be like that. But as far as the driver is > concerned, I would like to add in extra measures to ensure that it > encounters a variation from the above on a future platform. So, please > could you add a check to detect this case and add a WARNING ? Got it, I will update it according to your advice in the next patch series. Tao > > Suzuki > > >> >> >> Tao >> >>> >>> Suzuki >>> >>> >>>> >>>>> Suzuki >>>>> >>>>> >>> >
diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c index f712e11..8dcfc4a 100644 --- a/drivers/hwtracing/coresight/coresight-tpda.c +++ b/drivers/hwtracing/coresight/coresight-tpda.c @@ -21,6 +21,47 @@ 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; + struct coresight_device *in_csdev; + + if (inport > (TPDA_MAX_INPORTS - 1)) + return -EINVAL; + + if (parent) + nr_inport = inport; + + for (i = 0; i < csdev->pdata->nr_inconns; i++) { + in_csdev = csdev->pdata->in_conns[i].remote_dev; + if (!in_csdev) + break; + + if (parent) + if (csdev->pdata->in_conns[i].port != inport) + continue; + + if (in_csdev && strstr(dev_name(&in_csdev->dev), "tpdm")) { + of_property_read_u32(in_csdev->dev.parent->of_node, + "qcom,dsb-element-size", &drvdata->dsb_esize[nr_inport]); + break; + } + 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) { @@ -37,6 +78,18 @@ static void 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 + dev_err(drvdata->dev, + "DSB data size input from port[%d] is invalid\n", port); /* Enable the port */ val |= TPDA_Pn_CR_ENA; writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port)); @@ -57,6 +110,11 @@ static void __tpda_enable(struct tpda_drvdata *drvdata, int port) static int tpda_enable(struct coresight_device *csdev, int inport, int outport) { struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + int ret; + + ret = tpda_set_element_size(drvdata, csdev, inport, true); + if (ret) + return ret; spin_lock(&drvdata->spinlock); if (atomic_read(&csdev->refcnt[inport]) == 0) diff --git a/drivers/hwtracing/coresight/coresight-tpda.h b/drivers/hwtracing/coresight/coresight-tpda.h index 0399678..9ec5870 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 */ struct tpda_drvdata { void __iomem *base; @@ -30,6 +33,7 @@ struct tpda_drvdata { struct coresight_device *csdev; spinlock_t spinlock; u8 atid; + u32 dsb_esize[TPDA_MAX_INPORTS]; }; #endif /* _CORESIGHT_CORESIGHT_TPDA_H */