From ac65898f35401e87eb61825fca0e95a26055a581 Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Thu, 18 Jun 2020 12:59:20 +0800 Subject: [PATCH] cleanup spin lock in vtd.c move dm_unit->lock into dmar_issue_qi_request Tracked-On: #4958 Signed-off-by: Mingqiang Chi --- hypervisor/arch/x86/vtd.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/vtd.c b/hypervisor/arch/x86/vtd.c index c687eabd7..87df54897 100644 --- a/hypervisor/arch/x86/vtd.c +++ b/hypervisor/arch/x86/vtd.c @@ -551,6 +551,8 @@ static void dmar_issue_qi_request(struct dmar_drhd_rt *dmar_unit, struct dmar_en uint32_t qi_status = 0U; uint64_t start; + spinlock_obtain(&(dmar_unit->lock)); + invalidate_desc_ptr = (struct dmar_entry *)(dmar_unit->qi_queue + dmar_unit->qi_tail); invalidate_desc_ptr->hi_64 = invalidate_desc.hi_64; @@ -574,6 +576,8 @@ static void dmar_issue_qi_request(struct dmar_drhd_rt *dmar_unit, struct dmar_en } asm_pause(); } + + spinlock_release(&(dmar_unit->lock)); } /* @@ -606,11 +610,7 @@ static void dmar_invalid_context_cache(struct dmar_drhd_rt *dmar_unit, } if (invalidate_desc.lo_64 != 0UL) { - spinlock_obtain(&(dmar_unit->lock)); - dmar_issue_qi_request(dmar_unit, invalidate_desc); - - spinlock_release(&(dmar_unit->lock)); } } @@ -653,11 +653,7 @@ static void dmar_invalid_iotlb(struct dmar_drhd_rt *dmar_unit, uint16_t did, uin } if (invalidate_desc.lo_64 != 0UL) { - spinlock_obtain(&(dmar_unit->lock)); - dmar_issue_qi_request(dmar_unit, invalidate_desc); - - spinlock_release(&(dmar_unit->lock)); } } @@ -708,11 +704,7 @@ static void dmar_invalid_iec(struct dmar_drhd_rt *dmar_unit, uint16_t intr_index } if (invalidate_desc.lo_64 != 0UL) { - spinlock_obtain(&(dmar_unit->lock)); - dmar_issue_qi_request(dmar_unit, invalidate_desc); - - spinlock_release(&(dmar_unit->lock)); } }