Subject: Re: ppp/tty panic
To: Iain Hibbert <plunky@rya-online.net>
From: Andrew Doran <ad@netbsd.org>
List: current-users
Date: 11/12/2007 14:21:22
Hi Iain,

On Sat, Nov 10, 2007 at 10:13:10PM +0000, Iain Hibbert wrote:

> Well, I'm not sure 'kind of gross' covers it adequately, but I got
> slightly further this time:
> 
> panic: kernel diagnostic assertion "mutex_owned(&tty_lock)" failed: file "/home/plunky/src/sys/kern/tty.c", line 2204
> Stopped in pid 756.1 (rfcomm_sppd) at	netbsd:breakpoint+0x1:	ret
> db>
> breakpoint(c048cf6c,c0430041,c0451eef,c0451fb4,89c) at netbsd:breakpoint+0x1
> __kernassert(c0430041,c0451fb4,89c,c0451eef,3) at netbsd:__kernassert+0x39
> ttwakeup(cb74bdcc,cb74be04,c0a61d5d,c0a61d00,c0c8ce54) at netbsd:ttwakeup+0x8b
> pppasyncctlp(c0c8cc00,0,25,c0a61d38,0) at netbsd:pppasyncctlp+0x3e
> pppintr(c0c8cc00,330,3,0,c010100f) at netbsd:pppintr+0x287
> softintr_dispatch(1,cb722a00,0,uvm_fault(0xc04b1ac0, 0xca5bd000, 1) -> 0xe
> 
> I'm slightly afraid to touch this but following your lead I tried:
> 
>  static void
>  pppasyncctlp(struct ppp_softc *sc)
>  {
>      struct tty *tp;
>      int s;
> 
>      /* Put a placeholder byte in canq for ttselect()/ttnread(). */
>      s = spltty();
>      tp = (struct tty *) sc->sc_devp;
>      putc(0, &tp->t_canq);
> +    mutex_spin_enter(&tty_lock);
>      ttwakeup(tp);
> +    mutex_spin_exit(&tty_lock);
>      splx(s);
>  }
> 
> and that workedr; is it right?

It should be held around the putc(), too but yes it's right. I just checked
in a fix. Sorry about that.

Andrew