From: "Joakim Zhang" <joakim.zhang@cixtech.com>
To: "andersson@kernel.org" <andersson@kernel.org>,
"mathieu.poirier@linaro.org" <mathieu.poirier@linaro.org>,
"arnaud.pouliquen@foss.st.com" <arnaud.pouliquen@foss.st.com>
Cc: "linux-remoteproc@vger.kernel.org"
<linux-remoteproc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
cix-kernel-upstream <cix-kernel-upstream@cixtech.com>
Subject: 回复: [PATCH V1] remoteproc: virtio: Fix wdg cannot recovery remote processor
Date: Tue, 12 Dec 2023 14:11:05 +0000 [thread overview]
Message-ID: <SEYPR06MB6278AE38D53CA55FB06574F6828EA@SEYPR06MB6278.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <20231212052357.2052629-1-joakim.zhang@cixtech.com>
Hello maintainers,
This patch may not fix it in a correct way, after applying this patch, in rproc_add_virtio_dev():
1) If the allocate path is dma_declare_coherent_memory(), it will be freed from dma_release_coherent_memory(), which is expected
2) If the allocate path is of_reserved_mem_device_init_by_idx(), it will still be freed from dma_release_coherent_memory(), which is not expected
Try to fix this issue, I also introduce another patch: https://lore.kernel.org/lkml/20231212052130.2051333-1-joakim.zhang@cixtech.com/T/
Are there any suggestions? Thanks.
Joakim
> -----邮件原件-----
> 发件人: Joakim Zhang <joakim.zhang@cixtech.com>
> 发送时间: 2023年12月12日 13:24
> 收件人: andersson@kernel.org; mathieu.poirier@linaro.org;
> arnaud.pouliquen@foss.st.com
> 抄送: linux-remoteproc@vger.kernel.org; linux-kernel@vger.kernel.org;
> cix-kernel-upstream <cix-kernel-upstream@cixtech.com>; Joakim Zhang
> <joakim.zhang@cixtech.com>
> 主题: [PATCH V1] remoteproc: virtio: Fix wdg cannot recovery remote
> processor
>
> 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.
>
> We can see that dma coherent mem allocated from rproc_add_virtio_dev(), so
> should release it from rproc_remove_virtio_dev(). These functions should
> appear symmetrically:
> -rproc_vdev_do_start()->rproc_add_virtio_dev()->dma_declare_coherent_mem
> ory()
> -rproc_vdev_do_stop()->rproc_remove_virtio_dev()->dma_release_coherent_m
> emory()
>
> Fixes: 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the
> remoteproc_virtio")
> Signed-off-by: Joakim Zhang <joakim.zhang@cixtech.com>
> ---
> drivers/remoteproc/remoteproc_virtio.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/remoteproc_virtio.c
> b/drivers/remoteproc/remoteproc_virtio.c
> index 83d76915a6ad..725b957ee226 100644
> --- a/drivers/remoteproc/remoteproc_virtio.c
> +++ b/drivers/remoteproc/remoteproc_virtio.c
> @@ -465,8 +465,12 @@ static int rproc_add_virtio_dev(struct rproc_vdev
> *rvdev, int id) static int rproc_remove_virtio_dev(struct device *dev, void
> *data) {
> struct virtio_device *vdev = dev_to_virtio(dev);
> + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
>
> unregister_virtio_device(vdev);
> +
> + dma_release_coherent_memory(&rvdev->pdev->dev);
> +
> return 0;
> }
>
> @@ -585,7 +589,6 @@ static void rproc_virtio_remove(struct platform_device
> *pdev)
> rproc_remove_rvdev(rvdev);
>
> of_reserved_mem_device_release(&pdev->dev);
> - dma_release_coherent_memory(&pdev->dev);
>
> put_device(&rproc->dev);
> }
> --
> 2.25.1
prev parent reply other threads:[~2023-12-12 14:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 5:23 [PATCH V1] remoteproc: virtio: Fix wdg cannot recovery remote processor joakim.zhang
2023-12-12 14:11 ` Joakim Zhang [this message]
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=SEYPR06MB6278AE38D53CA55FB06574F6828EA@SEYPR06MB6278.apcprd06.prod.outlook.com \
--to=joakim.zhang@cixtech.com \
--cc=andersson@kernel.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=cix-kernel-upstream@cixtech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).