From 84235bf07c23c768c6f425c8239fc7186388c555 Mon Sep 17 00:00:00 2001 From: Fei Li Date: Tue, 3 Aug 2021 11:23:57 +0800 Subject: [PATCH] hv: vtd: a minor refine about dmar_wait_completion Check whether condition is met before check whether time is out after iommu_read32. This is because iommu_read32 would cause time out on some virtual platform in spite of the current DMAR status meets the pre_condition. Tracked-On: #6371 Signed-off-by: Fei Li Acked-by: Eddie Dong --- hypervisor/arch/x86/vtd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index 961439b0b..75e86bb45 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -251,10 +251,9 @@ static inline void dmar_wait_completion(const struct dmar_drhd_rt *dmar_unit, ui __unused uint64_t start = cpu_ticks(); do { - *status = iommu_read32(dmar_unit, offset); - ASSERT(((cpu_ticks() - start) < TICKS_PER_MS), - "DMAR OP Timeout!"); + ASSERT(((cpu_ticks() - start) < TICKS_PER_MS), "DMAR OP Timeout!"); asm_pause(); + *status = iommu_read32(dmar_unit, offset); } while( (*status & mask) == pre_condition); }