Subject: kern/4227: blocked state of hardware flow control is not cleared
To: None <gnats-bugs@gnats.netbsd.org>
From: Noriyuki Shiota <nori@shiota.imasy.or.jp>
List: netbsd-bugs
Date: 10/07/1997 02:05:13
>Number:         4227
>Category:       kern
>Synopsis:       blocked state of hardware flow control is not cleared
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct  6 10:05:01 1997
>Last-Modified:
>Originator:     Noriyuki Shiota
>Organization:
Noriyuki Shiota		nori@shiota.imasy.or.jp
>Release:        NetBSD-current as of October 6, 1997
>Environment:
System: NetBSD escar 1.2G NetBSD 1.2G (ESCAR_BT_BOCA) #15: Mon Oct 6 23:26:37 JST 1997 root@escar:/usr/src/sys/arch/i386/compile/ESCAR_BT_BOCA i386

>Description:
	On establishing ppp connection, I used following command:
		pppd `chat ...` ....
	and chat script is done normally.
	But if the host machine send the long motd message, serial driver
	negates RTS signal line.
	then pppd changes line descipline to ppp, RTS signal is still
	low. (serial driver's state is still blocked.)
	In this situation, pppd never receive PPP packet.

>How-To-Repeat:
	Try to connect ppp to long motd ppp server.
    or
	f = open("/dev/tty00", O_RDWR);

	<receive may characters from serial line.
	 (*tp->t_hwiflow)(tp, 1) is called.
	 serial driver clears RTS signal line and enter block state>

	what = FREAD;
	ioctl(f, TIOCFLUSH, &what);	/* flush receive buffer */

	read(f, buf, sizeof(buf));	<-- block forever...
					    receive no character because
					    RTS is still low.
    or
	f = open("/dev/tty00", O_RDWR);

	<receive may characters from serial line.
	 (*tp->t_hwiflow)(tp, 1) is called.
	 serial driver clears RTS signal line and enter block state>

	ldisc = PPPDISC;
	ioctl(f, TIOCSETD, &ldisc);	/* change to PPP line descipline */

	read(f, buf, sizeof(buf));	<-- block forever...
					    receive no character because
					    RTS is still low.

>Fix:
*** tty.c.ORIG	Fri Jun 20 20:33:34 1997
--- tty.c	Tue Oct  7 02:04:29 1997
***************
*** 1057,1082 ****
--- 1057,1086 ----
  ttyflush(tp, rw)
  	register struct tty *tp;
  	int rw;
  {
  	register int s;
  
  	s = spltty();
  	if (rw & FREAD) {
  		FLUSHQ(&tp->t_canq);
  		FLUSHQ(&tp->t_rawq);
  		tp->t_rocount = 0;
  		tp->t_rocol = 0;
  		CLR(tp->t_state, TS_LOCAL);
+ 		if (ISSET(tp->t_state, TS_TBLOCK) &&
+ 		    ISSET(tp->t_cflag, CHWFLOW) && tp->t_hwiflow &&
+ 		    (*tp->t_hwiflow)(tp, 0) != 0)
+ 			CLR(tp->t_state, TS_TBLOCK);
  		ttwakeup(tp);
  	}
  	if (rw & FWRITE) {
  		CLR(tp->t_state, TS_TTSTOP);
  		(*cdevsw[major(tp->t_dev)].d_stop)(tp, rw);
  		FLUSHQ(&tp->t_outq);
  		wakeup((caddr_t)&tp->t_outq);
  		selwakeup(&tp->t_wsel);
  	}
  	splx(s);
  }
  
  /*
>Audit-Trail:
>Unformatted: