Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/dev/pci Iwm locking fixes.



details:   https://anonhg.NetBSD.org/src-all/rev/b14dc8d20170
branches:  trunk
changeset: 951882:b14dc8d20170
user:      Nathanial Sloss <nat%netbsd.org@localhost>
date:      Sun Jan 17 04:05:38 2021 +1100

description:
Iwm locking fixes.

Locking rework requred for some functions.

diffstat:

 sys/dev/pci/if_iwm.c |  23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diffs (113 lines):

diff -r 2720df81d902 -r b14dc8d20170 sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Sun Jan 17 04:03:52 2021 +1100
+++ b/sys/dev/pci/if_iwm.c      Sun Jan 17 04:05:38 2021 +1100
@@ -2864,8 +2864,10 @@
        struct iwm_softc *sc = ic->ic_softc;
 
        IWM_LOCK(sc);
-       if (sc->sc_rx_ba_sessions >= IWM_MAX_RX_BA_SESSIONS)
+       if (sc->sc_rx_ba_sessions >= IWM_MAX_RX_BA_SESSIONS) {
+               IWM_UNLOCK(sc);
                return ENOSPC;
+       }
 
        sc->ba_start = 1;
        sc->ba_tid = tid;
@@ -4000,7 +4002,7 @@
        uint32_t rx_pkt_status;
        int rssi;
 
-       IWM_LOCK(sc);
+       IWM_ASSERT_LOCKED(sc);
 
        bus_dmamap_sync(sc->sc_dmat, data->map, 0, IWM_RBUF_SIZE,
            BUS_DMASYNC_POSTREAD);
@@ -4019,14 +4021,12 @@
        if (__predict_false(phy_info->cfg_phy_cnt > 20)) {
                DPRINTF(("dsp size out of range [0,20]: %d\n",
                    phy_info->cfg_phy_cnt));
-               IWM_UNLOCK(sc);
                return;
        }
 
        if (!(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_CRC_OK) ||
            !(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_OVERRUN_OK)) {
                DPRINTF(("Bad CRC or FIFO: 0x%08X.\n", rx_pkt_status));
-               IWM_UNLOCK(sc);
                return; /* drop */
        }
 
@@ -4043,7 +4043,6 @@
 #endif
 
        if (iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0) {
-               IWM_UNLOCK(sc);
                return;
        }
 
@@ -4094,7 +4093,6 @@
 
                bpf_mtap2(sc->sc_drvbpf, tap, sc->sc_rxtap_len, m, BPF_D_IN);
        }
-       IWM_UNLOCK(sc);
 
        ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
        if (c)
@@ -6101,7 +6099,7 @@
 
        IWM_LOCK(sc);
        (void)iwm_add_sta_cmd(sc, in, 1);
-       IWM_ASSERT_LOCKED(sc);
+       IWM_UNLOCK(sc);
 
        return;
 }
@@ -6290,8 +6288,11 @@
        DPRINTF(("switching state %s->%s\n", ieee80211_state_name[ostate],
            ieee80211_state_name[nstate]));
 
-       if (ostate == IEEE80211_S_SCAN && nstate != ostate)
+       if (ostate == IEEE80211_S_SCAN && nstate != ostate) {
+               IWM_LOCK(sc);
                iwm_led_blink_stop(sc);
+               IWM_UNLOCK(sc);
+       }
 
        if (ostate == IEEE80211_S_RUN && nstate != ostate)
                iwm_disable_beacon_filter(sc);
@@ -6339,7 +6340,9 @@
                        return err;
                }
                SET(sc->sc_flags, IWM_FLAG_SCANNING);
+               IWM_LOCK(sc);
                iwm_led_blink_start(sc);
+               IWM_UNLOCK(sc);
                break;
 
        case IEEE80211_S_AUTH:
@@ -6740,13 +6743,13 @@
 
        /* Restart, this time with the regular firmware */
        err = iwm_load_ucode_wait_alive(sc, IWM_UCODE_TYPE_REGULAR);
+       IWM_LOCK(sc);
        if (err) {
                aprint_error_dev(sc->sc_dev,
                    "could not load firmware (error %d)\n", err);
                return err;
        }
 
-       IWM_LOCK(sc);
        err = iwm_send_bt_init_conf(sc);
        if (err) {
                aprint_error_dev(sc->sc_dev,
@@ -7685,9 +7688,9 @@
 
                aprint_error_dev(sc->sc_dev, "fatal firmware error\n");
  fatal:
-               iwm_stop(sc);
                /* Don't restore interrupt mask */
                IWM_UNLOCK(sc);
+               iwm_stop(sc);
                return;
 
        }



Home | Main Index | Thread Index | Old Index