diff mbox series

[V3] remoteproc: virtio: Fix wdg cannot recovery remote processor

Message ID 20231217053659.3245745-1-joakim.zhang@cixtech.com (mailing list archive)
State Queued
Headers show
Series [V3] remoteproc: virtio: Fix wdg cannot recovery remote processor | expand

Commit Message

Joakim Zhang Dec. 17, 2023, 5:36 a.m. UTC
From: Joakim Zhang <joakim.zhang@cixtech.com>

Recovery remote processor failed when wdg irq received:
[    0.842574] remoteproc remoteproc0: crash detected in cix-dsp-rproc: type watchdog
[    0.842750] remoteproc remoteproc0: handling crash #1 in cix-dsp-rproc
[    0.842824] remoteproc remoteproc0: recovering cix-dsp-rproc
[    0.843342] remoteproc remoteproc0: stopped remote processor cix-dsp-rproc
[    0.847901] rproc-virtio rproc-virtio.0.auto: Failed to associate buffer
[    0.847979] remoteproc remoteproc0: failed to probe subdevices for cix-dsp-rproc: -16

The reason is that dma coherent mem would not be released when
recovering the remote processor, due to rproc_virtio_remove()
would not be called, where the mem released. It will fail when
it try to allocate and associate buffer again.

Releasing reserved memory from rproc_virtio_dev_release(), instead of
rproc_virtio_remove().

Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>
---
ChangeLogs:
V1->V2:
	* the same for of_reserved_mem_device_release()
V2->V3:
	* release reserved memory in rproc_virtio_dev_release()
---
 drivers/remoteproc/remoteproc_virtio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Joakim Zhang Jan. 9, 2024, 8:53 a.m. UTC | #1
Kindly Ping...

On Sunday, December 17, 2023 1:37 PM, Joakim Zhang wrote:
> Recovery remote processor failed when wdg irq received:
> [    0.842574] remoteproc remoteproc0: crash detected in cix-dsp-rproc: type
> watchdog
> [    0.842750] remoteproc remoteproc0: handling crash #1 in cix-dsp-rproc
> [    0.842824] remoteproc remoteproc0: recovering cix-dsp-rproc
> [    0.843342] remoteproc remoteproc0: stopped remote processor cix-dsp-
> rproc
> [    0.847901] rproc-virtio rproc-virtio.0.auto: Failed to associate buffer
> [    0.847979] remoteproc remoteproc0: failed to probe subdevices for cix-
> dsp-rproc: -16
> 
> The reason is that dma coherent mem would not be released when recovering
> the remote processor, due to rproc_virtio_remove() would not be called,
> where the mem released. It will fail when it try to allocate and associate buffer
> again.
> 
> Releasing reserved memory from rproc_virtio_dev_release(), instead of
> rproc_virtio_remove().
> 
> Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the
> remoteproc_virtio")
> Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>
> ---
> ChangeLogs:
> V1->V2:
> 	* the same for of_reserved_mem_device_release()
> V2->V3:
> 	* release reserved memory in rproc_virtio_dev_release()
> ---
>  drivers/remoteproc/remoteproc_virtio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_virtio.c
> b/drivers/remoteproc/remoteproc_virtio.c
> index 83d76915a6ad..25b66b113b69 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -351,6 +351,9 @@ static void rproc_virtio_dev_release(struct device
> *dev)
> 
>  	kfree(vdev);
> 
> +	of_reserved_mem_device_release(&rvdev->pdev->dev);
> +	dma_release_coherent_memory(&rvdev->pdev->dev);
> +
>  	put_device(&rvdev->pdev->dev);
>  }
> 
> @@ -584,9 +587,6 @@ static void rproc_virtio_remove(struct
> platform_device *pdev)
>  	rproc_remove_subdev(rproc, &rvdev->subdev);
>  	rproc_remove_rvdev(rvdev);
> 
> -	of_reserved_mem_device_release(&pdev->dev);
> -	dma_release_coherent_memory(&pdev->dev);
> -
>  	put_device(&rproc->dev);
>  }
> 
> --
> 2.25.1
Arnaud POULIQUEN Jan. 9, 2024, 10:57 a.m. UTC | #2
On 12/17/23 06:36, joakim.zhang@cixtech.com wrote:
> From: Joakim Zhang <joakim.zhang@cixtech.com>
> 
> Recovery remote processor failed when wdg irq received:
> [    0.842574] remoteproc remoteproc0: crash detected in cix-dsp-rproc: type watchdog
> [    0.842750] remoteproc remoteproc0: handling crash #1 in cix-dsp-rproc
> [    0.842824] remoteproc remoteproc0: recovering cix-dsp-rproc
> [    0.843342] remoteproc remoteproc0: stopped remote processor cix-dsp-rproc
> [    0.847901] rproc-virtio rproc-virtio.0.auto: Failed to associate buffer
> [    0.847979] remoteproc remoteproc0: failed to probe subdevices for cix-dsp-rproc: -16
> 
> The reason is that dma coherent mem would not be released when
> recovering the remote processor, due to rproc_virtio_remove()
> would not be called, where the mem released. It will fail when
> it try to allocate and associate buffer again.
> 
> Releasing reserved memory from rproc_virtio_dev_release(), instead of
> rproc_virtio_remove().
> 
> Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
> Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>

LGTM

Acked-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

Thanks,
Arnaud

> ---
> ChangeLogs:
> V1->V2:
>         * the same for of_reserved_mem_device_release()
> V2->V3:
>         * release reserved memory in rproc_virtio_dev_release()
> ---
>  drivers/remoteproc/remoteproc_virtio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
> index 83d76915a6ad..25b66b113b69 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -351,6 +351,9 @@ static void rproc_virtio_dev_release(struct device *dev)
> 
>         kfree(vdev);
> 
> +       of_reserved_mem_device_release(&rvdev->pdev->dev);
> +       dma_release_coherent_memory(&rvdev->pdev->dev);
> +
>         put_device(&rvdev->pdev->dev);
>  }
> 
> @@ -584,9 +587,6 @@ static void rproc_virtio_remove(struct platform_device *pdev)
>         rproc_remove_subdev(rproc, &rvdev->subdev);
>         rproc_remove_rvdev(rvdev);
> 
> -       of_reserved_mem_device_release(&pdev->dev);
> -       dma_release_coherent_memory(&pdev->dev);
> -
>         put_device(&rproc->dev);
>  }
> 
> --
> 2.25.1
> 
> 
> 
> This email (including its attachments) is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Unauthorized use, dissemination, distribution or copying of this email or the information herein or taking any action in reliance on the contents of this email or the information herein, by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is strictly prohibited. If you are not the intended recipient, please do not read, copy, use or disclose any part of this e-mail to others. Please notify the sender immediately and permanently delete this e-mail and any attachments if you received it in error. Internet communications cannot be guaranteed to be timely, secure, error-free or virus-free. The sender does not accept liability for any errors or omissions.
Mathieu Poirier Jan. 10, 2024, 6:48 p.m. UTC | #3
Good day Joakim,

On Sun, Dec 17, 2023 at 01:36:59PM +0800, joakim.zhang@cixtech.com wrote:
> From: Joakim Zhang <joakim.zhang@cixtech.com>
> 
> Recovery remote processor failed when wdg irq received:
> [    0.842574] remoteproc remoteproc0: crash detected in cix-dsp-rproc: type watchdog
> [    0.842750] remoteproc remoteproc0: handling crash #1 in cix-dsp-rproc
> [    0.842824] remoteproc remoteproc0: recovering cix-dsp-rproc
> [    0.843342] remoteproc remoteproc0: stopped remote processor cix-dsp-rproc
> [    0.847901] rproc-virtio rproc-virtio.0.auto: Failed to associate buffer
> [    0.847979] remoteproc remoteproc0: failed to probe subdevices for cix-dsp-rproc: -16
> 
> The reason is that dma coherent mem would not be released when
> recovering the remote processor, due to rproc_virtio_remove()
> would not be called, where the mem released. It will fail when
> it try to allocate and associate buffer again.
> 
> Releasing reserved memory from rproc_virtio_dev_release(), instead of
> rproc_virtio_remove().
> 
> Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
> Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>

I am in agreement with your patch.  I will apply it when 6.8-rc1 comes out.

Thanks,
Mathieu

> ---
> ChangeLogs:
> V1->V2:
> 	* the same for of_reserved_mem_device_release()
> V2->V3:
> 	* release reserved memory in rproc_virtio_dev_release()
> ---
>  drivers/remoteproc/remoteproc_virtio.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
> index 83d76915a6ad..25b66b113b69 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -351,6 +351,9 @@ static void rproc_virtio_dev_release(struct device *dev)
>  
>  	kfree(vdev);
>  
> +	of_reserved_mem_device_release(&rvdev->pdev->dev);
> +	dma_release_coherent_memory(&rvdev->pdev->dev);
> +
>  	put_device(&rvdev->pdev->dev);
>  }
>  
> @@ -584,9 +587,6 @@ static void rproc_virtio_remove(struct platform_device *pdev)
>  	rproc_remove_subdev(rproc, &rvdev->subdev);
>  	rproc_remove_rvdev(rvdev);
>  
> -	of_reserved_mem_device_release(&pdev->dev);
> -	dma_release_coherent_memory(&pdev->dev);
> -
>  	put_device(&rproc->dev);
>  }
>  
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c
index 83d76915a6ad..25b66b113b69 100644
--- a/drivers/remoteproc/remoteproc_virtio.c
+++ b/drivers/remoteproc/remoteproc_virtio.c
@@ -351,6 +351,9 @@  static void rproc_virtio_dev_release(struct device *dev)
 
 	kfree(vdev);
 
+	of_reserved_mem_device_release(&rvdev->pdev->dev);
+	dma_release_coherent_memory(&rvdev->pdev->dev);
+
 	put_device(&rvdev->pdev->dev);
 }
 
@@ -584,9 +587,6 @@  static void rproc_virtio_remove(struct platform_device *pdev)
 	rproc_remove_subdev(rproc, &rvdev->subdev);
 	rproc_remove_rvdev(rvdev);
 
-	of_reserved_mem_device_release(&pdev->dev);
-	dma_release_coherent_memory(&pdev->dev);
-
 	put_device(&rproc->dev);
 }