From owner-svn-src-head@freebsd.org Wed Jul 29 13:23:29 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 728EC3AACA6; Wed, 29 Jul 2020 13:23:29 +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 4BGvPY2N8Mz3Xkp; Wed, 29 Jul 2020 13:23:29 +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 34EB8203FD; Wed, 29 Jul 2020 13:23:29 +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 06TDNS9I019489; Wed, 29 Jul 2020 13:23:28 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06TDNSdU019484; Wed, 29 Jul 2020 13:23:28 GMT (envelope-from br@FreeBSD.org) Message-Id: <202007291323.06TDNSdU019484@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Wed, 29 Jul 2020 13:23:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363663 - in head/sys: dev/iommu x86/include x86/iommu X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys: dev/iommu x86/include x86/iommu X-SVN-Commit-Revision: 363663 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: Wed, 29 Jul 2020 13:23:29 -0000 Author: br Date: Wed Jul 29 13:23:27 2020 New Revision: 363663 URL: https://svnweb.freebsd.org/changeset/base/363663 Log: o Move iommu_set_buswide_ctx, iommu_is_buswide_ctx to the generic iommu busdma backend; o Move bus_dma_iommu_set_buswide, bus_dma_iommu_load_ident prototypes to iommu.h. Reviewed by: kib Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D25866 Modified: head/sys/dev/iommu/busdma_iommu.c head/sys/dev/iommu/iommu.h head/sys/x86/include/bus_dma.h head/sys/x86/iommu/intel_dmar.h head/sys/x86/iommu/intel_drv.c Modified: head/sys/dev/iommu/busdma_iommu.c ============================================================================== --- head/sys/dev/iommu/busdma_iommu.c Wed Jul 29 11:19:57 2020 (r363662) +++ head/sys/dev/iommu/busdma_iommu.c Wed Jul 29 13:23:27 2020 (r363663) @@ -326,6 +326,26 @@ bus_dma_iommu_set_buswide(device_t dev) return (true); } +void +iommu_set_buswide_ctx(struct iommu_unit *unit, u_int busno) +{ + + MPASS(busno <= PCI_BUSMAX); + IOMMU_LOCK(unit); + unit->buswide_ctxs[busno / NBBY / sizeof(uint32_t)] |= + 1 << (busno % (NBBY * sizeof(uint32_t))); + IOMMU_UNLOCK(unit); +} + +bool +iommu_is_buswide_ctx(struct iommu_unit *unit, u_int busno) +{ + + MPASS(busno <= PCI_BUSMAX); + return ((unit->buswide_ctxs[busno / NBBY / sizeof(uint32_t)] & + (1U << (busno % (NBBY * sizeof(uint32_t))))) != 0); +} + static MALLOC_DEFINE(M_IOMMU_DMAMAP, "iommu_dmamap", "IOMMU DMA Map"); static void iommu_bus_schedule_dmamap(struct iommu_unit *unit, Modified: head/sys/dev/iommu/iommu.h ============================================================================== --- head/sys/dev/iommu/iommu.h Wed Jul 29 11:19:57 2020 (r363662) +++ head/sys/dev/iommu/iommu.h Wed Jul 29 13:23:27 2020 (r363663) @@ -221,6 +221,13 @@ int iommu_gas_map_region(struct iommu_domain *domain, int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start, iommu_gaddr_t end); +void iommu_set_buswide_ctx(struct iommu_unit *unit, u_int busno); +bool iommu_is_buswide_ctx(struct iommu_unit *unit, u_int busno); + +bool bus_dma_iommu_set_buswide(device_t dev); +int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map, + vm_paddr_t start, vm_size_t length, int flags); + SYSCTL_DECL(_hw_iommu); #endif /* !_SYS_IOMMU_H_ */ Modified: head/sys/x86/include/bus_dma.h ============================================================================== --- head/sys/x86/include/bus_dma.h Wed Jul 29 11:19:57 2020 (r363662) +++ head/sys/x86/include/bus_dma.h Wed Jul 29 13:23:27 2020 (r363663) @@ -191,11 +191,5 @@ _bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t return (tc->impl->map_complete(dmat, map, segs, nsegs, error)); } -#ifdef _KERNEL -bool bus_dma_iommu_set_buswide(device_t dev); -int bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map, - vm_paddr_t start, vm_size_t length, int flags); -#endif - #endif /* !_X86_BUS_DMA_H_ */ Modified: head/sys/x86/iommu/intel_dmar.h ============================================================================== --- head/sys/x86/iommu/intel_dmar.h Wed Jul 29 11:19:57 2020 (r363662) +++ head/sys/x86/iommu/intel_dmar.h Wed Jul 29 13:23:27 2020 (r363663) @@ -281,9 +281,6 @@ void dmar_quirks_pre_use(struct iommu_unit *dmar); int dmar_init_irt(struct dmar_unit *unit); void dmar_fini_irt(struct dmar_unit *unit); -void iommu_set_buswide_ctx(struct iommu_unit *unit, u_int busno); -bool iommu_is_buswide_ctx(struct iommu_unit *unit, u_int busno); - extern iommu_haddr_t dmar_high; extern int haw; extern int dmar_tbl_pagecnt; Modified: head/sys/x86/iommu/intel_drv.c ============================================================================== --- head/sys/x86/iommu/intel_drv.c Wed Jul 29 11:19:57 2020 (r363662) +++ head/sys/x86/iommu/intel_drv.c Wed Jul 29 13:23:27 2020 (r363663) @@ -592,26 +592,6 @@ static driver_t dmar_driver = { DRIVER_MODULE(dmar, acpi, dmar_driver, dmar_devclass, 0, 0); MODULE_DEPEND(dmar, acpi, 1, 1, 1); -void -iommu_set_buswide_ctx(struct iommu_unit *unit, u_int busno) -{ - - MPASS(busno <= PCI_BUSMAX); - IOMMU_LOCK(unit); - unit->buswide_ctxs[busno / NBBY / sizeof(uint32_t)] |= - 1 << (busno % (NBBY * sizeof(uint32_t))); - IOMMU_UNLOCK(unit); -} - -bool -iommu_is_buswide_ctx(struct iommu_unit *unit, u_int busno) -{ - - MPASS(busno <= PCI_BUSMAX); - return ((unit->buswide_ctxs[busno / NBBY / sizeof(uint32_t)] & - (1U << (busno % (NBBY * sizeof(uint32_t))))) != 0); -} - static void dmar_print_path(int busno, int depth, const ACPI_DMAR_PCI_PATH *path) {