Subject: Kernels hanging at ttyflags during boot
To: Henry B. Hotz <hotz@jpl.nasa.gov>
From: Bill Studenmund <wrstuden@loki.stanford.edu>
List: port-mac68k
Date: 03/10/1998 17:12:49
Here's the patch to try and stop kernels from hanging when they go to set
ttyflags.

I'd appreciate it if folks both having and not having these problems could
try this patch. It _shouldn't_ break anything, but I want to make sure.

I haven't actually tested the patch, so keep a good kernel around as
backup. :-)

Take care,

Bill

--- /sup/sys/dev/ic/z8530tty.c	Sun Feb 22 04:12:32 1998
+++ z8530tty.c	Tue Mar 10 17:32:02 1998
@@ -432,10 +432,6 @@
 
 		s2 = splzs();
 
-		/* Turn on interrupts. */
-		cs->cs_creg[1] = cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_SIE;
-		zs_write_reg(cs, 1, cs->cs_creg[1]);
-
 		/* Fetch the current modem control status, needed later. */
 		cs->cs_rr0 = zs_read_csr(cs);
 
@@ -458,6 +454,10 @@
 			SET(t.c_cflag, MDMBUF);
 		/* Make sure zsparam will see changes. */
 		tp->t_ospeed = 0;
+
+		/* Turn on interrupts when zsparam writes the chip. */
+		cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_SIE;
+
 		(void) zsparam(tp, &t);
 		/*
 		 * Note: zsparam has done: cflag, ispeed, ospeed
@@ -838,7 +838,7 @@
 
 	cs->cs_rr0_mask = cs->cs_rr0_cts | cs->cs_rr0_dcd;
 	tmp15 = cs->cs_preg[15];
-#if 0
+#if 1
 	if (ISSET(cs->cs_rr0_mask, ZSRR0_DCD))
 		SET(tmp15, ZSWR15_DCD_IE);
 	else
@@ -936,9 +936,14 @@
 	/*
 	 * Update the tty layer's idea of the carrier bit, in case we changed
 	 * CLOCAL or MDMBUF.  We don't hang up here; we only do that by
-	 * explicit request.
+	 * explicit request. Do this only if we have enabled interrupts on
+	 * this pin. mac68k serial ports might have a clock on DCD, and so
+	 * it makes no sense to pass the clock state further up the tty
+	 * system.
 	 */
-	(void) (*linesw[tp->t_line].l_modem)(tp, ISSET(cs->cs_rr0, ZSRR0_DCD));
+	if (ISSET(cs->cs_rr0_mask, ZSRR0_DCD))
+		(void) (*linesw[tp->t_line].l_modem)(tp, 
+				ISSET(cs->cs_rr0, ZSRR0_DCD));
 
 	if (!ISSET(cflag, CHWFLOW)) {
 		if (zst->zst_tx_stopped) {