Current-Users archive

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

Re: fwohci panic at boot



Hi! all,


I fixed some problems.
The last problem that I know is this now.

From: "Christoph Egger" <Christoph_Egger%gmx.de@localhost>
Date: Wed, 12 May 2010 14:13:15 +0200

> fwohci0: BUS reset
> panic: kernel diagnostic assertion "!cpu_intr_p()" failed: file 
> "sys/kern/subr_kmem.c", line 195
> fatal breakpoint trap in supervisor mode
> trap type 1 code 0 rip ffffffff80229ffd cs 8 rflags 246 cr2  0 cpl 6 rsp 
> fffffff
> f80f30b18
> Stopped in pid 0.1 (system) at  netbsd:breakpoint+0x5:  leave
> db{0}> bt
> breakpoint() at netbsd:breakpoint+0x5
> panic() at netbsd:panic+0x2ba
> kern_assert() at netbsd:kern_assert+0x2d
> kmem_alloc() at netbsd:kmem_alloc+0x140
> kmem_zalloc() at netbsd:kmem_zalloc+0xf
> fw_busreset() at netbsd:fw_busreset+0x23b
> fwohci_intr() at netbsd:fwohci_intr+0xa56
> intr_biglock_wrapper() at netbsd:intr_biglock_wrapper+0x1d
> Xintr_ioapic_level9() at netbsd:Xintr_ioapic_level9+0xf4
> --- interrupt ---
> Xspllower() at netbsd:Xspllower+0xe
> main() at netbsd:main+0x21c

Can you try this patch?
It use static data buffer and mutex globally.

Can you solve it smarter?  ;-)

Thanks,
--
kiyohara
Index: firewire.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ieee1394/firewire.c,v
retrieving revision 1.33
diff -u -r1.33 firewire.c
--- firewire.c  15 May 2010 10:42:51 -0000      1.33
+++ firewire.c  15 May 2010 10:46:24 -0000
@@ -190,6 +190,10 @@
 u_int gap_cnt[] = { 5,  5,  7,  8, 10, 13, 16, 18,
                   21, 24, 26, 29, 32, 35, 37, 40};
 
+/* newrom_mtx uses to mutual exclusion for newrom_space in fw_busreset(). */
+static int newrom_mtx_initialized;
+static kmutex_t newrom_mtx;
+
 
 static int
 firewirematch(device_t parent, cfdata_t cf, void *aux)
@@ -281,6 +285,15 @@
        if (!pmf_device_register(self, NULL, NULL))
                aprint_error_dev(self, "couldn't establish power handler\n");
 
+       if (!newrom_mtx_initialized) {
+               /*
+                * newrom_mtx uses to mutual exclusion for newrom_space in
+                * fw_busreset() globally.
+                */
+               mutex_init(&newrom_mtx, MUTEX_DEFAULT, IPL_BIO);
+               newrom_mtx_initialized = 1;
+       }
+
        return;
 }
 
@@ -541,6 +554,7 @@
 /*
  * Called after bus reset.
  */
+static uint32_t newrom_space[CROMSIZE];
 void
 fw_busreset(struct firewire_comm *fc, uint32_t new_status)
 {
@@ -548,7 +562,6 @@
        struct firewire_dev_list *devlist;
        struct firewire_dev_comm *fdc;
        struct crom_src *src;
-       uint32_t *newrom;
 
        if (fc->status == FWBUSMGRELECT)
                callout_stop(&fc->bmr_callout);
@@ -583,15 +596,15 @@
         * Configuration ROM.
         */
 #define FW_MAX_GENERATION      0xF
-       newrom = kmem_zalloc(CROMSIZE, KM_NOSLEEP);
        src = &fc->crom_src_buf->src;
-       crom_load(src, newrom, CROMSIZE);
-       if (memcmp(newrom, fc->config_rom, CROMSIZE) != 0) {
+       mutex_enter(&newrom_mtx);
+       crom_load(src, newrom_space, CROMSIZE);
+       if (memcmp(newrom_space, fc->config_rom, CROMSIZE) != 0) {
                if (src->businfo.generation++ > FW_MAX_GENERATION)
                        src->businfo.generation = FW_GENERATION_CHANGEABLE;
-               memcpy((void *)fc->config_rom, newrom, CROMSIZE);
+               memcpy(fc->config_rom, newrom_space, CROMSIZE);
        }
-       kmem_free(newrom, CROMSIZE);
+       mutex_exit(&newrom_mtx);
 }
 
 /* Call once after reboot */


Home | Main Index | Thread Index | Old Index