Skip to content

Commit a0c446d

Browse files
Dawei LiKAGA-KOKO
authored andcommitted
irqchip/gic-v3: Use readl_relaxed_poll_timeout_atomic()
Replace the open coded register polling loop with readl_relaxed_poll_timeout_atomic() which provides the same functionality. Signed-off-by: Dawei Li <dawei.li@shingroup.cn> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/r/20240122085716.2999875-2-dawei.li@shingroup.cn
1 parent b184c8c commit a0c446d

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

drivers/irqchip/irq-gic-v3.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/percpu.h>
2020
#include <linux/refcount.h>
2121
#include <linux/slab.h>
22+
#include <linux/iopoll.h>
2223

2324
#include <linux/irqchip.h>
2425
#include <linux/irqchip/arm-gic-common.h>
@@ -251,17 +252,13 @@ static inline void __iomem *gic_dist_base(struct irq_data *d)
251252

252253
static void gic_do_wait_for_rwp(void __iomem *base, u32 bit)
253254
{
254-
u32 count = 1000000; /* 1s! */
255+
u32 val;
256+
int ret;
255257

256-
while (readl_relaxed(base + GICD_CTLR) & bit) {
257-
count--;
258-
if (!count) {
259-
pr_err_ratelimited("RWP timeout, gone fishing\n");
260-
return;
261-
}
262-
cpu_relax();
263-
udelay(1);
264-
}
258+
ret = readl_relaxed_poll_timeout_atomic(base + GICD_CTLR, val, !(val & bit),
259+
1, USEC_PER_SEC);
260+
if (ret == -ETIMEDOUT)
261+
pr_err_ratelimited("RWP timeout, gone fishing\n");
265262
}
266263

267264
/* Wait for completion of a distributor change */
@@ -279,8 +276,8 @@ static void gic_redist_wait_for_rwp(void)
279276
static void gic_enable_redist(bool enable)
280277
{
281278
void __iomem *rbase;
282-
u32 count = 1000000; /* 1s! */
283279
u32 val;
280+
int ret;
284281

285282
if (gic_data.flags & FLAGS_WORKAROUND_GICR_WAKER_MSM8996)
286283
return;
@@ -301,16 +298,13 @@ static void gic_enable_redist(bool enable)
301298
return; /* No PM support in this redistributor */
302299
}
303300

304-
while (--count) {
305-
val = readl_relaxed(rbase + GICR_WAKER);
306-
if (enable ^ (bool)(val & GICR_WAKER_ChildrenAsleep))
307-
break;
308-
cpu_relax();
309-
udelay(1);
310-
}
311-
if (!count)
301+
ret = readl_relaxed_poll_timeout_atomic(rbase + GICR_WAKER, val,
302+
enable ^ (bool)(val & GICR_WAKER_ChildrenAsleep),
303+
1, USEC_PER_SEC);
304+
if (ret == -ETIMEDOUT) {
312305
pr_err_ratelimited("redistributor failed to %s...\n",
313306
enable ? "wakeup" : "sleep");
307+
}
314308
}
315309

316310
/*

0 commit comments

Comments
 (0)