svn commit: r363016 - in stable/12/sys: dev/aac dev/bge dev/isci dev/pci dev/twa x86/iommu
Alexander Motin
mav at FreeBSD.org
Wed Jul 8 17:59:03 UTC 2020
Author: mav
Date: Wed Jul 8 17:59:00 2020
New Revision: 363016
URL: https://svnweb.freebsd.org/changeset/base/363016
Log:
MFC r346386, r347890, r347896, r349895:
remove the 4GB boundary requirement on PCI DMA segments
Modified:
stable/12/sys/dev/aac/aac_pci.c
stable/12/sys/dev/bge/if_bge.c
stable/12/sys/dev/bge/if_bgereg.h
stable/12/sys/dev/isci/isci.c
stable/12/sys/dev/isci/isci.h
stable/12/sys/dev/isci/isci_controller.c
stable/12/sys/dev/pci/pci.c
stable/12/sys/dev/pci/pcivar.h
stable/12/sys/dev/twa/tw_osl.h
stable/12/sys/dev/twa/tw_osl_freebsd.c
stable/12/sys/x86/iommu/intel_ctx.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/dev/aac/aac_pci.c
==============================================================================
--- stable/12/sys/dev/aac/aac_pci.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/aac/aac_pci.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -443,7 +443,8 @@ aac_pci_attach(device_t dev)
* Note that some of these controllers are 64-bit capable.
*/
if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */
- PAGE_SIZE, 0, /* algnmnt, boundary */
+ PAGE_SIZE, /* algnmnt */
+ ((bus_size_t)((uint64_t)1 << 32)), /* boundary*/
BUS_SPACE_MAXADDR, /* lowaddr */
BUS_SPACE_MAXADDR, /* highaddr */
NULL, NULL, /* filter, filterarg */
Modified: stable/12/sys/dev/bge/if_bge.c
==============================================================================
--- stable/12/sys/dev/bge/if_bge.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/bge/if_bge.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -2927,10 +2927,14 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
bus_addr_t *paddr, const char *msg)
{
struct bge_dmamap_arg ctx;
+ bus_addr_t lowaddr;
+ bus_size_t ring_end;
int error;
+ lowaddr = BUS_SPACE_MAXADDR;
+again:
error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag,
- alignment, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL,
+ alignment, 0, lowaddr, BUS_SPACE_MAXADDR, NULL,
NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag);
if (error != 0) {
device_printf(sc->bge_dev,
@@ -2955,6 +2959,25 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t al
return (ENOMEM);
}
*paddr = ctx.bge_busaddr;
+ ring_end = *paddr + maxsize;
+ if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0 &&
+ BGE_ADDR_HI(*paddr) != BGE_ADDR_HI(ring_end)) {
+ /*
+ * 4GB boundary crossed. Limit maximum allowable DMA
+ * address space to 32bit and try again.
+ */
+ bus_dmamap_unload(*tag, *map);
+ bus_dmamem_free(*tag, *ring, *map);
+ bus_dma_tag_destroy(*tag);
+ if (bootverbose)
+ device_printf(sc->bge_dev, "4GB boundary crossed, "
+ "limit DMA address space to 32bit for %s\n", msg);
+ *ring = NULL;
+ *tag = NULL;
+ *map = NULL;
+ lowaddr = BUS_SPACE_MAXADDR_32BIT;
+ goto again;
+ }
return (0);
}
@@ -2962,7 +2985,7 @@ static int
bge_dma_alloc(struct bge_softc *sc)
{
bus_addr_t lowaddr;
- bus_size_t rxmaxsegsz, sbsz, txsegsz, txmaxsegsz;
+ bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
int i, error;
lowaddr = BUS_SPACE_MAXADDR;
@@ -3049,7 +3072,9 @@ bge_dma_alloc(struct bge_softc *sc)
}
/* Create parent tag for buffers. */
+ boundary = 0;
if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) {
+ boundary = BGE_DMA_BNDRY;
/*
* XXX
* watchdog timeout issue was observed on BCM5704 which
@@ -3060,10 +3085,10 @@ bge_dma_alloc(struct bge_softc *sc)
if (sc->bge_pcixcap != 0)
lowaddr = BUS_SPACE_MAXADDR_32BIT;
}
- error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr,
- BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0,
- BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
- &sc->bge_cdata.bge_buffer_tag);
+ error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
+ 1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
+ NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
+ 0, NULL, NULL, &sc->bge_cdata.bge_buffer_tag);
if (error != 0) {
device_printf(sc->bge_dev,
"could not allocate buffer dma tag\n");
Modified: stable/12/sys/dev/bge/if_bgereg.h
==============================================================================
--- stable/12/sys/dev/bge/if_bgereg.h Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/bge/if_bgereg.h Wed Jul 8 17:59:00 2020 (r363016)
@@ -2866,6 +2866,12 @@ struct bge_gib {
#define BGE_DMA_MAXADDR 0xFFFFFFFFFF
#endif
+#if (BUS_SPACE_MAXSIZE > 0xFFFFFFFF)
+#define BGE_DMA_BNDRY 0x100000000
+#else
+#define BGE_DMA_BNDRY 0
+#endif
+
/*
* Ring structures. Most of these reside in host memory and we tell
* the NIC where they are via the ring control blocks. The exceptions
@@ -3067,3 +3073,11 @@ struct bge_softc {
#define BGE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->bge_mtx, MA_OWNED)
#define BGE_UNLOCK(_sc) mtx_unlock(&(_sc)->bge_mtx)
#define BGE_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->bge_mtx)
+
+#ifdef BUS_SPACE_MAXADDR
+#if (BUS_SPACE_MAXADDR > 0xFFFFFFFF)
+#define BGE_DMA_BOUNDARY (0x100000000)
+#else
+#define BGE_DMA_BOUNDARY 0
+#endif
+#endif
Modified: stable/12/sys/dev/isci/isci.c
==============================================================================
--- stable/12/sys/dev/isci/isci.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/isci/isci.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -414,7 +414,8 @@ isci_allocate_dma_buffer(device_t device, struct ISCI_
uint32_t status;
status = bus_dma_tag_create(bus_get_dma_tag(device),
- 0x40 /* cacheline alignment */, 0x0, BUS_SPACE_MAXADDR,
+ 0x40 /* cacheline alignment */,
+ ISCI_DMA_BOUNDARY, BUS_SPACE_MAXADDR,
BUS_SPACE_MAXADDR, NULL, NULL, memory->size,
0x1 /* we want physically contiguous */,
memory->size, 0, busdma_lock_mutex, &controller->lock,
Modified: stable/12/sys/dev/isci/isci.h
==============================================================================
--- stable/12/sys/dev/isci/isci.h Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/isci/isci.h Wed Jul 8 17:59:00 2020 (r363016)
@@ -75,6 +75,9 @@
#define ISCI_NUM_PCI_BARS 2
#define ISCI_MAX_LUN 8
+/* This device cannot DMA across a 4GB boundary */
+#define ISCI_DMA_BOUNDARY ((bus_addr_t)((uint64_t)1 << 32))
+
MALLOC_DECLARE(M_ISCI);
struct ISCI_TIMER {
Modified: stable/12/sys/dev/isci/isci_controller.c
==============================================================================
--- stable/12/sys/dev/isci/isci_controller.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/isci/isci_controller.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -477,9 +477,9 @@ int isci_controller_allocate_memory(struct ISCI_CONTRO
* will enable better performance than creating the DMA maps every time we get
* an I/O.
*/
- status = bus_dma_tag_create(bus_get_dma_tag(device), 0x1, 0x0,
- BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL,
- isci_io_request_get_max_io_size(),
+ status = bus_dma_tag_create(bus_get_dma_tag(device), 0x1,
+ ISCI_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
+ NULL, NULL, isci_io_request_get_max_io_size(),
SCI_MAX_SCATTER_GATHER_ELEMENTS, max_segment_size, 0,
busdma_lock_mutex, &controller->lock,
&controller->buffer_dma_tag);
Modified: stable/12/sys/dev/pci/pci.c
==============================================================================
--- stable/12/sys/dev/pci/pci.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/pci/pci.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -4345,9 +4345,6 @@ pci_attach_common(device_t dev)
{
struct pci_softc *sc;
int busno, domain;
-#ifdef PCI_DMA_BOUNDARY
- int error, tag_valid;
-#endif
#ifdef PCI_RES_BUS
int rid;
#endif
@@ -4367,23 +4364,7 @@ pci_attach_common(device_t dev)
if (bootverbose)
device_printf(dev, "domain=%d, physical bus=%d\n",
domain, busno);
-#ifdef PCI_DMA_BOUNDARY
- tag_valid = 0;
- if (device_get_devclass(device_get_parent(device_get_parent(dev))) !=
- devclass_find("pci")) {
- error = bus_dma_tag_create(bus_get_dma_tag(dev), 1,
- PCI_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
- NULL, NULL, BUS_SPACE_MAXSIZE, BUS_SPACE_UNRESTRICTED,
- BUS_SPACE_MAXSIZE, 0, NULL, NULL, &sc->sc_dma_tag);
- if (error)
- device_printf(dev, "Failed to create DMA tag: %d\n",
- error);
- else
- tag_valid = 1;
- }
- if (!tag_valid)
-#endif
- sc->sc_dma_tag = bus_get_dma_tag(dev);
+ sc->sc_dma_tag = bus_get_dma_tag(dev);
return (0);
}
Modified: stable/12/sys/dev/pci/pcivar.h
==============================================================================
--- stable/12/sys/dev/pci/pcivar.h Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/pci/pcivar.h Wed Jul 8 17:59:00 2020 (r363016)
@@ -686,14 +686,6 @@ int pcie_link_reset(device_t port, int pcie_location);
void pci_print_faulted_dev(void);
-#ifdef BUS_SPACE_MAXADDR
-#if (BUS_SPACE_MAXADDR > 0xFFFFFFFF)
-#define PCI_DMA_BOUNDARY 0x100000000
-#else
-#define PCI_DMA_BOUNDARY 0
-#endif
-#endif
-
#endif /* _SYS_BUS_H_ */
/*
Modified: stable/12/sys/dev/twa/tw_osl.h
==============================================================================
--- stable/12/sys/dev/twa/tw_osl.h Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/twa/tw_osl.h Wed Jul 8 17:59:00 2020 (r363016)
@@ -57,6 +57,12 @@
#define TW_OSLI_MAX_NUM_IOS (TW_OSLI_MAX_NUM_REQUESTS - 2)
#define TW_OSLI_MAX_NUM_AENS 0x100
+#ifdef PAE
+#define TW_OSLI_DMA_BOUNDARY (1u << 31)
+#else
+#define TW_OSLI_DMA_BOUNDARY ((bus_size_t)((uint64_t)1 << 32))
+#endif
+
/* Possible values of req->state. */
#define TW_OSLI_REQ_STATE_INIT 0x0 /* being initialized */
#define TW_OSLI_REQ_STATE_BUSY 0x1 /* submitted to CL */
Modified: stable/12/sys/dev/twa/tw_osl_freebsd.c
==============================================================================
--- stable/12/sys/dev/twa/tw_osl_freebsd.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/dev/twa/tw_osl_freebsd.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -551,7 +551,7 @@ tw_osli_alloc_mem(struct twa_softc *sc)
/* Create the parent dma tag. */
if (bus_dma_tag_create(bus_get_dma_tag(sc->bus_dev), /* parent */
sc->alignment, /* alignment */
- 0, /* boundary */
+ TW_OSLI_DMA_BOUNDARY, /* boundary */
BUS_SPACE_MAXADDR, /* lowaddr */
BUS_SPACE_MAXADDR, /* highaddr */
NULL, NULL, /* filter, filterarg */
Modified: stable/12/sys/x86/iommu/intel_ctx.c
==============================================================================
--- stable/12/sys/x86/iommu/intel_ctx.c Wed Jul 8 17:14:44 2020 (r363015)
+++ stable/12/sys/x86/iommu/intel_ctx.c Wed Jul 8 17:59:00 2020 (r363016)
@@ -130,7 +130,7 @@ ctx_tag_init(struct dmar_ctx *ctx, device_t dev)
maxaddr = MIN(ctx->domain->end, BUS_SPACE_MAXADDR);
ctx->ctx_tag.common.ref_count = 1; /* Prevent free */
ctx->ctx_tag.common.impl = &bus_dma_dmar_impl;
- ctx->ctx_tag.common.boundary = PCI_DMA_BOUNDARY;
+ ctx->ctx_tag.common.boundary = 0;
ctx->ctx_tag.common.lowaddr = maxaddr;
ctx->ctx_tag.common.highaddr = maxaddr;
ctx->ctx_tag.common.maxsize = maxaddr;
More information about the svn-src-stable
mailing list