On Fri, Nov 27, 2026 at 03:26:38PM +0530, Anandu Krishnan E wrote:
> /*
> * Linked into cctx->users so fastrpc_rpmsg_remove() can abort us
> * via fastrpc_notify_users() instead of waiting out the timeout.
> */
I think this abort path currently deadlocks, and that the series makes
an existing bug much easier to reach rather than introducing one.
The work links fl onto cctx->users and then calls
fastrpc_get_info_from_dsp(), which goes through
fastrpc_internal_invoke() -> fastrpc_context_alloc(), and that puts a
ctx on fl->pending. So for as long as the query is outstanding, the
throwaway fl is on cctx->users with a non-empty fl->pending. That is
exactly the state fastrpc_notify_users() walks, and on this base it
does:
fastrpc_notify_users(): spin_lock(&user->lock);
fastrpc_context_schedule_put_work(): spin_lock(&ctx->fl->lock);
with ctx->fl == user, since fastrpc_context_alloc() sets ctx->fl to the
same fl it links the ctx onto. Same spinlock twice on one CPU, and
fastrpc_rpmsg_remove() is holding cctx->lock with interrupts masked
while it does this, so it is a hard lockup rather than a stall.
Vinayak's "misc: fastrpc: make put_work scheduling lock-free" fixes
that lock, and I think this series needs it underneath rather than
alongside: both are based on a9c48428cbd8 and neither mentions the
other. That patch now carries Ekansh's Reviewed-by and a Tested-by
from Shawn Guo, who hit the same deadlock on Nord and reports it
firing on every remoteproc stop of a DSP with an active fastrpc user,
so none of this is theoretical.
Worth noting how much this series changes the exposure. Today you need a
userspace process with an invocation in flight at unbind time. With
this series the driver itself has an invocation in flight on every
probe, for up to the full timeout, and the mechanism it deliberately
relies on to be aborted is the one that hangs. An unbind shortly after
bind would hit it.
There is a third change in this area now, too: Shawn Guo's "misc:
fastrpc: Keep compute-cb devices across channel removal", posted today,
reworks fastrpc_cb_devices_create() and fastrpc_cb_devices_destroy()
and adjusts both fastrpc_rpmsg_probe() and fastrpc_rpmsg_remove() --
the same two functions this series restructures, with overlapping
hunks. Together with the put_work fix that makes three changes in
flight against the same teardown path. It seemed better to say so than
to let it turn up as a conflict.
Second, a behaviour change I did not see mentioned. Before this patch
fastrpc_rpmsg_probe() called fastrpc_device_register() itself, from the
domain switch, so the device nodes existed by the time probe()
returned. Now probe() queues the work and returns, and the nodes appear
only after the query finishes. fastrpc_get_info_from_dsp() is a kernel invoke,
so
fastrpc_wait_for_response() uses wait_for_completion_timeout(&ctx->work,
10 * HZ): on a DSP that never answers, /dev/fastrpc-* shows up ten
seconds after the device is bound. Anything that binds and then opens
the node, a udev rule or an init script, now races where it did not
before. If that is an acceptable trade it would be good to have it in
the commit message, since it is the kind of thing that gets bisected to
later.
It also looks avoidable for most domains. fastrpc_register_devices()
only consults the queried attributes for ADSP_DOMAIN_ID; for MDSP,
SDSP, CDSP and GDSP the result does not affect which nodes are created,
yet all of them now wait for it. Queueing the query only for ADSP, and
leaving the other domains registering inline as they do today, would
keep the new asynchrony confined to the domain that actually needs it.
Which leads to a question rather than a comment. The capability is
already queried lazily and cached in cctx->dsp_attributes behind
cctx->valid_attributes on the FASTRPC_IOCTL_GET_DSP_INFO path, so the
only reason to ask at probe time is to decide the ADSP node. Does
compute-capability vary by firmware image at runtime, or only by SoC?
If it only varies by SoC, soc_data already carries that sort of
per-platform difference and would settle it without the workqueue, the
throwaway user and session, the cancel_work_sync() dance, or the new
cctx->rpdev re-checks in fastrpc_device_open() -- 264 added lines to
learn one bit. If it really is per-image then that does not work and
the query is needed, but it seemed worth asking, and it is close to the
question already raised on 2/2 about dropping the domain_id handling.
Two small things:
checkpatch --strict has one complaint on 1/2:
CHECK: Alignment should match open parenthesis
+ data->cap_wq = alloc_ordered_workqueue("fastrpc_cap_wq_%s",
+ WQ_HIGHPRI, domain);
And, pre-existing rather than yours, but in a function you are
restructuring anyway: fastrpc_device_open() publishes fl on cctx->users
and drops cctx->lock before kref_init(&fl->refcount) runs, so fl is
briefly reachable from the list with a refcount of zero. Nothing takes
a reference off that list today, so it is latent, but moving the
kref_init() above the list_add_tail() would cost nothing.
On the mechanical side, on linux-next next-20261127:
git apply --check clean, 1/2 then 2/2 in order
make W=1 fastrpc.o 0 warnings
sparse 0.6.4 C=1 only the two pre-existing of_device_id
warnings, unchanged
checkpatch --strict 1/2: 0 errors, 0 warnings, 1 check (above)
2/2: clean
I have no Qualcomm hardware, so none of this was run; it is all reading
the code and building it. I may well have the firmware-versus-SoC
question backwards, in which case most of the above falls away.
Thanks,
Murali Krishna