Skip to content

Commit 9b45a77

Browse files
committed
iommu/amd: Fix loop timeout issue in iommu_ga_log_enable()
The polling loop for the register change in iommu_ga_log_enable() needs to have a udelay() in it. Otherwise the CPU might be faster than the IOMMU hardware and wrongly trigger the WARN_ON() further down the code stream. Use a 10us for udelay(), has there is some hardware where activation of the GA log can take more than a 100ms. A future optimization should move the activation check of the GA log to the point where it gets used for the first time. But that is a bigger change and not suitable for a fix. Fixes: 8bda0cf ("iommu/amd: Detect and initialize guest vAPIC log") Signed-off-by: Joerg Roedel <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 99e675d commit 9b45a77

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/iommu/amd/init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/export.h>
2222
#include <linux/kmemleak.h>
2323
#include <linux/cc_platform.h>
24+
#include <linux/iopoll.h>
2425
#include <asm/pci-direct.h>
2526
#include <asm/iommu.h>
2627
#include <asm/apic.h>
@@ -834,6 +835,7 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
834835
status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET);
835836
if (status & (MMIO_STATUS_GALOG_RUN_MASK))
836837
break;
838+
udelay(10);
837839
}
838840

839841
if (WARN_ON(i >= LOOP_TIMEOUT))

0 commit comments

Comments
 (0)