diff mbox series

[04/10] remoteproc: imx_rproc: make syscon optional

Message ID 20200724080813.24884-5-peng.fan@nxp.com
State New
Headers show
Series remoteproc: imx_rproc: support iMX8M and early boot | expand

Commit Message

Peng Fan July 24, 2020, 8:08 a.m. UTC
Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to control M4.
But currently i.MX8QM/QXP/7ULP not added, so still check regmap
when start/stop to avoid unhappy things.

Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/remoteproc/imx_rproc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Mathieu Poirier Aug. 11, 2020, 10:40 p.m. UTC | #1
On Fri, Jul 24, 2020 at 04:08:07PM +0800, Peng Fan wrote:
> Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to control M4.
> But currently i.MX8QM/QXP/7ULP not added, so still check regmap
> when start/stop to avoid unhappy things.
> 
> Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 82594a800a1b..4fad5c0b1c05 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -162,6 +162,9 @@ static int imx_rproc_start(struct rproc *rproc)
>  	struct device *dev = priv->dev;
>  	int ret;
>  
> +	if (!priv->regmap)
> +		return -EOPNOTSUPP;

Proceeding this way is hard to maintain.  I would perfer to add specific
operations based on the scenario or coprocessor we are working with.

> +
>  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
>  				 dcfg->src_mask, dcfg->src_start);
>  	if (ret)
> @@ -177,6 +180,9 @@ static int imx_rproc_stop(struct rproc *rproc)
>  	struct device *dev = priv->dev;
>  	int ret;
>  
> +	if (!priv->regmap)
> +		return -EOPNOTSUPP;
> +
>  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
>  				 dcfg->src_mask, dcfg->src_stop);
>  	if (ret)
> @@ -325,9 +331,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
>  	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
>  	if (IS_ERR(regmap)) {
>  		dev_err(dev, "failed to find syscon\n");
> -		return PTR_ERR(regmap);
> +		regmap = NULL;
> +	} else {
> +		regmap_attach_dev(dev, regmap, &config);

Here you are altering how all the existing implemenation are currently working.
Add a new field to imx_rproc_dcfg and based on that, determine if a regmap is
mandatory or not.

>  	}
> -	regmap_attach_dev(dev, regmap, &config);
>  
>  	/* set some other name then imx */
>  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> -- 
> 2.16.4
>
Mathieu Poirier Aug. 18, 2020, 9:43 p.m. UTC | #2
Hi Peng,

On Fri, Jul 24, 2020 at 04:08:07PM +0800, Peng Fan wrote:
> Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to control M4.
> But currently i.MX8QM/QXP/7ULP not added, so still check regmap
> when start/stop to avoid unhappy things.

On the i.MX8QM/QXP/7ULP processors, the remote processors are not handled by the
remoteproc cores, as implemented in this patch.  In such a scenario how does the
remoteproc core know the remote processor has crashed and how does it recover
from such a condition?

Thanks,
Mathieu

> 
> Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/remoteproc/imx_rproc.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 82594a800a1b..4fad5c0b1c05 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -162,6 +162,9 @@ static int imx_rproc_start(struct rproc *rproc)
>  	struct device *dev = priv->dev;
>  	int ret;
>  
> +	if (!priv->regmap)
> +		return -EOPNOTSUPP;
> +
>  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
>  				 dcfg->src_mask, dcfg->src_start);
>  	if (ret)
> @@ -177,6 +180,9 @@ static int imx_rproc_stop(struct rproc *rproc)
>  	struct device *dev = priv->dev;
>  	int ret;
>  
> +	if (!priv->regmap)
> +		return -EOPNOTSUPP;
> +
>  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
>  				 dcfg->src_mask, dcfg->src_stop);
>  	if (ret)
> @@ -325,9 +331,10 @@ static int imx_rproc_probe(struct platform_device *pdev)
>  	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
>  	if (IS_ERR(regmap)) {
>  		dev_err(dev, "failed to find syscon\n");
> -		return PTR_ERR(regmap);
> +		regmap = NULL;
> +	} else {
> +		regmap_attach_dev(dev, regmap, &config);
>  	}
> -	regmap_attach_dev(dev, regmap, &config);
>  
>  	/* set some other name then imx */
>  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> -- 
> 2.16.4
>
Peng Fan Aug. 19, 2020, 12:51 a.m. UTC | #3
> Subject: Re: [PATCH 04/10] remoteproc: imx_rproc: make syscon optional
> 
> Hi Peng,
> 
> On Fri, Jul 24, 2020 at 04:08:07PM +0800, Peng Fan wrote:
> > Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to control
> M4.
> > But currently i.MX8QM/QXP/7ULP not added, so still check regmap when
> > start/stop to avoid unhappy things.
> 
> On the i.MX8QM/QXP/7ULP processors, the remote processors are not
> handled by the remoteproc cores, as implemented in this patch.  In such a
> scenario how does the remoteproc core know the remote processor has
> crashed and how does it recover from such a condition?

For 7ULP dual boot case, A7 is under control of M4, so if m4 crash, I suppose
A7 would not work properly.

For 8QM/QXP partition case, M4 is in a standalone partition, if M4 crash or
reboot, the system controller unit will restart M4 and notify Acore that M4
restart.

Thanks,
Peng.

> 
> Thanks,
> Mathieu
> 
> >
> > Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > ---
> >  drivers/remoteproc/imx_rproc.c | 11 +++++++++--
> >  1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/remoteproc/imx_rproc.c
> > b/drivers/remoteproc/imx_rproc.c index 82594a800a1b..4fad5c0b1c05
> > 100644
> > --- a/drivers/remoteproc/imx_rproc.c
> > +++ b/drivers/remoteproc/imx_rproc.c
> > @@ -162,6 +162,9 @@ static int imx_rproc_start(struct rproc *rproc)
> >  	struct device *dev = priv->dev;
> >  	int ret;
> >
> > +	if (!priv->regmap)
> > +		return -EOPNOTSUPP;
> > +
> >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> >  				 dcfg->src_mask, dcfg->src_start);
> >  	if (ret)
> > @@ -177,6 +180,9 @@ static int imx_rproc_stop(struct rproc *rproc)
> >  	struct device *dev = priv->dev;
> >  	int ret;
> >
> > +	if (!priv->regmap)
> > +		return -EOPNOTSUPP;
> > +
> >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> >  				 dcfg->src_mask, dcfg->src_stop);
> >  	if (ret)
> > @@ -325,9 +331,10 @@ static int imx_rproc_probe(struct platform_device
> *pdev)
> >  	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> >  	if (IS_ERR(regmap)) {
> >  		dev_err(dev, "failed to find syscon\n");
> > -		return PTR_ERR(regmap);
> > +		regmap = NULL;
> > +	} else {
> > +		regmap_attach_dev(dev, regmap, &config);
> >  	}
> > -	regmap_attach_dev(dev, regmap, &config);
> >
> >  	/* set some other name then imx */
> >  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> > --
> > 2.16.4
> >
Mathieu Poirier Aug. 19, 2020, 7:45 p.m. UTC | #4
On Wed, Aug 19, 2020 at 12:51:27AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH 04/10] remoteproc: imx_rproc: make syscon optional
> > 
> > Hi Peng,
> > 
> > On Fri, Jul 24, 2020 at 04:08:07PM +0800, Peng Fan wrote:
> > > Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to control
> > M4.
> > > But currently i.MX8QM/QXP/7ULP not added, so still check regmap when
> > > start/stop to avoid unhappy things.
> > 
> > On the i.MX8QM/QXP/7ULP processors, the remote processors are not
> > handled by the remoteproc cores, as implemented in this patch.  In such a
> > scenario how does the remoteproc core know the remote processor has
> > crashed and how does it recover from such a condition?
> 
> For 7ULP dual boot case, A7 is under control of M4, so if m4 crash, I suppose
> A7 would not work properly.

In that case I assume the whole system gets rebooted, which puts the A7 in a
state where it can "attach" with the M4 again.

> 
> For 8QM/QXP partition case, M4 is in a standalone partition, if M4 crash or
> reboot, the system controller unit will restart M4 and notify Acore that M4
> restart.

And how does that notification work exactly?  Does rproc_report_crash() get
called somewhere in that process in order for the remoteproc core to attach to
the M4 again?

Many thanks for the help,
Mathieu

> 
> Thanks,
> Peng.
> 
> > 
> > Thanks,
> > Mathieu
> > 
> > >
> > > Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > ---
> > >  drivers/remoteproc/imx_rproc.c | 11 +++++++++--
> > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/remoteproc/imx_rproc.c
> > > b/drivers/remoteproc/imx_rproc.c index 82594a800a1b..4fad5c0b1c05
> > > 100644
> > > --- a/drivers/remoteproc/imx_rproc.c
> > > +++ b/drivers/remoteproc/imx_rproc.c
> > > @@ -162,6 +162,9 @@ static int imx_rproc_start(struct rproc *rproc)
> > >  	struct device *dev = priv->dev;
> > >  	int ret;
> > >
> > > +	if (!priv->regmap)
> > > +		return -EOPNOTSUPP;
> > > +
> > >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > >  				 dcfg->src_mask, dcfg->src_start);
> > >  	if (ret)
> > > @@ -177,6 +180,9 @@ static int imx_rproc_stop(struct rproc *rproc)
> > >  	struct device *dev = priv->dev;
> > >  	int ret;
> > >
> > > +	if (!priv->regmap)
> > > +		return -EOPNOTSUPP;
> > > +
> > >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > >  				 dcfg->src_mask, dcfg->src_stop);
> > >  	if (ret)
> > > @@ -325,9 +331,10 @@ static int imx_rproc_probe(struct platform_device
> > *pdev)
> > >  	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> > >  	if (IS_ERR(regmap)) {
> > >  		dev_err(dev, "failed to find syscon\n");
> > > -		return PTR_ERR(regmap);
> > > +		regmap = NULL;
> > > +	} else {
> > > +		regmap_attach_dev(dev, regmap, &config);
> > >  	}
> > > -	regmap_attach_dev(dev, regmap, &config);
> > >
> > >  	/* set some other name then imx */
> > >  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> > > --
> > > 2.16.4
> > >
Peng Fan Aug. 20, 2020, 2:04 a.m. UTC | #5
> Subject: Re: [PATCH 04/10] remoteproc: imx_rproc: make syscon optional
> 
> On Wed, Aug 19, 2020 at 12:51:27AM +0000, Peng Fan wrote:
> > > Subject: Re: [PATCH 04/10] remoteproc: imx_rproc: make syscon
> > > optional
> > >
> > > Hi Peng,
> > >
> > > On Fri, Jul 24, 2020 at 04:08:07PM +0800, Peng Fan wrote:
> > > > Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to
> > > > control
> > > M4.
> > > > But currently i.MX8QM/QXP/7ULP not added, so still check regmap
> > > > when start/stop to avoid unhappy things.
> > >
> > > On the i.MX8QM/QXP/7ULP processors, the remote processors are not
> > > handled by the remoteproc cores, as implemented in this patch.  In
> > > such a scenario how does the remoteproc core know the remote
> > > processor has crashed and how does it recover from such a condition?
> >
> > For 7ULP dual boot case, A7 is under control of M4, so if m4 crash, I
> > suppose
> > A7 would not work properly.
> 
> In that case I assume the whole system gets rebooted, which puts the A7 in a
> state where it can "attach" with the M4 again.

Yes. Whole system get rebooted.

> 
> >
> > For 8QM/QXP partition case, M4 is in a standalone partition, if M4
> > crash or reboot, the system controller unit will restart M4 and notify
> > Acore that M4 restart.
> 
> And how does that notification work exactly?  Does rproc_report_crash() get
> called somewhere in that process in order for the remoteproc core to attach
> to the M4 again?

Yes. We registered a interrupt notification handler with system controller unit.
When M4 rebooted, the system controller will raise interrupt to A53 core.
Then the notification callback will be invoked, the callback will call
rproc_report_crash. I not included this part code in the patchset, since
this patchset is to add initial support for 8M case.

Thanks,
Peng.

> 
> Many thanks for the help,
> Mathieu
> 
> >
> > Thanks,
> > Peng.
> >
> > >
> > > Thanks,
> > > Mathieu
> > >
> > > >
> > > > Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > > ---
> > > >  drivers/remoteproc/imx_rproc.c | 11 +++++++++--
> > > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/remoteproc/imx_rproc.c
> > > > b/drivers/remoteproc/imx_rproc.c index 82594a800a1b..4fad5c0b1c05
> > > > 100644
> > > > --- a/drivers/remoteproc/imx_rproc.c
> > > > +++ b/drivers/remoteproc/imx_rproc.c
> > > > @@ -162,6 +162,9 @@ static int imx_rproc_start(struct rproc *rproc)
> > > >  	struct device *dev = priv->dev;
> > > >  	int ret;
> > > >
> > > > +	if (!priv->regmap)
> > > > +		return -EOPNOTSUPP;
> > > > +
> > > >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > > >  				 dcfg->src_mask, dcfg->src_start);
> > > >  	if (ret)
> > > > @@ -177,6 +180,9 @@ static int imx_rproc_stop(struct rproc *rproc)
> > > >  	struct device *dev = priv->dev;
> > > >  	int ret;
> > > >
> > > > +	if (!priv->regmap)
> > > > +		return -EOPNOTSUPP;
> > > > +
> > > >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > > >  				 dcfg->src_mask, dcfg->src_stop);
> > > >  	if (ret)
> > > > @@ -325,9 +331,10 @@ static int imx_rproc_probe(struct
> > > > platform_device
> > > *pdev)
> > > >  	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> > > >  	if (IS_ERR(regmap)) {
> > > >  		dev_err(dev, "failed to find syscon\n");
> > > > -		return PTR_ERR(regmap);
> > > > +		regmap = NULL;
> > > > +	} else {
> > > > +		regmap_attach_dev(dev, regmap, &config);
> > > >  	}
> > > > -	regmap_attach_dev(dev, regmap, &config);
> > > >
> > > >  	/* set some other name then imx */
> > > >  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> > > > --
> > > > 2.16.4
> > > >
Mathieu Poirier Aug. 20, 2020, 7:27 p.m. UTC | #6
On Thu, Aug 20, 2020 at 02:04:10AM +0000, Peng Fan wrote:
> > Subject: Re: [PATCH 04/10] remoteproc: imx_rproc: make syscon optional
> > 
> > On Wed, Aug 19, 2020 at 12:51:27AM +0000, Peng Fan wrote:
> > > > Subject: Re: [PATCH 04/10] remoteproc: imx_rproc: make syscon
> > > > optional
> > > >
> > > > Hi Peng,
> > > >
> > > > On Fri, Jul 24, 2020 at 04:08:07PM +0800, Peng Fan wrote:
> > > > > Make syscon optional, since i.MX8QM/QXP/7ULP not have SRC to
> > > > > control
> > > > M4.
> > > > > But currently i.MX8QM/QXP/7ULP not added, so still check regmap
> > > > > when start/stop to avoid unhappy things.
> > > >
> > > > On the i.MX8QM/QXP/7ULP processors, the remote processors are not
> > > > handled by the remoteproc cores, as implemented in this patch.  In
> > > > such a scenario how does the remoteproc core know the remote
> > > > processor has crashed and how does it recover from such a condition?
> > >
> > > For 7ULP dual boot case, A7 is under control of M4, so if m4 crash, I
> > > suppose
> > > A7 would not work properly.
> > 
> > In that case I assume the whole system gets rebooted, which puts the A7 in a
> > state where it can "attach" with the M4 again.
> 
> Yes. Whole system get rebooted.
> 
> > 
> > >
> > > For 8QM/QXP partition case, M4 is in a standalone partition, if M4
> > > crash or reboot, the system controller unit will restart M4 and notify
> > > Acore that M4 restart.
> > 
> > And how does that notification work exactly?  Does rproc_report_crash() get
> > called somewhere in that process in order for the remoteproc core to attach
> > to the M4 again?
> 
> Yes. We registered a interrupt notification handler with system controller unit.
> When M4 rebooted, the system controller will raise interrupt to A53 core.
> Then the notification callback will be invoked, the callback will call
> rproc_report_crash. I not included this part code in the patchset, since
> this patchset is to add initial support for 8M case.

All this information is really appreciated.

> 
> Thanks,
> Peng.
> 
> > 
> > Many thanks for the help,
> > Mathieu
> > 
> > >
> > > Thanks,
> > > Peng.
> > >
> > > >
> > > > Thanks,
> > > > Mathieu
> > > >
> > > > >
> > > > > Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> > > > > Signed-off-by: Peng Fan <peng.fan@nxp.com>
> > > > > ---
> > > > >  drivers/remoteproc/imx_rproc.c | 11 +++++++++--
> > > > >  1 file changed, 9 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/drivers/remoteproc/imx_rproc.c
> > > > > b/drivers/remoteproc/imx_rproc.c index 82594a800a1b..4fad5c0b1c05
> > > > > 100644
> > > > > --- a/drivers/remoteproc/imx_rproc.c
> > > > > +++ b/drivers/remoteproc/imx_rproc.c
> > > > > @@ -162,6 +162,9 @@ static int imx_rproc_start(struct rproc *rproc)
> > > > >  	struct device *dev = priv->dev;
> > > > >  	int ret;
> > > > >
> > > > > +	if (!priv->regmap)
> > > > > +		return -EOPNOTSUPP;
> > > > > +
> > > > >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > > > >  				 dcfg->src_mask, dcfg->src_start);
> > > > >  	if (ret)
> > > > > @@ -177,6 +180,9 @@ static int imx_rproc_stop(struct rproc *rproc)
> > > > >  	struct device *dev = priv->dev;
> > > > >  	int ret;
> > > > >
> > > > > +	if (!priv->regmap)
> > > > > +		return -EOPNOTSUPP;
> > > > > +
> > > > >  	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
> > > > >  				 dcfg->src_mask, dcfg->src_stop);
> > > > >  	if (ret)
> > > > > @@ -325,9 +331,10 @@ static int imx_rproc_probe(struct
> > > > > platform_device
> > > > *pdev)
> > > > >  	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
> > > > >  	if (IS_ERR(regmap)) {
> > > > >  		dev_err(dev, "failed to find syscon\n");
> > > > > -		return PTR_ERR(regmap);
> > > > > +		regmap = NULL;
> > > > > +	} else {
> > > > > +		regmap_attach_dev(dev, regmap, &config);
> > > > >  	}
> > > > > -	regmap_attach_dev(dev, regmap, &config);
> > > > >
> > > > >  	/* set some other name then imx */
> > > > >  	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,
> > > > > --
> > > > > 2.16.4
> > > > >
diff mbox series

Patch

diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
index 82594a800a1b..4fad5c0b1c05 100644
--- a/drivers/remoteproc/imx_rproc.c
+++ b/drivers/remoteproc/imx_rproc.c
@@ -162,6 +162,9 @@  static int imx_rproc_start(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (!priv->regmap)
+		return -EOPNOTSUPP;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_start);
 	if (ret)
@@ -177,6 +180,9 @@  static int imx_rproc_stop(struct rproc *rproc)
 	struct device *dev = priv->dev;
 	int ret;
 
+	if (!priv->regmap)
+		return -EOPNOTSUPP;
+
 	ret = regmap_update_bits(priv->regmap, dcfg->src_reg,
 				 dcfg->src_mask, dcfg->src_stop);
 	if (ret)
@@ -325,9 +331,10 @@  static int imx_rproc_probe(struct platform_device *pdev)
 	regmap = syscon_regmap_lookup_by_phandle(np, "syscon");
 	if (IS_ERR(regmap)) {
 		dev_err(dev, "failed to find syscon\n");
-		return PTR_ERR(regmap);
+		regmap = NULL;
+	} else {
+		regmap_attach_dev(dev, regmap, &config);
 	}
-	regmap_attach_dev(dev, regmap, &config);
 
 	/* set some other name then imx */
 	rproc = rproc_alloc(dev, "imx-rproc", &imx_rproc_ops,