Hi!

the ix(4)-Driver stores a pointer to the pci_attach_args structure (as
passed to ixgbe_attach) in its softc. However, the pci_attach_args
structure lives on the stack somewhere in autoconf, i.e. its contents are
undefined after ixgbe_attach returns.

However, the pointer to that data remains in ix_softc and is used at least
in ixgbe_detach. The diff below changes this by storing a copy of the
pci_attach_args in ix_softc.

Tested (with a slightly modified source tree) on x86.

    regards    Christian

Index: if_ix.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_ix.c,v
retrieving revision 1.59
diff -u -p -r1.59 if_ix.c
--- if_ix.c     13 Jan 2012 09:38:23 -0000      1.59
+++ if_ix.c     20 Jan 2012 14:02:04 -0000
@@ -209,7 +209,7 @@ ixgbe_attach(struct device *parent, stru
        INIT_DEBUGOUT("ixgbe_attach: begin");
 
        sc->osdep.os_sc = sc;
-       sc->osdep.os_pa = pa;
+       sc->osdep.os_pa = *pa;
 
        /* Core Lock Init*/
        mtx_init(&sc->core_mtx, IPL_NET);
@@ -1400,7 +1400,7 @@ void
 ixgbe_identify_hardware(struct ix_softc *sc)
 {
        struct ixgbe_osdep      *os = &sc->osdep;
-       struct pci_attach_args  *pa = os->os_pa;
+       struct pci_attach_args  *pa = &os->os_pa;
        uint32_t                 reg;
 
        /* Save off the information about this board */
@@ -1534,7 +1534,7 @@ ixgbe_allocate_legacy(struct ix_softc *s
 {
        struct ifnet            *ifp = &sc->arpcom.ac_if;
        struct ixgbe_osdep      *os = &sc->osdep;
-       struct pci_attach_args  *pa = os->os_pa;
+       struct pci_attach_args  *pa = &os->os_pa;
        const char              *intrstr = NULL;
        pci_chipset_tag_t       pc = pa->pa_pc;
        pci_intr_handle_t       ih;
@@ -1576,7 +1576,7 @@ int
 ixgbe_allocate_pci_resources(struct ix_softc *sc)
 {
        struct ixgbe_osdep      *os = &sc->osdep;
-       struct pci_attach_args  *pa = os->os_pa;
+       struct pci_attach_args  *pa = &os->os_pa;
        int                      val;
 
        val = pci_conf_read(pa->pa_pc, pa->pa_tag, PCIR_BAR(0));
@@ -1609,7 +1609,7 @@ void
 ixgbe_free_pci_resources(struct ix_softc * sc)
 {
        struct ixgbe_osdep      *os = &sc->osdep;
-       struct pci_attach_args  *pa = os->os_pa;
+       struct pci_attach_args  *pa = &os->os_pa;
        struct ix_queue *que = sc->queues;
        int i;
 
@@ -1749,7 +1749,7 @@ ixgbe_dma_malloc(struct ix_softc *sc, bu
        struct ixgbe_osdep      *os = &sc->osdep;
        int                      r;
 
-       dma->dma_tag = os->os_pa->pa_dmat;
+       dma->dma_tag = os->os_pa.pa_dmat;
        r = bus_dmamap_create(dma->dma_tag, size, 1,
            size, 0, BUS_DMA_NOWAIT, &dma->dma_map);
        if (r != 0) {
@@ -3330,7 +3330,7 @@ ixgbe_read_pci_cfg(struct ixgbe_hw *hw, 
                high = 1;
                reg &= ~0x2;
        }
-       pa = ((struct ixgbe_osdep *)hw->back)->os_pa;
+       pa = &((struct ixgbe_osdep *)hw->back)->os_pa;
        value = pci_conf_read(pa->pa_pc, pa->pa_tag, reg);
 
        if (high)
@@ -3351,7 +3351,7 @@ ixgbe_write_pci_cfg(struct ixgbe_hw *hw,
                high = 1;
                reg &= ~0x2;
        }
-       pa = ((struct ixgbe_osdep *)hw->back)->os_pa;
+       pa = &((struct ixgbe_osdep *)hw->back)->os_pa;
        rv = pci_conf_read(pa->pa_pc, pa->pa_tag, reg);
        if (!high)
                rv = (rv & 0xffff0000) | value;
Index: ixgbe.h
===================================================================
RCS file: /cvs/src/sys/dev/pci/ixgbe.h,v
retrieving revision 1.7
diff -u -p -r1.7 ixgbe.h
--- ixgbe.h     10 Jun 2011 12:46:35 -0000      1.7
+++ ixgbe.h     20 Jan 2012 14:02:04 -0000
@@ -127,7 +127,7 @@ struct ixgbe_osdep {
        bus_addr_t               os_membase;
 
        void                    *os_sc;
-       struct pci_attach_args  *os_pa;
+       struct pci_attach_args   os_pa;
 };
 
 extern uint16_t ixgbe_read_pci_cfg(struct ixgbe_hw *, uint32_t);

Reply via email to