From owner-svn-src-head@freebsd.org Thu Aug 6 12:49:26 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 902803A1F4F; Thu, 6 Aug 2020 12:49:26 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BMpGZ3Fprz45Sy; Thu, 6 Aug 2020 12:49:26 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 531BE270AE; Thu, 6 Aug 2020 12:49:26 +0000 (UTC) (envelope-from br@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 076CnQ6c018211; Thu, 6 Aug 2020 12:49:26 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 076CnPFI018209; Thu, 6 Aug 2020 12:49:25 GMT (envelope-from br@FreeBSD.org) Message-Id: <202008061249.076CnPFI018209@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Thu, 6 Aug 2020 12:49:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363949 - in head/sys: dev/iommu x86/iommu X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys: dev/iommu x86/iommu X-SVN-Commit-Revision: 363949 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2020 12:49:26 -0000 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 *