[PATCH 6/6] coresight: perf: Retry failed HW_ID writes

James Clark james.clark at linaro.org
Fri Aug 21 03:01:26 PDT 2026



On 21/08/2026 10:50, James Clark wrote:
> Don't set the aux_hwid_done bit when writes fail so that it can be
> retried later if the ring buffer was full.
> 
> Add a second attempt on stop in case this session only has one call
> to start. Otherwise there is no chance to retry and it isn't fixed by
> not setting aux_hwid_done.
> 
> Signed-off-by: James Clark <james.clark at linaro.org>
> ---
>   drivers/hwtracing/coresight/coresight-etm-perf.c | 52 +++++++++++++++---------
>   1 file changed, 32 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
> index 09b21a711a87..0ffc5cd9c88f 100644
> --- a/drivers/hwtracing/coresight/coresight-etm-perf.c
> +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
> @@ -536,6 +536,31 @@ static int etm_event_resume(struct coresight_path *path)
>   	return ret;
>   }
>   
> +static void etm_output_hw_id(struct perf_event *event,
> +			     struct etm_event_data *event_data,
> +			     struct coresight_path *path,
> +			     struct coresight_device *sink)
> +{
> +	int cpu = smp_processor_id();
> +	u64 hw_id;
> +
> +	/*
> +	 * output cpu / trace ID in perf record, once for the lifetime
> +	 * of the event.
> +	 */
> +	if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) {
> +		hw_id = FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK,
> +				CS_AUX_HW_ID_MAJOR_VERSION);
> +		hw_id |= FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK,
> +				CS_AUX_HW_ID_MINOR_VERSION);
> +		hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, path->trace_id);
> +		hw_id |= FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(sink));
> +
> +		if (!perf_report_aux_output_id(event, hw_id))
> +			cpumask_set_cpu(cpu, &event_data->aux_hwid_done);
> +	}
> +}
> +
>   static void etm_event_start(struct perf_event *event, int flags)
>   {
>   	int cpu = smp_processor_id();
> @@ -544,7 +569,6 @@ static void etm_event_start(struct perf_event *event, int flags)
>   	struct perf_output_handle *handle = &ctxt->handle;
>   	struct coresight_device *source, *sink;
>   	struct coresight_path *path;
> -	u64 hw_id;
>   
>   	if (flags & PERF_EF_RESUME) {
>   		path = etm_event_get_ctxt_path(ctxt);
> @@ -596,22 +620,7 @@ static void etm_event_start(struct perf_event *event, int flags)
>   	if (coresight_enable_source(source, event, CS_MODE_PERF, path))
>   		goto fail_disable_path;
>   
> -	/*
> -	 * output cpu / trace ID in perf record, once for the lifetime
> -	 * of the event.
> -	 */
> -	if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) {
> -		cpumask_set_cpu(cpu, &event_data->aux_hwid_done);
> -
> -		hw_id = FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK,
> -				CS_AUX_HW_ID_MAJOR_VERSION);
> -		hw_id |= FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK,
> -				CS_AUX_HW_ID_MINOR_VERSION);
> -		hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, path->trace_id);
> -		hw_id |= FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(sink));
> -
> -		perf_report_aux_output_id(event, hw_id);
> -	}
> +	etm_output_hw_id(event, event_data, path, sink);
>   
>   out:
>   	/* Tell the perf core the event is alive */
> @@ -630,7 +639,7 @@ static void etm_event_start(struct perf_event *event, int flags)
>   	 */
>   	if (READ_ONCE(handle->event)) {
>   		perf_aux_output_flag(handle, PERF_AUX_FLAG_TRUNCATED);
> -		perf_aux_output_end(handle, 0);
> +		perf_aux_output_end(path->handle, 0);

Accidentally left this in from hacking. It doesn't do anything so I'll 
remove it.




More information about the linux-arm-kernel mailing list