Skip to content

Commit 9116015

Browse files
diandersandersson
authored andcommitted
soc: qcom: rpmh-rsc: Timeout after 1 second in write_tcs_reg_sync()
If our data still isn't there after 1 second, shout and give up. Reported-by: Joe Perches <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Link: https://lore.kernel.org/r/20200415095953.v3.2.I8550512081c89ec7a545018a7d2d9418a27c1a7a@changeid Signed-off-by: Bjorn Andersson <[email protected]>
1 parent faa0c1f commit 9116015

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

drivers/soc/qcom/rpmh-rsc.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/delay.h>
1111
#include <linux/interrupt.h>
1212
#include <linux/io.h>
13+
#include <linux/iopoll.h>
1314
#include <linux/kernel.h>
1415
#include <linux/list.h>
1516
#include <linux/module.h>
@@ -175,12 +176,13 @@ static void write_tcs_reg(const struct rsc_drv *drv, int reg, int tcs_id,
175176
static void write_tcs_reg_sync(const struct rsc_drv *drv, int reg, int tcs_id,
176177
u32 data)
177178
{
179+
u32 new_data;
180+
178181
writel(data, tcs_reg_addr(drv, reg, tcs_id));
179-
for (;;) {
180-
if (data == readl(tcs_reg_addr(drv, reg, tcs_id)))
181-
break;
182-
udelay(1);
183-
}
182+
if (readl_poll_timeout_atomic(tcs_reg_addr(drv, reg, tcs_id), new_data,
183+
new_data == data, 1, USEC_PER_SEC))
184+
pr_err("%s: error writing %#x to %d:%#x\n", drv->name,
185+
data, tcs_id, reg);
184186
}
185187

186188
/**

0 commit comments

Comments
 (0)