On Wed, Sep 08, 2021 at 11:45:25AM +0200, Stefan Sperling wrote:
> I will fix the splnet() issue separately later.

And here is the patch for missing splnet() while loading firmware.

ok?

diff 5ebc9004f07f27c14bbae5eb2e8cab3d8cf3446d 
a34aaba3c6977adc3012688a6d24ef6d0499df07
blob - cb1fcf19f26a512274ac04a4e42a6389a203d08a
blob + 9fcdcaf46bc65084bd0ffa109017005665d22692
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -4147,6 +4147,8 @@ iwm_load_firmware(struct iwm_softc *sc, enum iwm_ucode
 {
        int err;
 
+       splassert(IPL_NET);
+
        sc->sc_uc.uc_intr = 0;
        sc->sc_uc.uc_ok = 0;
 
@@ -4292,7 +4294,7 @@ int
 iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justnvm)
 {
        const int wait_flags = (IWM_INIT_COMPLETE | IWM_CALIB_COMPLETE);
-       int err;
+       int err, s;
 
        if ((sc->sc_flags & IWM_FLAG_RFKILL) && !justnvm) {
                printf("%s: radio is disabled by hardware switch\n",
@@ -4300,10 +4302,12 @@ iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justn
                return EPERM;
        }
 
+       s = splnet();
        sc->sc_init_complete = 0;
        err = iwm_load_ucode_wait_alive(sc, IWM_UCODE_TYPE_INIT);
        if (err) {
                printf("%s: failed to load init firmware\n", DEVNAME(sc));
+               splx(s);
                return err;
        }
 
@@ -4312,6 +4316,7 @@ iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justn
                if (err) {
                        printf("%s: could not init bt coex (error %d)\n",
                            DEVNAME(sc), err);
+                       splx(s);
                        return err;
                }
        }
@@ -4320,6 +4325,7 @@ iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justn
                err = iwm_nvm_init(sc);
                if (err) {
                        printf("%s: failed to read nvm\n", DEVNAME(sc));
+                       splx(s);
                        return err;
                }
 
@@ -4327,25 +4333,32 @@ iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justn
                        IEEE80211_ADDR_COPY(sc->sc_ic.ic_myaddr,
                            sc->sc_nvm.hw_addr);
 
+               splx(s);
                return 0;
        }
 
        err = iwm_sf_config(sc, IWM_SF_INIT_OFF);
-       if (err)
+       if (err) {
+               splx(s);
                return err;
+       }
 
        /* Send TX valid antennas before triggering calibrations */
        err = iwm_send_tx_ant_cfg(sc, iwm_fw_valid_tx_ant(sc));
-       if (err)
+       if (err) {
+               splx(s);
                return err;
+       }
 
        /*
         * Send phy configurations command to init uCode
         * to start the 16.0 uCode init image internal calibrations.
         */
        err = iwm_send_phy_cfg_cmd(sc);
-       if (err)
+       if (err) {
+               splx(s);
                return err;
+       }
 
        /*
         * Nothing to do but wait for the init complete and phy DB
@@ -4358,6 +4371,7 @@ iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justn
                        break;
        }
 
+       splx(s);
        return err;
 }
 
blob - 39e5ecf5f6435687d6c998f65d69416ee592217d
blob + f7d69707ed0a98dfcd7717c9c82faac3af4f39d7
--- sys/dev/pci/if_iwx.c
+++ sys/dev/pci/if_iwx.c
@@ -3350,6 +3350,8 @@ iwx_load_firmware(struct iwx_softc *sc)
        struct iwx_fw_sects *fws;
        int err;
 
+       splassert(IPL_NET);
+
        sc->sc_uc.uc_intr = 0;
        sc->sc_uc.uc_ok = 0;
 
@@ -3465,7 +3467,7 @@ iwx_run_init_mvm_ucode(struct iwx_softc *sc, int readn
        struct iwx_init_extended_cfg_cmd init_cfg = {
                .init_flags = htole32(IWX_INIT_NVM),
        };
-       int err;
+       int err, s;
 
        if ((sc->sc_flags & IWX_FLAG_RFKILL) && !readnvm) {
                printf("%s: radio is disabled by hardware switch\n",
@@ -3473,10 +3475,12 @@ iwx_run_init_mvm_ucode(struct iwx_softc *sc, int readn
                return EPERM;
        }
 
+       s = splnet();
        sc->sc_init_complete = 0;
        err = iwx_load_ucode_wait_alive(sc);
        if (err) {
                printf("%s: failed to load init firmware\n", DEVNAME(sc));
+               splx(s);
                return err;
        }
 
@@ -3486,22 +3490,28 @@ iwx_run_init_mvm_ucode(struct iwx_softc *sc, int readn
         */
        err = iwx_send_cmd_pdu(sc, IWX_WIDE_ID(IWX_SYSTEM_GROUP,
            IWX_INIT_EXTENDED_CFG_CMD), 0, sizeof(init_cfg), &init_cfg);
-       if (err)
+       if (err) {
+               splx(s);
                return err;
+       }
 
        err = iwx_send_cmd_pdu(sc, IWX_WIDE_ID(IWX_REGULATORY_AND_NVM_GROUP,
            IWX_NVM_ACCESS_COMPLETE), 0, sizeof(nvm_complete), &nvm_complete);
-       if (err)
+       if (err) {
+               splx(s);
                return err;
+       }
 
        /* Wait for the init complete notification from the firmware. */
        while ((sc->sc_init_complete & wait_flags) != wait_flags) {
                err = tsleep_nsec(&sc->sc_init_complete, 0, "iwxinit",
                    SEC_TO_NSEC(2));
-               if (err)
+               if (err) {
+                       splx(s);
                        return err;
+               }
        }
-
+       splx(s);
        if (readnvm) {
                err = iwx_nvm_get(sc);
                if (err) {

Reply via email to