Linux Renesas SOC kernel development
 help / color / mirror / Atom feed
* [PATCH v4] iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic()
@ 2023-07-17 13:14 Geert Uytterhoeven
  2023-08-07 12:26 ` Joerg Roedel
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2023-07-17 13:14 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Robin Murphy, Yoshihiro Shimoda
  Cc: iommu, linux-renesas-soc, Geert Uytterhoeven

Use read_poll_timeout_atomic() instead of open-coding the same
operation.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v4:
  - Split off from series [1], as all dependencies and other patches
    from that series are now in v6.5-rc1,

v3:
  - New.

[1] "[PATCH v3 0/7] iopoll: Busy loop and timeout improvements + conversions"
    https://lore.kernel.org/r/dd0ba3ebc63a4b2ef1b59b798a0a7ef445af4b3b.1685692810.git.geert+renesas@glider.be
---
 drivers/iommu/ipmmu-vmsa.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 9f64c5c9f5b90ace..3b58a8ea3bdef190 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/io-pgtable.h>
 #include <linux/iommu.h>
 #include <linux/of.h>
@@ -253,17 +254,13 @@ static void ipmmu_imuctr_write(struct ipmmu_vmsa_device *mmu,
 /* Wait for any pending TLB invalidations to complete */
 static void ipmmu_tlb_sync(struct ipmmu_vmsa_domain *domain)
 {
-	unsigned int count = 0;
+	u32 val;
 
-	while (ipmmu_ctx_read_root(domain, IMCTR) & IMCTR_FLUSH) {
-		cpu_relax();
-		if (++count == TLB_LOOP_TIMEOUT) {
-			dev_err_ratelimited(domain->mmu->dev,
+	if (read_poll_timeout_atomic(ipmmu_ctx_read_root, val,
+				     !(val & IMCTR_FLUSH), 1, TLB_LOOP_TIMEOUT,
+				     false, domain, IMCTR))
+		dev_err_ratelimited(domain->mmu->dev,
 			"TLB sync timed out -- MMU may be deadlocked\n");
-			return;
-		}
-		udelay(1);
-	}
 }
 
 static void ipmmu_tlb_invalidate(struct ipmmu_vmsa_domain *domain)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic()
  2023-07-17 13:14 [PATCH v4] iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic() Geert Uytterhoeven
@ 2023-08-07 12:26 ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2023-08-07 12:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Will Deacon, Robin Murphy, Yoshihiro Shimoda, iommu,
	linux-renesas-soc

On Mon, Jul 17, 2023 at 03:14:40PM +0200, Geert Uytterhoeven wrote:
>  drivers/iommu/ipmmu-vmsa.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-07 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 13:14 [PATCH v4] iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic() Geert Uytterhoeven
2023-08-07 12:26 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox