bhndb(4): Enable addrext support on DMA64 devices, and fix an incorrect DMA

DMA boundary constraint applied in bhndb_dma_tag_create().

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
landonf 2017-12-16 04:35:37 +00:00
parent c8a7cf7b6a
commit b1b9c4df10
2 changed files with 11 additions and 13 deletions

View File

@ -511,7 +511,7 @@ static const struct bhndb_hwcfg bhndb_pci_hwcfg_v1_pcie = {
{
.base_addr = BHND_PCIE_DMA64_TRANSLATION,
.addr_mask = ~BHND_PCIE_DMA64_MASK,
.addrext_mask = 0
.addrext_mask = BHND_PCIE_DMA64_MASK
},
BHND_DMA_TRANSLATION_TABLE_END
}
@ -594,7 +594,7 @@ static const struct bhndb_hwcfg bhndb_pci_hwcfg_v2 = {
{
.base_addr = BHND_PCIE_DMA64_TRANSLATION,
.addr_mask = ~BHND_PCIE_DMA64_MASK,
.addrext_mask = 0
.addrext_mask = BHND_PCIE_DMA64_MASK
},
BHND_DMA_TRANSLATION_TABLE_END
}
@ -672,7 +672,7 @@ static const struct bhndb_hwcfg bhndb_pci_hwcfg_v3 = {
{
.base_addr = BHND_PCIE2_DMA64_TRANSLATION,
.addr_mask = ~BHND_PCIE2_DMA64_MASK,
.addrext_mask = 0
.addrext_mask = BHND_PCIE_DMA64_MASK
},
BHND_DMA_TRANSLATION_TABLE_END
}

View File

@ -521,12 +521,12 @@ bhndb_dma_tag_create(device_t dev, bus_dma_tag_t parent_dmat,
{
bus_dma_tag_t translation_tag;
bhnd_addr_t dt_mask;
bus_addr_t boundary;
bus_addr_t lowaddr, highaddr;
bus_size_t maxsegsz;
int error;
highaddr = BUS_SPACE_MAXADDR;
boundary = 0;
maxsegsz = BUS_SPACE_MAXSIZE;
/* Determine full addressable mask */
dt_mask = (translation->addr_mask | translation->addrext_mask);
@ -536,19 +536,17 @@ bhndb_dma_tag_create(device_t dev, bus_dma_tag_t parent_dmat,
/* (addr_mask|addrext_mask) is our maximum supported address */
lowaddr = MIN(dt_mask, BUS_SPACE_MAXADDR);
/* Do we need to to avoid crossing a DMA translation window boundary? */
if (translation->addr_mask < BUS_SPACE_MAXADDR) {
/* round down to nearest power of two */
boundary = translation->addr_mask & (~1ULL);
}
/* Constrain to translation window size */
if (translation->addr_mask < maxsegsz)
maxsegsz = translation->addr_mask;
/* Create our DMA tag */
error = bus_dma_tag_create(parent_dmat,
1, /* alignment */
boundary, lowaddr, highaddr,
1, 0, /* alignment, boundary */
lowaddr, highaddr,
NULL, NULL, /* filter, filterarg */
BUS_SPACE_MAXSIZE, 0, /* maxsize, nsegments */
BUS_SPACE_MAXSIZE, 0, /* maxsegsize, flags */
maxsegsz, 0, /* maxsegsize, flags */
NULL, NULL, /* lockfunc, lockarg */
&translation_tag);
if (error) {