- Unmap static DMA buffers allocated via bus_dmemem_alloc() before

freeing them instead of after.
- Check the bus address of a static DMA buffer to decide if the associated
  map should be unloaded.
- Don't try to destroy bus dma maps for static DMA buffers.

Reviewed by:	davidcs
This commit is contained in:
John Baldwin 2014-06-11 20:46:23 +00:00
parent a021956c93
commit 9afa8f431f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=267377

View File

@ -3251,6 +3251,13 @@ bce_dma_free(struct bce_softc *sc)
DBENTER(BCE_VERBOSE_RESET | BCE_VERBOSE_UNLOAD | BCE_VERBOSE_CTX);
/* Free, unmap, and destroy the status block. */
if (sc->status_block_paddr != 0) {
bus_dmamap_unload(
sc->status_tag,
sc->status_map);
sc->status_block_paddr = 0;
}
if (sc->status_block != NULL) {
bus_dmamem_free(
sc->status_tag,
@ -3259,15 +3266,6 @@ bce_dma_free(struct bce_softc *sc)
sc->status_block = NULL;
}
if (sc->status_map != NULL) {
bus_dmamap_unload(
sc->status_tag,
sc->status_map);
bus_dmamap_destroy(sc->status_tag,
sc->status_map);
sc->status_map = NULL;
}
if (sc->status_tag != NULL) {
bus_dma_tag_destroy(sc->status_tag);
sc->status_tag = NULL;
@ -3275,6 +3273,13 @@ bce_dma_free(struct bce_softc *sc)
/* Free, unmap, and destroy the statistics block. */
if (sc->stats_block_paddr != 0) {
bus_dmamap_unload(
sc->stats_tag,
sc->stats_map);
sc->stats_block_paddr = 0;
}
if (sc->stats_block != NULL) {
bus_dmamem_free(
sc->stats_tag,
@ -3283,15 +3288,6 @@ bce_dma_free(struct bce_softc *sc)
sc->stats_block = NULL;
}
if (sc->stats_map != NULL) {
bus_dmamap_unload(
sc->stats_tag,
sc->stats_map);
bus_dmamap_destroy(sc->stats_tag,
sc->stats_map);
sc->stats_map = NULL;
}
if (sc->stats_tag != NULL) {
bus_dma_tag_destroy(sc->stats_tag);
sc->stats_tag = NULL;
@ -3301,6 +3297,13 @@ bce_dma_free(struct bce_softc *sc)
/* Free, unmap and destroy all context memory pages. */
if (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5709) {
for (i = 0; i < sc->ctx_pages; i++ ) {
if (sc->ctx_paddr[i] != 0) {
bus_dmamap_unload(
sc->ctx_tag,
sc->ctx_map[i]);
sc->ctx_paddr[i] = 0;
}
if (sc->ctx_block[i] != NULL) {
bus_dmamem_free(
sc->ctx_tag,
@ -3308,16 +3311,6 @@ bce_dma_free(struct bce_softc *sc)
sc->ctx_map[i]);
sc->ctx_block[i] = NULL;
}
if (sc->ctx_map[i] != NULL) {
bus_dmamap_unload(
sc->ctx_tag,
sc->ctx_map[i]);
bus_dmamap_destroy(
sc->ctx_tag,
sc->ctx_map[i]);
sc->ctx_map[i] = NULL;
}
}
/* Destroy the context memory tag. */
@ -3330,6 +3323,13 @@ bce_dma_free(struct bce_softc *sc)
/* Free, unmap and destroy all TX buffer descriptor chain pages. */
for (i = 0; i < sc->tx_pages; i++ ) {
if (sc->tx_bd_chain_paddr[i] != 0) {
bus_dmamap_unload(
sc->tx_bd_chain_tag,
sc->tx_bd_chain_map[i]);
sc->tx_bd_chain_paddr[i] = 0;
}
if (sc->tx_bd_chain[i] != NULL) {
bus_dmamem_free(
sc->tx_bd_chain_tag,
@ -3337,16 +3337,6 @@ bce_dma_free(struct bce_softc *sc)
sc->tx_bd_chain_map[i]);
sc->tx_bd_chain[i] = NULL;
}
if (sc->tx_bd_chain_map[i] != NULL) {
bus_dmamap_unload(
sc->tx_bd_chain_tag,
sc->tx_bd_chain_map[i]);
bus_dmamap_destroy(
sc->tx_bd_chain_tag,
sc->tx_bd_chain_map[i]);
sc->tx_bd_chain_map[i] = NULL;
}
}
/* Destroy the TX buffer descriptor tag. */
@ -3358,6 +3348,13 @@ bce_dma_free(struct bce_softc *sc)
/* Free, unmap and destroy all RX buffer descriptor chain pages. */
for (i = 0; i < sc->rx_pages; i++ ) {
if (sc->rx_bd_chain_paddr[i] != 0) {
bus_dmamap_unload(
sc->rx_bd_chain_tag,
sc->rx_bd_chain_map[i]);
sc->rx_bd_chain_paddr[i] = 0;
}
if (sc->rx_bd_chain[i] != NULL) {
bus_dmamem_free(
sc->rx_bd_chain_tag,
@ -3365,16 +3362,6 @@ bce_dma_free(struct bce_softc *sc)
sc->rx_bd_chain_map[i]);
sc->rx_bd_chain[i] = NULL;
}
if (sc->rx_bd_chain_map[i] != NULL) {
bus_dmamap_unload(
sc->rx_bd_chain_tag,
sc->rx_bd_chain_map[i]);
bus_dmamap_destroy(
sc->rx_bd_chain_tag,
sc->rx_bd_chain_map[i]);
sc->rx_bd_chain_map[i] = NULL;
}
}
/* Destroy the RX buffer descriptor tag. */
@ -3387,6 +3374,13 @@ bce_dma_free(struct bce_softc *sc)
/* Free, unmap and destroy all page buffer descriptor chain pages. */
if (bce_hdr_split == TRUE) {
for (i = 0; i < sc->pg_pages; i++ ) {
if (sc->pg_bd_chain_paddr[i] != 0) {
bus_dmamap_unload(
sc->pg_bd_chain_tag,
sc->pg_bd_chain_map[i]);
sc->pg_bd_chain_paddr[i] = 0;
}
if (sc->pg_bd_chain[i] != NULL) {
bus_dmamem_free(
sc->pg_bd_chain_tag,
@ -3394,16 +3388,6 @@ bce_dma_free(struct bce_softc *sc)
sc->pg_bd_chain_map[i]);
sc->pg_bd_chain[i] = NULL;
}
if (sc->pg_bd_chain_map[i] != NULL) {
bus_dmamap_unload(
sc->pg_bd_chain_tag,
sc->pg_bd_chain_map[i]);
bus_dmamap_destroy(
sc->pg_bd_chain_tag,
sc->pg_bd_chain_map[i]);
sc->pg_bd_chain_map[i] = NULL;
}
}
/* Destroy the page buffer descriptor tag. */