From owner-svn-src-head@freebsd.org Tue Jul 21 10:38:54 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 872C737E6D5; Tue, 21 Jul 2020 10:38:54 +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 4B9w7L35Lnz4S77; Tue, 21 Jul 2020 10:38:54 +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 4956B1CA61; Tue, 21 Jul 2020 10:38:54 +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 06LAcsAX069265; Tue, 21 Jul 2020 10:38:54 GMT (envelope-from br@FreeBSD.org) Received: (from br@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 06LAcp2k069253; Tue, 21 Jul 2020 10:38:51 GMT (envelope-from br@FreeBSD.org) Message-Id: <202007211038.06LAcp2k069253@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: br set sender to br@FreeBSD.org using -f From: Ruslan Bukin Date: Tue, 21 Jul 2020 10:38:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363387 - in head/sys: conf dev/iommu x86/iommu X-SVN-Group: head X-SVN-Commit-Author: br X-SVN-Commit-Paths: in head/sys: conf dev/iommu x86/iommu X-SVN-Commit-Revision: 363387 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: Tue, 21 Jul 2020 10:38:54 -0000 Author: br Date: Tue Jul 21 10:38:51 2020 New Revision: 363387 URL: https://svnweb.freebsd.org/changeset/base/363387 Log: Move the Intel DMAR busdma backend to a generic place so it can be used on other IOMMU systems. Reviewed by: kib Sponsored by: DARPA/AFRL Differential Revision: https://reviews.freebsd.org/D25720 Added: head/sys/dev/iommu/ head/sys/dev/iommu/busdma_iommu.c - copied, changed from r363386, head/sys/x86/iommu/busdma_dmar.c head/sys/dev/iommu/busdma_iommu.h - copied unchanged from r363386, head/sys/x86/iommu/busdma_dmar.h Deleted: head/sys/x86/iommu/busdma_dmar.c head/sys/x86/iommu/busdma_dmar.h Modified: head/sys/conf/files.x86 head/sys/x86/iommu/intel_ctx.c head/sys/x86/iommu/intel_drv.c head/sys/x86/iommu/intel_fault.c head/sys/x86/iommu/intel_gas.c head/sys/x86/iommu/intel_idpgtbl.c head/sys/x86/iommu/intel_intrmap.c head/sys/x86/iommu/intel_qi.c head/sys/x86/iommu/intel_quirks.c head/sys/x86/iommu/intel_utils.c Modified: head/sys/conf/files.x86 ============================================================================== --- head/sys/conf/files.x86 Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/conf/files.x86 Tue Jul 21 10:38:51 2020 (r363387) @@ -165,6 +165,7 @@ dev/imcsmb/imcsmb.c optional imcsmb dev/imcsmb/imcsmb_pci.c optional imcsmb pci dev/intel/spi.c optional intelspi dev/io/iodev.c optional io +dev/iommu/busdma_iommu.c optional acpi acpi_dmar pci dev/ipmi/ipmi.c optional ipmi dev/ipmi/ipmi_acpi.c optional ipmi acpi dev/ipmi/ipmi_isa.c optional ipmi isa @@ -300,7 +301,6 @@ x86/cpufreq/hwpstate_amd.c optional cpufreq x86/cpufreq/hwpstate_intel.c optional cpufreq x86/cpufreq/p4tcc.c optional cpufreq x86/cpufreq/powernow.c optional cpufreq -x86/iommu/busdma_dmar.c optional acpi acpi_dmar pci x86/iommu/intel_ctx.c optional acpi acpi_dmar pci x86/iommu/intel_drv.c optional acpi acpi_dmar pci x86/iommu/intel_fault.c optional acpi acpi_dmar pci Copied and modified: head/sys/dev/iommu/busdma_iommu.c (from r363386, head/sys/x86/iommu/busdma_dmar.c) ============================================================================== --- head/sys/x86/iommu/busdma_dmar.c Tue Jul 21 08:13:35 2020 (r363386, copy source) +++ head/sys/dev/iommu/busdma_iommu.c Tue Jul 21 10:38:51 2020 (r363387) @@ -67,13 +67,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #endif /* - * busdma_dmar.c, the implementation of the busdma(9) interface using - * DMAR units from Intel VT-d. + * busdma_iommu.c, the implementation of the busdma(9) interface using + * IOMMU units from Intel VT-d. */ static bool Copied: head/sys/dev/iommu/busdma_iommu.h (from r363386, head/sys/x86/iommu/busdma_dmar.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/iommu/busdma_iommu.h Tue Jul 21 10:38:51 2020 (r363387, copy of r363386, head/sys/x86/iommu/busdma_dmar.h) @@ -0,0 +1,66 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2013 The FreeBSD Foundation + * All rights reserved. + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef __X86_IOMMU_BUSDMA_DMAR_H +#define __X86_IOMMU_BUSDMA_DMAR_H + +#include + +struct bus_dma_tag_iommu { + struct bus_dma_tag_common common; + struct iommu_ctx *ctx; + device_t owner; + int map_count; + bus_dma_segment_t *segments; +}; + +struct bus_dmamap_iommu { + struct bus_dma_tag_iommu *tag; + struct memdesc mem; + bus_dmamap_callback_t *callback; + void *callback_arg; + struct iommu_map_entries_tailq map_entries; + TAILQ_ENTRY(bus_dmamap_iommu) delay_link; + bool locked; + bool cansleep; + int flags; +}; + +#define BUS_DMAMAP_IOMMU_MALLOC 0x0001 +#define BUS_DMAMAP_IOMMU_KMEM_ALLOC 0x0002 + +extern struct bus_dma_impl bus_dma_iommu_impl; + +bus_dma_tag_t acpi_iommu_get_dma_tag(device_t dev, device_t child); + +#endif Modified: head/sys/x86/iommu/intel_ctx.c ============================================================================== --- head/sys/x86/iommu/intel_ctx.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_ctx.c Tue Jul 21 10:38:51 2020 (r363387) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include Modified: head/sys/x86/iommu/intel_drv.c ============================================================================== --- head/sys/x86/iommu/intel_drv.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_drv.c Tue Jul 21 10:38:51 2020 (r363387) @@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include Modified: head/sys/x86/iommu/intel_fault.c ============================================================================== --- head/sys/x86/iommu/intel_fault.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_fault.c Tue Jul 21 10:38:51 2020 (r363387) @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include /* Modified: head/sys/x86/iommu/intel_gas.c ============================================================================== --- head/sys/x86/iommu/intel_gas.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_gas.c Tue Jul 21 10:38:51 2020 (r363387) @@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include Modified: head/sys/x86/iommu/intel_idpgtbl.c ============================================================================== --- head/sys/x86/iommu/intel_idpgtbl.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_idpgtbl.c Tue Jul 21 10:38:51 2020 (r363387) @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include Modified: head/sys/x86/iommu/intel_intrmap.c ============================================================================== --- head/sys/x86/iommu/intel_intrmap.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_intrmap.c Tue Jul 21 10:38:51 2020 (r363387) @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include Modified: head/sys/x86/iommu/intel_qi.c ============================================================================== --- head/sys/x86/iommu/intel_qi.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_qi.c Tue Jul 21 10:38:51 2020 (r363387) @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include Modified: head/sys/x86/iommu/intel_quirks.c ============================================================================== --- head/sys/x86/iommu/intel_quirks.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_quirks.c Tue Jul 21 10:38:51 2020 (r363387) @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include Modified: head/sys/x86/iommu/intel_utils.c ============================================================================== --- head/sys/x86/iommu/intel_utils.c Tue Jul 21 08:13:35 2020 (r363386) +++ head/sys/x86/iommu/intel_utils.c Tue Jul 21 10:38:51 2020 (r363387) @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include