From nobody Fri Nov 14 02:37:35 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d71Wh2Gc2z6Gj3s; Fri, 14 Nov 2025 02:37:36 +0000 (UTC) (envelope-from git@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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d71Wh0Sc6z3xHN; Fri, 14 Nov 2025 02:37:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763087856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=erhPDfs5N4SqgH+XjvW49+94gh3M1MNsHJ+MYJD0AhU=; b=LqZzz62xqAJg30QcO2hO04lLR0IKgt6mDab8fKfTxE8UmMK7GmrFeevkv4fBa5Fe2xYgSU ZsrRTD8vsZ2SoEVZuCN6HiGzTvhS2Lwkodck63LhdV3EszlDg5AH/ptT73RR4yKuHbaZ5W vsEmLhX8MMwhvnAQ3ahOHfXN7IqIusDAJdzE8fFMpQ4CC1TIJDtDzXYNqQO7isxplhf0yA tv70040J63Xnmv9P0Ay5IOwvOOnVzW3l9aIFnpSPdXVhn2E1fXunqZOKSSuOqDylx4zBPc XticwQvfL6rlPTJWTrqYLRqPUogXy+bbmUCUv1/ul5Sjclpi2BVKxdA6ykd+fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763087856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=erhPDfs5N4SqgH+XjvW49+94gh3M1MNsHJ+MYJD0AhU=; b=d0YUVLxo69n2Z0TQ23khyQ+49ecsOlKRbkYs0jjleZ+2ccL2pFizM0jZ2oj2nywGlH14QZ I/DFwc2MYz2alIp2cIiZ1ESbz5MPmX6IxJGczSuEdZptjxarai4nKUmjj8sy7ytPajkfFi 9r1htRvIznoUhe6LWJUgAIC2ursjW381UOacQ35R9yMWAIcq84xu4cVKE5NwxHr8xLCvEl x4RWlUe+4JNUblhUerzHPbqPl+iZXEb6A0Ymo6pBHZsbe8fRTQHgAsZAGyRYIAneuewzo/ CpfmCJAIWvI5B3vGpE2Vi8kK40CmUxaZspGo280NWrNmGDmXOMI5eWXIWH5Lpw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763087856; a=rsa-sha256; cv=none; b=j7h+yYvwKz5tu2N6aYvvbSXE5kiMlT4YNYSi/7HBbB609rW+Z2Eah4Z9PRZHi/3ZuHIB4z 9EfXeRsqTOFX6nmUu157lcQnvwbR86DZPyrPvn3QoxyxUdVlebAbSVhs8fP304kprU4QVO 2CIZwPXOr5XOKiTX+AO4r3beFop3ilbyWHYIqqiz1Z+2I2e/DL17mQqGASdsctYFv0mCcj 4D0qxS0Pd9L/9Qbd8LZwNE6p8QL90HxQfBhcovD7pN4AQeEE6LAV8LwBZsv3Q0uGydK0Pi 2YE2AahbTf5NXVQt2s36xW9pDQbZJwt1VDQ9AWcixgcY+xBRlOxa1wnFu9fx8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d71Wg6tVpzp0g; Fri, 14 Nov 2025 02:37:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5AE2bZNb001281; Fri, 14 Nov 2025 02:37:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5AE2bZZ9001278; Fri, 14 Nov 2025 02:37:35 GMT (envelope-from git) Date: Fri, 14 Nov 2025 02:37:35 GMT Message-Id: <202511140237.5AE2bZZ9001278@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Adrian Chadd Subject: git: b4c35d4622d5 - main - iwx: fix and clean up suspend/resume path List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: adrian X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b4c35d4622d522c92bb080ee51e4a351e9d71897 Auto-Submitted: auto-generated The branch main has been updated by adrian: URL: https://cgit.FreeBSD.org/src/commit/?id=b4c35d4622d522c92bb080ee51e4a351e9d71897 commit b4c35d4622d522c92bb080ee51e4a351e9d71897 Author: Adrian Chadd AuthorDate: 2025-11-12 21:01:40 +0000 Commit: Adrian Chadd CommitDate: 2025-11-14 02:36:25 +0000 iwx: fix and clean up suspend/resume path I noticed a couple of things were happening: * during suspend, I'd get a timeout in the NIC lock path (which sets a bit on the NIC to say that the host wants to talk to it); * resume wouldn't come back - scan commands would fail, and you'd have to reinit the NIC again for it to work. The thing is: * the suspend path should already shut down the NIC by shutting down all the VAPs (and the last VAP should call ic_parent to bring it down), and * the resume path should already bring up the NIC by bringing up each VAP, and the first VAP to be brought up calls ic_parent to bring it up. So instead, I've shuffled around the code to just double check the hardware state is consistent /before/ ieee80211_suspend_all() and ieee80211_resume_all() is called. This both fixes the errant hardware timeout during suspend, and it fixes resume to work. Locally tested: * AX210, STA mode, both hardware ACPI suspend/resume and devctl suspend and devctl resume Differential Revision: https://reviews.freebsd.org/D53721 Reviewed by: thj --- sys/dev/iwx/if_iwx.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sys/dev/iwx/if_iwx.c b/sys/dev/iwx/if_iwx.c index 91f5baee9680..dac1c563c593 100644 --- a/sys/dev/iwx/if_iwx.c +++ b/sys/dev/iwx/if_iwx.c @@ -10711,9 +10711,13 @@ iwx_suspend(device_t dev) struct iwx_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; - if (sc->sc_flags & IWX_FLAG_HW_INITED) { - ieee80211_suspend_all(ic); + /* + * Suspend everything first, then shutdown hardware if it's + * still up. + */ + ieee80211_suspend_all(ic); + if (sc->sc_flags & IWX_FLAG_HW_INITED) { iwx_stop(sc); sc->sc_flags &= ~IWX_FLAG_HW_INITED; } @@ -10725,7 +10729,6 @@ iwx_resume(device_t dev) { struct iwx_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; - int err; /* * We disable the RETRY_TIMEOUT register (0x41) to keep @@ -10735,15 +10738,15 @@ iwx_resume(device_t dev) IWX_LOCK(sc); - err = iwx_init(sc); - if (err) { - iwx_stop_device(sc); - IWX_UNLOCK(sc); - return err; + /* Stop the hardware here if it's still thought of as "up" */ + if (sc->sc_flags & IWX_FLAG_HW_INITED) { + iwx_stop(sc); + sc->sc_flags &= ~IWX_FLAG_HW_INITED; } IWX_UNLOCK(sc); + /* Start the VAPs, which will bring the hardware back up again */ ieee80211_resume_all(ic); return (0); }