git: a5943b6e503d - stable/14 - iommu: change iommu_domain_map_ops to take iommu_map_entry
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 05 Oct 2024 07:11:33 UTC
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a5943b6e503df1b75436f85ca7efa7e94c631a24 commit a5943b6e503df1b75436f85ca7efa7e94c631a24 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-09-25 01:47:54 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-05 07:08:56 +0000 iommu: change iommu_domain_map_ops to take iommu_map_entry (cherry picked from commit bdd5eb33cacdbf174980b999c77847d0903fc12e) --- sys/arm64/iommu/iommu.c | 25 +++++++++++-------------- sys/dev/iommu/iommu.h | 8 ++++---- sys/dev/iommu/iommu_gas.c | 12 +++++------- sys/x86/iommu/intel_ctx.c | 4 ++-- sys/x86/iommu/intel_idpgtbl.c | 15 ++++++++++----- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index cdff7cdf4ae2..eb682a4a623f 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -81,22 +81,21 @@ struct iommu_entry { static LIST_HEAD(, iommu_entry) iommu_list = LIST_HEAD_INITIALIZER(iommu_list); static int -iommu_domain_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, int flags) +iommu_domain_unmap_buf(struct iommu_domain *iodom, + struct iommu_map_entry *entry, int flags) { struct iommu_unit *iommu; int error; iommu = iodom->iommu; - - error = IOMMU_UNMAP(iommu->dev, iodom, base, size); - + error = IOMMU_UNMAP(iommu->dev, iodom, entry->start, entry->end - + entry->start); return (error); } static int -iommu_domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t eflags, int flags) +iommu_domain_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t eflags, int flags) { struct iommu_unit *iommu; vm_prot_t prot; @@ -111,12 +110,10 @@ iommu_domain_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, if (eflags & IOMMU_MAP_ENTRY_WRITE) prot |= VM_PROT_WRITE; - va = base; - + va = entry->start; iommu = iodom->iommu; - - error = IOMMU_MAP(iommu->dev, iodom, va, ma, size, prot); - + error = IOMMU_MAP(iommu->dev, iodom, va, ma, entry->end - + entry->start, prot); return (error); } @@ -429,8 +426,8 @@ iommu_domain_unload(struct iommu_domain *iodom, TAILQ_FOREACH_SAFE(entry, entries, dmamap_link, entry1) { KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, ("not mapped entry %p %p", iodom, entry)); - error = iodom->ops->unmap(iodom, entry->start, entry->end - - entry->start, cansleep ? IOMMU_PGF_WAITOK : 0); + error = iodom->ops->unmap(iodom, entry, + cansleep ? IOMMU_PGF_WAITOK : 0); KASSERT(error == 0, ("unmap %p error %d", iodom, error)); TAILQ_REMOVE(entries, entry, dmamap_link); iommu_domain_free_entry(entry, true); diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h index 957d4e14e8e2..84d8c3680b71 100644 --- a/sys/dev/iommu/iommu.h +++ b/sys/dev/iommu/iommu.h @@ -86,10 +86,10 @@ struct iommu_unit { }; struct iommu_domain_map_ops { - int (*map)(struct iommu_domain *domain, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t pflags, int flags); - int (*unmap)(struct iommu_domain *domain, iommu_gaddr_t base, - iommu_gaddr_t size, int flags); + int (*map)(struct iommu_domain *domain, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t pflags, int flags); + int (*unmap)(struct iommu_domain *domain, struct iommu_map_entry *entry, + int flags); }; /* diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index 4b6141b981da..26ac38da3c4f 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -826,8 +826,7 @@ iommu_gas_map(struct iommu_domain *domain, entry->flags |= eflags; IOMMU_DOMAIN_UNLOCK(domain); - error = domain->ops->map(domain, entry->start, - entry->end - entry->start, ma, eflags, + error = domain->ops->map(domain, entry, ma, eflags, ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); if (error == ENOMEM) { iommu_domain_unload_entry(entry, true, @@ -868,9 +867,9 @@ iommu_gas_map_region(struct iommu_domain *domain, struct iommu_map_entry *entry, if (entry->end == entry->start) return (0); - error = domain->ops->map(domain, entry->start, - entry->end - entry->start, ma + OFF_TO_IDX(start - entry->start), - eflags, ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); + error = domain->ops->map(domain, entry, + ma + OFF_TO_IDX(start - entry->start), eflags, + ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); if (error == ENOMEM) { iommu_domain_unload_entry(entry, false, (flags & IOMMU_MF_CANWAIT) != 0); @@ -979,8 +978,7 @@ iommu_unmap_msi(struct iommu_ctx *ctx) if (entry == NULL) return; - domain->ops->unmap(domain, entry->start, entry->end - - entry->start, IOMMU_PGF_WAITOK); + domain->ops->unmap(domain, entry, IOMMU_PGF_WAITOK); iommu_gas_free_space(entry); diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index ade3f61328d7..bdb5f8740bf2 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -896,8 +896,8 @@ dmar_domain_unload(struct iommu_domain *iodom, TAILQ_FOREACH_SAFE(entry, entries, dmamap_link, entry1) { KASSERT((entry->flags & IOMMU_MAP_ENTRY_MAP) != 0, ("not mapped entry %p %p", domain, entry)); - error = iodom->ops->unmap(iodom, entry->start, entry->end - - entry->start, cansleep ? IOMMU_PGF_WAITOK : 0); + error = iodom->ops->unmap(iodom, entry, + cansleep ? IOMMU_PGF_WAITOK : 0); KASSERT(error == 0, ("unmap %p error %d", domain, error)); if (!unit->qi_enabled) { dmar_flush_iotlb_sync(domain, entry->start, diff --git a/sys/x86/iommu/intel_idpgtbl.c b/sys/x86/iommu/intel_idpgtbl.c index 538d09649377..a949e38cc9b1 100644 --- a/sys/x86/iommu/intel_idpgtbl.c +++ b/sys/x86/iommu/intel_idpgtbl.c @@ -463,14 +463,18 @@ dmar_map_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, } static int -dmar_map_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, vm_page_t *ma, uint64_t eflags, int flags) +dmar_map_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + vm_page_t *ma, uint64_t eflags, int flags) { struct dmar_domain *domain; struct dmar_unit *unit; + iommu_gaddr_t base, size; uint64_t pflags; int error; + base = entry->start; + size = entry->end - entry->start; + pflags = ((eflags & IOMMU_MAP_ENTRY_READ) != 0 ? DMAR_PTE_R : 0) | ((eflags & IOMMU_MAP_ENTRY_WRITE) != 0 ? DMAR_PTE_W : 0) | ((eflags & IOMMU_MAP_ENTRY_SNOOP) != 0 ? DMAR_PTE_SNP : 0) | @@ -648,8 +652,8 @@ dmar_unmap_buf_locked(struct dmar_domain *domain, iommu_gaddr_t base, } static int -dmar_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, - iommu_gaddr_t size, int flags) +dmar_unmap_buf(struct iommu_domain *iodom, struct iommu_map_entry *entry, + int flags) { struct dmar_domain *domain; int error; @@ -657,7 +661,8 @@ dmar_unmap_buf(struct iommu_domain *iodom, iommu_gaddr_t base, domain = IODOM2DOM(iodom); DMAR_DOMAIN_PGLOCK(domain); - error = dmar_unmap_buf_locked(domain, base, size, flags); + error = dmar_unmap_buf_locked(domain, entry->start, entry->end - + entry->start, flags); DMAR_DOMAIN_PGUNLOCK(domain); return (error); }