From f6c92c11f983c9e9dd370657ab43ccf9feb56be5 Mon Sep 17 00:00:00 2001 From: stsp Date: Sat, 19 Mar 2022 14:50:01 +0000 Subject: [PATCH] Fix attach of multiple iwm(4) or iwx(4) interfaces in the same machine. ok kettenis@, jca@ --- sys/dev/pci/if_iwm.c | 7 +++---- sys/dev/pci/if_iwmvar.h | 3 ++- sys/dev/pci/if_iwx.c | 7 +++---- sys/dev/pci/if_iwxvar.h | 3 ++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index 19ca8c08d3b..e82db1f229a 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.395 2022/03/19 10:26:52 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.396 2022/03/19 14:50:01 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -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)); diff --git a/sys/dev/pci/if_iwmvar.h b/sys/dev/pci/if_iwmvar.h index 53693a914a0..ec19f5462f1 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.76 2022/03/19 10:26:52 stsp Exp $ */ +/* $OpenBSD: if_iwmvar.h,v 1.77 2022/03/19 14:50:01 stsp Exp $ */ /* * Copyright (c) 2014 genua mbh @@ -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; diff --git a/sys/dev/pci/if_iwx.c b/sys/dev/pci/if_iwx.c index f2f6c046b42..6c1c1647fbc 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.137 2022/03/14 15:08:50 stsp Exp $ */ +/* $OpenBSD: if_iwx.c,v 1.138 2022/03/19 14:50:01 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -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)); diff --git a/sys/dev/pci/if_iwxvar.h b/sys/dev/pci/if_iwxvar.h index 0cd898b16c4..e78c9fe6fb4 100644 --- a/sys/dev/pci/if_iwxvar.h +++ b/sys/dev/pci/if_iwxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwxvar.h,v 1.30 2022/03/14 15:08:50 stsp Exp $ */ +/* $OpenBSD: if_iwxvar.h,v 1.31 2022/03/19 14:50:01 stsp Exp $ */ /* * Copyright (c) 2014 genua mbh @@ -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; -- 2.20.1