From: Jinlong Mao <quic_jinlmao@quicinc.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Konrad Dybcio <konradybcio@gmail.com>,
Mike Leach <mike.leach@linaro.org>
Cc: 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>,
Tingwei Zhang <quic_tingweiz@quicinc.com>,
Yuanfang Zhang <quic_yuanfang@quicinc.com>,
Tao Zhang <quic_taozha@quicinc.com>,
Trilok Soni <quic_tsoni@quicinc.com>,
Hao Zhang <quic_hazha@quicinc.com>,
<linux-arm-msm@vger.kernel.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>
Subject: Re: [PATCH v11 6/9] Coresight: Add TPDA link driver
Date: Fri, 1 Jul 2022 23:10:20 +0800 [thread overview]
Message-ID: <2181ae69-f681-41d7-65aa-bb44473802ee@quicinc.com> (raw)
In-Reply-To: <36f1cb8f-5ad9-9b3a-276e-2774a05707ca@arm.com>
Hi Suzuki,
Thanks for the review.
On 7/1/2022 6:24 PM, Suzuki K Poulose wrote:
> On 20/06/2022 13:00, Mao Jinlong wrote:
>> TPDA(Trace, Profiling and Diagnostics Aggregator) is
>> to provide packetization, funneling and timestamping of
>> TPDM data. Multiple monitors are connected to different
>> input ports of TPDA.This change is to add tpda
>> enable/disable/probe functions for coresight tpda driver.
>>
>> - - - - - - - - - - - -
>> | TPDM 0| | TPDM 1 | | TPDM 2|
>> - - - - - - - - - - - -
>> | | |
>> |_ _ _ _ _ _ | _ _ _ _ |
>> | | |
>> | | |
>> ------------------
>> | TPDA |
>> ------------------
>>
>> Signed-off-by: Tao Zhang <quic_taozha@quicinc.com>
>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>> ---
>> drivers/hwtracing/coresight/Kconfig | 11 +
>> drivers/hwtracing/coresight/Makefile | 1 +
>> drivers/hwtracing/coresight/coresight-tpda.c | 206 +++++++++++++++++++
>> drivers/hwtracing/coresight/coresight-tpda.h | 35 ++++
>> 4 files changed, 253 insertions(+)
>> create mode 100644 drivers/hwtracing/coresight/coresight-tpda.c
>> create mode 100644 drivers/hwtracing/coresight/coresight-tpda.h
>>
>> diff --git a/drivers/hwtracing/coresight/Kconfig
>> b/drivers/hwtracing/coresight/Kconfig
>> index b2b72a35e416..0cbebfd0d23e 100644
>> --- a/drivers/hwtracing/coresight/Kconfig
>> +++ b/drivers/hwtracing/coresight/Kconfig
>> @@ -205,6 +205,7 @@ config CORESIGHT_TRBE
>> config CORESIGHT_TPDM
>> tristate "CoreSight Trace, Profiling & Diagnostics Monitor driver"
>> select CORESIGHT_LINKS_AND_SINKS
>> + select CORESIGHT_TPDA
>> help
>> This driver provides support for configuring monitor.
>> Monitors are
>> primarily responsible for data set collection and support the
>> @@ -213,4 +214,14 @@ config CORESIGHT_TPDM
>> To compile this driver as a module, choose M here: the module
>> will be
>> called coresight-tpdm.
>> +config CORESIGHT_TPDA
>> + tristate "CoreSight Trace, Profiling & Diagnostics Aggregator
>> driver"
>> + help
>> + This driver provides support for configuring aggregator. This is
>> + primarily useful for pulling the data sets from one or more
>> + attached monitors and pushing the resultant data out. Multiple
>> + monitors are connected on different input ports of TPDA.
>> +
>> + To compile this driver as a module, choose M here: the module
>> will be
>> + called coresight-tpda.
>> endif
>> diff --git a/drivers/hwtracing/coresight/Makefile
>> b/drivers/hwtracing/coresight/Makefile
>> index 6bb9b1746bc7..1712d82e7260 100644
>> --- a/drivers/hwtracing/coresight/Makefile
>> +++ b/drivers/hwtracing/coresight/Makefile
>> @@ -26,5 +26,6 @@ obj-$(CONFIG_CORESIGHT_CATU) += coresight-catu.o
>> obj-$(CONFIG_CORESIGHT_CTI) += coresight-cti.o
>> obj-$(CONFIG_CORESIGHT_TRBE) += coresight-trbe.o
>> obj-$(CONFIG_CORESIGHT_TPDM) += coresight-tpdm.o
>> +obj-$(CONFIG_CORESIGHT_TPDA) += coresight-tpda.o
>> coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \
>> coresight-cti-sysfs.o
>> diff --git a/drivers/hwtracing/coresight/coresight-tpda.c
>> b/drivers/hwtracing/coresight/coresight-tpda.c
>> new file mode 100644
>> index 000000000000..7a0478a8b63e
>> --- /dev/null
>> +++ b/drivers/hwtracing/coresight/coresight-tpda.c
>> @@ -0,0 +1,206 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights
>> reserved.
>> + */
>> +
>> +#include <linux/amba/bus.h>
>> +#include <linux/bitfield.h>
>> +#include <linux/coresight.h>
>> +#include <linux/device.h>
>> +#include <linux/err.h>
>> +#include <linux/fs.h>
>> +#include <linux/io.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
>> +#include <linux/platform_device.h>
>> +
>> +#include "coresight-priv.h"
>> +#include "coresight-tpda.h"
>> +#include "coresight-trace-id.h"
>> +
>> +DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda");
>> +
>> +/* Settings pre enabling port control register */
>> +static void tpda_enable_pre_port(struct tpda_drvdata *drvdata)
>> +{
>> + u32 val;
>> +
>> + val = readl_relaxed(drvdata->base + TPDA_CR);
>
>
> Even though the drvdata->atid is constant during the life time
> of the driver, I would recommend clearing the field and then
> setting it. e.g, if you get a different ATID on unload-load
> sequence of the driver, the field will corrupted.
I will release the id in module exist function.
>
> val &= ~TPDA_CR_ATID;
>
>> + val |= FIELD_PREP(TPDA_CR_ATID, drvdata->atid);
>
>
>> + writel_relaxed(val, drvdata->base + TPDA_CR);
>> +}
>> +
>
> Is there no global turn-ON for the TPDA ? Or is it per-port
> enable only via TPDA_Pn_CR ?
No global turn-on for the TPDA. It is per-port enable via TPDA_Pn_CR.
>
>> +static void tpda_enable_port(struct tpda_drvdata *drvdata, int port)
>> +{
>> + u32 val;
>> +
>> + val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port));
>> + /* Enable the port */
>> + val |= TPDA_Pn_CR_ENA;
>> + writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port));
>> +}
>> +
>> +static void __tpda_enable(struct tpda_drvdata *drvdata, int port)
>> +{
>> + CS_UNLOCK(drvdata->base);
>> +
>> + if (!drvdata->csdev->enable)
>> + tpda_enable_pre_port(drvdata);
>> +
>> + tpda_enable_port(drvdata, port);
>> +
>> + CS_LOCK(drvdata->base);
>> +}
>> +
>> +static int tpda_enable(struct coresight_device *csdev, int inport,
>> int outport)
>> +{
>> + struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
>> +
>> + spin_lock(&drvdata->spinlock);
>> + if (atomic_read(&csdev->refcnt[inport]) == 0)
>> + __tpda_enable(drvdata, inport);
>> +
>> + atomic_inc(&csdev->refcnt[inport]);
>> + spin_unlock(&drvdata->spinlock);
>> +
>> + dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", inport);
>> + return 0;
>> +}
>> +
>> +static void __tpda_disable(struct tpda_drvdata *drvdata, int port)
>> +{
>> + u32 val;
>> +
>> + CS_UNLOCK(drvdata->base);
>> +
>> + val = readl_relaxed(drvdata->base + TPDA_Pn_CR(port));
>> + val &= ~TPDA_Pn_CR_ENA;
>> + writel_relaxed(val, drvdata->base + TPDA_Pn_CR(port));
>> +
>> + CS_LOCK(drvdata->base);
>> +}
>> +
>> +static void tpda_disable(struct coresight_device *csdev, int inport,
>> + int outport)
>> +{
>> + struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
>> +
>> + spin_lock(&drvdata->spinlock);
>> + if (atomic_dec_return(&csdev->refcnt[inport]) == 0)
>> + __tpda_disable(drvdata, inport);
>> +
>> + spin_unlock(&drvdata->spinlock);
>> +
>> + dev_dbg(drvdata->dev, "TPDA inport %d disabled\n", inport);
>> +}
>> +
>> +static const struct coresight_ops_link tpda_link_ops = {
>> + .enable = tpda_enable,
>> + .disable = tpda_disable,
>> +};
>> +
>> +static const struct coresight_ops tpda_cs_ops = {
>> + .link_ops = &tpda_link_ops,
>> +};
>> +
>> +static int tpda_init_default_data(struct tpda_drvdata *drvdata)
>> +{
>
> Is there a register that indicates the number of ports on the device ?
> We don't seem to be using that information.
No such register.
>
>> + int atid;
>> + /*
>> + * TPDA must has a unique atid. This atid can uniquely
>> + * identify the TPDM trace source connected to the TPDA.
>> + */
>> + atid =
>> coresight_trace_id_get_system_id(coresight_get_trace_id_map());
>> + if (atid < 0)
>> + return atid;
>> +
>
> You need to release this id at module exit. Otherwise, we are leaking
> the id.
>
I will address the comments.
>
> Suzuki
next prev parent reply other threads:[~2022-07-01 15:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 12:00 [PATCH v11 0/9] Coresight: Add support for TPDM and TPDA Mao Jinlong
2022-06-20 12:00 ` [PATCH v11 1/9] coresight: core: Use IDR for non-cpu bound sources' paths Mao Jinlong
2022-07-01 9:29 ` Suzuki K Poulose
2022-06-20 12:00 ` [PATCH v11 2/9] Coresight: Add coresight TPDM source driver Mao Jinlong
2022-06-20 12:00 ` [PATCH v11 3/9] dt-bindings: arm: Adds CoreSight TPDM hardware definitions Mao Jinlong
2022-06-20 12:00 ` [PATCH v11 4/9] coresight-tpdm: Add DSB dataset support Mao Jinlong
2022-06-20 12:00 ` [PATCH v11 5/9] coresight-tpdm: Add integration test support Mao Jinlong
2022-07-01 9:29 ` Suzuki K Poulose
2022-06-20 12:00 ` [PATCH v11 6/9] Coresight: Add TPDA link driver Mao Jinlong
2022-07-01 10:24 ` Suzuki K Poulose
2022-07-01 15:10 ` Jinlong Mao [this message]
2022-06-20 12:00 ` [PATCH v11 7/9] dt-bindings: arm: Adds CoreSight TPDA hardware definitions Mao Jinlong
2022-07-01 10:28 ` Suzuki K Poulose
2022-06-20 12:01 ` [PATCH v11 8/9] arm64: dts: qcom: sm8250: Add coresight components Mao Jinlong
2022-06-20 12:01 ` [PATCH v11 9/9] arm64: dts: qcom: sm8250: Add tpdm mm/prng Mao Jinlong
2022-06-30 11:41 ` [PATCH v11 0/9] Coresight: Add support for TPDM and TPDA Jinlong Mao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2181ae69-f681-41d7-65aa-bb44473802ee@quicinc.com \
--to=quic_jinlmao@quicinc.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bjorn.andersson@linaro.org \
--cc=coresight@lists.linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=konradybcio@gmail.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=quic_hazha@quicinc.com \
--cc=quic_taozha@quicinc.com \
--cc=quic_tingweiz@quicinc.com \
--cc=quic_tsoni@quicinc.com \
--cc=quic_yuanfang@quicinc.com \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®