ulpt_tick after close
Ian Dowse
iedowse at iedowse.com
Sun May 29 05:10:28 PDT 2005
In message <42998B18.8020806 at radiotube.org>, Jan-Espen Pettersen writes:
>I think I'll replace that printf with a panic in ulpt_read_cb to get a
>backtrace next time. (And at the same time update my sources) As it
>would reveal what is actually calling ulpt_read_cb after the callout has
>been stopped. The problem is that this is very unlikely to happen during
>a single print job, but it does over time, so it might take me some time
>to get that backtrace.
Thanks for the details. By the way, is it lpd or something else
that is actually accessing the ulpt device? Below is a patch you
could try that will hopefully find out a bit more about what is
going on. You could also change the new return statement in
ulpt_read_cb() to a panic, as the stack trace might reveal more
information like you say.
Ian
Index: ulpt.c
===================================================================
RCS file: /dump/FreeBSD-CVS/src/sys/dev/usb/ulpt.c,v
retrieving revision 1.65.2.1
diff -u -r1.65.2.1 ulpt.c
--- ulpt.c 30 Jan 2005 01:00:10 -0000 1.65.2.1
+++ ulpt.c 29 May 2005 11:51:30 -0000
@@ -122,6 +122,7 @@
#define ULPT_OPEN 0x01 /* device is open */
#define ULPT_OBUSY 0x02 /* printer is busy doing output */
#define ULPT_INIT 0x04 /* waiting to initialize for open */
+#define ULPT_CLOSING 0x05 /* closing */
u_char sc_flags;
#define ULPT_NOPRIME 0x40 /* don't prime on open */
u_char sc_laststatus;
@@ -660,9 +661,13 @@
USB_GET_SC(ulpt, ULPTUNIT(dev), sc);
- if (sc->sc_state != ULPT_OPEN)
+ if (sc->sc_state != ULPT_OPEN) {
/* We are being forced to close before the open completed. */
+ printf("%s: ignoring close in state %d\n",
+ USBDEVNAME(sc->sc_dev), sc->sc_state);
return (0);
+ }
+ sc->sc_state = ULPT_CLOSING;
if (sc->sc_has_callout) {
usb_uncallout(sc->sc_read_callout, ulpt_tick, sc);
@@ -810,6 +815,13 @@
usbd_get_xfer_status(xfer, &xsc, NULL, &n, &err);
sc = xsc;
+ if (sc->sc_state != ULPT_OPEN && (status != USBD_CANCELLED ||
+ err != USBD_CANCELLED)) {
+ printf("%s: ulpt_read_cb state=%d status=%s err=%s\n",
+ USBDEVNAME(sc->sc_dev), sc->sc_state, usbd_errstr(status),
+ usbd_errstr(err));
+ return;
+ }
DPRINTFN(1,("ulpt_read_cb: start sc=%p, err=%d n=%d\n", sc, err, n));
#ifdef ULPT_DEBUG
@@ -832,6 +844,11 @@
DPRINTFN(1,("ulpt_tick: start sc=%p\n", sc));
+ if (sc->sc_state != ULPT_OPEN) {
+ printf("%s: ulpt_tick state=%d\n", USBDEVNAME(sc->sc_dev),
+ sc->sc_state);
+ return;
+ }
usbd_setup_xfer(sc->sc_in_xfer, sc->sc_in_pipe, sc, sc->sc_in_buf,
ULPT_BSIZE, USBD_NO_COPY | USBD_SHORT_XFER_OK,
ULPT_READ_TIMO, ulpt_read_cb);
More information about the freebsd-usb
mailing list