Date: Thu, 2 Jan 2020 22:47:10 +0000 (UTC) From: Eric Joyner <erj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356299 - stable/12/sys/net Message-ID: <202001022247.002MlA1C022607@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: erj Date: Thu Jan 2 22:47:10 2020 New Revision: 356299 URL: https://svnweb.freebsd.org/changeset/base/356299 Log: MFC r354344: iflib: properly release memory allocated for DMA Prevents M_DEVBUF memory from leaking due to iflib DMA allocations. Sponsored by: Intel Corporation Modified: stable/12/sys/net/iflib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/iflib.c ============================================================================== --- stable/12/sys/net/iflib.c Thu Jan 2 22:44:38 2020 (r356298) +++ stable/12/sys/net/iflib.c Thu Jan 2 22:47:10 2020 (r356299) @@ -1735,20 +1735,16 @@ iflib_txsd_destroy(if_ctx_t ctx, iflib_txq_t txq, int { bus_dmamap_t map; - map = NULL; - if (txq->ift_sds.ifsd_map != NULL) + if (txq->ift_sds.ifsd_map != NULL) { map = txq->ift_sds.ifsd_map[i]; - if (map != NULL) { bus_dmamap_sync(txq->ift_buf_tag, map, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(txq->ift_buf_tag, map); bus_dmamap_destroy(txq->ift_buf_tag, map); txq->ift_sds.ifsd_map[i] = NULL; } - map = NULL; - if (txq->ift_sds.ifsd_tso_map != NULL) + if (txq->ift_sds.ifsd_tso_map != NULL) { map = txq->ift_sds.ifsd_tso_map[i]; - if (map != NULL) { bus_dmamap_sync(txq->ift_tso_buf_tag, map, BUS_DMASYNC_POSTWRITE); bus_dmamap_unload(txq->ift_tso_buf_tag, map); @@ -2158,9 +2154,6 @@ iflib_fl_bufs_free(iflib_fl_t fl) bus_dmamap_unload(fl->ifl_buf_tag, sd_map); if (*sd_cl != NULL) uma_zfree(fl->ifl_zone, *sd_cl); - // XXX: Should this get moved out? - if (iflib_in_detach(fl->ifl_rxq->ifr_ctx)) - bus_dmamap_destroy(fl->ifl_buf_tag, sd_map); if (*sd_m != NULL) { m_init(*sd_m, M_NOWAIT, MT_DATA, 0); uma_zfree(zone_mbuf, *sd_m); @@ -2248,9 +2241,6 @@ iflib_rx_sds_free(iflib_rxq_t rxq) if (fl->ifl_buf_tag != NULL) { if (fl->ifl_sds.ifsd_map != NULL) { for (j = 0; j < fl->ifl_size; j++) { - if (fl->ifl_sds.ifsd_map[j] == - NULL) - continue; bus_dmamap_sync( fl->ifl_buf_tag, fl->ifl_sds.ifsd_map[j], @@ -2258,6 +2248,9 @@ iflib_rx_sds_free(iflib_rxq_t rxq) bus_dmamap_unload( fl->ifl_buf_tag, fl->ifl_sds.ifsd_map[j]); + bus_dmamap_destroy( + fl->ifl_buf_tag, + fl->ifl_sds.ifsd_map[j]); } } bus_dma_tag_destroy(fl->ifl_buf_tag); @@ -5676,9 +5669,12 @@ static void iflib_rx_structures_free(if_ctx_t ctx) { iflib_rxq_t rxq = ctx->ifc_rxqs; - int i; + if_shared_ctx_t sctx = ctx->ifc_sctx; + int i, j; for (i = 0; i < ctx->ifc_softc_ctx.isc_nrxqsets; i++, rxq++) { + for (j = 0; j < sctx->isc_nrxqs; j++) + iflib_dma_free(&rxq->ifr_ifdi[j]); iflib_rx_sds_free(rxq); #if defined(INET6) || defined(INET) if (if_getcapabilities(ctx->ifc_ifp) & IFCAP_LRO)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202001022247.002MlA1C022607>