From owner-svn-src-head@freebsd.org Fri Oct 9 13:11:14 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 E5A423FA4D8; Fri, 9 Oct 2020 13:11:14 +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 4C77kB5t9Wz4N6N; Fri, 9 Oct 2020 13:11:14 +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 AE7561A02A; Fri, 9 Oct 2020 13:11:14 +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 099DBEdb065036; Fri, 9 Oct 2020 13:11:14 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 099DBEpM065035; Fri, 9 Oct 2020 13:11:14 GMT (envelope-from br@FreeBSD.org) Message-Id: <202010091311.099DBEpM065035@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Fri, 9 Oct 2020 13:11:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r366571 - head/sys/dev/iommu X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: head/sys/dev/iommu X-SVN-Commit-Revision: 366571 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: Fri, 09 Oct 2020 13:11:15 -0000 Author: br Date: Fri Oct 9 13:11:14 2020 New Revision: 366571 URL: https://svnweb.freebsd.org/changeset/base/366571 Log: Add iommu_get_dev_ctx() helper that allows to instantiate an iommu context for a given device_t. Submitted by: andrew Reviewed by: kib Sponsored by: DARPA, AFRL Modified: head/sys/dev/iommu/busdma_iommu.c head/sys/dev/iommu/iommu.h Modified: head/sys/dev/iommu/busdma_iommu.c ============================================================================== --- head/sys/dev/iommu/busdma_iommu.c Fri Oct 9 12:44:56 2020 (r366570) +++ head/sys/dev/iommu/busdma_iommu.c Fri Oct 9 13:11:14 2020 (r366571) @@ -269,14 +269,12 @@ iommu_instantiate_ctx(struct iommu_unit *unit, device_ return (ctx); } -bus_dma_tag_t -iommu_get_dma_tag(device_t dev, device_t child) +struct iommu_ctx * +iommu_get_dev_ctx(device_t dev) { struct iommu_unit *unit; - struct iommu_ctx *ctx; - bus_dma_tag_t res; - unit = iommu_find(child, bootverbose); + unit = iommu_find(dev, bootverbose); /* Not in scope of any IOMMU ? */ if (unit == NULL) return (NULL); @@ -288,8 +286,20 @@ iommu_get_dma_tag(device_t dev, device_t child) dmar_instantiate_rmrr_ctxs(unit); #endif - ctx = iommu_instantiate_ctx(unit, child, false); - res = ctx == NULL ? NULL : (bus_dma_tag_t)ctx->tag; + return (iommu_instantiate_ctx(unit, dev, false)); +} + +bus_dma_tag_t +iommu_get_dma_tag(device_t dev, device_t child) +{ + struct iommu_ctx *ctx; + bus_dma_tag_t res; + + ctx = iommu_get_dev_ctx(child); + if (ctx == NULL) + return (NULL); + + res = (bus_dma_tag_t)ctx->tag; return (res); } Modified: head/sys/dev/iommu/iommu.h ============================================================================== --- head/sys/dev/iommu/iommu.h Fri Oct 9 12:44:56 2020 (r366570) +++ head/sys/dev/iommu/iommu.h Fri Oct 9 13:11:14 2020 (r366571) @@ -233,6 +233,7 @@ int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_d vm_paddr_t start, vm_size_t length, int flags); bus_dma_tag_t iommu_get_dma_tag(device_t dev, device_t child); +struct iommu_ctx *iommu_get_dev_ctx(device_t dev); SYSCTL_DECL(_hw_iommu);