Index: head/sys/dev/iommu/busdma_iommu.c =================================================================== --- head/sys/dev/iommu/busdma_iommu.c +++ head/sys/dev/iommu/busdma_iommu.c @@ -1064,6 +1064,26 @@ return (error); } +static void +iommu_domain_unload_task(void *arg, int pending) +{ + struct iommu_domain *domain; + struct iommu_map_entries_tailq entries; + + domain = arg; + TAILQ_INIT(&entries); + + for (;;) { + IOMMU_DOMAIN_LOCK(domain); + TAILQ_SWAP(&domain->unload_entries, &entries, + iommu_map_entry, dmamap_link); + IOMMU_DOMAIN_UNLOCK(domain); + if (TAILQ_EMPTY(&entries)) + break; + iommu_domain_unload(domain, &entries, true); + } +} + void iommu_domain_init(struct iommu_unit *unit, struct iommu_domain *domain, const struct iommu_domain_map_ops *ops) @@ -1072,6 +1092,7 @@ domain->ops = ops; domain->iommu = unit; + TASK_INIT(&domain->unload_task, 0, iommu_domain_unload_task, domain); RB_INIT(&domain->rb_root); TAILQ_INIT(&domain->unload_entries); mtx_init(&domain->lock, "iodom", NULL, MTX_DEF); Index: head/sys/x86/iommu/intel_ctx.c =================================================================== --- head/sys/x86/iommu/intel_ctx.c +++ head/sys/x86/iommu/intel_ctx.c @@ -74,7 +74,6 @@ static MALLOC_DEFINE(M_DMAR_CTX, "dmar_ctx", "Intel DMAR Context"); static MALLOC_DEFINE(M_DMAR_DOMAIN, "dmar_dom", "Intel DMAR Domain"); -static void dmar_domain_unload_task(void *arg, int pending); static void dmar_unref_domain_locked(struct dmar_unit *dmar, struct dmar_domain *domain); static void dmar_domain_destroy(struct dmar_domain *domain); @@ -334,8 +333,6 @@ unit = DMAR2IOMMU(dmar); domain->domain = id; LIST_INIT(&domain->contexts); - TASK_INIT(&domain->iodom.unload_task, 0, dmar_domain_unload_task, - domain); iommu_domain_init(unit, iodom, &dmar_domain_map_ops); domain->dmar = dmar; @@ -875,26 +872,6 @@ } TAILQ_CONCAT(&unit->tlb_flush_entries, entries, dmamap_link); DMAR_UNLOCK(unit); -} - -static void -dmar_domain_unload_task(void *arg, int pending) -{ - struct dmar_domain *domain; - struct iommu_map_entries_tailq entries; - - domain = arg; - TAILQ_INIT(&entries); - - for (;;) { - DMAR_DOMAIN_LOCK(domain); - TAILQ_SWAP(&domain->iodom.unload_entries, &entries, - iommu_map_entry, dmamap_link); - DMAR_DOMAIN_UNLOCK(domain); - if (TAILQ_EMPTY(&entries)) - break; - dmar_domain_unload(domain, &entries, true); - } } struct iommu_ctx *