[PATCH v4 2/3] coresight: tmc: refactor the tmc-etr mode setting to avoid race conditions

Suzuki K Poulose suzuki.poulose at arm.com
Thu Nov 20 02:45:04 PST 2025


On 19/11/2025 18:04, Leo Yan wrote:
> On Thu, Nov 13, 2025 at 03:02:45PM +0000, Suzuki Kuruppassery Poulose wrote:
>> Hi Junhao,
>>
>> While your patch fixes the problem it introduces imbalance in the
>> way perf vs sysfs modes are handled.
> 
> Previously, I suggested setting the mode in a unified way in
> tmc_enable_etr_sink() [1]. After looking into the code again, it seems
> that both my suggestion and this patch set the perf mode is too late.
> 
> Maybe we need to set the sink's device mode once a session starts to use
> it.  So we should set the perf mode when allocating sink's buffer
> (tmc_alloc_etr_buffer()), as this is the first callback invoked for a
> perf session.

Thats too early, in setup_aux(), when the event is not scheduled in. We 
don't know when that would be.

> 
> As a result, we can keep to set the sysfs mode in
> tmc_enable_etr_sink_sysfs().
> 
> A side topic is we need to refactor the tmc_etr_get_sysfs_buffer()
> function, ideally this function is purely for allocating buffer without
> any locking. We can defer to assign "drvdata->sysfs_buf" until
> acquired spin lock in tmc_enable_etr_sink_sysfs().  Essetionally, we
> can enable sink in one go rather than acquire-release lock for several
> times.

Patche welcome :-)

Cheers
Suzuki

> 
> Thanks,
> Leo
> 
> [1] https://lore.kernel.org/linux-arm-kernel/20251020143718.GH281971@e132581.arm.com/




More information about the linux-arm-kernel mailing list