From 6e9127d8383c2a3b970daa6a90ed031f7fb1ada9 Mon Sep 17 00:00:00 2001 From: Ruslan Bukin Date: Wed, 14 Oct 2020 14:51:11 +0000 Subject: [PATCH] Add a per-each macro IOMMU_DOMAIN_UNLOAD_SLEEP which allows to sleep during iommu guest address space entries unload. Suggested by: kib Sponsored by: Innovate DSbD Differential Revision: https://reviews.freebsd.org/D26722 --- sys/dev/iommu/busdma_iommu.c | 6 +++--- sys/i386/include/iommu.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 959238b33445..9cafd49807ff 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -888,7 +888,7 @@ iommu_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map1) struct bus_dmamap_iommu *map; struct iommu_ctx *ctx; struct iommu_domain *domain; -#if defined(__amd64__) +#ifndef IOMMU_DOMAIN_UNLOAD_SLEEP struct iommu_map_entries_tailq entries; #endif @@ -898,13 +898,13 @@ iommu_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map1) domain = ctx->domain; atomic_add_long(&ctx->unloads, 1); -#if defined(__i386__) +#if defined(IOMMU_DOMAIN_UNLOAD_SLEEP) IOMMU_DOMAIN_LOCK(domain); TAILQ_CONCAT(&domain->unload_entries, &map->map_entries, dmamap_link); IOMMU_DOMAIN_UNLOCK(domain); taskqueue_enqueue(domain->iommu->delayed_taskqueue, &domain->unload_task); -#else /* defined(__amd64__) */ +#else TAILQ_INIT(&entries); IOMMU_DOMAIN_LOCK(domain); TAILQ_CONCAT(&entries, &map->map_entries, dmamap_link); diff --git a/sys/i386/include/iommu.h b/sys/i386/include/iommu.h index 3737d51fdcef..025e818c2393 100644 --- a/sys/i386/include/iommu.h +++ b/sys/i386/include/iommu.h @@ -4,3 +4,5 @@ /* $FreeBSD$ */ #include + +#define IOMMU_DOMAIN_UNLOAD_SLEEP