From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: bjorn.andersson@linaro.org, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, linux-imx@nxp.com,
linux-remoteproc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 3/9] remoteproc: support self recovery after rproc crash
Date: Tue, 18 Jan 2022 11:44:53 -0700 [thread overview]
Message-ID: <20220118184453.GE1119324@p14s> (raw)
In-Reply-To: <20220111033333.403448-6-peng.fan@oss.nxp.com>
On Tue, Jan 11, 2022 at 11:33:27AM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Current logic only support main processor to stop/start the remote
> processor after rproc crash. However to SoC, such as i.MX8QM/QXP, the
> remote processor could do self recovery after crash and trigger watchdog
> reboot. It does not need main processor to load image, stop/start M4
> core.
>
> This patch add a new flag to indicate whether the SoC has self recovery
> capability. And introduce two functions: rproc_self_recovery,
> rproc_assisted_recovery for the two cases. Assisted recovery is as
> before, let main processor to help recovery, while self recovery is
> recover itself withou help. To self recovery, we only do detach and
> attach.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> drivers/remoteproc/remoteproc_core.c | 66 ++++++++++++++++++++--------
> include/linux/remoteproc.h | 2 +
> 2 files changed, 49 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index 69f51acf235e..4bd5544dab8f 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1887,6 +1887,49 @@ static int __rproc_detach(struct rproc *rproc)
> return 0;
> }
>
> +static int rproc_self_recovery(struct rproc *rproc)
> +{
> + int ret;
> +
> + mutex_unlock(&rproc->lock);
> + ret = rproc_detach(rproc);
> + mutex_lock(&rproc->lock);
> + if (ret)
> + return ret;
> +
> + if (atomic_inc_return(&rproc->power) > 1)
> + return 0;
> + return rproc_attach(rproc);
> +}
> +
> +static int rproc_assisted_recovery(struct rproc *rproc)
> +{
> + const struct firmware *firmware_p;
> + struct device *dev = &rproc->dev;
> + int ret;
> +
> + ret = rproc_stop(rproc, true);
> + if (ret)
> + return ret;
> +
> + /* generate coredump */
> + rproc->ops->coredump(rproc);
> +
> + /* load firmware */
> + ret = request_firmware(&firmware_p, rproc->firmware, dev);
> + if (ret < 0) {
> + dev_err(dev, "request_firmware failed: %d\n", ret);
> + return ret;
> + }
> +
> + /* boot the remote processor up again */
> + ret = rproc_start(rproc, firmware_p);
> +
> + release_firmware(firmware_p);
> +
> + return ret;
> +}
> +
> /**
> * rproc_trigger_recovery() - recover a remoteproc
> * @rproc: the remote processor
> @@ -1901,7 +1944,6 @@ static int __rproc_detach(struct rproc *rproc)
> */
> int rproc_trigger_recovery(struct rproc *rproc)
> {
> - const struct firmware *firmware_p;
> struct device *dev = &rproc->dev;
> int ret;
>
> @@ -1915,24 +1957,10 @@ int rproc_trigger_recovery(struct rproc *rproc)
>
> dev_err(dev, "recovering %s\n", rproc->name);
>
> - ret = rproc_stop(rproc, true);
> - if (ret)
> - goto unlock_mutex;
> -
> - /* generate coredump */
> - rproc->ops->coredump(rproc);
> -
> - /* load firmware */
> - ret = request_firmware(&firmware_p, rproc->firmware, dev);
> - if (ret < 0) {
> - dev_err(dev, "request_firmware failed: %d\n", ret);
> - goto unlock_mutex;
> - }
> -
> - /* boot the remote processor up again */
> - ret = rproc_start(rproc, firmware_p);
> -
> - release_firmware(firmware_p);
> + if (rproc->self_recovery)
> + ret = rproc_self_recovery(rproc);
> + else
> + ret = rproc_assisted_recovery(rproc);
The problem of how to handle crash recoveries for processors that have been
attached to is difficult. Finding a solution for that should be on a patchset
of its own so that people can provide input.
>
> unlock_mutex:
> mutex_unlock(&rproc->lock);
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index e0600e1e5c17..b32ef46f8aa4 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -529,6 +529,7 @@ struct rproc_dump_segment {
> * @elf_machine: firmware ELF machine
> * @cdev: character device of the rproc
> * @cdev_put_on_release: flag to indicate if remoteproc should be shutdown on @char_dev release
> + * @self_recovery: flag to indicate if remoteproc support self recovery
> */
> struct rproc {
> struct list_head node;
> @@ -568,6 +569,7 @@ struct rproc {
> u16 elf_machine;
> struct cdev cdev;
> bool cdev_put_on_release;
> + bool self_recovery;
> };
>
> /**
> --
> 2.25.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-01-18 18:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 3:33 [PATCH V2] remoteproc: imx_rproc: use imx specific hook for find_loaded_rsc_table Peng Fan (OSS)
2022-01-11 3:33 ` [PATCH] remoteproc: imx_rproc: validate resource table Peng Fan (OSS)
2022-01-17 18:25 ` Mathieu Poirier
2022-01-18 1:24 ` Peng Fan
2022-01-11 3:33 ` [PATCH 0/9] remoteproc: imx_rproc: support i.MX8QXP/QM and self recovery Peng Fan (OSS)
2022-01-11 3:33 ` [PATCH 1/9] dt-bindings: remoteproc: imx_rproc: support i.MX8QXP Peng Fan (OSS)
2022-01-11 6:44 ` Peng Fan
2022-01-18 18:41 ` Mathieu Poirier
2022-01-19 2:20 ` Peng Fan
2022-01-11 3:33 ` [PATCH 2/9] dt-bindings: remoteproc: imx_rproc: support i.MX8QM Peng Fan (OSS)
2022-01-11 6:45 ` Peng Fan
2022-01-11 3:33 ` [PATCH 3/9] remoteproc: support self recovery after rproc crash Peng Fan (OSS)
2022-01-18 18:44 ` Mathieu Poirier [this message]
2022-01-19 2:21 ` Peng Fan
2022-01-11 3:33 ` [PATCH 4/9] remoteproc: imx_rproc: ignore create mem entry for resource table Peng Fan (OSS)
2022-01-18 18:47 ` Mathieu Poirier
2022-01-19 2:23 ` Peng Fan
2022-01-11 3:33 ` [PATCH 5/9] remoteproc: imx_rproc: make clk optional Peng Fan (OSS)
2022-01-18 18:50 ` Mathieu Poirier
2022-01-19 2:25 ` Peng Fan
2022-01-19 17:49 ` Mathieu Poirier
2022-01-11 3:33 ` [PATCH 6/9] remoteproc: imx_rproc: support attaching to i.MX8QXP M4 Peng Fan (OSS)
2022-01-18 18:57 ` Mathieu Poirier
2022-01-19 2:28 ` Peng Fan
2022-01-19 18:04 ` Mathieu Poirier
2022-01-19 18:31 ` Mathieu Poirier
2022-01-11 3:33 ` [PATCH 7/9] remoteproc: imx_rproc: support kicking Mcore from Linux for i.MX8QXP Peng Fan (OSS)
2022-01-19 18:58 ` Mathieu Poirier
2022-01-11 3:33 ` [PATCH 8/9] remoteproc: imx_rproc: support i.MX8QM Peng Fan (OSS)
2022-01-20 17:23 ` Mathieu Poirier
2022-01-21 1:00 ` Peng Fan
2022-01-11 3:33 ` [PATCH 9/9] remoteproc: imx_rproc: request mbox channel later Peng Fan (OSS)
2022-12-21 10:55 ` [PATCH V2] remoteproc: imx_rproc: use imx specific hook for find_loaded_rsc_table Marco Felsch
2023-01-02 22:46 ` Mathieu Poirier
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=20220118184453.GE1119324@p14s \
--to=mathieu.poirier@linaro.org \
--cc=bjorn.andersson@linaro.org \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=peng.fan@oss.nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.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 NNTP newsgroup(s).