From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Jie Gan <quic_jiegan@quicinc.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@linaro.org>,
James Clark <james.clark@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>
Cc: Jinlong Mao <quic_jinlmao@quicinc.com>,
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>,
linux-arm-msm@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v7 4/5] Coresight: Add Coresight TMC Control Unit driver
Date: Sat, 14 Dec 2024 23:21:15 +0100 [thread overview]
Message-ID: <d09097da-a07a-4dfa-9c0d-567b329b64ac@oss.qualcomm.com> (raw)
In-Reply-To: <20241210031545.3468561-5-quic_jiegan@quicinc.com>
On 10.12.2024 4:15 AM, Jie Gan wrote:
> The Coresight TMC Control Unit hosts miscellaneous configuration registers
> which control various features related to TMC ETR sink.
>
> Based on the trace ID, which is programmed in the related CTCU ATID
> register of a specific ETR, trace data with that trace ID gets into
> the ETR buffer, while other trace data gets dropped.
>
> Enabling source device sets one bit of the ATID register based on
> source device's trace ID.
> Disabling source device resets the bit according to the source
> device's trace ID.
>
> Signed-off-by: Jie Gan <quic_jiegan@quicinc.com>
> ---
[...]
> +static int __ctcu_set_etr_traceid(struct coresight_device *csdev,
> + u8 traceid,
> + int port_num,
> + bool enable)
> +{
> + uint32_t atid_offset;
> + struct ctcu_drvdata *drvdata;
> + unsigned long flags;
> + uint32_t reg_offset;
> + int bit;
> + uint32_t val;
> +
> + if (!IS_VALID_CS_TRACE_ID(traceid) || port_num < 0)
> + return -EINVAL;
> +
> + drvdata = dev_get_drvdata(csdev->dev.parent);
> + if (IS_ERR_OR_NULL(drvdata))
> + return -EINVAL;
> +
> + atid_offset = drvdata->atid_offset[port_num];
> + if (atid_offset == 0)
> + return -EINVAL;
> +
> + spin_lock_irqsave(&drvdata->spin_lock, flags);
guard(raw_spinlock_irqsave)(&drvdata->spin_lock);
and drop the unlocks
> + CS_UNLOCK(drvdata->base);
> +
> + reg_offset = CTCU_ATID_REG_OFFSET(traceid, atid_offset);
> + bit = CTCU_ATID_REG_BIT(traceid);
> + if (reg_offset - atid_offset >= CTCU_ATID_REG_SIZE ||
> + bit >= CORESIGHT_TRACE_IDS_MAX) {
> + CS_LOCK(drvdata);
> + spin_unlock_irqrestore(&drvdata->spin_lock, flags);
> + return -EINVAL;
> + }
> +
> + val = ctcu_readl(drvdata, reg_offset);
> + if (enable)
> + val = val | BIT(bit);
> + else
> + val = val & ~BIT(bit);
> + ctcu_writel(drvdata, val, reg_offset);
> +
> + CS_LOCK(drvdata->base);
> + spin_unlock_irqrestore(&drvdata->spin_lock, flags);
> +
> + return 0;
> +}
> +
> +static int ctcu_get_active_port(struct coresight_device *sink, struct coresight_device *helper)
> +{
> + int port, i;
> +
> + for (i = 0; i < sink->pdata->nr_outconns; ++i) {
> + if (sink->pdata->out_conns[i]->dest_dev) {
> + port = sink->pdata->out_conns[i]->dest_port;
> + return port;
Return sink->....
> + }
> + }
> +
> + return -EINVAL;
> +}
> +
> +/*
> + * ctcu_set_etr_traceid: Retrieve the ATID offset and trace ID.
> + *
> + * Returns 0 indicates success. None-zero result means failure.
> + */
> +static int ctcu_set_etr_traceid(struct coresight_device *csdev,
> + struct cs_sink_data *sink_data,
> + bool enable)
> +{
> + int port_num;
> +
> + if (!IS_VALID_CS_TRACE_ID(sink_data->traceid) ||
> + (csdev == NULL) ||
I'm not sure this can be null by the time it reaches this function
> + (sink_data->sink == NULL)) {
> + dev_dbg(&csdev->dev, "Invalid parameters\n");
dev_err?
> + return -EINVAL;
> + }
> +
> + port_num = ctcu_get_active_port(sink_data->sink, csdev);
> + if (port_num < 0)
> + return -EINVAL;
> +
> + dev_dbg(&csdev->dev, "traceid is %d\n", sink_data->traceid);
> +
> + return __ctcu_set_etr_traceid(csdev, sink_data->traceid, port_num, enable);
> +}
> +
> +static int ctcu_enable(struct coresight_device *csdev, enum cs_mode mode,
> + void *data)
> +{
> + int ret = 0;
Unnecessary initialization (you instantly overwrite it), also below
> + struct cs_sink_data *sink_data = (struct cs_sink_data *)data;
> +
> + ret = ctcu_set_etr_traceid(csdev, sink_data, true);
> + if (ret)
> + dev_dbg(&csdev->dev, "enable data filter failed\n");
Since the this function returns an int, maybe return ctcu_set_etr_traceid()
and let the upper layer throw an error (also for some other functions in this
file)
> +
> + return 0;
> +}
> +
> +static int ctcu_disable(struct coresight_device *csdev, void *data)
> +{> + int ret = 0;
> + struct cs_sink_data *sink_data = (struct cs_sink_data *)data;
> +
> + ret = ctcu_set_etr_traceid(csdev, sink_data, false);
> + if (ret)
> + dev_dbg(&csdev->dev, "disable data filter failed\n");
> +
> + return 0;
> +}
[...]
> enum coresight_dev_subtype_helper {
> CORESIGHT_DEV_SUBTYPE_HELPER_CATU,
> - CORESIGHT_DEV_SUBTYPE_HELPER_ECT_CTI
> + CORESIGHT_DEV_SUBTYPE_HELPER_ECT_CTI,
> + CORESIGHT_DEV_SUBTYPE_HELPER_CTCU
Please add a comma here too, so that future additions will be
less noisy
next prev parent reply other threads:[~2024-12-14 22:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-10 3:15 [PATCH v7 0/5] " Jie Gan
2024-12-10 3:15 ` [PATCH v7 1/5] Coresight: Add support for new APB clock name Jie Gan
2024-12-10 3:15 ` [PATCH v7 2/5] Coresight: Add trace_id function to retrieving the trace ID Jie Gan
2024-12-10 3:15 ` [PATCH v7 3/5] dt-bindings: arm: Add Coresight TMC Control Unit hardware Jie Gan
2024-12-12 18:19 ` Konrad Dybcio
2024-12-13 1:39 ` Jie Gan
2024-12-10 3:15 ` [PATCH v7 4/5] Coresight: Add Coresight TMC Control Unit driver Jie Gan
2024-12-14 22:21 ` Konrad Dybcio [this message]
2024-12-19 3:24 ` Jie Gan
2024-12-10 3:15 ` [PATCH v7 5/5] arm64: dts: qcom: Add CTCU and ETR nodes for SA8775p Jie Gan
2024-12-23 12:00 ` Konrad Dybcio
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=d09097da-a07a-4dfa-9c0d-567b329b64ac@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=coresight@lists.linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=james.clark@linaro.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=mike.leach@linaro.org \
--cc=quic_jiegan@quicinc.com \
--cc=quic_jinlmao@quicinc.com \
--cc=quic_tingweiz@quicinc.com \
--cc=robh@kernel.org \
--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®