Jie Gan <jie.gan(a)oss.qualcomm.com> writes:
> Update the sink_enable functions to accept coresight_path instead of
> a generic void *data, as coresight_path encapsulates all the necessary
> data required by devices along the path.
>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
Tested-by: Carl Worth <carl(a)os.amperecomputing.com>
Reviewed-by: Carl Worth <carl(a)os.amperecomputing.com>
-Carl
Jie Gan <jie.gan(a)oss.qualcomm.com> writes:
> Update the helper_enable and helper_disable functions to accept
> coresight_path instead of a generic void *data, as coresight_path
> encapsulates all the necessary data required by devices along the path.
>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
Tested-by: Carl Worth <carl(a)os.amperecomputing.com>
Reviewed-by: Carl Worth <carl(a)os.amperecomputing.com>
-Carl
Jie Gan <jie.gan(a)oss.qualcomm.com> writes:
> From: Carl Worth <carl(a)os.amperecomputing.com>
>
> The handle is essential for retrieving the AUX_EVENT of each CPU and is
> required in perf mode. It has been added to the coresight_path so that
> dependent devices can access it from the path when needed.
I'd still like to have the original command I used to trigger the bug in
the commit message. I really like having reproduction steps captured in
commit messages when I look back at commits in the future. So, that was:
perf record -e cs_etm//k -C 0-9 dd if=/dev/zero of=/dev/null
> /**
> * struct coresight_path - data needed by enable/disable path
> - * @path_list: path from source to sink.
> - * @trace_id: trace_id of the whole path.
> + * @path_list: path from source to sink.
> + * @trace_id: trace_id of the whole path.
> + * struct perf_output_handle: handle of the aux_event.
> */
Fixing to "@handle" was mentioned in another comment already.
Something about the above still feels a little off to me. It feels like
we're throwing new data into a structure just because it happens to be
conveniently at hand for the code paths we're needing, and not because
it really _belongs_ there.
Or, maybe it's the right place for it, and the cause of my concern is
that "path" is an overly-narrow name in struct coresight_path?
But if a renaming of this structure would improve the code, I'd also be
fine with that happening in a subsequent commit, so I won't try to hold
up the current series based on that.
-Carl
Jie Gan <jie.gan(a)oss.qualcomm.com> writes:
> I think it's better to explain my ideas with codes, so I directly created the
> patch series for sharing my solution. Please let me know if it's
> offend you.
Thanks, Jie! I'm not offended at all. My primary goal is the improvement
of our shared code base, and this is helpful for that. And I agree with
you that code can bring a lot of clarity to the discussion.
I've tested the series and it works and fixes the bug. I'll comment
specifically on each patch separately.
-Carl
On Fri, Sep 19, 2025 at 12:06:52PM -0400, Sean Anderson wrote:
> If registering the CPU map fails, we need to put the fwnode. free_percpu
> works when called with a NULL pointer, so just use
> coresight_device_release.
>
> Fixes: 5ad628a76176 ("coresight: Use per-sink trace ID maps for Perf sessions")
> Signed-off-by: Sean Anderson <sean.anderson(a)linux.dev>
I have a patch that fixes the same issue:
https://lore.kernel.org/linux-arm-kernel/20250512154108.23920-2-leo.yan@arm…
The difference in my patch is about the sequence: first it allocates the
resource, then increases the fw node's reference count. During release,
it first decreases the reference count, and then safely releases the
resource.
After comparing your patch, I still think the above reason is valid.
That said, I agree we should put this fixing before the panic notifier
fix. This would be friendly for backporting.
Thanks,
Leo
> ---
>
> Changes in v4:
> - New
>
> drivers/hwtracing/coresight/coresight-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index fa758cc21827..022c8384b98d 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -1352,7 +1352,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
> raw_spin_lock_init(&csdev->perf_sink_id_map.lock);
> csdev->perf_sink_id_map.cpu_map = alloc_percpu(atomic_t);
> if (!csdev->perf_sink_id_map.cpu_map) {
> - kfree(csdev);
> + coresight_device_release(&csdev->dev);
> ret = -ENOMEM;
> goto err_out;
> }
> --
> 2.35.1.1320.gc452695387.dirty
>
On Mon, Sep 22, 2025 at 03:31:41PM +0800, Jie Gan wrote:
> Update the sink_enable functions to accept coresight_path instead of
> a generic void *data, as coresight_path encapsulates all the necessary
> data required by devices along the path.
>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
Good refactoring for me, thanks!
Reviewed-by: Leo Yan <leo.yan(a)arm.com>
On Mon, Sep 22, 2025 at 03:31:40PM +0800, Jie Gan wrote:
> Update the helper_enable and helper_disable functions to accept
> coresight_path instead of a generic void *data, as coresight_path
> encapsulates all the necessary data required by devices along the path.
>
> Signed-off-by: Jie Gan <jie.gan(a)oss.qualcomm.com>
Reviewed-by: Leo Yan <leo.yan(a)arm.com>