The branch main has been updated by thj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=969f6c635358a079c50fd3ecd3d060bb5d9e0816

commit 969f6c635358a079c50fd3ecd3d060bb5d9e0816
Author:     Tom Jones <t...@freebsd.org>
AuthorDate: 2025-05-28 09:02:54 +0000
Commit:     Tom Jones <t...@freebsd.org>
CommitDate: 2025-05-28 09:02:54 +0000

    if_iwx: use net80211 suspend and resume methods
    
    Use net80211 suspend and resume methods when entering and leaving
    suspend. Move the resume action outside of the IWX_LOCK.
    
    Re-assert disabling the PCI timeout, this is copied from OpenBSD (and a
    common pattern), but it doesn't seem to hurt.
    
    PR:             286059
    Reviewed by:    adrian
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D50462
---
 sys/dev/iwx/if_iwx.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/sys/dev/iwx/if_iwx.c b/sys/dev/iwx/if_iwx.c
index 029031802a26..a0e4bf8a53f6 100644
--- a/sys/dev/iwx/if_iwx.c
+++ b/sys/dev/iwx/if_iwx.c
@@ -195,6 +195,8 @@ int iwx_lomark = 192;
 
 #include <dev/iwx/if_iwx_debug.h>
 
+#define        PCI_CFG_RETRY_TIMEOUT   0x41
+
 #define PCI_VENDOR_INTEL               0x8086
 #define        PCI_PRODUCT_INTEL_WL_22500_1    0x2723          /* Wi-Fi 6 
AX200 */
 #define        PCI_PRODUCT_INTEL_WL_22500_2    0x02f0          /* Wi-Fi 6 
AX201 */
@@ -10142,7 +10144,6 @@ iwx_attach(device_t dev)
         * We disable the RETRY_TIMEOUT register (0x41) to keep
         * PCI Tx retries from interfering with C3 CPU state.
         */
-#define        PCI_CFG_RETRY_TIMEOUT   0x41
        pci_write_config(dev, PCI_CFG_RETRY_TIMEOUT, 0x00, 1);
 
        if (pci_msix_count(dev)) {
@@ -10657,8 +10658,11 @@ static int
 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);
+
                iwx_stop(sc);
                sc->sc_flags &= ~IWX_FLAG_HW_INITED;
        }
@@ -10669,21 +10673,27 @@ static int
 iwx_resume(device_t dev)
 {
        struct iwx_softc *sc = device_get_softc(dev);
+       struct ieee80211com *ic = &sc->sc_ic;
        int err;
 
-       err = iwx_start_hw(sc);
-       if (err) {
-               return err;
-       }
+       /*
+        * We disable the RETRY_TIMEOUT register (0x41) to keep
+        * PCI Tx retries from interfering with C3 CPU state.
+        */
+       pci_write_config(dev, PCI_CFG_RETRY_TIMEOUT, 0x00, 1);
 
-       err = iwx_init_hw(sc);
+       IWX_LOCK(sc);
+
+       err = iwx_init(sc);
        if (err) {
                iwx_stop_device(sc);
+               IWX_UNLOCK(sc);
                return err;
        }
 
-       ieee80211_start_all(&sc->sc_ic);
+       IWX_UNLOCK(sc);
 
+       ieee80211_resume_all(ic);
        return (0);
 }
 

Reply via email to