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

Leo Yan leo.yan at arm.com
Wed Nov 19 10:04:47 PST 2025


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.

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.

Thanks,
Leo

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



More information about the linux-arm-kernel mailing list