Bogus usage of tsleep(9) in USB.

Pawel Jakub Dawidek pjd at FreeBSD.org
Fri Aug 20 02:09:37 PDT 2004


On Fri, Aug 20, 2004 at 11:00:06AM +0200, Pawel Jakub Dawidek wrote:
+> There are many calls to tsleep(9) with no timeout in our USB code.
+> As you all know, it is not permitted and we have KASSERT() for this:
+> 
+>         KASSERT(timo != 0 || mtx_owned(&Giant) || mtx != NULL,
+>             ("sleeping without a mutex"));
+> 
+> ehci.c:2441:    tsleep(&sc->sc_softwake, PZERO, "ehciab", 0);
+> ohci.c:2288:    tsleep(&sc->sc_softwake, PZERO, "ohciab", 0);
+> ubser.c:882:            tsleep(&sc->sc_opening, PRIBIO, "ubser_op", 0);
+> ucom.c:275:             tsleep(&sc->sc_opening, PRIBIO, "ucomop", 0);
+> ugen.c:633:                     error = tsleep(sce, PZERO | PCATCH, "ugenri", 0);
+> ugen.c:697:                     error = tsleep(sce, PZERO | PCATCH, "ugenri", 0);
+> uhci.c:1982:    tsleep(&sc->sc_softwake, PZERO, "uhciab", 0);
+> uhid.c:496:             error = tsleep(&sc->sc_q, PZERO | PCATCH, "uhidrea", 0);
+> ums.c:639:              error = tsleep(sc, PZERO | PCATCH, "umsrea", 0);
+> usb.c:456:                      tsleep(&usb_all_tasks, PWAIT, "usbtsk", 0);
+> usb.c:534:              error = tsleep(&usb_events, PZERO | PCATCH, "usbrea", 0);
+> usbdi.c:342:            tsleep(xfer, PRIBIO, "usbsyn", 0);
+> usbdi_util.c:435:       error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
+> usbdi_util.c:477:       error = tsleep(xfer, PZERO | PCATCH, lbl, 0);
+> 
+> I saw only panic on tsleep(9) from usbdi.c, so I know for sure we don't
+> hold Giant there.

BTW. It looks there are more interesting places:

	anger:root:~# egrep -r 'tsleep.*[^0-9]0\)' /sys/ | wc -l
	     123

I don't know where we hold Giant, but I'm quite sure not everywhere.

-- 
Pawel Jakub Dawidek                       http://www.FreeBSD.org
pjd at FreeBSD.org                           http://garage.freebsd.pl
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20040820/0c5901fb/attachment.bin


More information about the freebsd-current mailing list