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>
On 19/09/2025 02:20, Jie Gan wrote:
>
>
> On 9/19/2025 6:18 AM, Carl Worth wrote:
>> Jie Gan <jie.gan(a)oss.qualcomm.com> writes:
>>> I dont think we can change back to sink_data since we introduced
>>> coresight_path to wrap 'data' which is needed by the path.
>>>
>>> I suggest you to add the struct perf_output_handle to the
>>> coresight_path, then retrieving it with data->perf_handle in
>>> tmc_etr_get_buffer.
>> ...
>>> We can assign the perf_output_handle to the coresight_path after we
>>> constructed the coresight_path in perf mode.
>>
>> Thanks. That much makes sense to me, and I'll put together a patch along
>> those lines.
>>
>> But, further: with core coresight code assembling into the path all the
>> data that is necessary, is there any reason to be using void* in these
>> enable/disable functions?
>
> In my opinion, yes, we can change void * to coresight_path * for
> helper's enable/disable functions since we have everything in path so
> the cast is not necessary now.
>
>>
>> Could we also change these functions to accept a coresight_path* and
>> actually get some compiler help at finding mistakes like the one we're
>> fixing here?
>
Yes, please. I was going to suggest that. May be we could do that as
a separate patch after fixing the problem here first (so that it
can be back ported).
This was initially a perf_handle only used for the perf mode, and
it didn't make sens to have a "perf" argument to "enable" which
could be used for both sysfs and perf. Now that the path
is a generic data structure, it makes sense to move everything
to accept the path.
Suzuki
> That's the only benefit in my mind so far.
>
> Thanks,
> Jie
>
>>
>> -Carl
>
Jie Gan <jie.gan(a)oss.qualcomm.com> writes:
> I dont think we can change back to sink_data since we introduced
> coresight_path to wrap 'data' which is needed by the path.
>
> I suggest you to add the struct perf_output_handle to the
> coresight_path, then retrieving it with data->perf_handle in
> tmc_etr_get_buffer.
...
> We can assign the perf_output_handle to the coresight_path after we
> constructed the coresight_path in perf mode.
Thanks. That much makes sense to me, and I'll put together a patch along
those lines.
But, further: with core coresight code assembling into the path all the
data that is necessary, is there any reason to be using void* in these
enable/disable functions?
Could we also change these functions to accept a coresight_path* and
actually get some compiler help at finding mistakes like the one we're
fixing here?
-Carl