Author: br
Date: Thu Aug  6 12:49:25 2020
New Revision: 363949
URL: https://svnweb.freebsd.org/changeset/base/363949

Log:
  Move dmar_domain_unload_task to busdma_iommu.c.
  
  Reviewed by:  kib
  Sponsored by: DARPA/AFRL
  Differential Revision:        https://reviews.freebsd.org/D25972

Modified:
  head/sys/dev/iommu/busdma_iommu.c
  head/sys/x86/iommu/intel_ctx.c

Modified: head/sys/dev/iommu/busdma_iommu.c
==============================================================================
--- head/sys/dev/iommu/busdma_iommu.c   Thu Aug  6 11:18:06 2020        
(r363948)
+++ head/sys/dev/iommu/busdma_iommu.c   Thu Aug  6 12:49:25 2020        
(r363949)
@@ -1064,6 +1064,26 @@ bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmama
        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 @@ iommu_domain_init(struct iommu_unit *unit, struct iomm
        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);

Modified: head/sys/x86/iommu/intel_ctx.c
==============================================================================
--- head/sys/x86/iommu/intel_ctx.c      Thu Aug  6 11:18:06 2020        
(r363948)
+++ head/sys/x86/iommu/intel_ctx.c      Thu Aug  6 12:49:25 2020        
(r363949)
@@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$");
 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 @@ dmar_domain_alloc(struct dmar_unit *dmar, bool id_mapp
        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 @@ dmar_domain_unload(struct dmar_domain *domain,
        }
        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 *
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to