git: f776a2b84972 - main - dmar_qi_XXX_invalidate_glob(): reduce code duplication
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Sep 2024 21:50:42 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f776a2b849726e7b86735b2930be64f5a2edf731 commit f776a2b849726e7b86735b2930be64f5a2edf731 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-06-09 17:24:31 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-09-04 21:50:18 +0000 dmar_qi_XXX_invalidate_glob(): reduce code duplication Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/x86/iommu/intel_qi.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/sys/x86/iommu/intel_qi.c b/sys/x86/iommu/intel_qi.c index a94fbb54e7f7..b474d695552f 100644 --- a/sys/x86/iommu/intel_qi.c +++ b/sys/x86/iommu/intel_qi.c @@ -195,14 +195,14 @@ dmar_qi_invalidate_emit(struct iommu_domain *idomain, iommu_gaddr_t base, iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), pseq, emit_wait); } -void -dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit) +static void +dmar_qi_invalidate_glob_impl(struct dmar_unit *unit, uint64_t data1) { struct iommu_qi_genseq gseq; DMAR_ASSERT_LOCKED(unit); dmar_qi_ensure(DMAR2IOMMU(unit), 2); - dmar_qi_emit(unit, DMAR_IQ_DESCR_CTX_INV | DMAR_IQ_DESCR_CTX_GLOB, 0); + dmar_qi_emit(unit, data1, 0); iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), &gseq, true); /* See dmar_qi_invalidate_sync(). */ unit->x86c.inv_seq_waiters++; @@ -211,34 +211,24 @@ dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit) } void -dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit) +dmar_qi_invalidate_ctx_glob_locked(struct dmar_unit *unit) { - struct iommu_qi_genseq gseq; + dmar_qi_invalidate_glob_impl(unit, DMAR_IQ_DESCR_CTX_INV | + DMAR_IQ_DESCR_CTX_GLOB); +} - DMAR_ASSERT_LOCKED(unit); - dmar_qi_ensure(DMAR2IOMMU(unit), 2); - dmar_qi_emit(unit, DMAR_IQ_DESCR_IOTLB_INV | DMAR_IQ_DESCR_IOTLB_GLOB | - DMAR_IQ_DESCR_IOTLB_DW | DMAR_IQ_DESCR_IOTLB_DR, 0); - iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), &gseq, true); - /* See dmar_qi_invalidate_sync(). */ - unit->x86c.inv_seq_waiters++; - dmar_qi_advance_tail(DMAR2IOMMU(unit)); - iommu_qi_wait_for_seq(DMAR2IOMMU(unit), &gseq, false); +void +dmar_qi_invalidate_iotlb_glob_locked(struct dmar_unit *unit) +{ + dmar_qi_invalidate_glob_impl(unit, DMAR_IQ_DESCR_IOTLB_INV | + DMAR_IQ_DESCR_IOTLB_GLOB | DMAR_IQ_DESCR_IOTLB_DW | + DMAR_IQ_DESCR_IOTLB_DR); } void dmar_qi_invalidate_iec_glob(struct dmar_unit *unit) { - struct iommu_qi_genseq gseq; - - DMAR_ASSERT_LOCKED(unit); - dmar_qi_ensure(DMAR2IOMMU(unit), 2); - dmar_qi_emit(unit, DMAR_IQ_DESCR_IEC_INV, 0); - iommu_qi_emit_wait_seq(DMAR2IOMMU(unit), &gseq, true); - /* See dmar_qi_invalidate_sync(). */ - unit->x86c.inv_seq_waiters++; - dmar_qi_advance_tail(DMAR2IOMMU(unit)); - iommu_qi_wait_for_seq(DMAR2IOMMU(unit), &gseq, false); + dmar_qi_invalidate_glob_impl(unit, DMAR_IQ_DESCR_IEC_INV); } void