git: ba33e74c7d48 - main - busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Sep 2024 21:50:53 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ba33e74c7d48479784896807eb8a1c2e1012d163 commit ba33e74c7d48479784896807eb8a1c2e1012d163 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-07-27 16:28:01 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-09-04 21:50:19 +0000 busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx() Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/arm64/iommu/iommu.c | 5 +++++ sys/dev/iommu/busdma_iommu.c | 6 +----- sys/dev/iommu/iommu.h | 1 + sys/x86/iommu/intel_drv.c | 8 ++++++++ sys/x86/iommu/iommu_utils.c | 6 ++++++ sys/x86/iommu/x86_iommu.h | 1 + 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index b765763e3a60..af0edfee70d8 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -501,6 +501,11 @@ iommu_find(device_t dev, bool verbose) return (NULL); } +void +iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ +} + void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free, bool cansleep __unused) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 3d554249ba3f..bddb466547d1 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -278,11 +278,7 @@ iommu_get_dev_ctx(device_t dev) if (!unit->dma_enabled) return (NULL); -#if defined(__amd64__) || defined(__i386__) - dmar_quirks_pre_use(unit); - dmar_instantiate_rmrr_ctxs(unit); -#endif - + iommu_unit_pre_instantiate_ctx(unit); return (iommu_instantiate_ctx(unit, dev, false)); } diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h index 157f4c62423f..9845b09e8732 100644 --- a/sys/dev/iommu/iommu.h +++ b/sys/dev/iommu/iommu.h @@ -158,6 +158,7 @@ void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free, void iommu_domain_unload(struct iommu_domain *domain, struct iommu_map_entries_tailq *entries, bool cansleep); +void iommu_unit_pre_instantiate_ctx(struct iommu_unit *iommu); struct iommu_ctx *iommu_instantiate_ctx(struct iommu_unit *iommu, device_t dev, bool rmrr); device_t iommu_get_requester(device_t dev, uint16_t *rid); diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 2439ef9e4ef5..05fb49538add 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -1310,8 +1310,16 @@ dmar_get_x86_common(struct iommu_unit *unit) return (&dmar->x86c); } +static void +dmar_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ + dmar_quirks_pre_use(unit); + dmar_instantiate_rmrr_ctxs(unit); +} + static struct x86_iommu dmar_x86_iommu = { .get_x86_common = dmar_get_x86_common, + .unit_pre_instantiate_ctx = dmar_unit_pre_instantiate_ctx, .domain_unload_entry = dmar_domain_unload_entry, .domain_unload = dmar_domain_unload, .get_ctx = dmar_get_ctx, diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index 5d22c6584ab7..2c647fd21c67 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -278,6 +278,12 @@ iommu_unmap_ioapic_intr(u_int ioapic_id, u_int *cookie) return (x86_iommu->unmap_ioapic_intr(ioapic_id, cookie)); } +void +iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit) +{ + x86_iommu->unit_pre_instantiate_ctx(unit); +} + #define IOMMU2X86C(iommu) (x86_iommu->get_x86_common(iommu)) static bool diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h index 210ce82c8f6d..a1ed5c71c513 100644 --- a/sys/x86/iommu/x86_iommu.h +++ b/sys/x86/iommu/x86_iommu.h @@ -64,6 +64,7 @@ struct x86_unit_common; struct x86_iommu { struct x86_unit_common *(*get_x86_common)(struct iommu_unit *iommu); + void (*unit_pre_instantiate_ctx)(struct iommu_unit *iommu); void (*qi_ensure)(struct iommu_unit *unit, int descr_count); void (*qi_emit_wait_descr)(struct iommu_unit *unit, uint32_t seq, bool, bool, bool);