git: eb8326421e6b - main - iommu_qi_seq_processed: use atomic to read hw-written seq number

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 03 Oct 2024 07:29:51 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=eb8326421e6b35b0dee1a8db669914a97bce5cdf

commit eb8326421e6b35b0dee1a8db669914a97bce5cdf
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-10-03 03:51:20 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-10-03 06:19:09 +0000

    iommu_qi_seq_processed: use atomic to read hw-written seq number
    
    otherwise iommu_qi_wait_for_seq() can be legitimately optimized out.
    
    Sponsored by:   Advanced Micro Devices (AMD)
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/x86/iommu/iommu_utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c
index 8ff15cc86cb8..db8f94eb584f 100644
--- a/sys/x86/iommu/iommu_utils.c
+++ b/sys/x86/iommu/iommu_utils.c
@@ -350,8 +350,8 @@ iommu_qi_seq_processed(struct iommu_unit *unit,
 
 	x86c = IOMMU2X86C(unit);
 	gen = x86c->inv_waitd_gen;
-	return (pseq->gen < gen ||
-	    (pseq->gen == gen && pseq->seq <= x86c->inv_waitd_seq_hw));
+	return (pseq->gen < gen || (pseq->gen == gen && pseq->seq <=
+	    atomic_load_64(&x86c->inv_waitd_seq_hw)));
 }
 
 void