git: c5c01f6276ee - stable/14 - x86: always provide dummy x86_iommu virtual methods

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 11 Sep 2024 08:44:39 UTC
The branch stable/14 has been updated by kib:

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

commit c5c01f6276ee117af069ca84f84f46362b0b279c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-09-05 00:33:34 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-09-11 08:44:00 +0000

    x86: always provide dummy x86_iommu virtual methods
    
    (cherry picked from commit 99e3d96fc1a2b1d5cac5a635608ec3044ec4fa13)
---
 sys/x86/iommu/iommu_utils.c | 52 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 50 insertions(+), 2 deletions(-)

diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c
index 2c647fd21c67..2011c632f770 100644
--- a/sys/x86/iommu/iommu_utils.c
+++ b/sys/x86/iommu/iommu_utils.c
@@ -190,12 +190,60 @@ SYSCTL_INT(_hw_iommu, OID_AUTO, batch_coalesce, CTLFLAG_RWTUN,
     &iommu_qi_batch_coalesce, 0,
     "Number of qi batches between interrupt");
 
-static struct x86_iommu *x86_iommu;
+static struct iommu_unit *
+x86_no_iommu_find(device_t dev, bool verbose)
+{
+	return (NULL);
+}
+
+static int
+x86_no_iommu_alloc_msi_intr(device_t src, u_int *cookies, u_int count)
+{
+	return (EOPNOTSUPP);
+}
+
+static int
+x86_no_iommu_map_msi_intr(device_t src, u_int cpu, u_int vector,
+    u_int cookie, uint64_t *addr, uint32_t *data)
+{
+	return (EOPNOTSUPP);
+}
+
+static int
+x86_no_iommu_unmap_msi_intr(device_t src, u_int cookie)
+{
+	return (0);
+}
+
+static int
+x86_no_iommu_map_ioapic_intr(u_int ioapic_id, u_int cpu, u_int vector,
+    bool edge, bool activehi, int irq, u_int *cookie, uint32_t *hi,
+    uint32_t *lo)
+{
+	return (EOPNOTSUPP);
+}
+
+static int
+x86_no_iommu_unmap_ioapic_intr(u_int ioapic_id, u_int *cookie)
+{
+	return (0);
+}
+
+static struct x86_iommu x86_no_iommu = {
+	.find = x86_no_iommu_find,
+	.alloc_msi_intr = x86_no_iommu_alloc_msi_intr,
+	.map_msi_intr = x86_no_iommu_map_msi_intr,
+	.unmap_msi_intr = x86_no_iommu_unmap_msi_intr,
+	.map_ioapic_intr = x86_no_iommu_map_ioapic_intr,
+	.unmap_ioapic_intr = x86_no_iommu_unmap_ioapic_intr,
+};
+
+static struct x86_iommu *x86_iommu = &x86_no_iommu;
 
 void
 set_x86_iommu(struct x86_iommu *x)
 {
-	MPASS(x86_iommu == NULL);
+	MPASS(x86_iommu == &x86_no_iommu);
 	x86_iommu = x;
 }