linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: stm32: fix probe error case
@ 2019-10-04 12:02 Fabien Dessenne
  2019-10-05  4:03 ` Bjorn Andersson
  0 siblings, 1 reply; 2+ messages in thread
From: Fabien Dessenne @ 2019-10-04 12:02 UTC (permalink / raw)
  To: Maxime Coquelin, Alexandre Torgue, Ohad Ben-Cohen,
	Bjorn Andersson, linux-stm32, linux-arm-kernel, linux-kernel,
	linux-remoteproc
  Cc: Fabien Dessenne, Loic Pallardy, Arnaud Pouliquen

If the rproc driver is probed before the mailbox driver and if the rproc
Device Tree node has some mailbox properties, the rproc driver probe
shall be deferred instead of being probed without mailbox support.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
---
 drivers/remoteproc/stm32_rproc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
index 2cf4b29..410b794 100644
--- a/drivers/remoteproc/stm32_rproc.c
+++ b/drivers/remoteproc/stm32_rproc.c
@@ -310,7 +310,7 @@ static const struct stm32_mbox stm32_rproc_mbox[MBOX_NB_MBX] = {
 	}
 };
 
-static void stm32_rproc_request_mbox(struct rproc *rproc)
+static int stm32_rproc_request_mbox(struct rproc *rproc)
 {
 	struct stm32_rproc *ddata = rproc->priv;
 	struct device *dev = &rproc->dev;
@@ -328,11 +328,15 @@ static void stm32_rproc_request_mbox(struct rproc *rproc)
 		cl->dev = dev->parent;
 
 		ddata->mb[i].chan = mbox_request_channel_byname(cl, name);
-		if (IS_ERR(ddata->mb[i].chan)) {
+		if (PTR_ERR(ddata->mb[i].chan) == -EPROBE_DEFER) {
+			return -EPROBE_DEFER;
+		} else if (IS_ERR(ddata->mb[i].chan)) {
 			dev_warn(dev, "cannot get %s mbox\n", name);
 			ddata->mb[i].chan = NULL;
 		}
 	}
+
+	return 0;
 }
 
 static int stm32_rproc_set_hold_boot(struct rproc *rproc, bool hold)
@@ -596,7 +600,9 @@ static int stm32_rproc_probe(struct platform_device *pdev)
 	if (ret)
 		goto free_rproc;
 
-	stm32_rproc_request_mbox(rproc);
+	ret = stm32_rproc_request_mbox(rproc);
+	if (ret)
+		goto free_rproc;
 
 	ret = rproc_add(rproc);
 	if (ret)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] remoteproc: stm32: fix probe error case
  2019-10-04 12:02 [PATCH] remoteproc: stm32: fix probe error case Fabien Dessenne
@ 2019-10-05  4:03 ` Bjorn Andersson
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Andersson @ 2019-10-05  4:03 UTC (permalink / raw)
  To: Fabien Dessenne
  Cc: Maxime Coquelin, Alexandre Torgue, Ohad Ben-Cohen, linux-stm32,
	linux-arm-kernel, linux-kernel, linux-remoteproc, Loic Pallardy,
	Arnaud Pouliquen

On Fri 04 Oct 05:02 PDT 2019, Fabien Dessenne wrote:

> If the rproc driver is probed before the mailbox driver and if the rproc
> Device Tree node has some mailbox properties, the rproc driver probe
> shall be deferred instead of being probed without mailbox support.
> 
> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
> ---
>  drivers/remoteproc/stm32_rproc.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c
> index 2cf4b29..410b794 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -310,7 +310,7 @@ static const struct stm32_mbox stm32_rproc_mbox[MBOX_NB_MBX] = {
>  	}
>  };
>  
> -static void stm32_rproc_request_mbox(struct rproc *rproc)
> +static int stm32_rproc_request_mbox(struct rproc *rproc)
>  {
>  	struct stm32_rproc *ddata = rproc->priv;
>  	struct device *dev = &rproc->dev;
> @@ -328,11 +328,15 @@ static void stm32_rproc_request_mbox(struct rproc *rproc)
>  		cl->dev = dev->parent;
>  
>  		ddata->mb[i].chan = mbox_request_channel_byname(cl, name);
> -		if (IS_ERR(ddata->mb[i].chan)) {
> +		if (PTR_ERR(ddata->mb[i].chan) == -EPROBE_DEFER) {

You may not use PTR_ERR() without first checking IS_ERR(), apart from
that your patch looks good.

Regards,
Bjorn

> +			return -EPROBE_DEFER;
> +		} else if (IS_ERR(ddata->mb[i].chan)) {
>  			dev_warn(dev, "cannot get %s mbox\n", name);
>  			ddata->mb[i].chan = NULL;
>  		}
>  	}
> +
> +	return 0;
>  }
>  
>  static int stm32_rproc_set_hold_boot(struct rproc *rproc, bool hold)
> @@ -596,7 +600,9 @@ static int stm32_rproc_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto free_rproc;
>  
> -	stm32_rproc_request_mbox(rproc);
> +	ret = stm32_rproc_request_mbox(rproc);
> +	if (ret)
> +		goto free_rproc;
>  
>  	ret = rproc_add(rproc);
>  	if (ret)
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-05  4:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-04 12:02 [PATCH] remoteproc: stm32: fix probe error case Fabien Dessenne
2019-10-05  4:03 ` Bjorn Andersson

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).