From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F08B73D3302 for ; Fri, 10 Apr 2026 14:28:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775831296; cv=none; b=Y+VkU62oigyPcxjYgWGdP9nrZFw3hb4LXbyH/Y48+Serc2Z1pLai1jbw2fIgbysNav60ipMrNaMdz9HOFQY6l6y8TFVMN8kQTcSWgom0UXuLc3AP5/rmdEL7Ymz6jCuB8xJBmM+4f3Ul3YrIpuB2AoC6FJEwmO6sN8sDei0BLLk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775831296; c=relaxed/simple; bh=SlHkwVDj6sqnc4C0GPhidA6If3ojZ4N4s0pvp5GpblU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f0T/+2jF/j+42taRmUFjSMzB8kqUvx+kTQtKvJi7W9zl1lBShsE4CS3HKYOsXmp9cN78brlLaU6JGdPfI5h/VAz2+XdiwHxAjTeSgZdFa8c2Bt3UHeLXxRgJny5DS0GP6D9y5WNX2eatSrpJaQMFsrpV/t+J7NzpFXNwiN53cPs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=aSvWFVwm; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aSvWFVwm" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-488a29e6110so24289055e9.3 for ; Fri, 10 Apr 2026 07:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1775831293; x=1776436093; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=0ADKIwr4ulE9AlL8WuP29OLGHGCvedZpXQ2D+7VFVVM=; b=aSvWFVwmNadM5+UM92ybSDn7nwmUUnnp+Iw3sxXRqDPBuYynR9WRy4YTDlnS5b7sQm AfDiWRBDLOAe1XXjFjLgWdUOxSiuN+PTqJywHdh8Im5jP4P6gprZdEx2ceJERUynuI4C JS4dRa44PUI5GOv5KFSDqBV7Swyu9OnZ7mHI8WIP3S6AMY5S04KBuVUJaFn8B7W44O+L d1+bS/PDCcdZeNcgl9GLFN9Ac1GW96gvKB4rdrvdifEHWKupKtRzG0wGMBg6RGS7+TFz 5Z7T1nHxLF0q0h3HgDab8fFGNwJJKr4ds0NxJWfgJ/2XlEIFgR5dJnMMYUIg0oz+BOy/ fsVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775831293; x=1776436093; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0ADKIwr4ulE9AlL8WuP29OLGHGCvedZpXQ2D+7VFVVM=; b=ZEIWOzo30pJGq62dv1aQ+Lp+e+Ki81sgO0t9AMmq4U9rwID92e73yaPNvU+vLn+Hgw VlLyZFj6dE6d+zeF6p7uhaq86Bk5eA+QgAgdmYcd3+S85XuslTlaliELkhwZ5zNcDUJs W+aDtchkLvv9USqBj3iEHGkFza/Yem7NJRiue125S5i2ATAO4yZo6RrO7aDzHa+hFuHr G+VmM6PONJxsk0dmhMXsopjV9+iubqKsR53ePY8fKEJ0fY6I2vEwgyMzsHUt8bvT+HM7 kGTmE0ZtRW798c3GS6eybpRRqEX0m+CDfGBdeI93mt+JSfWZ3VYJXXPOBKMBeBiiGShD dHfg== X-Forwarded-Encrypted: i=1; AJvYcCXdaMCb4fA0LawVWYWcBxyFiM5S7mKSaOtb3W4UCNMlogNTp5tPN3ejZPk9b8EBQszTRfJVBbCAdofNsGY=@vger.kernel.org X-Gm-Message-State: AOJu0YwYvoUTdJKQsRY/ng40ABQybmCwffDykQgmnsMf84jFkr3Q3jGS OysR7ZVhTceKAczlnKPs5LlGKTNu76I59zpFqVhmYcCgRHsRD/S/wBq+nN3bproPUq0= X-Gm-Gg: AeBDieuxH2KhsdEBxJltLL2uu6TWt19xogrsrN1Wa2BX/3+dCt9e7vALdhbVZibrFsS HYoZOocHPfzcFEdgjHZ7JsQnbGvppC1vQwgm/o4WjRu5NF7U8mPrAbkw2hgHGmkKmvgRbDdF4wm A0XxexUl3pz6lpV7AacXEuunz+kmNSF7Q/8EGXf0bRnxLS9wddPYsKHyUXWDzLAAh0vUJi+Z3AY sCZKLdkFTlVQB+1gkcFnVWFEYI4RjyfxmdDdMoXga9qhMoVUmn1QmylDvcmIXY830hr1KptGBL0 kfyjjV9T6t37kC+vYBZ4bOiNUz5s+CnVfsyJuozFx+X6TSec7ZDnQwTonvTEqxXUBi/UEpuvVz1 e98e/MBHVX9LCzhh9YmDHpU1jfNYarPrnVfofnLGoE9JidnNV8oQ4FjXh5WErIJgBgWGJLNj2r/ xNhEWQwv5FZ2a3EvDjjreUr2Laram6 X-Received: by 2002:a05:600c:674f:b0:488:a82f:bb9b with SMTP id 5b1f17b1804b1-488d68cb47amr48303285e9.30.1775831293221; Fri, 10 Apr 2026 07:28:13 -0700 (PDT) Received: from linaro.org ([77.64.147.107]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d5d9dd86sm36941185e9.4.2026.04.10.07.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 07:28:12 -0700 (PDT) Date: Fri, 10 Apr 2026 16:28:01 +0200 From: Stephan Gerhold To: Jingyi Wang Cc: Bjorn Andersson , Mathieu Poirier , 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 , Dmitry Baryshkov Subject: Re: [PATCH 1/2] remoteproc: core: Attach rproc asynchronously in rproc_add() path Message-ID: References: <20260409-rproc-attach-issue-v1-0-088a1c348e7a@oss.qualcomm.com> <20260409-rproc-attach-issue-v1-1-088a1c348e7a@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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/