Author: adrian Date: Thu Jun 23 01:11:52 2016 New Revision: 302103 URL: https://svnweb.freebsd.org/changeset/base/302103
Log: [iwm] Add and use iwm_phy_db_free(), to plug phy_db memory leak. (Together with other iwm(4) memory leak fixes) Memory leakage in M_DEVBUF is now at ca. 2KB for each iwm(4) module load/unload cycle. Submitted by: Imre Vadasz <i...@vdsz.com> Approved by: re (gjb) Obtained from: DragonflyBSD git eaf551a1d464c643e98ce5781971dd32124e9af1 Differential Revision: https://reviews.freebsd.org/D6819 Modified: head/sys/dev/iwm/if_iwm.c head/sys/dev/iwm/if_iwm_phy_db.c head/sys/dev/iwm/if_iwm_phy_db.h Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Thu Jun 23 01:00:13 2016 (r302102) +++ head/sys/dev/iwm/if_iwm.c Thu Jun 23 01:11:52 2016 (r302103) @@ -5014,6 +5014,8 @@ iwm_detach_local(struct iwm_softc *sc, i if (do_net80211) ieee80211_ifdetach(&sc->sc_ic); + iwm_phy_db_free(sc); + /* Free descriptor rings */ iwm_free_rx_ring(sc, &sc->rxq); for (i = 0; i < nitems(sc->txq); i++) Modified: head/sys/dev/iwm/if_iwm_phy_db.c ============================================================================== --- head/sys/dev/iwm/if_iwm_phy_db.c Thu Jun 23 01:00:13 2016 (r302102) +++ head/sys/dev/iwm/if_iwm_phy_db.c Thu Jun 23 01:11:52 2016 (r302103) @@ -451,3 +451,33 @@ iwm_send_phy_db_data(struct iwm_softc *s __func__); return 0; } + +static void +iwm_phy_db_free_section(struct iwm_softc *sc, + enum iwm_phy_db_section_type type, uint16_t chg_id) +{ + struct iwm_phy_db_entry *entry = + iwm_phy_db_get_section(sc, type, chg_id); + if (!entry) + return; + + if (entry->data != NULL) + free(entry->data, M_DEVBUF); + entry->data = NULL; + entry->size = 0; +} + +void +iwm_phy_db_free(struct iwm_softc *sc) +{ + int i; + + iwm_phy_db_free_section(sc, IWM_PHY_DB_CFG, 0); + iwm_phy_db_free_section(sc, IWM_PHY_DB_CALIB_NCH, 0); + + for (i = 0; i < IWM_NUM_PAPD_CH_GROUPS; i++) + iwm_phy_db_free_section(sc, IWM_PHY_DB_CALIB_CHG_PAPD, i); + + for (i = 0; i < IWM_NUM_TXP_CH_GROUPS; i++) + iwm_phy_db_free_section(sc, IWM_PHY_DB_CALIB_CHG_TXP, i); +} Modified: head/sys/dev/iwm/if_iwm_phy_db.h ============================================================================== --- head/sys/dev/iwm/if_iwm_phy_db.h Thu Jun 23 01:00:13 2016 (r302102) +++ head/sys/dev/iwm/if_iwm_phy_db.h Thu Jun 23 01:11:52 2016 (r302103) @@ -109,4 +109,5 @@ extern int iwm_phy_db_set_section(struct iwm_softc *sc, struct iwm_calib_res_notif_phy_db *phy_db_notif); extern int iwm_send_phy_db_data(struct iwm_softc *sc); +extern void iwm_phy_db_free(struct iwm_softc *sc); #endif /* __IF_IWM_PHY_DB_H__ */ _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"