When multiple ETMs are enabled simultaneously, the time required
to complete a flush in the process of reading the TMC device node
may exceed the default wait time of 100us. If the TMC capture is
stopped while any ETM has not completed its flush, it can cause
the corresponding CPU to hang.
Fix the by checking the TMCReady bit after the flush. If TMCReady
bit is set, TraceCaptEn bit can be clear; otherwise, return directly
and stop the TMC read.
Signed-off-by: Yuanfang Zhang <quic_yuanfang(a)quicinc.com>
---
drivers/hwtracing/coresight/coresight-tmc-etf.c | 17 +++++++++++++++--
drivers/hwtracing/coresight/coresight-tmc-etr.c | 22 +++++++++++++++++-----
2 files changed, 32 insertions(+), 7 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c
index d4f641cd9de69488fe3d1c1dc9b5a9eafb55ed59..bded290c42891d782344d9a6e63ebdbed6719133 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etf.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c
@@ -80,11 +80,21 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
return;
}
-static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
+static int __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
{
+ int rc;
+
CS_UNLOCK(drvdata->base);
tmc_flush_and_stop(drvdata);
+
+ rc = tmc_wait_for_tmcready(drvdata);
+ if (rc) {
+ dev_err(&drvdata->csdev->dev,
+ "Failed to disable : TMC is not ready\n");
+ CS_LOCK(drvdata->base);
+ return rc;
+ }
/*
* When operating in sysFS mode the content of the buffer needs to be
* read before the TMC is disabled.
@@ -94,6 +104,7 @@ static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
tmc_disable_hw(drvdata);
CS_LOCK(drvdata->base);
+ return 0;
}
static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
@@ -650,7 +661,9 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata)
ret = -EINVAL;
goto out;
}
- __tmc_etb_disable_hw(drvdata);
+ ret = __tmc_etb_disable_hw(drvdata);
+ if (ret)
+ goto out;
}
drvdata->reading = true;
diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c
index a48bb85d0e7f44a25b813f3c828cc3d705d16012..63a1f7501562fa0b5c2fe6ea53dce4d82842bec3 100644
--- a/drivers/hwtracing/coresight/coresight-tmc-etr.c
+++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c
@@ -1135,11 +1135,21 @@ static void tmc_etr_sync_sysfs_buf(struct tmc_drvdata *drvdata)
}
}
-static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
+static int __tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
{
+ int rc;
+
CS_UNLOCK(drvdata->base);
tmc_flush_and_stop(drvdata);
+
+ rc = tmc_wait_for_tmcready(drvdata);
+ if (rc) {
+ dev_err(&drvdata->csdev->dev,
+ "Failed to disable : TMC is not ready\n");
+ CS_LOCK(drvdata->base);
+ return rc;
+ }
/*
* When operating in sysFS mode the content of the buffer needs to be
* read before the TMC is disabled.
@@ -1150,7 +1160,7 @@ static void __tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
tmc_disable_hw(drvdata);
CS_LOCK(drvdata->base);
-
+ return 0;
}
void tmc_etr_disable_hw(struct tmc_drvdata *drvdata)
@@ -1779,9 +1789,11 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)
}
/* Disable the TMC if we are trying to read from a running session. */
- if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS)
- __tmc_etr_disable_hw(drvdata);
-
+ if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
+ ret = __tmc_etr_disable_hw(drvdata);
+ if (ret)
+ goto out;
+ }
drvdata->reading = true;
out:
spin_unlock_irqrestore(&drvdata->spinlock, flags);
---
base-commit: fac04efc5c793dccbd07e2d59af9f90b7fc0dca4
change-id: 20250103-fix_cpu_hung-b5a95179ada4
Best regards,
--
Yuanfang Zhang <quic_yuanfang(a)quicinc.com>
On 24/01/2025 7:25 am, Jie Gan wrote:
> Add 'struct coresight_path' to store the data that is needed by
> coresight_enable_path/coresight_disable_path. The structure
> will be transmitted to the helper and sink device to enable
> related funcationalities.
>
> Signed-off-by: Jie Gan <quic_jiegan(a)quicinc.com>
> ---
[...]
> /*
> * If we still have access to the event_data via handle,
> @@ -595,11 +599,11 @@ static void etm_event_stop(struct perf_event *event, int mode)
> if (!csdev)
> return;
>
> - path = etm_event_cpu_path(event_data, cpu);
> - if (!path)
> + cs_path = etm_event_cpu_path(event_data, cpu);
> + if (!cs_path)
I don't think renaming 'path' to 'cs_path' is worth the churn. It's in a
lot of places in this change, but I think path is already good enough.
> return;
>
> - sink = coresight_get_sink(path);
> + sink = coresight_get_sink(cs_path->path);
coresight_get_sink() is always called with cs_path->path, so we might as
well make it take a whole path struct. The same with any of the other
functions that operate on path like coresight_get_source().
Proof of concept to support CTCU device. Applies to Jie's patchset in
the parent email. I think this would be a good simplification, it
removes some code and makes things a bit clearer, and works for both the
old and new CTCU requirements. It will require merging into the parent
patchset somehow as it undoes some of those changes.
James Clark (3):
coresight: Don't save handle in path
coresight: Export coresight_get_sink()
coresight: Alloc trace ID after building the path
drivers/hwtracing/coresight/coresight-core.c | 107 +++++++++++++-----
drivers/hwtracing/coresight/coresight-dummy.c | 9 +-
drivers/hwtracing/coresight/coresight-etb10.c | 8 +-
.../hwtracing/coresight/coresight-etm-perf.c | 20 ++--
drivers/hwtracing/coresight/coresight-etm.h | 1 -
.../coresight/coresight-etm3x-core.c | 84 ++------------
.../coresight/coresight-etm3x-sysfs.c | 3 +-
.../coresight/coresight-etm4x-core.c | 83 ++------------
.../coresight/coresight-etm4x-sysfs.c | 4 +-
drivers/hwtracing/coresight/coresight-etm4x.h | 1 -
drivers/hwtracing/coresight/coresight-priv.h | 17 +--
drivers/hwtracing/coresight/coresight-stm.c | 5 +-
drivers/hwtracing/coresight/coresight-sysfs.c | 6 +-
.../hwtracing/coresight/coresight-tmc-etf.c | 9 +-
.../hwtracing/coresight/coresight-tmc-etr.c | 13 +--
drivers/hwtracing/coresight/coresight-tmc.h | 2 +-
drivers/hwtracing/coresight/coresight-tpda.c | 3 +-
drivers/hwtracing/coresight/coresight-tpdm.c | 3 +-
drivers/hwtracing/coresight/coresight-tpiu.c | 2 +-
drivers/hwtracing/coresight/coresight-trbe.c | 4 +-
drivers/hwtracing/coresight/ultrasoc-smb.c | 8 +-
include/linux/coresight.h | 25 +++-
22 files changed, 159 insertions(+), 258 deletions(-)
--
2.34.1
On 29/01/2025 1:02 pm, Jie Gan wrote:
>
>
> On 1/29/2025 6:35 PM, James Clark wrote:
>>
>>
>> On 29/01/2025 12:46 am, Jie Gan wrote:
>>>
>>>
>>> On 1/28/2025 7:55 PM, James Clark wrote:
>>>>
>>>>
>>>> On 24/01/2025 7:25 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(a)quicinc.com>
>>>>> ---
>>>>> drivers/hwtracing/coresight/Kconfig | 12 +
>>>>> drivers/hwtracing/coresight/Makefile | 1 +
>>>>> drivers/hwtracing/coresight/coresight-ctcu.c | 276 ++++++++++++++
>>>>> + ++++
>>>>> drivers/hwtracing/coresight/coresight-ctcu.h | 30 ++
>>>>> include/linux/coresight.h | 3 +-
>>>>> 5 files changed, 321 insertions(+), 1 deletion(-)
>>>>> create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.c
>>>>> create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.h
>>>> >
>>>>
>>>> [...]
>>>>
>>>>> +/*
>>>>> + * 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 coresight_path *cs_path,
>>>>> + bool enable)
>>>>> +{
>>>>> + struct coresight_device *sink = coresight_get_sink(cs_path-
>>>>> >path);
>>>>> + struct ctcu_drvdata *drvdata = dev_get_drvdata(csdev-
>>>>> >dev.parent);
>>>>> + u8 trace_id = cs_path->trace_id;
>>>>> + int port_num;
>>>>> +
>>>>> + if ((sink == NULL) || !IS_VALID_CS_TRACE_ID(trace_id) ||
>>>>> IS_ERR_OR_NULL(drvdata)) {
>>>>> + dev_err(&csdev->dev, "Invalid parameters\n");
>>>>> + return -EINVAL;
>>>>> + }
>>>>> +
>>>>> + port_num = ctcu_get_active_port(sink, csdev);
>>>>> + if (port_num < 0)
>>>>> + return -EINVAL;
>>>>> +
>>>>> + /*
>>>>> + * Skip the disable session if more than one TPDM device that
>>>>> + * connected to the same TPDA device has been enabled.
>>>>> + */
>>>>> + if (enable)
>>>>> + atomic_inc(&drvdata->traceid_refcnt[port_num][trace_id]);
>>>>> + else {
>>>>> + if (atomic_dec_return(&drvdata->traceid_refcnt[port_num]
>>>>> [trace_id]) > 0) {
>>>>> + dev_dbg(&csdev->dev, "Skip the disable session\n");
>>>>> + return 0;
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + dev_dbg(&csdev->dev, "traceid is %d\n", cs_path->trace_id);
>>>>> +
>>>>> + return __ctcu_set_etr_traceid(csdev, trace_id, port_num, enable);
>>>>
>>>> Hi Jie,
>>>>
>>>> Using atomic_dec_return() here doesn't prevent
>>>> __ctcu_set_etr_traceid() from running concurrent enable and
>>>> disables. Once you pass the atomic_dec_return() a second call to
>>>> enable it will mess it up.
>>>>
>>>> I think you need a spinlock around the whole thing and then the
>>>> refcounts don't need to be atomics.
>>>>
>>> Hi, James
>>> Thanks for comment. I may not fully tested my codes here. What I was
>>> thinking is there's no way the refcnt could become a negative number
>>> under current framework. So I just added spinlock in
>>> __ctcu_set_etr_traceid() to ensure concurrent sessions correctly
>>> manipulate the register.
>>>
>>> As the trace_id related to the bit of the ATID register, I think the
>>> concurrent processes are working fine with spinlock around read/write
>>> register.
>>>
>>> I may not fully got your point here. Please help me to correct it.
>>>
>>> Thanks,
>>> Jie
>>>
>>>
>>
>> No it can't become negative, but the refcount can be a different state
>> to the one that was actually written:
>>
>>
>> CPU0 CPU1
>> ---- ----
>> ctcu_set_etr_traceid(enable)
>> ctcu_set_etr_traceid(disable)
>> atomic_inc()
>> recount == 1
>> atomic_dec()
>> recount == 0
>>
>> __ctcu_set_etr_traceid(disable)
>> Lock and write disable state to
>> device
>>
>> __ctcu_set_etr_traceid(enable)
>> Lock and write enable state to
>> device
>>
>>
>> As you can see this leaves the device in an enabled state but the
>> refcount is 0.
> Yes, you are right. I didnt consider this scenario. We definitely need
> spinlock here.
>
>>
>> This is also quite large if you use atomic types:
>>
>> /* refcnt for each traceid of each sink */
>> atomic_t traceid_refcnt[ATID_MAX_NUM][CORESIGHT_TRACE_ID_RES_TOP];
>>
>> Presumably you can't have the refcount for each ID be higher than the
>> max number of TPDMs connected? If you make the locked area a bit wider
>> you don't need atomic types and also solve the above problem. So you
>> could do u8, or DECLARE_BITMAP() and bitmap_read() etc to read 3 bit
>> values. Or however wide it needs to be.
> The original purpose of using atomic here is trying to narrow the locked
> area.
>
> I think u8 is ok here.
> u8 traceid_refcnt[ATID_MAX_NUM][CORESIGHT_TRACE_ID_RES_TOP] will cost
> 224 bytes, I think it's acceptable here.
>
> Thanks,
> Jie
>
Yep u8 sounds ok then
On 29/01/2025 12:46 am, Jie Gan wrote:
>
>
> On 1/28/2025 7:55 PM, James Clark wrote:
>>
>>
>> On 24/01/2025 7:25 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(a)quicinc.com>
>>> ---
>>> drivers/hwtracing/coresight/Kconfig | 12 +
>>> drivers/hwtracing/coresight/Makefile | 1 +
>>> drivers/hwtracing/coresight/coresight-ctcu.c | 276 +++++++++++++++++++
>>> drivers/hwtracing/coresight/coresight-ctcu.h | 30 ++
>>> include/linux/coresight.h | 3 +-
>>> 5 files changed, 321 insertions(+), 1 deletion(-)
>>> create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.c
>>> create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.h
>> >
>>
>> [...]
>>
>>> +/*
>>> + * 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 coresight_path *cs_path,
>>> + bool enable)
>>> +{
>>> + struct coresight_device *sink = coresight_get_sink(cs_path->path);
>>> + struct ctcu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
>>> + u8 trace_id = cs_path->trace_id;
>>> + int port_num;
>>> +
>>> + if ((sink == NULL) || !IS_VALID_CS_TRACE_ID(trace_id) ||
>>> IS_ERR_OR_NULL(drvdata)) {
>>> + dev_err(&csdev->dev, "Invalid parameters\n");
>>> + return -EINVAL;
>>> + }
>>> +
>>> + port_num = ctcu_get_active_port(sink, csdev);
>>> + if (port_num < 0)
>>> + return -EINVAL;
>>> +
>>> + /*
>>> + * Skip the disable session if more than one TPDM device that
>>> + * connected to the same TPDA device has been enabled.
>>> + */
>>> + if (enable)
>>> + atomic_inc(&drvdata->traceid_refcnt[port_num][trace_id]);
>>> + else {
>>> + if (atomic_dec_return(&drvdata->traceid_refcnt[port_num]
>>> [trace_id]) > 0) {
>>> + dev_dbg(&csdev->dev, "Skip the disable session\n");
>>> + return 0;
>>> + }
>>> + }
>>> +
>>> + dev_dbg(&csdev->dev, "traceid is %d\n", cs_path->trace_id);
>>> +
>>> + return __ctcu_set_etr_traceid(csdev, trace_id, port_num, enable);
>>
>> Hi Jie,
>>
>> Using atomic_dec_return() here doesn't prevent
>> __ctcu_set_etr_traceid() from running concurrent enable and disables.
>> Once you pass the atomic_dec_return() a second call to enable it will
>> mess it up.
>>
>> I think you need a spinlock around the whole thing and then the
>> refcounts don't need to be atomics.
>>
> Hi, James
> Thanks for comment. I may not fully tested my codes here. What I was
> thinking is there's no way the refcnt could become a negative number
> under current framework. So I just added spinlock in
> __ctcu_set_etr_traceid() to ensure concurrent sessions correctly
> manipulate the register.
>
> As the trace_id related to the bit of the ATID register, I think the
> concurrent processes are working fine with spinlock around read/write
> register.
>
> I may not fully got your point here. Please help me to correct it.
>
> Thanks,
> Jie
>
>
No it can't become negative, but the refcount can be a different state
to the one that was actually written:
CPU0 CPU1
---- ----
ctcu_set_etr_traceid(enable)
ctcu_set_etr_traceid(disable)
atomic_inc()
recount == 1
atomic_dec()
recount == 0
__ctcu_set_etr_traceid(disable)
Lock and write disable state to
device
__ctcu_set_etr_traceid(enable)
Lock and write enable state to
device
As you can see this leaves the device in an enabled state but the
refcount is 0.
This is also quite large if you use atomic types:
/* refcnt for each traceid of each sink */
atomic_t traceid_refcnt[ATID_MAX_NUM][CORESIGHT_TRACE_ID_RES_TOP];
Presumably you can't have the refcount for each ID be higher than the
max number of TPDMs connected? If you make the locked area a bit wider
you don't need atomic types and also solve the above problem. So you
could do u8, or DECLARE_BITMAP() and bitmap_read() etc to read 3 bit
values. Or however wide it needs to be.
On 24/01/2025 7:25 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(a)quicinc.com>
> ---
> drivers/hwtracing/coresight/Kconfig | 12 +
> drivers/hwtracing/coresight/Makefile | 1 +
> drivers/hwtracing/coresight/coresight-ctcu.c | 276 +++++++++++++++++++
> drivers/hwtracing/coresight/coresight-ctcu.h | 30 ++
> include/linux/coresight.h | 3 +-
> 5 files changed, 321 insertions(+), 1 deletion(-)
> create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.c
> create mode 100644 drivers/hwtracing/coresight/coresight-ctcu.h
>
[...]
> +/*
> + * 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 coresight_path *cs_path,
> + bool enable)
> +{
> + struct coresight_device *sink = coresight_get_sink(cs_path->path);
> + struct ctcu_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
> + u8 trace_id = cs_path->trace_id;
> + int port_num;
> +
> + if ((sink == NULL) || !IS_VALID_CS_TRACE_ID(trace_id) || IS_ERR_OR_NULL(drvdata)) {
> + dev_err(&csdev->dev, "Invalid parameters\n");
> + return -EINVAL;
> + }
> +
> + port_num = ctcu_get_active_port(sink, csdev);
> + if (port_num < 0)
> + return -EINVAL;
> +
> + /*
> + * Skip the disable session if more than one TPDM device that
> + * connected to the same TPDA device has been enabled.
> + */
> + if (enable)
> + atomic_inc(&drvdata->traceid_refcnt[port_num][trace_id]);
> + else {
> + if (atomic_dec_return(&drvdata->traceid_refcnt[port_num][trace_id]) > 0) {
> + dev_dbg(&csdev->dev, "Skip the disable session\n");
> + return 0;
> + }
> + }
> +
> + dev_dbg(&csdev->dev, "traceid is %d\n", cs_path->trace_id);
> +
> + return __ctcu_set_etr_traceid(csdev, trace_id, port_num, enable);
Hi Jie,
Using atomic_dec_return() here doesn't prevent __ctcu_set_etr_traceid()
from running concurrent enable and disables. Once you pass the
atomic_dec_return() a second call to enable it will mess it up.
I think you need a spinlock around the whole thing and then the
refcounts don't need to be atomics.
On 24/01/2025 7:25 am, Jie Gan wrote:
> Add 'struct coresight_path' to store the data that is needed by
> coresight_enable_path/coresight_disable_path. The structure
> will be transmitted to the helper and sink device to enable
> related funcationalities.
>
> Signed-off-by: Jie Gan <quic_jiegan(a)quicinc.com>
> ---
> drivers/hwtracing/coresight/coresight-core.c | 87 ++++++++++++++-----
> drivers/hwtracing/coresight/coresight-etb10.c | 3 +-
> .../hwtracing/coresight/coresight-etm-perf.c | 52 ++++++-----
> .../hwtracing/coresight/coresight-etm-perf.h | 2 +-
> drivers/hwtracing/coresight/coresight-priv.h | 21 +++--
> drivers/hwtracing/coresight/coresight-sysfs.c | 32 +++----
> .../hwtracing/coresight/coresight-tmc-etf.c | 3 +-
> .../hwtracing/coresight/coresight-tmc-etr.c | 6 +-
> drivers/hwtracing/coresight/coresight-trbe.c | 4 +-
> drivers/hwtracing/coresight/ultrasoc-smb.c | 3 +-
> 10 files changed, 137 insertions(+), 76 deletions(-)
>
[...]
> INIT_LIST_HEAD(path);
> + cs_path->path = path;
> + /*
> + * Since not all source devices have a defined trace_id function,
> + * make sure to check for it before use.
> + *
> + * Assert the mode is CS_MODE_SYSFS, the trace_id will be assigned
> + * again later if the mode is CS_MODE_PERF.
> + */
> + if (source_ops(source)->trace_id != NULL) {
> + rc = source_ops(source)->trace_id(source, CS_MODE_SYSFS, NULL);
I don't think we should do this. Doesn't this consume two trace IDs for
each session? And I'm not even sure if it's released properly if it's
overwritten.
It should be possible to consolidate the all the trace ID allocation to
a single step when building the path, or another function that gets
called just after the path is built. At the moment the ID can be
allocated from about 5 different places and it's quite hard to
understand, especially with these new changes. I have some of it coded
up, let me finish it off and I can share it.
> + if(IS_VALID_CS_TRACE_ID(rc))
> + cs_path->trace_id = rc;
> + else
> + cs_path->trace_id = 0;
> + }
> + else
> + cs_path->trace_id = 0;
[...]
> +/**
> + * struct coresight_path - data needed by enable/disable path
> + * @handle: perf aux handle for ETM.
> + * @path: path from source to sink.
> + * @trace_id: trace_id of the whole path.
> + */
> +struct coresight_path {
> + struct perf_output_handle *handle;
This is only needed to avoid adding *handle to the enable function call
signature, but having it here implies it needs to be stored. And then we
need to manage the lifecycle of it by nulling it on deletion. All of
this can be avoided by just adding handle to enable().
Unrelated to this patch, but I'm not sure why we were passing around
void* for handle either. It just makes the code hard to read and implies
some flexibility that doesn't exist. It's always "struct
perf_output_handle", so we can change void* to that in the enable
functions. I also have a patch for this that I'll share in a bit.
> + struct list_head *path;
> + u8 trace_id;
> +};
> +
> static inline void coresight_insert_barrier_packet(void *buf)
> {
> if (buf)
> @@ -132,16 +144,15 @@ static inline void CS_UNLOCK(void __iomem *addr)
> } while (0);
> }
>
> -void coresight_disable_path(struct list_head *path);
> -int coresight_enable_path(struct list_head *path, enum cs_mode mode,
> - void *sink_data);
> +void coresight_disable_path(struct coresight_path *cs_path);
> +int coresight_enable_path(struct coresight_path *cs_path, enum cs_mode mode);
> struct coresight_device *coresight_get_sink(struct list_head *path);
This needs to be exported otherwise the build fails because you use it
in a module in another commit. I assume you are building as static?