git: 8c6540b94d02 - stable/14 - x86/amdiommu: add amdiommu_is_running()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Apr 2025 00:53:45 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=8c6540b94d02bd1f61705df47186ec1736ef3df2
commit 8c6540b94d02bd1f61705df47186ec1736ef3df2
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-01-25 09:58:35 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-04-09 00:53:17 +0000
x86/amdiommu: add amdiommu_is_running()
(cherry picked from commit 3b1093e2562a62c96d8e80a306e19f4ac2d2a2f4)
---
sys/x86/iommu/amd_drv.c | 8 ++++++++
sys/x86/iommu/amd_iommu.h | 2 ++
2 files changed, 10 insertions(+)
diff --git a/sys/x86/iommu/amd_drv.c b/sys/x86/iommu/amd_drv.c
index 04e5444b0b46..7190387aa426 100644
--- a/sys/x86/iommu/amd_drv.c
+++ b/sys/x86/iommu/amd_drv.c
@@ -71,6 +71,7 @@
#include <x86/iommu/amd_iommu.h>
static int amdiommu_enable = 0;
+static bool amdiommu_running = false;
/*
* All enumerated AMD IOMMU units.
@@ -555,6 +556,7 @@ amdiommu_attach(device_t dev)
AMDIOMMU_UNLOCK(sc);
TAILQ_INSERT_TAIL(&amdiommu_units, sc, unit_next);
+ amdiommu_running = true;
return (0);
errout8:
@@ -617,6 +619,12 @@ static driver_t amdiommu_driver = {
EARLY_DRIVER_MODULE(amdiommu, pci, amdiommu_driver, 0, 0, BUS_PASS_SUPPORTDEV);
MODULE_DEPEND(amdiommu, pci, 1, 1, 1);
+int
+amdiommu_is_running(void)
+{
+ return (amdiommu_running ? 0 : ENXIO);
+}
+
static struct amdiommu_unit *
amdiommu_unit_by_device_id(u_int pci_seg, u_int device_id)
{
diff --git a/sys/x86/iommu/amd_iommu.h b/sys/x86/iommu/amd_iommu.h
index 64dd13db9745..b9f07418ca9d 100644
--- a/sys/x86/iommu/amd_iommu.h
+++ b/sys/x86/iommu/amd_iommu.h
@@ -239,4 +239,6 @@ int amdiommu_domain_alloc_pgtbl(struct amdiommu_domain *domain);
void amdiommu_domain_free_pgtbl(struct amdiommu_domain *domain);
extern const struct iommu_domain_map_ops amdiommu_domain_map_ops;
+int amdiommu_is_running(void);
+
#endif