From ea4c01156a9244a084a4044bc77147adfd9167ce Mon Sep 17 00:00:00 2001
From: Ruslan Bukin
Date: Tue, 28 Jul 2020 16:08:14 +0000
Subject: o Move the buswide_ctxs bitmap to iommu_unit and rename related
functions. o Rename bus_dma_dmar_load_ident() as well.
Reviewed by: kib
Sponsored by: DARPA/AFRL
Differential Revision: https://reviews.freebsd.org/D25852
---
sys/dev/iommu/busdma_iommu.c | 8 ++++----
sys/dev/iommu/iommu.h | 12 +++++++++++-
sys/dev/ntb/ntb_hw/ntb_hw_intel.c | 2 +-
sys/dev/ntb/ntb_hw/ntb_hw_plx.c | 2 +-
4 files changed, 17 insertions(+), 7 deletions(-)
(limited to 'sys/dev')
diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c
index a4fe8ee9d063..0fd54e8b641a 100644
--- a/sys/dev/iommu/busdma_iommu.c
+++ b/sys/dev/iommu/busdma_iommu.c
@@ -299,7 +299,7 @@ acpi_iommu_get_dma_tag(device_t dev, device_t child)
}
bool
-bus_dma_dmar_set_buswide(device_t dev)
+bus_dma_iommu_set_buswide(device_t dev)
{
struct iommu_unit *unit;
device_t parent;
@@ -317,12 +317,12 @@ bus_dma_dmar_set_buswide(device_t dev)
if (slot != 0 || func != 0) {
if (bootverbose) {
device_printf(dev,
- "dmar%d pci%d:%d:%d requested buswide busdma\n",
+ "iommu%d pci%d:%d:%d requested buswide busdma\n",
unit->unit, busno, slot, func);
}
return (false);
}
- dmar_set_buswide_ctx(unit, busno);
+ iommu_set_buswide_ctx(unit, busno);
return (true);
}
@@ -987,7 +987,7 @@ iommu_fini_busdma(struct iommu_unit *unit)
}
int
-bus_dma_dmar_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map1,
+bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map1,
vm_paddr_t start, vm_size_t length, int flags)
{
struct bus_dma_tag_common *tc;
diff --git a/sys/dev/iommu/iommu.h b/sys/dev/iommu/iommu.h
index c3bc3d26b765..380f4cdfe5f6 100644
--- a/sys/dev/iommu/iommu.h
+++ b/sys/dev/iommu/iommu.h
@@ -34,11 +34,13 @@
#ifndef _SYS_IOMMU_H_
#define _SYS_IOMMU_H_
+#include
#include
#include
#include
#include
-#include
+
+#include
/* Host or physical memory address, after translation. */
typedef uint64_t iommu_haddr_t;
@@ -96,6 +98,14 @@ struct iommu_unit {
struct task dmamap_load_task;
TAILQ_HEAD(, bus_dmamap_iommu) delayed_maps;
struct taskqueue *delayed_taskqueue;
+
+ /*
+ * Bitmap of buses for which context must ignore slot:func,
+ * duplicating the page table pointer into all context table
+ * entries. This is a client-controlled quirk to support some
+ * NTBs.
+ */
+ uint32_t buswide_ctxs[(PCI_BUSMAX + 1) / NBBY / sizeof(uint32_t)];
};
/*
diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
index 9182461fe9a5..ba61fdc9ffcd 100644
--- a/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
+++ b/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
@@ -811,7 +811,7 @@ intel_ntb_map_pci_bars(struct ntb_softc *ntb)
device_printf(ntb->device, "Unable to create BAR0 map\n");
return (ENOMEM);
}
- if (bus_dma_dmar_load_ident(ntb->bar0_dma_tag, ntb->bar0_dma_map,
+ if (bus_dma_iommu_load_ident(ntb->bar0_dma_tag, ntb->bar0_dma_map,
bar->pbase, bar->size, 0)) {
device_printf(ntb->device, "Unable to load BAR0 map\n");
return (ENOMEM);
diff --git a/sys/dev/ntb/ntb_hw/ntb_hw_plx.c b/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
index 97df9ce3a4cc..a9654e7f6725 100644
--- a/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
+++ b/sys/dev/ntb/ntb_hw/ntb_hw_plx.c
@@ -343,7 +343,7 @@ ntb_plx_attach(device_t dev)
* The device occupies whole bus. In translated TLP slot field
* keeps LUT index (original bus/slot), function is passed through.
*/
- bus_dma_dmar_set_buswide(dev);
+ bus_dma_iommu_set_buswide(dev);
/* Identify chip port we are connected to. */
val = bus_read_4(sc->conf_res, 0x360);
--
cgit v1.3