Subject: kern/2644: isa/com driver fails with ispeed = 0
To: None <gnats-bugs@NetBSD.ORG>
From: None <louis@marco.de>
List: netbsd-bugs
Date: 07/19/1996 16:00:00
>Number:         2644
>Category:       kern
>Synopsis:       isa/com driver fails with ispeed = 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 19 10:20:01 1996
>Last-Modified:
>Originator:     Ju"rgen Fluk
>Organization:
louis@dachau.marco.de		in real life: Ju"rgen Fluk
marco GmbH, 85221 Dachau	tel: +49 8131 516142
>Release:        1.2_ALPHA
>Environment:
	
System: NetBSD tabatha 1.2_BETA NetBSD 1.2_BETA (TABATHA) #3: Thu Jul 11 17:48:38 MET DST 1996 leo@tabatha:/usr/src/sys/arch/i386/compile/TABATHA i386


>Description:
	If ispeed is set to 0, input baudrate should be the same as
	output baudrate. However the isa/com driver does rely on "real"
	ispeed values in several places.
>How-To-Repeat:
	tcgetattr(0, &tty);
	cfsetispeed(&tty, 0);

	cfsetospeed(&tty, 38400);
	tcsetattr(0, TCSADRAIN, &tty);
	/* terminal is switched to 38400 */

	cfsetospeed(&tty, 9600);
	tcsetattr(0, TCSADRAIN, &tty);
	/* terminal should switch to 9600, but remains at 38400 */
>Fix:
	As isa/com can't handle ispeed != ospeed anyway, only use t_ospeed.

diff -ub /sys/dev/isa/com.c /tmp/com.c
--- /sys/dev/isa/com.c	Mon Jun  3 16:30:06 1996
+++ /tmp/com.c	Fri Jul 19 15:52:19 1996
@@ -553,7 +553,7 @@
 		if (ISSET(sc->sc_swflags, COM_SW_MDMBUF))
 			SET(tp->t_cflag, MDMBUF);
 		tp->t_lflag = TTYDEF_LFLAG;
-		tp->t_ispeed = tp->t_ospeed = comdefaultrate;
+		tp->t_ospeed = comdefaultrate;
 
 		s = spltty();
 
@@ -605,7 +605,7 @@
 			/* Set the FIFO threshold based on the receive speed. */
 			bus_io_write_1(bc, ioh, com_fifo,
 			    FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST |
-			    (tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
+			    (tp->t_ospeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
 		/* flush any pending I/O */
 		while (ISSET(bus_io_read_1(bc, ioh, com_lsr), LSR_RXRDY))
 			(void) bus_io_read_1(bc, ioh, com_data);
@@ -906,7 +906,7 @@
 	 * changing it.
 	 */
 #if 1
-	if (tp->t_ispeed != t->c_ispeed) {
+	if (tp->t_ospeed != t->c_ospeed) {
 #else
 	if (1) {
 #endif
@@ -946,7 +946,7 @@
 		    ISSET(sc->sc_hwflags, COM_HW_FIFO))
 			bus_io_write_1(bc, ioh, com_fifo,
 			    FIFO_ENABLE |
-			    (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
+			    (t->c_ospeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8));
 	} else
 		bus_io_write_1(bc, ioh, com_lcr, lcr);
 
@@ -968,7 +968,6 @@
 		sc->sc_dtr = MCR_DTR;
 
 	/* and copy to tty */
-	tp->t_ispeed = t->c_ispeed;
 	tp->t_ospeed = t->c_ospeed;
 	oldcflag = tp->t_cflag;
 	tp->t_cflag = t->c_cflag;
>Audit-Trail:
>Unformatted: