reinstate 4GB DMA boundary workarounds for bge and aac

Reviewed by:	kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D20277
This commit is contained in:
Tycho Nightingale 2019-05-16 20:41:28 +00:00
parent 39881afcba
commit e86fa024ac
3 changed files with 39 additions and 7 deletions

View File

@ -443,7 +443,8 @@ aac_pci_attach(device_t dev)
* Note that some of these controllers are 64-bit capable. * Note that some of these controllers are 64-bit capable.
*/ */
if (bus_dma_tag_create(bus_get_dma_tag(dev), /* parent */ 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, /* lowaddr */
BUS_SPACE_MAXADDR, /* highaddr */ BUS_SPACE_MAXADDR, /* highaddr */
NULL, NULL, /* filter, filterarg */ NULL, NULL, /* filter, filterarg */

View File

@ -2927,10 +2927,14 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t alignment,
bus_addr_t *paddr, const char *msg) bus_addr_t *paddr, const char *msg)
{ {
struct bge_dmamap_arg ctx; struct bge_dmamap_arg ctx;
bus_addr_t lowaddr;
bus_size_t ring_end;
int error; int error;
lowaddr = BUS_SPACE_MAXADDR;
again:
error = bus_dma_tag_create(sc->bge_cdata.bge_parent_tag, 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); NULL, maxsize, 1, maxsize, 0, NULL, NULL, tag);
if (error != 0) { if (error != 0) {
device_printf(sc->bge_dev, device_printf(sc->bge_dev,
@ -2955,6 +2959,25 @@ bge_dma_ring_alloc(struct bge_softc *sc, bus_size_t alignment,
return (ENOMEM); return (ENOMEM);
} }
*paddr = ctx.bge_busaddr; *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); return (0);
} }
@ -2962,7 +2985,7 @@ static int
bge_dma_alloc(struct bge_softc *sc) bge_dma_alloc(struct bge_softc *sc)
{ {
bus_addr_t lowaddr; bus_addr_t lowaddr;
bus_size_t rxmaxsegsz, sbsz, txsegsz, txmaxsegsz; bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
int i, error; int i, error;
lowaddr = BUS_SPACE_MAXADDR; lowaddr = BUS_SPACE_MAXADDR;
@ -3049,7 +3072,9 @@ bge_dma_alloc(struct bge_softc *sc)
} }
/* Create parent tag for buffers. */ /* Create parent tag for buffers. */
boundary = 0;
if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) { if ((sc->bge_flags & BGE_FLAG_4G_BNDRY_BUG) != 0) {
boundary = BGE_DMA_BNDRY;
/* /*
* XXX * XXX
* watchdog timeout issue was observed on BCM5704 which * watchdog timeout issue was observed on BCM5704 which
@ -3060,10 +3085,10 @@ bge_dma_alloc(struct bge_softc *sc)
if (sc->bge_pcixcap != 0) if (sc->bge_pcixcap != 0)
lowaddr = BUS_SPACE_MAXADDR_32BIT; lowaddr = BUS_SPACE_MAXADDR_32BIT;
} }
error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev), 1, 0, lowaddr, error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, 1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT, 0, BUS_SPACE_MAXSIZE_32BIT,
&sc->bge_cdata.bge_buffer_tag); 0, NULL, NULL, &sc->bge_cdata.bge_buffer_tag);
if (error != 0) { if (error != 0) {
device_printf(sc->bge_dev, device_printf(sc->bge_dev,
"could not allocate buffer dma tag\n"); "could not allocate buffer dma tag\n");

View File

@ -2866,6 +2866,12 @@ struct bge_gib {
#define BGE_DMA_MAXADDR 0xFFFFFFFFFF #define BGE_DMA_MAXADDR 0xFFFFFFFFFF
#endif #endif
#if (BUS_SPACE_MAXADDR > 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 * Ring structures. Most of these reside in host memory and we tell
* the NIC where they are via the ring control blocks. The exceptions * the NIC where they are via the ring control blocks. The exceptions