Current-Users archive

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

Re: assert in sys/dev/usb/ohci.c



On 03/24/13 22:05, Aleksey Cheusov wrote:
I tried to boot today's kernel on x86_64 machine.
The result is here

http://mova.org/~cheusov/priv/panic-2013-03-25.jpg

Is this something well known or I can open a PR?
Obviously, usb keyboard doesn't work, so I cannot show backtrace


Actually, this patch might help, but it's a little strange.

Nick

Index: sys/dev/usb/ohci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/ohci.c,v
retrieving revision 1.235
diff -u -p -u -r1.235 ohci.c
--- sys/dev/usb/ohci.c  22 Mar 2013 13:28:11 -0000      1.235
+++ sys/dev/usb/ohci.c  24 Mar 2013 22:39:55 -0000
@@ -2122,7 +2144,7 @@ ohci_open(usbd_pipe_handle pipe)
 
        if (sc->sc_dying) {
                err = USBD_IOERROR;
-               goto bad0;
+               goto bad;
        }
 
        std = NULL;
@@ -2138,19 +2160,20 @@ ohci_open(usbd_pipe_handle pipe)
                        break;
                default:
                        err = USBD_INVAL;
-                       goto bad0;
+                       goto bad;
                }
        } else {
                sed = ohci_alloc_sed(sc);
                if (sed == NULL)
-                       goto bad0;
+                       goto bad;
                opipe->sed = sed;
                if (xfertype == UE_ISOCHRONOUS) {
                        mutex_enter(&sc->sc_lock);
                        sitd = ohci_alloc_sitd(sc);
-                       mutex_exit(&sc->sc_lock);
                        if (sitd == NULL)
-                               goto bad1;
+                               goto badlocked;
+                       mutex_exit(&sc->sc_lock);
+
                        opipe->tail.itd = sitd;
                        tdphys = sitd->physaddr;
                        fmt = OHCI_ED_FORMAT_ISO;
@@ -2161,9 +2184,10 @@ ohci_open(usbd_pipe_handle pipe)
                } else {
                        mutex_enter(&sc->sc_lock);
                        std = ohci_alloc_std(sc);
-                       mutex_exit(&sc->sc_lock);
                        if (std == NULL)
-                               goto bad1;
+                               goto badlocked;
+                       mutex_exit(&sc->sc_lock);
+
                        opipe->tail.td = std;
                        tdphys = std->physaddr;
                        fmt = OHCI_ED_FORMAT_GEN | OHCI_ED_DIR_TD;
@@ -2186,9 +2210,9 @@ ohci_open(usbd_pipe_handle pipe)
                        err = usb_allocmem(&sc->sc_bus,
                                  sizeof(usb_device_request_t),
                                  0, &opipe->u.ctl.reqdma);
-                       if (err)
-                               goto bad;
                        mutex_enter(&sc->sc_lock);
+                       if (err)
+                               goto badlocked;
                        ohci_add_ed(sc, sed, sc->sc_ctrl_head);
                        mutex_exit(&sc->sc_lock);
                        break;
@@ -2215,13 +2239,14 @@ ohci_open(usbd_pipe_handle pipe)
 
        return USBD_NORMAL_COMPLETION;
 
- bad:
+ badlocked:
+       KASSERT(mutex_owned(&sc->sc_lock));
        if (std != NULL)
                ohci_free_std(sc, std);
- bad1:
        if (sed != NULL)
                ohci_free_sed(sc, sed);
- bad0:
+       mutex_exit(&sc->sc_lock);
+ bad:
        return err;
 
 }



Home | Main Index | Thread Index | Old Index