soc: qcom: rpmh-rsc: Timeout after 1 second in write_tcs_reg_sync()
authorDouglas Anderson <dianders@chromium.org>
Wed, 15 Apr 2020 17:00:28 +0000 (10:00 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 12 May 2020 17:36:23 +0000 (10:36 -0700)
If our data still isn't there after 1 second, shout and give up.

Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20200415095953.v3.2.I8550512081c89ec7a545018a7d2d9418a27c1a7a@changeid
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/soc/qcom/rpmh-rsc.c

index ce39d83..e09d1ad 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
@@ -175,12 +176,13 @@ static void write_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id,
 static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id,
                               u32 data)
 {
+       u32 new_data;
+
        writel(data, tcs_reg_addr(drv, reg, tcs_id));
-       for (;;) {
-               if (data == readl(tcs_reg_addr(drv, reg, tcs_id)))
-                       break;
-               udelay(1);
-       }
+       if (readl_poll_timeout_atomic(tcs_reg_addr(drv, reg, tcs_id), new_data,
+                                     new_data == data, 1, USEC_PER_SEC))
+               pr_err("%s: error writing %#x to %d:%#x\n", drv->name,
+                      data, tcs_id, reg);
 }
 
 /**