Author: jhb Date: Tue Oct 22 20:01:47 2019 New Revision: 353899 URL: https://svnweb.freebsd.org/changeset/base/353899
Log: Always allocate the atid table during attach. Previously the table was allocated on first use by TOE and the ratelimit code. The forthcoming NIC KTLS code also uses this table. Allocate it unconditionally during attach to simplify consumers. Reviewed by: np Differential Revision: https://reviews.freebsd.org/D22028 Modified: head/sys/dev/cxgbe/adapter.h head/sys/dev/cxgbe/t4_filter.c head/sys/dev/cxgbe/t4_main.c head/sys/dev/cxgbe/tom/t4_tom.c Modified: head/sys/dev/cxgbe/adapter.h ============================================================================== --- head/sys/dev/cxgbe/adapter.h Tue Oct 22 18:30:51 2019 (r353898) +++ head/sys/dev/cxgbe/adapter.h Tue Oct 22 20:01:47 2019 (r353899) @@ -1160,8 +1160,6 @@ int vi_full_uninit(struct vi_info *); void vi_sysctls(struct vi_info *); void vi_tick(void *); int rw_via_memwin(struct adapter *, int, uint32_t, uint32_t *, int, int); -int alloc_atid_tab(struct tid_info *, int); -void free_atid_tab(struct tid_info *); int alloc_atid(struct adapter *, void *); void *lookup_atid(struct adapter *, int); void free_atid(struct adapter *, int); Modified: head/sys/dev/cxgbe/t4_filter.c ============================================================================== --- head/sys/dev/cxgbe/t4_filter.c Tue Oct 22 18:30:51 2019 (r353898) +++ head/sys/dev/cxgbe/t4_filter.c Tue Oct 22 20:01:47 2019 (r353899) @@ -891,11 +891,6 @@ set_filter(struct adapter *sc, struct t4_filter *t) if (rc != 0) goto done; } - if (__predict_false(sc->tids.atid_tab == NULL)) { - rc = alloc_atid_tab(&sc->tids, M_NOWAIT); - if (rc != 0) - goto done; - } } else if (separate_hpfilter_region(sc) && t->fs.prio && __predict_false(ti->hpftid_tab == NULL)) { MPASS(ti->nhpftids != 0); Modified: head/sys/dev/cxgbe/t4_main.c ============================================================================== --- head/sys/dev/cxgbe/t4_main.c Tue Oct 22 18:30:51 2019 (r353898) +++ head/sys/dev/cxgbe/t4_main.c Tue Oct 22 20:01:47 2019 (r353899) @@ -626,6 +626,8 @@ static void quiesce_fl(struct adapter *, struct sge_fl static int t4_alloc_irq(struct adapter *, struct irq *, int rid, driver_intr_t *, void *, char *); static int t4_free_irq(struct adapter *, struct irq *); +static void t4_init_atid_table(struct adapter *); +static void t4_free_atid_table(struct adapter *); static void get_regs(struct adapter *, struct t4_regdump *, uint8_t *); static void vi_refresh_stats(struct adapter *, struct vi_info *); static void cxgbe_refresh_stats(struct adapter *, struct port_info *); @@ -1236,6 +1238,7 @@ t4_attach(device_t dev) t4_init_l2t(sc, M_WAITOK); t4_init_smt(sc, M_WAITOK); t4_init_tx_sched(sc); + t4_init_atid_table(sc); #ifdef RATELIMIT t4_init_etid_table(sc); #endif @@ -1540,6 +1543,7 @@ t4_detach_common(device_t dev) t4_free_l2t(sc->l2t); if (sc->smt) t4_free_smt(sc->smt); + t4_free_atid_table(sc); #ifdef RATELIMIT t4_free_etid_table(sc); #endif @@ -1568,7 +1572,6 @@ t4_detach_common(device_t dev) free(sc->tids.ftid_tab, M_CXGBE); free(sc->tids.hpftid_tab, M_CXGBE); free_hftid_hash(&sc->tids); - free(sc->tids.atid_tab, M_CXGBE); free(sc->tids.tid_tab, M_CXGBE); free(sc->tt.tls_rx_ports, M_CXGBE); t4_destroy_dma_tag(sc); @@ -2829,31 +2832,34 @@ rw_via_memwin(struct adapter *sc, int idx, uint32_t ad return (0); } -int -alloc_atid_tab(struct tid_info *t, int flags) +static void +t4_init_atid_table(struct adapter *sc) { + struct tid_info *t; int i; - MPASS(t->natids > 0); + t = &sc->tids; + if (t->natids == 0) + return; + MPASS(t->atid_tab == NULL); t->atid_tab = malloc(t->natids * sizeof(*t->atid_tab), M_CXGBE, - M_ZERO | flags); - if (t->atid_tab == NULL) - return (ENOMEM); + M_ZERO | M_WAITOK); mtx_init(&t->atid_lock, "atid lock", NULL, MTX_DEF); t->afree = t->atid_tab; t->atids_in_use = 0; for (i = 1; i < t->natids; i++) t->atid_tab[i - 1].next = &t->atid_tab[i]; t->atid_tab[t->natids - 1].next = NULL; - - return (0); } -void -free_atid_tab(struct tid_info *t) +static void +t4_free_atid_table(struct adapter *sc) { + struct tid_info *t; + + t = &sc->tids; KASSERT(t->atids_in_use == 0, ("%s: %d atids still in use.", __func__, t->atids_in_use)); Modified: head/sys/dev/cxgbe/tom/t4_tom.c ============================================================================== --- head/sys/dev/cxgbe/tom/t4_tom.c Tue Oct 22 18:30:51 2019 (r353898) +++ head/sys/dev/cxgbe/tom/t4_tom.c Tue Oct 22 20:01:47 2019 (r353899) @@ -1368,7 +1368,6 @@ free_tid_tabs(struct tid_info *t) { free_tid_tab(t); - free_atid_tab(t); free_stid_tab(t); } @@ -1378,10 +1377,6 @@ alloc_tid_tabs(struct tid_info *t) int rc; rc = alloc_tid_tab(t, M_NOWAIT); - if (rc != 0) - goto failed; - - rc = alloc_atid_tab(t, M_NOWAIT); if (rc != 0) goto failed; _______________________________________________ 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"