Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ieee1394 Don't allocate sid scratch memory from an i...



details:   https://anonhg.NetBSD.org/src/rev/3700830b40ac
branches:  trunk
changeset: 755120:3700830b40ac
user:      christos <christos%NetBSD.org@localhost>
date:      Sun May 23 02:25:50 2010 +0000

description:
Don't allocate sid scratch memory from an interrupt context:

fwohci0: BUS reset
fwohci0: node_id=0xc800ffc0, gen=1, CYCLEMASTER mode
panic: kernel diagnostic assertion "!cpu_intr_p()" failed: file "../../../../ker
n/subr_kmem.c", line 195
fatal breakpoint trap in supervisor mode
trap type 1 code 0 rip ffffffff8022db1d cs 8 rflags 246 cr2  0 cpl 6 rsp fffffff
f80fafb68
breakpoint() at netbsd:breakpoint+0x5
panic() at netbsd:panic+0x2ba
kern_assert() at netbsd:kern_assert+0x2d
kmem_alloc() at netbsd:kmem_alloc+0x18a
fwohci_intr() at netbsd:fwohci_intr+0xbe2
...

I will send-pr for the next one... Looks like someone did not use DIAGNOSTIC
when made the changes.

diffstat:

 sys/dev/ieee1394/fwohci.c    |  19 ++++++++++---------
 sys/dev/ieee1394/fwohcivar.h |   3 ++-
 2 files changed, 12 insertions(+), 10 deletions(-)

diffs (95 lines):

diff -r 3e96cd079d99 -r 3700830b40ac sys/dev/ieee1394/fwohci.c
--- a/sys/dev/ieee1394/fwohci.c Sun May 23 02:24:40 2010 +0000
+++ b/sys/dev/ieee1394/fwohci.c Sun May 23 02:25:50 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwohci.c,v 1.126 2010/05/10 12:17:32 kiyohara Exp $    */
+/*     $NetBSD: fwohci.c,v 1.127 2010/05/23 02:25:50 christos Exp $    */
 
 /*-
  * Copyright (c) 2003 Hidetoshi Shimokawa
@@ -37,7 +37,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.126 2010/05/10 12:17:32 kiyohara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.127 2010/05/23 02:25:50 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -414,6 +414,7 @@
                aprint_error_dev(sc->fc.dev, "config_rom alloc failed.");
                return ENOMEM;
        }
+       sc->fc.new_rom = kmem_zalloc(CROMSIZE, KM_SLEEP);
 
 #if 0
        memset(sc->fc.config_rom, 0, CROMSIZE);
@@ -427,7 +428,7 @@
        sc->fc.config_rom[0] |= fw_crc16(&sc->fc.config_rom[1], 5*4);
 #endif
 
-/* SID recieve buffer must align 2^11 */
+/* SID receive buffer must align 2^11 */
 #define        OHCI_SIDSIZE    (1 << 11)
        sc->sid_buf = fwdma_alloc_setup(sc->fc.dev, sc->fc.dmat, OHCI_SIDSIZE,
            &sc->sid_dma, OHCI_SIDSIZE, BUS_DMA_NOWAIT);
@@ -435,6 +436,7 @@
                aprint_error_dev(sc->fc.dev, "sid_buf alloc failed.");
                return ENOMEM;
        }
+       sc->sid_tmp_buf = kmem_alloc(OHCI_SIDSIZE, KM_SLEEP);
 
        fwdma_alloc_setup(sc->fc.dev, sc->fc.dmat, sizeof(uint32_t),
            &sc->dummy_dma, sizeof(uint32_t), BUS_DMA_NOWAIT);
@@ -506,9 +508,13 @@
        if (sc->sid_buf != NULL)
                fwdma_free(sc->sid_dma.dma_tag, sc->sid_dma.dma_map,
                    sc->sid_dma.v_addr);
+       if (sc->sid_tmp_buf != NULL)
+               kmem_free(sc->sid_tmp_buf, OHCI_SIDSIZE);
        if (sc->fc.config_rom != NULL)
                fwdma_free(sc->crom_dma.dma_tag, sc->crom_dma.dma_map,
                    sc->crom_dma.v_addr);
+       if (sc->fc.new_rom != NULL)
+               kmem_free(sc->fc.new_rom, CROMSIZE);
 
        fwohci_db_free(sc, &sc->arrq);
        fwohci_db_free(sc, &sc->arrs);
@@ -2140,11 +2146,7 @@
                return;
        }
        plen -= 4; /* chop control info */
-       buf = kmem_alloc(OHCI_SIDSIZE, KM_NOSLEEP);
-       if (buf == NULL) {
-               aprint_error_dev(fc->dev, "kmem alloc failed\n");
-               return;
-       }
+       buf = sc->sid_tmp_buf;
        for (i = 0; i < plen / 4; i++)
                buf[i] = FWOHCI_DMA_READ(sc->sid_buf[i + 1]);
 #if 1 /* XXX needed?? */
@@ -2156,7 +2158,6 @@
        fw_drain_txq(fc);
 #endif
        fw_sidrcv(fc, buf, plen);
-       kmem_free(buf, OHCI_SIDSIZE);
 }
 
 static void
diff -r 3e96cd079d99 -r 3700830b40ac sys/dev/ieee1394/fwohcivar.h
--- a/sys/dev/ieee1394/fwohcivar.h      Sun May 23 02:24:40 2010 +0000
+++ b/sys/dev/ieee1394/fwohcivar.h      Sun May 23 02:25:50 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwohcivar.h,v 1.30 2010/03/29 03:05:28 kiyohara Exp $  */
+/*     $NetBSD: fwohcivar.h,v 1.31 2010/05/23 02:25:50 christos Exp $  */
 
 /*-
  * Copyright (c) 2003 Hidetoshi SHimokawa
@@ -66,6 +66,7 @@
        } arrq, arrs, atrq, atrs, it[OHCI_DMA_ITCH], ir[OHCI_DMA_IRCH];
        u_int maxrec;
        uint32_t *sid_buf;
+       uint32_t *sid_tmp_buf;
        struct fwdma_alloc sid_dma;
        struct fwdma_alloc crom_dma;
        struct fwdma_alloc dummy_dma;



Home | Main Index | Thread Index | Old Index