git: b7bd54e4ec5b - stable/13 - x86/iommu: Shrink the critical section in dmar_qi_task()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Aug 2022 03:22:08 UTC
The branch stable/13 has been updated by dougm:
URL: https://cgit.FreeBSD.org/src/commit/?id=b7bd54e4ec5b5f59c1651e3600dbc808ddefa316
commit b7bd54e4ec5b5f59c1651e3600dbc808ddefa316
Author: Alan Cox <alc@FreeBSD.org>
AuthorDate: 2022-07-18 00:56:39 +0000
Commit: Doug Moore <dougm@FreeBSD.org>
CommitDate: 2022-08-08 03:19:02 +0000
x86/iommu: Shrink the critical section in dmar_qi_task()
It is safe to test and clear the Invalidation Wait Descriptor
Complete flag before acquiring the DMAR lock in dmar_qi_task(),
rather than waiting until the lock is held.
Reviewed by: kib
MFC after: 2 weeks
(cherry picked from commit 4eaaacc75535befdb9894cca4e0d8da376328fa4)
---
sys/x86/iommu/intel_qi.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/sys/x86/iommu/intel_qi.c b/sys/x86/iommu/intel_qi.c
index 1400be3852e9..174cf9ea19a8 100644
--- a/sys/x86/iommu/intel_qi.c
+++ b/sys/x86/iommu/intel_qi.c
@@ -354,6 +354,16 @@ dmar_qi_task(void *arg, int pending __unused)
unit = arg;
+ /*
+ * Request an interrupt on the completion of the next invalidation
+ * wait descriptor with the IF field set.
+ */
+ ics = dmar_read4(unit, DMAR_ICS_REG);
+ if ((ics & DMAR_ICS_IWC) != 0) {
+ ics = DMAR_ICS_IWC;
+ dmar_write4(unit, DMAR_ICS_REG, ics);
+ }
+
DMAR_LOCK(unit);
for (;;) {
entry = TAILQ_FIRST(&unit->tlb_flush_entries);
@@ -366,11 +376,6 @@ dmar_qi_task(void *arg, int pending __unused)
dmar_domain_free_entry(entry, true);
DMAR_LOCK(unit);
}
- ics = dmar_read4(unit, DMAR_ICS_REG);
- if ((ics & DMAR_ICS_IWC) != 0) {
- ics = DMAR_ICS_IWC;
- dmar_write4(unit, DMAR_ICS_REG, ics);
- }
if (unit->inv_seq_waiters > 0)
wakeup(&unit->inv_seq_waiters);
DMAR_UNLOCK(unit);