From owner-svn-src-all@FreeBSD.ORG Wed Jun 11 20:46:24 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2C699B75; Wed, 11 Jun 2014 20:46:24 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0EA01244F; Wed, 11 Jun 2014 20:46:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s5BKkNrE089493; Wed, 11 Jun 2014 20:46:23 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s5BKkNlZ089492; Wed, 11 Jun 2014 20:46:23 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201406112046.s5BKkNlZ089492@svn.freebsd.org> From: John Baldwin Date: Wed, 11 Jun 2014 20:46:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267377 - head/sys/dev/bce X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jun 2014 20:46:24 -0000 Author: jhb Date: Wed Jun 11 20:46:23 2014 New Revision: 267377 URL: http://svnweb.freebsd.org/changeset/base/267377 Log: - 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 Modified: head/sys/dev/bce/if_bce.c Modified: head/sys/dev/bce/if_bce.c ============================================================================== --- head/sys/dev/bce/if_bce.c Wed Jun 11 20:44:54 2014 (r267376) +++ head/sys/dev/bce/if_bce.c Wed Jun 11 20:46:23 2014 (r267377) @@ -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; } }