From 0317870298fb69b40114a9056b1974f78e5365ce Mon Sep 17 00:00:00 2001 From: stsp Date: Fri, 3 Sep 2021 11:41:41 +0000 Subject: [PATCH] Ensure that iwm(4) and iwx(4) will reload firmware from disk on down/up, and will not do so during resume. Tested by kevlo@ on iwx(4) and by myself on iwm(4). --- sys/dev/pci/if_iwm.c | 13 +++++++------ sys/dev/pci/if_iwx.c | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 0447b445424..c66035ef2aa 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwm.c,v 1.363 2021/08/29 20:31:18 gnezdo Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.364 2021/09/03 11:41:41 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -254,7 +254,7 @@ int iwm_firmware_store_section(struct iwm_softc *, enum iwm_ucode_type, int iwm_set_default_calib(struct iwm_softc *, const void *); void iwm_fw_info_free(struct iwm_fw_info *); void iwm_fw_version_str(char *, size_t, uint32_t, uint32_t, uint32_t); -int iwm_read_firmware(struct iwm_softc *, enum iwm_ucode_type); +int iwm_read_firmware(struct iwm_softc *); uint32_t iwm_read_prph_unlocked(struct iwm_softc *, uint32_t); uint32_t iwm_read_prph(struct iwm_softc *, uint32_t); void iwm_write_prph_unlocked(struct iwm_softc *, uint32_t, uint32_t); @@ -681,7 +681,7 @@ iwm_fw_version_str(char *buf, size_t bufsize, } int -iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type) +iwm_read_firmware(struct iwm_softc *sc) { struct iwm_fw_info *fw = &sc->sc_fw; struct iwm_tlv_ucode_header *uhdr; @@ -693,8 +693,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type) int err; size_t len; - if (fw->fw_status == IWM_FW_STATUS_DONE && - ucode_type != IWM_UCODE_TYPE_INIT) + if (fw->fw_status == IWM_FW_STATUS_DONE) return 0; while (fw->fw_status == IWM_FW_STATUS_INPROGRESS) @@ -4245,7 +4244,7 @@ iwm_load_ucode_wait_alive(struct iwm_softc *sc, struct iwm_fw_sects *fw = &sc->sc_fw.fw_sects[ucode_type]; int err; - err = iwm_read_firmware(sc, ucode_type); + err = iwm_read_firmware(sc); if (err) return err; @@ -9991,6 +9990,8 @@ iwm_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) { + /* Force reload of firmware image from disk. */ + sc->sc_fw.fw_status = IWM_FW_STATUS_NONE; err = iwm_init(ifp); } } else { diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index f43fe1db2ef..06f0b877872 100644 --- a/sys/dev/pci/if_iwx.c +++ b/sys/dev/pci/if_iwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwx.c,v 1.101 2021/09/02 13:44:10 stsp Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.102 2021/09/03 11:41:41 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -8204,6 +8204,8 @@ iwx_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) case SIOCSIFFLAGS: if (ifp->if_flags & IFF_UP) { if (!(ifp->if_flags & IFF_RUNNING)) { + /* Force reload of firmware image from disk. */ + sc->sc_fw.fw_status = IWX_FW_STATUS_NONE; err = iwx_init(ifp); } } else { -- 2.20.1