diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/bce/if_bce.c | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c index 1605d24c5062..c888b499b19f 100644 --- a/sys/dev/bce/if_bce.c +++ b/sys/dev/bce/if_bce.c @@ -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,21 +3273,19 @@ bce_dma_free(struct bce_softc *sc) /* Free, unmap, and destroy the statistics block. */ - if (sc->stats_block != NULL) { - bus_dmamem_free( + if (sc->stats_block_paddr != 0) { + bus_dmamap_unload( sc->stats_tag, - sc->stats_block, sc->stats_map); - sc->stats_block = NULL; + sc->stats_block_paddr = 0; } - if (sc->stats_map != NULL) { - bus_dmamap_unload( + if (sc->stats_block != NULL) { + bus_dmamem_free( sc->stats_tag, + sc->stats_block, sc->stats_map); - bus_dmamap_destroy(sc->stats_tag, - sc->stats_map); - sc->stats_map = NULL; + sc->stats_block = NULL; } if (sc->stats_tag != NULL) { @@ -3301,22 +3297,19 @@ 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_block[i] != NULL) { - bus_dmamem_free( + if (sc->ctx_paddr[i] != 0) { + bus_dmamap_unload( sc->ctx_tag, - sc->ctx_block[i], sc->ctx_map[i]); - sc->ctx_block[i] = NULL; + sc->ctx_paddr[i] = 0; } - if (sc->ctx_map[i] != NULL) { - bus_dmamap_unload( - sc->ctx_tag, - sc->ctx_map[i]); - bus_dmamap_destroy( + if (sc->ctx_block[i] != NULL) { + bus_dmamem_free( sc->ctx_tag, + sc->ctx_block[i], sc->ctx_map[i]); - sc->ctx_map[i] = NULL; + sc->ctx_block[i] = NULL; } } @@ -3330,22 +3323,19 @@ 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[i] != NULL) { - bus_dmamem_free( + if (sc->tx_bd_chain_paddr[i] != 0) { + bus_dmamap_unload( sc->tx_bd_chain_tag, - sc->tx_bd_chain[i], sc->tx_bd_chain_map[i]); - sc->tx_bd_chain[i] = NULL; + sc->tx_bd_chain_paddr[i] = 0; } - 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( + if (sc->tx_bd_chain[i] != NULL) { + bus_dmamem_free( sc->tx_bd_chain_tag, + sc->tx_bd_chain[i], sc->tx_bd_chain_map[i]); - sc->tx_bd_chain_map[i] = NULL; + sc->tx_bd_chain[i] = NULL; } } @@ -3358,22 +3348,19 @@ 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[i] != NULL) { - bus_dmamem_free( + if (sc->rx_bd_chain_paddr[i] != 0) { + bus_dmamap_unload( sc->rx_bd_chain_tag, - sc->rx_bd_chain[i], sc->rx_bd_chain_map[i]); - sc->rx_bd_chain[i] = NULL; + sc->rx_bd_chain_paddr[i] = 0; } - 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( + if (sc->rx_bd_chain[i] != NULL) { + bus_dmamem_free( sc->rx_bd_chain_tag, + sc->rx_bd_chain[i], sc->rx_bd_chain_map[i]); - sc->rx_bd_chain_map[i] = NULL; + sc->rx_bd_chain[i] = NULL; } } @@ -3387,22 +3374,19 @@ 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[i] != NULL) { - bus_dmamem_free( + if (sc->pg_bd_chain_paddr[i] != 0) { + bus_dmamap_unload( sc->pg_bd_chain_tag, - sc->pg_bd_chain[i], sc->pg_bd_chain_map[i]); - sc->pg_bd_chain[i] = NULL; + sc->pg_bd_chain_paddr[i] = 0; } - 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( + if (sc->pg_bd_chain[i] != NULL) { + bus_dmamem_free( sc->pg_bd_chain_tag, + sc->pg_bd_chain[i], sc->pg_bd_chain_map[i]); - sc->pg_bd_chain_map[i] = NULL; + sc->pg_bd_chain[i] = NULL; } } |