diff mbox series

[v4,8/9] remoteproc: Refactor function rproc_free_vring()

Message ID 20200601175139.22097-9-mathieu.poirier@linaro.org (mailing list archive)
State Superseded
Headers show
Series remoteproc: Add support for attaching with rproc | expand

Commit Message

Mathieu Poirier June 1, 2020, 5:51 p.m. UTC
When function rproc_free_vring() clears the virtio device section
it does so on the cached resource table rather than the one
installed in the remote processor memory.  When a remote processor
has been booted by another entity there is no need to use a cached
table and as such, no need to clear the virtio device section in
it.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
---
 drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Comments

Bjorn Andersson June 22, 2020, 7:27 a.m. UTC | #1
On Mon 01 Jun 10:51 PDT 2020, Mathieu Poirier wrote:

> When function rproc_free_vring() clears the virtio device section
> it does so on the cached resource table rather than the one
> installed in the remote processor memory.  When a remote processor
> has been booted by another entity there is no need to use a cached
> table and as such, no need to clear the virtio device section in
> it.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> ---
>  drivers/remoteproc/remoteproc_core.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index d32ac8f0c872..0e23284fbd25 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -411,10 +411,22 @@ void rproc_free_vring(struct rproc_vring *rvring)
>  
>  	idr_remove(&rproc->notifyids, rvring->notifyid);
>  
> -	/* reset resource entry info */
> -	rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset;
> -	rsc->vring[idx].da = 0;
> -	rsc->vring[idx].notifyid = -1;
> +	/*
> +	 * At this point rproc_stop() has been called and the installed resource
> +	 * table in the remote processor memory may no longer be accessible. As
> +	 * such and as per rproc_stop(), rproc->table_ptr points to the cached
> +	 * resource table (rproc->cached_table).  The cached resource table is
> +	 * only available when a remote processor has been booted by the
> +	 * remoteproc core, otherwise it is NULL.
> +	 *
> +	 * Based on the above, reset the virtio device section in the cached
> +	 * resource table only if there is one to work with.
> +	 */
> +	if (rproc->table_ptr) {
> +		rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset;
> +		rsc->vring[idx].da = 0;
> +		rsc->vring[idx].notifyid = -1;
> +	}
>  }
>  
>  static int rproc_vdev_do_start(struct rproc_subdev *subdev)
> -- 
> 2.20.1
>
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index d32ac8f0c872..0e23284fbd25 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -411,10 +411,22 @@  void rproc_free_vring(struct rproc_vring *rvring)
 
 	idr_remove(&rproc->notifyids, rvring->notifyid);
 
-	/* reset resource entry info */
-	rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset;
-	rsc->vring[idx].da = 0;
-	rsc->vring[idx].notifyid = -1;
+	/*
+	 * At this point rproc_stop() has been called and the installed resource
+	 * table in the remote processor memory may no longer be accessible. As
+	 * such and as per rproc_stop(), rproc->table_ptr points to the cached
+	 * resource table (rproc->cached_table).  The cached resource table is
+	 * only available when a remote processor has been booted by the
+	 * remoteproc core, otherwise it is NULL.
+	 *
+	 * Based on the above, reset the virtio device section in the cached
+	 * resource table only if there is one to work with.
+	 */
+	if (rproc->table_ptr) {
+		rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset;
+		rsc->vring[idx].da = 0;
+		rsc->vring[idx].notifyid = -1;
+	}
 }
 
 static int rproc_vdev_do_start(struct rproc_subdev *subdev)