Re: [PATCH RFC 03/10] coresight: cpu-debug: Publish the per-CPU data under debug_lock

From: Leo Yan

Date: Fri Dec 04 2026 - 12:04:17 EST


On Fri, Nov 27, 2026 at 08:38:40AM +0200, Igor Velkov via B4 Relay wrote:

[...]

> Store the pointer once the device is known to be usable, and change it
> only under debug_lock, which the knob holds while it takes or drops the
> runtime PM references of the published devices.

The problem is the duplicate check per_cpu(debug_drvdata, cpu) still
runs outside debug_lock in __debug_probe().

Maybe it is good to go a bit further:

- Call debug_func_init() from debug_init() and debug_func_exit() from
debug_exit(). The debugfs knob and notifier would then exist for the
lifetime of the driver. That would let us drop debug_count and avoid
racing debugfs setup in probe against teardown in remove.

- In __debug_probe(), after the SMP call succeeds and the hardware
checks pass, take debug_lock, check if the CPU slot is duplicated,
and publish drvdata before unlocking.

Thanks,
Leo