> Date: Sat, 19 Mar 2022 14:18:14 +0100
> From: Stefan Sperling <[email protected]>
> 
> On Wed, Mar 16, 2022 at 10:03:36PM +0100, Stefan Sperling wrote:
> > On Wed, Mar 16, 2022 at 08:46:01PM +0100, Jeremie Courreges-Anglas wrote:
> > > On Mon, Mar 14 2022, Stefan Sperling <[email protected]> wrote:
> > > > It is currently impossible to use more than one iwm or iwx interface
> > > > in a system because I don't understand C.
> > > >
> > > > Trying to bring up an uninitialized interface anyway results in a
> > > > kernel panic ("bogus channel pointer" from net80211), so prevent
> > > > the device from being used in case we never managed to initialize it.
> > > >
> > > > ok?
> > > 
> > > I only tested iwm(4) 8265 but the change makes sense, ok jca@
> > 
> > I will need to revisit this later.
> > 
> > Somehow it fails in bsd.rd. The interface remains unusable.
> > Firmware load fails because of rootfs not being mounted yet (expected),
> > and it still doesn't work once firmware becomes available (not expected).
> 
> Just moving the variable to the soft fixes the multi-device problem,
> and it works in bsd.rd. ok?

ok kettenis@

> I will leave the issue of partial initialization due to errors for later.
> That problem already affects the existing code and there is no need to
> fix it in the same diff.
>  
> diff 216d1e6a5ea1a2af70c6b285d1b35ab0008729c4 
> 24648d7cb335eaa6548221fea3e70572f6349676
> blob - 19ca8c08d3bf6cbeeedfc8b19de01aab5bc531f9
> blob + 2c01f718d47acb01a227795fef659ef353f5c7f6
> --- sys/dev/pci/if_iwm.c
> +++ sys/dev/pci/if_iwm.c
> @@ -11558,7 +11558,6 @@ iwm_preinit(struct iwm_softc *sc)
>       struct ieee80211com *ic = &sc->sc_ic;
>       struct ifnet *ifp = IC2IFP(ic);
>       int err;
> -     static int attached;
>  
>       err = iwm_prepare_card_hw(sc);
>       if (err) {
> @@ -11566,7 +11565,7 @@ iwm_preinit(struct iwm_softc *sc)
>               return err;
>       }
>  
> -     if (attached) {
> +     if (sc->attached) {
>               /* Update MAC in case the upper layers changed it. */
>               IEEE80211_ADDR_COPY(sc->sc_ic.ic_myaddr,
>                   ((struct arpcom *)ifp)->ac_enaddr);
> @@ -11585,7 +11584,7 @@ iwm_preinit(struct iwm_softc *sc)
>               return err;
>  
>       /* Print version info and MAC address on first successful fw load. */
> -     attached = 1;
> +     sc->attached = 1;
>       printf("%s: hw rev 0x%x, fw ver %s, address %s\n",
>           DEVNAME(sc), sc->sc_hw_rev & IWM_CSR_HW_REV_TYPE_MSK,
>           sc->sc_fwver, ether_sprintf(sc->sc_nvm.hw_addr));
> blob - 53693a914a0e1fe20b0954322a7487ada68be821
> blob + 5c2e387480d3ad45f585e4c84bd7162d2ef70df9
> --- sys/dev/pci/if_iwmvar.h
> +++ sys/dev/pci/if_iwmvar.h
> @@ -476,6 +476,7 @@ struct iwm_softc {
>       struct ieee80211com sc_ic;
>       int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int);
>       int sc_newstate_pending;
> +     int attached;
>  
>       struct ieee80211_amrr sc_amrr;
>       struct timeout sc_calib_to;
> blob - f2f6c046b4266e5c9f214cfcb0b6c9b1069341fc
> blob + ba54430a5bbe62eea3749d62d72ee14d97ffb11e
> --- sys/dev/pci/if_iwx.c
> +++ sys/dev/pci/if_iwx.c
> @@ -9470,7 +9470,6 @@ iwx_preinit(struct iwx_softc *sc)
>       struct ieee80211com *ic = &sc->sc_ic;
>       struct ifnet *ifp = IC2IFP(ic);
>       int err;
> -     static int attached;
>  
>       err = iwx_prepare_card_hw(sc);
>       if (err) {
> @@ -9478,7 +9477,7 @@ iwx_preinit(struct iwx_softc *sc)
>               return err;
>       }
>  
> -     if (attached) {
> +     if (sc->attached) {
>               /* Update MAC in case the upper layers changed it. */
>               IEEE80211_ADDR_COPY(sc->sc_ic.ic_myaddr,
>                   ((struct arpcom *)ifp)->ac_enaddr);
> @@ -9497,7 +9496,7 @@ iwx_preinit(struct iwx_softc *sc)
>               return err;
>  
>       /* Print version info and MAC address on first successful fw load. */
> -     attached = 1;
> +     sc->attached = 1;
>       printf("%s: hw rev 0x%x, fw ver %s, address %s\n",
>           DEVNAME(sc), sc->sc_hw_rev & IWX_CSR_HW_REV_TYPE_MSK,
>           sc->sc_fwver, ether_sprintf(sc->sc_nvm.hw_addr));
> blob - 0cd898b16c4e2a59efe22d1f61ca9a37429a590b
> blob + 255c28db4dd487f497b26eaaef2a12fd12ef5c66
> --- sys/dev/pci/if_iwxvar.h
> +++ sys/dev/pci/if_iwxvar.h
> @@ -456,6 +456,7 @@ struct iwx_softc {
>       struct ieee80211com sc_ic;
>       int (*sc_newstate)(struct ieee80211com *, enum ieee80211_state, int);
>       int sc_newstate_pending;
> +     int attached;
>  
>       struct task             init_task; /* NB: not reference-counted */
>       struct refcnt           task_refs;
> 
> 

Reply via email to