summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_bnx.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2007-01-20 00:36:09 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2007-01-20 00:36:09 +0000
commitbb36b97051abda47dc8c7936bea8fc621756b93d (patch)
treef2d66bea3c428da1f37714da025a438e573f92ab /sys/dev/pci/if_bnx.c
parenta603dc203c85611b8ba9af04a118553cf377b477 (diff)
move the interrupt establishment till after everything in the softc is
set up and allocated (which happens in a mountroothook). this prevents an early call to the interrupt handler from causing a null deref when trying to look into the unallocated regions. found by mcbride when ciss and bnx were sharing an interrupt. mounting root caused interrupts before the bnx was properly set up. "commit your fix" mcbride@
Diffstat (limited to 'sys/dev/pci/if_bnx.c')
-rw-r--r--sys/dev/pci/if_bnx.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c
index f233f0e4d10..1ebfb24cd3a 100644
--- a/sys/dev/pci/if_bnx.c
+++ b/sys/dev/pci/if_bnx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnx.c,v 1.39 2007/01/19 18:35:50 mcbride Exp $ */
+/* $OpenBSD: if_bnx.c,v 1.40 2007/01/20 00:36:07 dlg Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -627,7 +627,6 @@ bnx_attach(struct device *parent, struct device *self, void *aux)
u_int32_t val;
pcireg_t memtype;
const char *intrstr = NULL;
- pci_intr_handle_t ih;
sc->bnx_pa = *pa;
@@ -647,12 +646,11 @@ bnx_attach(struct device *parent, struct device *self, void *aux)
return;
}
- if (pci_intr_map(pa, &ih)) {
+ if (pci_intr_map(pa, &sc->bnx_ih)) {
printf(": couldn't map interrupt\n");
goto bnx_attach_fail;
}
-
- intrstr = pci_intr_string(pc, ih);
+ intrstr = pci_intr_string(pc, sc->bnx_ih);
/*
* Configure byte swap and enable indirect register access.
@@ -744,16 +742,6 @@ bnx_attach(struct device *parent, struct device *self, void *aux)
if (val & BNX_PCICFG_MISC_STATUS_32BIT_DET)
sc->bnx_flags |= BNX_PCI_32BIT_FLAG;
- /* Hookup IRQ last. */
- sc->bnx_intrhand = pci_intr_establish(pc, ih, IPL_NET, bnx_intr, sc,
- sc->bnx_dev.dv_xname);
- if (sc->bnx_intrhand == NULL) {
- printf("%s: couldn't establish interrupt", sc->bnx_dev.dv_xname);
- if (intrstr != NULL)
- printf(" at %s", intrstr);
- printf("\n");
- goto bnx_attach_fail;
- }
printf(": %s\n", intrstr);
mountroothook_establish(bnx_attachhook, sc);
@@ -769,6 +757,7 @@ bnx_attachhook(void *xsc)
{
struct bnx_softc *sc = xsc;
struct pci_attach_args *pa = &sc->bnx_pa;
+ pci_chipset_tag_t pc = pa->pa_pc;
struct ifnet *ifp;
u_int32_t val;
int error;
@@ -934,6 +923,15 @@ bnx_attachhook(void *xsc)
/* Get the firmware running so ASF still works. */
bnx_mgmt_init(sc);
+ /* Hookup IRQ last. */
+ sc->bnx_intrhand = pci_intr_establish(pc, sc->bnx_ih, IPL_NET,
+ bnx_intr, sc, sc->bnx_dev.dv_xname);
+ if (sc->bnx_intrhand == NULL) {
+ printf("%s: couldn't establish interrupt\n",
+ sc->bnx_dev.dv_xname);
+ goto bnx_attach_fail;
+ }
+
goto bnx_attach_exit;
bnx_attach_fail: