From: stsp Date: Wed, 14 Jun 2017 16:56:04 +0000 (+0000) Subject: Make iwm(4) wait for the PHY calibration result notification during HW init. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=626e1a0594dfa3a93f068df763589b3682cce52a;p=openbsd Make iwm(4) wait for the PHY calibration result notification during HW init. Code inspection revealed that Linux does this, and so should we. ok deraadt@ --- diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 062919b59cc..9478ce76dec 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.192 2017/06/09 13:47:26 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.193 2017/06/14 16:56:04 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -3126,6 +3126,7 @@ iwm_load_ucode_wait_alive(struct iwm_softc *sc, int iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justnvm) { + const int wait_flags = (IWM_INIT_COMPLETE | IWM_CALIB_COMPLETE); int err; if ((sc->sc_flags & IWM_FLAG_RFKILL) && !justnvm) { @@ -3177,10 +3178,10 @@ iwm_run_init_mvm_ucode(struct iwm_softc *sc, int justnvm) return err; /* - * Nothing to do but wait for the init complete notification - * from the firmware + * Nothing to do but wait for the init complete and phy DB + * notifications from the firmware. */ - while (!sc->sc_init_complete) { + while ((sc->sc_init_complete & wait_flags) != wait_flags) { err = tsleep(&sc->sc_init_complete, 0, "iwminit", 2*hz); if (err) break; @@ -6680,6 +6681,8 @@ iwm_notif_intr(struct iwm_softc *sc) struct iwm_calib_res_notif_phy_db *phy_db_notif; SYNC_RESP_STRUCT(phy_db_notif, pkt); iwm_phy_db_set_section(sc, phy_db_notif); + sc->sc_init_complete |= IWM_CALIB_COMPLETE; + wakeup(&sc->sc_init_complete); break; } @@ -6746,7 +6749,7 @@ iwm_notif_intr(struct iwm_softc *sc) break; case IWM_INIT_COMPLETE_NOTIF: - sc->sc_init_complete = 1; + sc->sc_init_complete |= IWM_INIT_COMPLETE; wakeup(&sc->sc_init_complete); break; diff --git a/sys/dev/pci/if_iwmvar.h b/sys/dev/pci/if_iwmvar.h index a78c5eddd32..23f27c91019 100644 --- a/sys/dev/pci/if_iwmvar.h +++ b/sys/dev/pci/if_iwmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwmvar.h,v 1.27 2017/05/28 09:59:58 stsp Exp $ */ +/* $OpenBSD: if_iwmvar.h,v 1.28 2017/06/14 16:56:04 stsp Exp $ */ /* * Copyright (c) 2014 genua mbh @@ -407,6 +407,8 @@ struct iwm_softc { int sc_fw_chunk_done; int sc_init_complete; +#define IWM_INIT_COMPLETE 0x01 +#define IWM_CALIB_COMPLETE 0x02 struct iwm_ucode_status sc_uc; enum iwm_ucode_type sc_uc_current;