git: 3b1093e2562a - main - x86/amdiommu: add amdiommu_is_running()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 01 Apr 2025 23:07:14 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3b1093e2562a62c96d8e80a306e19f4ac2d2a2f4 commit 3b1093e2562a62c96d8e80a306e19f4ac2d2a2f4 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2025-01-25 09:58:35 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2025-04-01 23:01:42 +0000 x86/amdiommu: add amdiommu_is_running() Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- 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 77c4c68765c9..bf7ac4b157c4 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