Commit a0c446dc authored by Dawei Li's avatar Dawei Li Committed by Thomas Gleixner

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: default avatarDawei Li <dawei.li@shingroup.cn>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20240122085716.2999875-2-dawei.li@shingroup.cn
parent b184c8c2
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/iopoll.h>
#include <linux/irqchip.h> #include <linux/irqchip.h>
#include <linux/irqchip/arm-gic-common.h> #include <linux/irqchip/arm-gic-common.h>
...@@ -251,17 +252,13 @@ static inline void __iomem *gic_dist_base(struct irq_data *d) ...@@ -251,17 +252,13 @@ static inline void __iomem *gic_dist_base(struct irq_data *d)
static void gic_do_wait_for_rwp(void __iomem *base, u32 bit) static void gic_do_wait_for_rwp(void __iomem *base, u32 bit)
{ {
u32 count = 1000000; /* 1s! */ u32 val;
int ret;
while (readl_relaxed(base + GICD_CTLR) & bit) { ret = readl_relaxed_poll_timeout_atomic(base + GICD_CTLR, val, !(val & bit),
count--; 1, USEC_PER_SEC);
if (!count) { if (ret == -ETIMEDOUT)
pr_err_ratelimited("RWP timeout, gone fishing\n"); pr_err_ratelimited("RWP timeout, gone fishing\n");
return;
}
cpu_relax();
udelay(1);
}
} }
/* Wait for completion of a distributor change */ /* Wait for completion of a distributor change */
...@@ -279,8 +276,8 @@ static void gic_redist_wait_for_rwp(void) ...@@ -279,8 +276,8 @@ static void gic_redist_wait_for_rwp(void)
static void gic_enable_redist(bool enable) static void gic_enable_redist(bool enable)
{ {
void __iomem *rbase; void __iomem *rbase;
u32 count = 1000000; /* 1s! */
u32 val; u32 val;
int ret;
if (gic_data.flags & FLAGS_WORKAROUND_GICR_WAKER_MSM8996) if (gic_data.flags & FLAGS_WORKAROUND_GICR_WAKER_MSM8996)
return; return;
...@@ -301,16 +298,13 @@ static void gic_enable_redist(bool enable) ...@@ -301,16 +298,13 @@ static void gic_enable_redist(bool enable)
return; /* No PM support in this redistributor */ return; /* No PM support in this redistributor */
} }
while (--count) { ret = readl_relaxed_poll_timeout_atomic(rbase + GICR_WAKER, val,
val = readl_relaxed(rbase + GICR_WAKER); enable ^ (bool)(val & GICR_WAKER_ChildrenAsleep),
if (enable ^ (bool)(val & GICR_WAKER_ChildrenAsleep)) 1, USEC_PER_SEC);
break; if (ret == -ETIMEDOUT) {
cpu_relax();
udelay(1);
}
if (!count)
pr_err_ratelimited("redistributor failed to %s...\n", pr_err_ratelimited("redistributor failed to %s...\n",
enable ? "wakeup" : "sleep"); enable ? "wakeup" : "sleep");
}
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment