From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
Cc: Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
aiqun.yu@oss.qualcomm.com, tingwei.zhang@oss.qualcomm.com,
trilok.soni@oss.qualcomm.com, yijie.yang@oss.qualcomm.com,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org,
Bartosz Golaszewski <brgl@kernel.org>,
Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Subject: Re: [PATCH 1/2] remoteproc: core: Attach rproc asynchronously in rproc_add() path
Date: Fri, 10 Apr 2026 16:28:01 +0200 [thread overview]
Message-ID: <adkI8Si4ejf6T73T@linaro.org> (raw)
In-Reply-To: <20260409-rproc-attach-issue-v1-1-088a1c348e7a@oss.qualcomm.com>
+Cc Bartosz, Dmitry
On Thu, Apr 09, 2026 at 01:46:21AM -0700, Jingyi Wang wrote:
> For rproc with state RPROC_DETACHED and auto_boot enabled, the attach
> callback will be called in the rproc_add()->rproc_trigger_auto_boot()->
> rproc_boot() path, the failure in this path will cause the rproc_add()
> fail and the resource release, which will cause issue like rproc recovery
> or falling back to firmware load fail. Add attach_work for rproc and call
> it asynchronously in rproc_add() path like what rproc_start() do.
>
> Signed-off-by: Jingyi Wang <jingyi.wang@oss.qualcomm.com>
> ---
> drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++--------
> include/linux/remoteproc.h | 1 +
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index b087ed21858a..f02db1113fae 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1673,18 +1673,21 @@ static void rproc_auto_boot_callback(const struct firmware *fw, void *context)
> release_firmware(fw);
> }
>
> +static void rproc_attach_work(struct work_struct *work)
> +{
> + struct rproc *rproc = container_of(work, struct rproc, attach_work);
> +
> + rproc_boot(rproc);
> +}
> +
> static int rproc_trigger_auto_boot(struct rproc *rproc)
> {
> int ret;
>
> - /*
> - * Since the remote processor is in a detached state, it has already
> - * been booted by another entity. As such there is no point in waiting
> - * for a firmware image to be loaded, we can simply initiate the process
> - * of attaching to it immediately.
> - */
> - if (rproc->state == RPROC_DETACHED)
> - return rproc_boot(rproc);
> + if (rproc->state == RPROC_DETACHED) {
> + schedule_work(&rproc->attach_work);
> + return 0;
> + }
I think the change itself is reasonable to make "auto-attach" behavior
consistent with "auto-boot". The commit message is a bit misleading
though:
- You're really doing two separate functional changes here:
(1) Ignore the return value of rproc_boot() during auto-boot attach,
to keep the remoteproc registered and available in sysfs even if
attaching fails.
(2) Run the rproc_boot() in the background using schedule_work().
[To improve boot performance? To work around some locking issues?]
- The actual issue you are seeing sounds like a use-after-free in the
remoteproc core error cleanup path. I think this one is still
present, we should really have a call to
cancel_work_sync(&rproc->crash_handler) as Dmitry wrote in the
previous discussion [1].
Thanks,
Stephan
[1]: https://lore.kernel.org/all/ce24a2sgg4b6wymoxwgl2ve6np2nxn2wuxfqxfpmvqqrpvgouf@xihd6ziqwu4m/
next prev parent reply other threads:[~2026-04-10 14:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 8:46 [PATCH 0/2] remoteproc: improve robustness for rproc_attach fail cases Jingyi Wang
2026-04-09 8:46 ` [PATCH 1/2] remoteproc: core: Attach rproc asynchronously in rproc_add() path Jingyi Wang
2026-04-10 14:28 ` Stephan Gerhold [this message]
2026-04-14 3:41 ` Jingyi Wang
2026-04-14 8:13 ` Stephan Gerhold
2026-04-09 8:46 ` [PATCH 2/2] remoteproc: qcom: Check glink->edge in glink_subdev_stop() Jingyi Wang
2026-04-10 14:15 ` Stephan Gerhold
2026-04-14 3:23 ` Jingyi Wang
2026-04-14 8:27 ` Stephan Gerhold
2026-04-16 2:52 ` Jingyi Wang
2026-04-21 13:45 ` Stephan Gerhold
2026-04-28 4:19 ` Jingyi Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=adkI8Si4ejf6T73T@linaro.org \
--to=stephan.gerhold@linaro.org \
--cc=aiqun.yu@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=brgl@kernel.org \
--cc=dmitry.baryshkov@oss.qualcomm.com \
--cc=jingyi.wang@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=tingwei.zhang@oss.qualcomm.com \
--cc=trilok.soni@oss.qualcomm.com \
--cc=yijie.yang@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.