On Fri, Nov 27, 2026 at 03:34:09PM +0530, Vinayak Katoch wrote:
> fastrpc_context_schedule_put_work() guards the once-only schedule_work()
> with fl->lock. That helper is called from fastrpc_rpmsg_callback(), which
> runs in hard-IRQ context on the glink rx interrupt, while every other
> user of fl->lock takes it with a plain spin_lock() in process context
> with interrupts enabled.
>
> If the glink interrupt fires on a CPU that is already holding fl->lock,
> for example fastrpc_context_put_wq() -> fastrpc_context_free() or
> fastrpc_free_map() running in a kworker on that CPU, the handler spins
> on the lock the interrupted code holds. The holder can never run again,
> so the CPU hangs with interrupts masked, an RCU stall is reported for
> it, and the system is eventually reset by the watchdog. It is easy to
> hit because schedule_work() queues onto the local CPU's worker pool, so
> the worker that takes fl->lock tends to run on the very CPU that
> receives the glink interrupt.
>
> The same helper is also called by fastrpc_notify_users() while it holds
> user->lock, and ctx->fl == user, so a context left on fl->pending or
> fl->interrupted when the channel is removed deadlocks on the same lock
> there too.
>
> The flag is only used to make sure put_work is queued once, so no lock
> is needed. Turn it into an atomic_t and claim it with atomic_xchg().
> Whichever caller sees the old value 0 queues the work; any later or
> racing caller sees 1 and does nothing. This makes the helper safe from
> hard-IRQ context and with fl->lock already held.
>
> Fixes: 3f645f6884b5 ("misc: fastrpc: fix context leak and hang on
> signal-interrupted invoke")
> Cc: [email protected]
> Signed-off-by: Vinayak Katoch <[email protected]>
It fixes the regression [1] on Nord I reported yesterday.
Tested-by: Shawn Guo <[email protected]>
Shawn
[1] https://lore.kernel.org/all/awz0TMG1-NdBWqyZ@QCOM-aGQu4IUr3Y/