Re: [PATCH 3/3] remoteproc: Force shutdown during device removal

Konrad Dybcio <[email protected]> Thu, 23 Jul 2026 12:54:58 +0200
Newsgroups org.kernel.vger.linux-remoteproc,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 7/23/26 5:52 AM, Bjorn Andersson wrote:
> rproc_del() is subjected to the reference counted shutdown path, as such
> a remoteproc with more than one reference will be left running as its
> resources are released underneath it.
> 
> Refactor the shutdown path such that the reference count value is
> ignored when called from rproc_del().
> 
> Assisted-by: OpenCode:GPT-5.5
> Signed-off-by: Bjorn Andersson <[email protected]>
> ---

[...]

> +static int __rproc_shutdown(struct rproc *rproc, bool force)
>  {
>  	struct device *dev = &rproc->dev;
>  	bool crashed;
> @@ -2029,9 +2008,10 @@ int rproc_shutdown(struct rproc *rproc)
>  	}
>  	crashed = rproc->state == RPROC_CRASHED;
>  
> -	/* if the remote proc is still needed, bail out */
> -	if (!atomic_dec_and_test(&rproc->power))
> +	if (!atomic_dec_and_test(&rproc->power) && !force) {
> +		/* The remote processor is still needed by another user. */
>  		goto out;
> +	}

GPT makes some unclear suggestions, effectively saying that rproc_shutdown(),
unlike other paths, seems not to first check whether the rproc is deleting
if the shutdown isn't forced. I think it's a valid concern.

Konrad