Module Name:    src
Committed By:   christos
Date:           Sun May 23 02:25:50 UTC 2010

Modified Files:
        src/sys/dev/ieee1394: fwohci.c fwohcivar.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/ieee1394/fwohci.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/ieee1394/fwohcivar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/ieee1394/fwohci.c
diff -u src/sys/dev/ieee1394/fwohci.c:1.126 src/sys/dev/ieee1394/fwohci.c:1.127
--- src/sys/dev/ieee1394/fwohci.c:1.126	Mon May 10 08:17:32 2010
+++ src/sys/dev/ieee1394/fwohci.c	Sat May 22 22:25:50 2010
@@ -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

Index: src/sys/dev/ieee1394/fwohcivar.h
diff -u src/sys/dev/ieee1394/fwohcivar.h:1.30 src/sys/dev/ieee1394/fwohcivar.h:1.31
--- src/sys/dev/ieee1394/fwohcivar.h:1.30	Sun Mar 28 23:05:28 2010
+++ src/sys/dev/ieee1394/fwohcivar.h	Sat May 22 22:25:50 2010
@@ -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;

Reply via email to