git: f279f9ec2923 - stable/14 - DMAR: move hw.iommu.dmar.{tbl_pagecnt,batch_coalesce} sysctls up one level

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

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

commit f279f9ec29236d8517d2800f6d109a37d73c3143
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-08-23 21:10:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-09-11 08:44:00 +0000

    DMAR: move hw.iommu.dmar.{tbl_pagecnt,batch_coalesce} sysctls up one level
    
    (cherry picked from commit 0386b2451592ec04e4cff826b698f978a45ab3e4)
---
 sys/x86/iommu/intel_ctx.c   | 2 +-
 sys/x86/iommu/intel_dmar.h  | 3 ++-
 sys/x86/iommu/intel_utils.c | 4 ----
 sys/x86/iommu/iommu_utils.c | 9 +++++++--
 sys/x86/iommu/x86_iommu.h   | 2 +-
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c
index 814a5a8c7105..9d2d607d11a6 100644
--- a/sys/x86/iommu/intel_ctx.c
+++ b/sys/x86/iommu/intel_ctx.c
@@ -878,7 +878,7 @@ dmar_domain_unload_emit_wait(struct dmar_domain *domain,
 
 	if (TAILQ_NEXT(entry, dmamap_link) == NULL)
 		return (true);
-	return (domain->batch_no++ % dmar_batch_coalesce == 0);
+	return (domain->batch_no++ % iommu_qi_batch_coalesce == 0);
 }
 
 void
diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h
index c1e6c8f06f64..188e40dec36c 100644
--- a/sys/x86/iommu/intel_dmar.h
+++ b/sys/x86/iommu/intel_dmar.h
@@ -166,6 +166,8 @@ struct dmar_unit {
 #define	DMAR_BARRIER_RMRR	0
 #define	DMAR_BARRIER_USEQ	1
 
+SYSCTL_DECL(_hw_iommu_dmar);
+
 struct dmar_unit *dmar_find(device_t dev, bool verbose);
 struct dmar_unit *dmar_find_hpet(device_t dev, uint16_t *rid);
 struct dmar_unit *dmar_find_ioapic(u_int apic_id, uint16_t *rid);
@@ -265,7 +267,6 @@ int dmar_map_ioapic_intr(u_int ioapic_id, u_int cpu, u_int vector, bool edge,
 int dmar_unmap_ioapic_intr(u_int ioapic_id, u_int *cookie);
 
 extern int haw;
-extern int dmar_batch_coalesce;
 extern int dmar_rmrr_enable;
 
 static inline uint32_t
diff --git a/sys/x86/iommu/intel_utils.c b/sys/x86/iommu/intel_utils.c
index 7e15299c1bd3..1746bcdae8ed 100644
--- a/sys/x86/iommu/intel_utils.c
+++ b/sys/x86/iommu/intel_utils.c
@@ -508,7 +508,6 @@ dmar_barrier_exit(struct dmar_unit *dmar, u_int barrier_id)
 	DMAR_UNLOCK(dmar);
 }
 
-int dmar_batch_coalesce = 100;
 struct timespec dmar_hw_timeout = {
 	.tv_sec = 0,
 	.tv_nsec = 1000000
@@ -547,9 +546,6 @@ dmar_timeout_sysctl(SYSCTL_HANDLER_ARGS)
 	return (error);
 }
 
-SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, batch_coalesce, CTLFLAG_RWTUN,
-    &dmar_batch_coalesce, 0,
-    "Number of qi batches between interrupt");
 SYSCTL_PROC(_hw_iommu_dmar, OID_AUTO, timeout,
     CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
     dmar_timeout_sysctl, "QU",
diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c
index 645c7e15740a..5d22c6584ab7 100644
--- a/sys/x86/iommu/iommu_utils.c
+++ b/sys/x86/iommu/iommu_utils.c
@@ -181,9 +181,14 @@ int iommu_tbl_pagecnt;
 
 SYSCTL_NODE(_hw_iommu, OID_AUTO, dmar, CTLFLAG_RD | CTLFLAG_MPSAFE,
     NULL, "");
-SYSCTL_INT(_hw_iommu_dmar, OID_AUTO, tbl_pagecnt, CTLFLAG_RD,
+SYSCTL_INT(_hw_iommu, OID_AUTO, tbl_pagecnt, CTLFLAG_RD,
     &iommu_tbl_pagecnt, 0,
-    "Count of pages used for DMAR pagetables");
+    "Count of pages used for IOMMU pagetables");
+
+int iommu_qi_batch_coalesce = 100;
+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;
 
diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h
index b2caed550e35..210ce82c8f6d 100644
--- a/sys/x86/iommu/x86_iommu.h
+++ b/sys/x86/iommu/x86_iommu.h
@@ -55,9 +55,9 @@ void iommu_unmap_pgtbl(struct sf_buf *sf);
 
 extern iommu_haddr_t iommu_high;
 extern int iommu_tbl_pagecnt;
+extern int iommu_qi_batch_coalesce;
 
 SYSCTL_DECL(_hw_iommu);
-SYSCTL_DECL(_hw_iommu_dmar);
 
 struct x86_unit_common;