Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/iommu/busdma_iommu.c
Show First 20 Lines • Show All 1,058 Lines • ▼ Show 20 Lines | if (error == 0) { | ||||
iommu_domain_unload_entry(entry, true); | iommu_domain_unload_entry(entry, true); | ||||
} | } | ||||
for (i = 0; i < atop(length); i++) | for (i = 0; i < atop(length); i++) | ||||
vm_page_putfake(ma[i]); | vm_page_putfake(ma[i]); | ||||
free(ma, M_TEMP); | free(ma, M_TEMP); | ||||
return (error); | 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 | void | ||||
iommu_domain_init(struct iommu_unit *unit, struct iommu_domain *domain, | iommu_domain_init(struct iommu_unit *unit, struct iommu_domain *domain, | ||||
const struct iommu_domain_map_ops *ops) | const struct iommu_domain_map_ops *ops) | ||||
{ | { | ||||
domain->ops = ops; | domain->ops = ops; | ||||
domain->iommu = unit; | domain->iommu = unit; | ||||
TASK_INIT(&domain->unload_task, 0, iommu_domain_unload_task, domain); | |||||
RB_INIT(&domain->rb_root); | RB_INIT(&domain->rb_root); | ||||
TAILQ_INIT(&domain->unload_entries); | TAILQ_INIT(&domain->unload_entries); | ||||
mtx_init(&domain->lock, "iodom", NULL, MTX_DEF); | mtx_init(&domain->lock, "iodom", NULL, MTX_DEF); | ||||
} | } | ||||
void | void | ||||
iommu_domain_fini(struct iommu_domain *domain) | iommu_domain_fini(struct iommu_domain *domain) | ||||
{ | { | ||||
mtx_destroy(&domain->lock); | mtx_destroy(&domain->lock); | ||||
} | } |