Skip to content

Commit

Permalink
Add MSI interrupt index check.
Browse files Browse the repository at this point in the history
  • Loading branch information
zxystd committed Mar 12, 2024
1 parent d48ea5d commit 428b98c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
15 changes: 7 additions & 8 deletions itlwm/hal_iwm/mac80211.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4452,7 +4452,6 @@ iwm_attach(struct iwm_softc *sc, struct pci_attach_args *pa)
pcireg_t reg, memtype;
struct ieee80211com *ic = &sc->sc_ic;
struct _ifnet *ifp = &ic->ic_if;
const char *intrstr = {0};
int err;
int txq_i, i, j;

Expand Down Expand Up @@ -4509,7 +4508,7 @@ iwm_attach(struct iwm_softc *sc, struct pci_attach_args *pa)
PCI_COMMAND_STATUS_REG, reg);
}

int msiIntrIndex = 0;
int msiIntrIndex = -1;
for (int index = 0; ; index++)
{
int interruptType;
Expand All @@ -4522,6 +4521,11 @@ iwm_attach(struct iwm_softc *sc, struct pci_attach_args *pa)
break;
}
}
if (msiIntrIndex == -1) {
XYLog("%s: can't find MSI interrupt controller\n", DEVNAME(sc));
return false;
}

if (sc->sc_msix)
sc->sc_ih =
IOFilterInterruptEventSource::filterInterruptEventSource(this,
Expand All @@ -4533,15 +4537,10 @@ iwm_attach(struct iwm_softc *sc, struct pci_attach_args *pa)
(IOInterruptEventSource::Action)&ItlIwm::iwm_intr, &ItlIwm::intrFilter
, pa->pa_tag, msiIntrIndex);
if (sc->sc_ih == NULL || pa->workloop->addEventSource(sc->sc_ih) != kIOReturnSuccess) {
XYLog("\n");
XYLog("%s: can't establish interrupt", DEVNAME(sc));
if (intrstr != NULL)
XYLog(" at %s", intrstr);
XYLog("\n");
XYLog("%s: can't establish interrupt\n", DEVNAME(sc));
return false;
}
sc->sc_ih->enable();
XYLog(", %s\n", intrstr);

sc->sc_hw_rev = IWM_READ(sc, IWM_CSR_HW_REV);
int pa_id = pa->pa_tag->configRead16(kIOPCIConfigDeviceID);
Expand Down
10 changes: 6 additions & 4 deletions itlwm/hal_iwn/ItlIwn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,6 @@ iwn_attach(struct iwn_softc *sc, struct pci_attach_args *pa)
{
struct ieee80211com *ic = &sc->sc_ic;
struct _ifnet *ifp = &ic->ic_if;
const char *intrstr;
pci_intr_handle_t ih;
pcireg_t memtype, reg;
int i, error;

Expand Down Expand Up @@ -395,7 +393,7 @@ iwn_attach(struct iwn_softc *sc, struct pci_attach_args *pa)
return false;
}

int msiIntrIndex = 0;
int msiIntrIndex = -1;
for (int index = 0; ; index++)
{
int interruptType;
Expand All @@ -408,12 +406,16 @@ iwn_attach(struct iwn_softc *sc, struct pci_attach_args *pa)
break;
}
}
if (msiIntrIndex == -1) {
XYLog("%s: can't find MSI interrupt controller\n", DEVNAME(sc));
return false;
}

sc->sc_ih = IOFilterInterruptEventSource::filterInterruptEventSource(this,
(IOInterruptEventSource::Action)&ItlIwn::iwn_intr, &ItlIwn::intrFilter
,pa->pa_tag, msiIntrIndex);
if (sc->sc_ih == NULL || pa->workloop->addEventSource(sc->sc_ih) != kIOReturnSuccess) {
XYLog("%s: can't establish interrupt", DEVNAME(sc));
XYLog("%s: can't establish interrupt\n", DEVNAME(sc));
return false;
}
sc->sc_ih->enable();
Expand Down
10 changes: 7 additions & 3 deletions itlwm/hal_iwx/ItlIwx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12786,7 +12786,6 @@ intrFilter(OSObject *object, IOFilterInterruptEventSource *src)
bool ItlIwx::
iwx_attach(struct iwx_softc *sc, struct pci_attach_args *pa)
{
pci_intr_handle_t ih;
pcireg_t reg, memtype;
struct ieee80211com *ic = &sc->sc_ic;
struct _ifnet *ifp = &ic->ic_if;
Expand Down Expand Up @@ -12845,7 +12844,7 @@ iwx_attach(struct iwx_softc *sc, struct pci_attach_args *pa)
PCI_COMMAND_STATUS_REG, reg);
}

int msiIntrIndex = 0;
int msiIntrIndex = -1;
for (int index = 0; ; index++)
{
int interruptType;
Expand All @@ -12858,6 +12857,11 @@ iwx_attach(struct iwx_softc *sc, struct pci_attach_args *pa)
break;
}
}
if (msiIntrIndex == -1) {
XYLog("%s: can't find MSI interrupt controller\n", DEVNAME(sc));
return false;
}

if (sc->sc_msix)
sc->sc_ih =
IOFilterInterruptEventSource::filterInterruptEventSource(this,
Expand All @@ -12869,7 +12873,7 @@ iwx_attach(struct iwx_softc *sc, struct pci_attach_args *pa)
(IOInterruptEventSource::Action)&ItlIwx::iwx_intr, &ItlIwx::intrFilter
,pa->pa_tag, msiIntrIndex);
if (sc->sc_ih == NULL || pa->workloop->addEventSource(sc->sc_ih) != kIOReturnSuccess) {
XYLog("%s: can't establish interrupt", DEVNAME(sc));
XYLog("%s: can't establish interrupt\n", DEVNAME(sc));
return false;
}
sc->sc_ih->enable();
Expand Down

0 comments on commit 428b98c

Please sign in to comment.