From: stsp Date: Fri, 16 Feb 2024 14:18:36 +0000 (+0000) Subject: fix qwx(4) not coming up on first try if firmware was missing from disk at boot X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=160cf663fb70731484e4bc42ee29b51be9667811;p=openbsd fix qwx(4) not coming up on first try if firmware was missing from disk at boot --- diff --git a/sys/dev/ic/qwx.c b/sys/dev/ic/qwx.c index 8d0c26fc074..fcbae624d16 100644 --- a/sys/dev/ic/qwx.c +++ b/sys/dev/ic/qwx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: qwx.c,v 1.43 2024/02/16 14:16:16 stsp Exp $ */ +/* $OpenBSD: qwx.c,v 1.44 2024/02/16 14:18:36 stsp Exp $ */ /* * Copyright 2023 Stefan Sperling @@ -211,29 +211,13 @@ qwx_init(struct ifnet *ifp) ieee80211_media_init(ifp, qwx_media_change, ieee80211_media_status); if (sc->attached) { - /* - * We are either going up for the first time or qwx_stop() ran - * before us and has waited for any stale tasks to finish up. - */ - KASSERT(sc->task_refs.r_refs == 0); - refcnt_init(&sc->task_refs); - - ifq_clr_oactive(&ifp->if_snd); - ifp->if_flags |= IFF_RUNNING; - /* Update MAC in case the upper layers changed it. */ IEEE80211_ADDR_COPY(ic->ic_myaddr, ((struct arpcom *)ifp)->ac_enaddr); - - error = qwx_mac_start(sc); - if (error) - return error; - - ieee80211_begin_scan(ifp); } else { sc->attached = 1; - /* Configure MAC address at boot-time. */ + /* Configure initial MAC address. */ error = if_setlladdr(ifp, ic->ic_myaddr); if (error) printf("%s: could not set MAC address %s: %d\n", @@ -241,6 +225,19 @@ qwx_init(struct ifnet *ifp) error); } + if (ifp->if_flags & IFF_UP) { + refcnt_init(&sc->task_refs); + + ifq_clr_oactive(&ifp->if_snd); + ifp->if_flags |= IFF_RUNNING; + + error = qwx_mac_start(sc); + if (error) + return error; + + ieee80211_begin_scan(ifp); + } + return 0; }