diff mbox

remoteproc: wcnss: Wait for iris before starting

Message ID 1528822711-13342-1-git-send-email-loic.poulain@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Loic Poulain June 12, 2018, 4:58 p.m. UTC
wcnss_start fails when called by remoteproc before iris probing.
Fix this by adding synchronization/completion on iris assignment.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/remoteproc/qcom_wcnss.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Stephen Boyd June 18, 2018, 4:50 p.m. UTC | #1
Quoting Loic Poulain (2018-06-12 09:58:31)
> wcnss_start fails when called by remoteproc before iris probing.

Please add () to functions so we know they're functions and not
variables or something else.

> Fix this by adding synchronization/completion on iris assignment.
> 
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
>  drivers/remoteproc/qcom_wcnss.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
> index b0e07e9..e5fbf91 100644
> --- a/drivers/remoteproc/qcom_wcnss.c
> +++ b/drivers/remoteproc/qcom_wcnss.c
> @@ -86,6 +86,7 @@ struct qcom_wcnss {
>  
>         struct mutex iris_lock;
>         struct qcom_iris *iris;
> +       struct completion iris_assigned;
>  
>         struct regulator_bulk_data *vregs;
>         size_t num_vregs;
> @@ -146,6 +147,7 @@ void qcom_wcnss_assign_iris(struct qcom_wcnss *wcnss,
>  
>         wcnss->iris = iris;
>         wcnss->use_48mhz_xo = use_48mhz_xo;
> +       complete(&wcnss->iris_assigned);
>  
>         mutex_unlock(&wcnss->iris_lock);

Do you need this mutex anymore then? It looks like assign and start are
synchronized with the completion variable now.

--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
index b0e07e9..e5fbf91 100644
--- a/drivers/remoteproc/qcom_wcnss.c
+++ b/drivers/remoteproc/qcom_wcnss.c
@@ -86,6 +86,7 @@  struct qcom_wcnss {
 
 	struct mutex iris_lock;
 	struct qcom_iris *iris;
+	struct completion iris_assigned;
 
 	struct regulator_bulk_data *vregs;
 	size_t num_vregs;
@@ -146,6 +147,7 @@  void qcom_wcnss_assign_iris(struct qcom_wcnss *wcnss,
 
 	wcnss->iris = iris;
 	wcnss->use_48mhz_xo = use_48mhz_xo;
+	complete(&wcnss->iris_assigned);
 
 	mutex_unlock(&wcnss->iris_lock);
 }
@@ -221,6 +223,13 @@  static int wcnss_start(struct rproc *rproc)
 	struct qcom_wcnss *wcnss = (struct qcom_wcnss *)rproc->priv;
 	int ret;
 
+	ret = wait_for_completion_timeout(&wcnss->iris_assigned,
+					  msecs_to_jiffies(5000));
+	if (ret == 0) {
+		dev_err(wcnss->dev, "Timeout waiting for iris device\n");
+		return -ENODEV;
+	}
+
 	mutex_lock(&wcnss->iris_lock);
 	if (!wcnss->iris) {
 		dev_err(wcnss->dev, "no iris registered\n");
@@ -496,6 +505,7 @@  static int wcnss_probe(struct platform_device *pdev)
 
 	init_completion(&wcnss->start_done);
 	init_completion(&wcnss->stop_done);
+	init_completion(&wcnss->iris_assigned);
 
 	mutex_init(&wcnss->iris_lock);