Subject: port-pmax/6848: Bogus test in scc.c breaks 115200 bps
To: None <gnats-bugs@gnats.netbsd.org>
From: Jason R Thorpe <thorpej@og.org>
List: netbsd-bugs
Date: 01/19/1999 01:08:49
>Number:         6848
>Category:       port-pmax
>Synopsis:       Bogus test in scc.c breaks 115200 bps
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-pmax-maintainer (NetBSD/pmax Portmaster)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 19 01:20:01 1999
>Last-Modified:
>Originator:     Jason R Thorpe
>Organization:
People in search of shiny things.
>Release:        NetBSD-1.3.3 and NetBSD-current Tue Jan 19 00:49:16 PST 1999
>Environment:
	DECstation 5000/125.  Affects any DECstation w/ Zilog serial ports.

>Description:
	Part of my weekend was spent installing a DECstation 5000/125
	running NetBSD-1.3.3 for a friend, to act as a NAT/router for
	her ISDN line.  We quickly discovered that 115200 didn't work,
	though 57600 did, even with the SCC_HIGHSPEED option specified
	in the kernel config.

	The lossage was due to a bogus test in cold_sccparam().  When the
	terminal is set to a speed of 0, the modem control lines are
	supposed to go low, and no further initialization is to occur.
	This is done by testing the return value from ttspeedtab().

	However, in order to use 115200, the clock rate generator must
	be programmed with the value 0.  So, 0 is a legitimate return
	value from ttspeedtab().

	Amusingly, there is a comment in the driver claiming that
	115200 is not reliable.  Well, no kidding, given this bug :-)

>How-To-Repeat:
	Attempt to use an SCC serial port at 115200 bps, e.g. using
	tip(1) or pppd(8) to talk to a 3Com ISDN modem.

>Fix:
	The following changes cold_sccparam() to test the ospeed
	in the termios structure; if 0, drop the modem control
	lines.  This is the case which would have caused ttspeedtab()
	to return 0 if SCC_HIGHSPEED was not defined.

	The patch also eliminates SCC_HIGHSPEED, and just includes
	the 76800 and 115200 clock rate values unconditionally.  With
	this patch, the DECstation is able to communicate with the
	3Com ISDN modem at 115200 bps without any noticeable problems.

	A similar change should probably be applied to the NetBSD/alpha
	version of this driver.

Index: scc.c
===================================================================
RCS file: /cvsroot/src/sys/arch/pmax/tc/scc.c,v
retrieving revision 1.44
diff -c -r1.44 scc.c
*** scc.c	1998/11/15 11:21:53	1.44
--- scc.c	1999/01/19 08:48:41
***************
*** 232,241 ****
  	{ 28800,	6,	},	/* non-POSIX */
  	{ 38400,	4,	},	/* non-POSIX */
  	{ 57600,	2,	},	/* non-POSIX */
- #ifdef SCC_HIGHSPEED
  	{ 76800,	1,	},	/* non-POSIX, doesn't work reliably */
! 	{ 115200, 	0	},	/* non-POSIX doesn't work reliably */
! #endif
  	{ -1,		-1,	},
  };
  
--- 232,239 ----
  	{ 28800,	6,	},	/* non-POSIX */
  	{ 38400,	4,	},	/* non-POSIX */
  	{ 57600,	2,	},	/* non-POSIX */
  	{ 76800,	1,	},	/* non-POSIX, doesn't work reliably */
! 	{ 115200, 	0,	},	/* non-POSIX, doesn't work reliably */
  	{ -1,		-1,	},
  };
  
***************
*** 959,965 ****
  	tp->t_ospeed = t->c_ospeed;
  	tp->t_cflag = cflag;
  
! 	if (ospeed == 0) {
  		(void) sccmctl(tp->t_dev, 0, DMSET);	/* hang up line */
  		return (0);
  	}
--- 957,963 ----
  	tp->t_ospeed = t->c_ospeed;
  	tp->t_cflag = cflag;
  
! 	if (t->c_ospeed == 0) {
  		(void) sccmctl(tp->t_dev, 0, DMSET);	/* hang up line */
  		return (0);
  	}
>Audit-Trail:
>Unformatted: