Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jul 2020 10:38:51 +0000 (UTC)
From:      Ruslan Bukin <br@FreeBSD.org>
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
Message-ID:  <202007211038.06LAcp2k069253@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <machine/specialreg.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 #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 <kib@FreeBSD.org>
+ * 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 <sys/iommu.h>
+
+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 <contrib/dev/acpica/include/accommon.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 #include <dev/pci/pcivar.h>

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 <vm/vm_map.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 #include <x86/iommu/intel_dmar.h>

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 <vm/vm_map.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <x86/iommu/intel_dmar.h>
 
 /*

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 <machine/specialreg.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 

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 <machine/specialreg.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 

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 <x86/include/apicvar.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 #include <dev/pci/pcivar.h>

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 <machine/cpu.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 

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 <vm/vm_map.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 #include <dev/pci/pcivar.h>

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 <x86/include/apicvar.h>
 #include <x86/include/busdma_impl.h>
 #include <x86/iommu/intel_reg.h>
-#include <x86/iommu/busdma_dmar.h>
+#include <dev/iommu/busdma_iommu.h>
 #include <dev/pci/pcireg.h>
 #include <x86/iommu/intel_dmar.h>
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007211038.06LAcp2k069253>