From owner-svn-src-all@freebsd.org Wed May 20 08:15:10 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 5134D2CA504; Wed, 20 May 2020 08:15:10 +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 49Rlt61Qmgz3cmV; Wed, 20 May 2020 08:15:10 +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 27A881928B; Wed, 20 May 2020 08:15:10 +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 04K8F9pZ009856; Wed, 20 May 2020 08:15:09 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04K8F95i009854; Wed, 20 May 2020 08:15:09 GMT (envelope-from avg@FreeBSD.org) Message-Id: <202005200815.04K8F95i009854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 20 May 2020 08:15:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361273 - head/sys/dev/iwm X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/dev/iwm X-SVN-Commit-Revision: 361273 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.33 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: Wed, 20 May 2020 08:15:10 -0000 Author: avg Date: Wed May 20 08:15:09 2020 New Revision: 361273 URL: https://svnweb.freebsd.org/changeset/base/361273 Log: 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. Reviewed by: adrian MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D24923 Modified: head/sys/dev/iwm/if_iwm.c head/sys/dev/iwm/if_iwmvar.h Modified: head/sys/dev/iwm/if_iwm.c ============================================================================== --- head/sys/dev/iwm/if_iwm.c Wed May 20 04:16:13 2020 (r361272) +++ head/sys/dev/iwm/if_iwm.c Wed May 20 08:15:09 2020 (r361273) @@ -5064,20 +5064,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 */ @@ -5814,12 +5842,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); } /* @@ -6024,7 +6047,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; @@ -6590,6 +6623,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: head/sys/dev/iwm/if_iwmvar.h ============================================================================== --- head/sys/dev/iwm/if_iwmvar.h Wed May 20 04:16:13 2020 (r361272) +++ head/sys/dev/iwm/if_iwmvar.h Wed May 20 08:15:09 2020 (r361273) @@ -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;