Re: lpt stopped working

From: Alexey Shuvaev <shuvaev_at_physik.uni-wuerzburg.de>
Date: Tue, 10 Feb 2009 22:57:20 +0100
On Tue, Feb 10, 2009 at 04:12:57PM -0500, John Baldwin wrote:
> On Tuesday 10 February 2009 3:14:47 pm Alexey Shuvaev wrote:
> > Hello all!
> > 
> > [snip]
> > 
> > And this is from kgdb:
> > (kgdb) p *(struct ppb_data *)ppbus_devclass->devices[0]->softc
> > $1 = {class_id = 0, state = 1, error = 0, mode = 0,
> >   ppb_owner = 0xffffff0004668700, ppc_lock = 0xffffff0004668eb8,
> >   ppc_irq_res = 0xffffff0004677900}
> > (kgdb) p *(device_t)((struct 
> ppb_data*)ppbus_devclass->devices[0]->softc)->ppb
> > _owner
> > $2 = {ops = 0xffffff0001520000, link = {tqe_next = 0xffffff0004668500,
> >     tqe_prev = 0xffffff0004668908}, devlink = {tqe_next = 
> 0xffffff0004668500,
> >     tqe_prev = 0xffffff0004668918}, parent = 0xffffff0004669000, children = 
> {
> >     tqh_first = 0x0, tqh_last = 0xffffff0004668730},
> >   driver = 0xffffffff806961c0, devclass = 0xffffff00014f4900, unit = 0,
> >   nameunit = 0xffffff0004666940 "lpt0", desc = 0xffffffff804fc110 "Printer",
> >   busy = 0, state = DS_ATTACHED, devflags = 0, flags = 7, order = 0 '\0',
> >   pad = 0 '\0', ivars = 0xffffff0004668800, softc = 0xffffff0004668400,
> >   sysctl_ctx = {tqh_first = 0xffffff0004674180,
> >     tqh_last = 0xffffff0004674288}, sysctl_tree = 0xffffff000467d480}
> > (kgdb)
> > 
> > The driver stays in this state even after exit of 'cat' process
> > (I think this was already reported):
> > ~> cat monitor_info > /dev/lpt0
> > /dev/lpt0: Device busy.
> 
> Ok, so the first cat works, the second one gets EBUSY?
>
Mmm... I don't think the first cat really works.
It hangs, I suppose nothing goes to the wire,
and during this I got the above printigs from kgdb.

> Can you see if the first 'cat' process is still around?
> 
It is possible to kill this cat process either by kill
or just type Ctrl-C twice in the terminal where it hangs.
I don't see it in ps output thereafter.
Nevertheless the lpt returns 'Device busy'
and if I try kgdb commands again the results are the same.

> Hmm, I think I've found it.  Due to a bug, lptclose() wasn't releasing the 
> bus.
> 
> --- //depot/user/jhb/acpipci/dev/ppbus/lpt.c
> +++ /home/jhb/work/p4/acpipci/dev/ppbus/lpt.c
> _at__at_ -611,11 +611,8 _at__at_
>  	int err;
>  
>  	ppb_lock(ppbus);
> -	if (sc->sc_flags & LP_BYPASS) {
> -		sc->sc_state = 0;
> -		ppb_unlock(ppbus);
> +	if (sc->sc_flags & LP_BYPASS)
>  		goto end_close;
> -	}
>  
>  	if ((err = lpt_request_ppbus(lptdev, PPB_WAIT|PPB_INTR)) != 0) {
>  		ppb_unlock(ppbus);
> _at__at_ -635,16 +632,16 _at__at_
>  	sc->sc_state &= ~OPEN;
>  	callout_stop(&sc->sc_timer);
>  	ppb_wctr(ppbus, LPC_NINIT);
> -	sc->sc_state = 0;
> -	sc->sc_xfercnt = 0;
>  
>  	/*
>  	 * unregistration of interrupt forced by release
>  	 */
>  	lpt_release_ppbus(lptdev);
> -	ppb_unlock(ppbus);
>  
>  end_close:
> +	sc->sc_state = 0;
> +	sc->sc_xfercnt = 0;
> +	ppb_unlock(ppbus);
>  	lprintf(("closed.\n"));
>  	return(0);
>  }
> 
Just recompiled the whole kernel and tried again. The same symptoms
and almost the same kgdb output:
--- old 2009-02-10 22:42:53.000000000 +0100
+++ lpt_2       2009-02-10 22:41:20.000000000 +0100
_at__at_ -9,9 +9,10 _at__at_
     tqe_prev = 0xffffff0004668918}, parent = 0xffffff0004669000, children = {
     tqh_first = 0x0, tqh_last = 0xffffff0004668730},
   driver = 0xffffffff806961c0, devclass = 0xffffff00014f4900, unit = 0,
-  nameunit = 0xffffff0004666940 "lpt0", desc = 0xffffffff804fc110 "Printer",
+  nameunit = 0xffffff0004666930 "lpt0", desc = 0xffffffff804fc110 "Printer",
   busy = 0, state = DS_ATTACHED, devflags = 0, flags = 7, order = 0 '\0',
   pad = 0 '\0', ivars = 0xffffff0004668800, softc = 0xffffff0004668400,
-  sysctl_ctx = {tqh_first = 0xffffff0004674180,
-    tqh_last = 0xffffff0004674288}, sysctl_tree = 0xffffff000467d480}
+  sysctl_ctx = {tqh_first = 0xffffff0004674160,
+    tqh_last = 0xffffff0004674268}, sysctl_tree = 0xffffff000467d480}
 (kgdb)

Interesting, I get something in the dmesg about the printer:
ppbus0: <Parallel port bus> on ppc0
ppbus0: IEEE1284 device found /NIBBLE/ECP
ppbus0: Probing for PnP devices:
ppbus0: <HEWLETT-PACKARD OFFICEJET R60> PRINTER MLC,PCL,PML,SCL

AFAIK the second core is not launched at this moment (and yes, I am on
a dual-core machine :).

Just some thoughts,
Alexey.
Received on Tue Feb 10 2009 - 20:57:22 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:42 UTC