Skip to content

Commit aedd11e

Browse files
geertujoergroedel
authored andcommitted
iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic()
Use read_poll_timeout_atomic() instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/649c7e09841b998c5c8d7fc274884a85e4b5bfe9.1689599528.git.geert+renesas@glider.be Signed-off-by: Joerg Roedel <[email protected]>
1 parent 06c2afb commit aedd11e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

drivers/iommu/ipmmu-vmsa.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/init.h>
1515
#include <linux/interrupt.h>
1616
#include <linux/io.h>
17+
#include <linux/iopoll.h>
1718
#include <linux/io-pgtable.h>
1819
#include <linux/iommu.h>
1920
#include <linux/of.h>
@@ -253,17 +254,13 @@ static void ipmmu_imuctr_write(struct ipmmu_vmsa_device *mmu,
253254
/* Wait for any pending TLB invalidations to complete */
254255
static void ipmmu_tlb_sync(struct ipmmu_vmsa_domain *domain)
255256
{
256-
unsigned int count = 0;
257+
u32 val;
257258

258-
while (ipmmu_ctx_read_root(domain, IMCTR) & IMCTR_FLUSH) {
259-
cpu_relax();
260-
if (++count == TLB_LOOP_TIMEOUT) {
261-
dev_err_ratelimited(domain->mmu->dev,
259+
if (read_poll_timeout_atomic(ipmmu_ctx_read_root, val,
260+
!(val & IMCTR_FLUSH), 1, TLB_LOOP_TIMEOUT,
261+
false, domain, IMCTR))
262+
dev_err_ratelimited(domain->mmu->dev,
262263
"TLB sync timed out -- MMU may be deadlocked\n");
263-
return;
264-
}
265-
udelay(1);
266-
}
267264
}
268265

269266
static void ipmmu_tlb_invalidate(struct ipmmu_vmsa_domain *domain)

0 commit comments

Comments
 (0)