Module Name: src Committed By: riastradh Date: Wed Jul 22 17:23:52 UTC 2020
Modified Files: src/sys/dev/ic: bwfm.c bwfmvar.h Log Message: bwfm: Switch from pcq to pool_cache. pcq_get is required to be serialized, but it's far from clear that it is serialized here. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/bwfm.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/bwfmvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/bwfm.c diff -u src/sys/dev/ic/bwfm.c:1.28 src/sys/dev/ic/bwfm.c:1.29 --- src/sys/dev/ic/bwfm.c:1.28 Wed Jul 22 17:21:25 2020 +++ src/sys/dev/ic/bwfm.c Wed Jul 22 17:23:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bwfm.c,v 1.28 2020/07/22 17:21:25 riastradh Exp $ */ +/* $NetBSD: bwfm.c,v 1.29 2020/07/22 17:23:52 riastradh Exp $ */ /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -24,7 +24,7 @@ #include <sys/device.h> #include <sys/kernel.h> #include <sys/kmem.h> -#include <sys/pcq.h> +#include <sys/pool.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/systm.h> @@ -319,7 +319,6 @@ bwfm_attach(struct bwfm_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = &sc->sc_if; - struct bwfm_task *t; char fw_version[BWFM_DCMD_SMLEN]; uint32_t bandlist[3]; uint32_t tmp; @@ -331,12 +330,10 @@ bwfm_attach(struct bwfm_softc *sc) printf("%s: could not create workqueue\n", DEVNAME(sc)); return; } - sc->sc_freetask = pcq_create(BWFM_TASK_COUNT, KM_SLEEP); - for (i = 0; i < BWFM_TASK_COUNT; i++) { - t = &sc->sc_task[i]; - t->t_sc = sc; - pcq_put(sc->sc_freetask, t); - } + sc->sc_freetask = pool_cache_init(sizeof(struct bwfm_task), 0, 0, 0, + "bwfmtask", NULL, IPL_NET /* XXX IPL_SOFTNET? */, + NULL, NULL, NULL); + pool_cache_prime(sc->sc_freetask, BWFM_TASK_COUNT); /* Stop the device in case it was previously initialized */ bwfm_fwvar_cmd_set_int(sc, BWFM_C_DOWN, 1); @@ -429,7 +426,7 @@ bwfm_attach(struct bwfm_softc *sc) error = if_initialize(ifp); if (error != 0) { printf("%s: if_initialize failed(%d)\n", DEVNAME(sc), error); - pcq_destroy(sc->sc_freetask); + pool_cache_destroy(sc->sc_freetask); workqueue_destroy(sc->sc_taskq); return; /* Error */ @@ -469,7 +466,7 @@ bwfm_detach(struct bwfm_softc *sc, int f if (sc->sc_taskq) workqueue_destroy(sc->sc_taskq); if (sc->sc_freetask) - pcq_destroy(sc->sc_freetask); + pool_cache_destroy(sc->sc_freetask); return 0; } @@ -780,12 +777,13 @@ bwfm_key_set(struct ieee80211com *ic, co struct bwfm_softc *sc = ic->ic_ifp->if_softc; struct bwfm_task *t; - t = pcq_get(sc->sc_freetask); + t = pool_cache_get(sc->sc_freetask, PR_NOWAIT); if (t == NULL) { printf("%s: no free tasks\n", DEVNAME(sc)); return 0; } + t->t_sc = sc; t->t_cmd = BWFM_TASK_KEY_SET; t->t_key.key = wk; memcpy(t->t_key.mac, mac, sizeof(t->t_key.mac)); @@ -871,12 +869,13 @@ bwfm_key_delete(struct ieee80211com *ic, struct bwfm_softc *sc = ic->ic_ifp->if_softc; struct bwfm_task *t; - t = pcq_get(sc->sc_freetask); + t = pool_cache_get(sc->sc_freetask, PR_NOWAIT); if (t == NULL) { printf("%s: no free tasks\n", DEVNAME(sc)); return 0; } + t->t_sc = sc; t->t_cmd = BWFM_TASK_KEY_DELETE; t->t_key.key = wk; memset(t->t_key.mac, 0, sizeof(t->t_key.mac)); @@ -905,12 +904,13 @@ bwfm_newstate(struct ieee80211com *ic, e struct bwfm_softc *sc = ic->ic_ifp->if_softc; struct bwfm_task *t; - t = pcq_get(sc->sc_freetask); + t = pool_cache_get(sc->sc_freetask, PR_NOWAIT); if (t == NULL) { printf("%s: no free tasks\n", DEVNAME(sc)); return EIO; } + t->t_sc = sc; t->t_cmd = BWFM_TASK_NEWSTATE; t->t_newstate.state = nstate; t->t_newstate.arg = arg; @@ -988,7 +988,7 @@ bwfm_task(struct work *wk, void *arg) panic("bwfm: unknown task command %d", t->t_cmd); } - pcq_put(sc->sc_freetask, t); + pool_cache_put(sc->sc_freetask, t); } int @@ -2086,13 +2086,14 @@ bwfm_rx_event(struct bwfm_softc *sc, str { struct bwfm_task *t; - t = pcq_get(sc->sc_freetask); + t = pool_cache_get(sc->sc_freetask, PR_NOWAIT); if (t == NULL) { m_freem(m); printf("%s: no free tasks\n", DEVNAME(sc)); return; } + t->t_sc = sc; t->t_cmd = BWFM_TASK_RX_EVENT; t->t_mbuf = m; workqueue_enqueue(sc->sc_taskq, (struct work*)t, NULL); Index: src/sys/dev/ic/bwfmvar.h diff -u src/sys/dev/ic/bwfmvar.h:1.11 src/sys/dev/ic/bwfmvar.h:1.12 --- src/sys/dev/ic/bwfmvar.h:1.11 Wed Jul 22 17:21:25 2020 +++ src/sys/dev/ic/bwfmvar.h Wed Jul 22 17:23:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bwfmvar.h,v 1.11 2020/07/22 17:21:25 riastradh Exp $ */ +/* $NetBSD: bwfmvar.h,v 1.12 2020/07/22 17:23:52 riastradh Exp $ */ /* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation @@ -24,7 +24,6 @@ #include <sys/cdefs.h> #include <sys/device_if.h> -#include <sys/pcq.h> #include <sys/queue.h> #include <sys/workqueue.h> @@ -36,6 +35,7 @@ struct ieee80211_key; struct mbuf; +struct pool_cache; /* Chipcommon Core Chip IDs */ #define BRCM_CC_43143_CHIP_ID 43143 @@ -223,8 +223,7 @@ struct bwfm_softc { int sc_tx_timer; bool sc_if_attached; - struct bwfm_task sc_task[BWFM_TASK_COUNT]; - pcq_t *sc_freetask; + struct pool_cache *sc_freetask; struct workqueue *sc_taskq; int (*sc_newstate)(struct ieee80211com *,