From owner-svn-src-stable-12@freebsd.org Thu Jun 4 13:03:14 2020 Return-Path: Delivered-To: svn-src-stable-12@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 A7F6E2F2537; Thu, 4 Jun 2020 13:03:14 +0000 (UTC) (envelope-from avg@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 49d5YZ3xt3z3TGh; Thu, 4 Jun 2020 13:03:14 +0000 (UTC) (envelope-from avg@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 82D851FDB9; Thu, 4 Jun 2020 13:03:14 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 054D3ExY085943; Thu, 4 Jun 2020 13:03:14 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 054D3E2a085941; Thu, 4 Jun 2020 13:03:14 GMT (envelope-from avg@FreeBSD.org) Message-Id: <202006041303.054D3E2a085941@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 4 Jun 2020 13:03:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r361786 - stable/12/sys/dev/iwm X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/iwm X-SVN-Commit-Revision: 361786 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2020 13:03:14 -0000 Author: avg Date: Thu Jun 4 13:03:13 2020 New Revision: 361786 URL: https://svnweb.freebsd.org/changeset/base/361786 Log: MFC r361273: iwm: improve rfkill handling Previously the driver handled the bit within itself, but did not expose the state change to net80211 and interface layers. This change uses net80211 KPI for rfkill signaling. The code is modeled after similar code in iwn and wpi. Modified: stable/12/sys/dev/iwm/if_iwm.c stable/12/sys/dev/iwm/if_iwmvar.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/iwm/if_iwm.c ============================================================================== --- stable/12/sys/dev/iwm/if_iwm.c Thu Jun 4 12:23:15 2020 (r361785) +++ stable/12/sys/dev/iwm/if_iwm.c Thu Jun 4 13:03:13 2020 (r361786) @@ -5059,20 +5059,48 @@ iwm_parent(struct ieee80211com *ic) { struct iwm_softc *sc = ic->ic_softc; int startall = 0; + int rfkill = 0; IWM_LOCK(sc); if (ic->ic_nrunning > 0) { if (!(sc->sc_flags & IWM_FLAG_HW_INITED)) { iwm_init(sc); - startall = 1; + rfkill = iwm_check_rfkill(sc); + if (!rfkill) + startall = 1; } } else if (sc->sc_flags & IWM_FLAG_HW_INITED) iwm_stop(sc); IWM_UNLOCK(sc); if (startall) ieee80211_start_all(ic); + else if (rfkill) + taskqueue_enqueue(sc->sc_tq, &sc->sc_rftoggle_task); } +static void +iwm_rftoggle_task(void *arg, int npending __unused) +{ + struct iwm_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + int rfkill; + + IWM_LOCK(sc); + rfkill = iwm_check_rfkill(sc); + IWM_UNLOCK(sc); + if (rfkill) { + device_printf(sc->sc_dev, + "%s: rfkill switch, disabling interface\n", __func__); + ieee80211_suspend_all(ic); + ieee80211_notify_radio(ic, 0); + } else { + device_printf(sc->sc_dev, + "%s: rfkill cleared, re-enabling interface\n", __func__); + ieee80211_resume_all(ic); + ieee80211_notify_radio(ic, 1); + } +} + /* * The interrupt side of things */ @@ -5809,12 +5837,7 @@ iwm_intr(void *arg) if (r1 & IWM_CSR_INT_BIT_RF_KILL) { handled |= IWM_CSR_INT_BIT_RF_KILL; - if (iwm_check_rfkill(sc)) { - device_printf(sc->sc_dev, - "%s: rfkill switch, disabling interface\n", - __func__); - iwm_stop(sc); - } + taskqueue_enqueue(sc->sc_tq, &sc->sc_rftoggle_task); } /* @@ -6019,7 +6042,17 @@ iwm_attach(device_t dev) callout_init_mtx(&sc->sc_watchdog_to, &sc->sc_mtx, 0); callout_init_mtx(&sc->sc_led_blink_to, &sc->sc_mtx, 0); TASK_INIT(&sc->sc_es_task, 0, iwm_endscan_cb, sc); + TASK_INIT(&sc->sc_rftoggle_task, 0, iwm_rftoggle_task, sc); + sc->sc_tq = taskqueue_create("iwm_taskq", M_WAITOK, + taskqueue_thread_enqueue, &sc->sc_tq); + error = taskqueue_start_threads(&sc->sc_tq, 1, 0, "iwm_taskq"); + if (error != 0) { + device_printf(dev, "can't start taskq thread, error %d\n", + error); + goto fail; + } + error = iwm_dev_check(dev); if (error != 0) goto fail; @@ -6585,6 +6618,8 @@ iwm_detach_local(struct iwm_softc *sc, int do_net80211 ieee80211_draintask(&sc->sc_ic, &sc->sc_es_task); } iwm_stop_device(sc); + taskqueue_drain_all(sc->sc_tq); + taskqueue_free(sc->sc_tq); if (do_net80211) { IWM_LOCK(sc); iwm_xmit_queue_drain(sc); Modified: stable/12/sys/dev/iwm/if_iwmvar.h ============================================================================== --- stable/12/sys/dev/iwm/if_iwmvar.h Thu Jun 4 12:23:15 2020 (r361785) +++ stable/12/sys/dev/iwm/if_iwmvar.h Thu Jun 4 13:03:13 2020 (r361786) @@ -499,7 +499,9 @@ struct iwm_softc { uint8_t sc_cmd_resp[IWM_CMD_RESP_MAX]; int sc_wantresp; + struct taskqueue *sc_tq; struct task sc_es_task; + struct task sc_rftoggle_task; struct iwm_rx_phy_info sc_last_phy_info; int sc_ampdu_ref;