From owner-svn-src-all@freebsd.org Thu Feb 20 07:12:45 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 33332256A20; Thu, 20 Feb 2020 07:12:45 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48NQlc669Cz4YPG; Thu, 20 Feb 2020 07:12:44 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 546561E035; Thu, 20 Feb 2020 07:12:44 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01K7Cic9095995; Thu, 20 Feb 2020 07:12:44 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01K7ChWl095993; Thu, 20 Feb 2020 07:12:43 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <202002200712.01K7ChWl095993@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Thu, 20 Feb 2020 07:12:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358156 - head/sys/dev/ath X-SVN-Group: head X-SVN-Commit-Author: adrian X-SVN-Commit-Paths: head/sys/dev/ath X-SVN-Commit-Revision: 358156 X-SVN-Commit-Repository: base 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.29 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: Thu, 20 Feb 2020 07:12:45 -0000 Author: adrian Date: Thu Feb 20 07:12:43 2020 New Revision: 358156 URL: https://svnweb.freebsd.org/changeset/base/358156 Log: [ath] Attempt to fix epoch handling. The epoch stuff with taskqueues works fine if the driver never calls the receive path in other contexts, but this driver does. If there was a chip reset during active receive then part of the reset will call the receive path to flush out any active packets before reinitialising the receive queue and that needs to be done with the epoch held. So: * make the receive task a normal task again * explicitly call epoch enter/exit around the legacy and newer DMA receive paths * add a couple of epoch asserts to ensure that the receive packet path itself is called with epoch held. This fixes it on my Atom eeepc laptop (circa 2010!) that I did all of my initial 802.11n work in this driver and net80211. Tested: * AR9285, STA mode TODO: * Test on EDMA chipset (AR9380) * Test in AP/adhoc modes, just to be sure (eg for beacon receive processing in particular.) Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_rx.c head/sys/dev/ath/if_ath_rx_edma.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Thu Feb 20 06:45:51 2020 (r358155) +++ head/sys/dev/ath/if_ath.c Thu Feb 20 07:12:43 2020 (r358156) @@ -760,7 +760,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) taskqueue_start_threads(&sc->sc_tq, 1, PI_NET, "%s taskq", device_get_nameunit(sc->sc_dev)); - NET_TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc); + TASK_INIT(&sc->sc_rxtask, 0, sc->sc_rx.recv_tasklet, sc); TASK_INIT(&sc->sc_bmisstask, 0, ath_bmiss_proc, sc); TASK_INIT(&sc->sc_bstucktask,0, ath_bstuck_proc, sc); TASK_INIT(&sc->sc_resettask,0, ath_reset_proc, sc); Modified: head/sys/dev/ath/if_ath_rx.c ============================================================================== --- head/sys/dev/ath/if_ath_rx.c Thu Feb 20 06:45:51 2020 (r358155) +++ head/sys/dev/ath/if_ath_rx.c Thu Feb 20 07:12:43 2020 (r358156) @@ -656,6 +656,8 @@ ath_rx_pkt(struct ath_softc *sc, struct ath_rx_status int is_good = 0; struct ath_rx_edma *re = &sc->sc_rxedma[qtype]; + NET_EPOCH_ASSERT(); + /* * Calculate the correct 64 bit TSF given * the TSF64 register value and rs_tstamp. @@ -1074,6 +1076,8 @@ ath_rx_proc(struct ath_softc *sc, int resched) int kickpcu = 0; int ret; + NET_EPOCH_ASSERT(); + /* XXX we must not hold the ATH_LOCK here */ ATH_UNLOCK_ASSERT(sc); ATH_PCU_UNLOCK_ASSERT(sc); @@ -1293,6 +1297,7 @@ static void ath_legacy_rx_tasklet(void *arg, int npending) { struct ath_softc *sc = arg; + struct epoch_tracker et; ATH_KTR(sc, ATH_KTR_RXPROC, 1, "ath_rx_proc: pending=%d", npending); DPRINTF(sc, ATH_DEBUG_RX_PROC, "%s: pending %u\n", __func__, npending); @@ -1305,14 +1310,18 @@ ath_legacy_rx_tasklet(void *arg, int npending) } ATH_PCU_UNLOCK(sc); + NET_EPOCH_ENTER(et); ath_rx_proc(sc, 1); + NET_EPOCH_EXIT(et); } static void ath_legacy_flushrecv(struct ath_softc *sc) { - + struct epoch_tracker et; + NET_EPOCH_ENTER(et); ath_rx_proc(sc, 0); + NET_EPOCH_EXIT(et); } static void Modified: head/sys/dev/ath/if_ath_rx_edma.c ============================================================================== --- head/sys/dev/ath/if_ath_rx_edma.c Thu Feb 20 06:45:51 2020 (r358155) +++ head/sys/dev/ath/if_ath_rx_edma.c Thu Feb 20 07:12:43 2020 (r358156) @@ -521,6 +521,7 @@ ath_edma_recv_proc_deferred_queue(struct ath_softc *sc int16_t nf; ath_bufhead rxlist; struct mbuf *m; + struct epoch_tracker et; TAILQ_INIT(&rxlist); @@ -537,6 +538,8 @@ ath_edma_recv_proc_deferred_queue(struct ath_softc *sc TAILQ_CONCAT(&rxlist, &sc->sc_rx_rxlist[qtype], bf_list); ATH_RX_UNLOCK(sc); + NET_EPOCH_ENTER(et); + /* Handle the completed descriptors */ /* * XXX is this SAFE call needed? The ath_buf entries @@ -560,6 +563,7 @@ ath_edma_recv_proc_deferred_queue(struct ath_softc *sc if (ngood) { sc->sc_lastrx = tsf; } + NET_EPOCH_EXIT(et); ATH_KTR(sc, ATH_KTR_INTERRUPTS, 1, "ath edma rx deferred proc: ngood=%d\n",