Subject: sys/dev/ic/z8530tty.c 1.52 -> 1.53 is broken.
To: None <port-sparc@netbsd.org>
From: matthew green <mrg@eterna.com.au>
List: tech-kern
Date: 01/23/1999 15:36:55
the change  associated with this log message is broken:

revision 1.53
date: 1998/11/23 22:10:09;  author: wrstuden;  state: Exp;  lines: +15 -9
Changes to deal with mac serial ports having clock sources on DCD or CTS.

- When doing a first open, don't enable receive & status interupts before
        the MD layer has had a chance to set things up.
- Enable logic to only enable DCD/CTS interupts if we are looking for/
        expecting interupts on those pins. Disable otherwise.
- in zs_param, only pass up the state of ZSRR0_DCD if we have enabled
        interupts on that pin.

Henry Hotz (<hotz@jpl.nasa.gov>) and Greg walsh <gwalsh@artec.com> have
tried these changes to get certain printers from hanging at boot. They
work in a 1.3.2 kernel for Greg.


this is the cause of the SPARC kernel hanging up after the ppp daemon
connects that greywolf has been seeing for some time, and others have
also seen that i just saw, after upgrading my kernel for the first time
in 86 days.  backout the 1.52 -> 1.53 change leaves my pppd happily
connected after it connects.



greywolf, if you want a fix right now, apply this patch to your kernel.
i don't know which parts are the cause, and i have no desire to debug
this further... 


Index: z8530tty.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/z8530tty.c,v
retrieving revision 1.53
retrieving revision 1.52
diff -c -r1.53 -r1.52
*** z8530tty.c	1998/11/23 22:10:09	1.53
--- z8530tty.c	1998/10/01 18:52:42	1.52
***************
*** 309,314 ****
--- 309,318 ----
  
  		s = 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);
  
***************
*** 320,329 ****
  		t.c_cflag = cs->cs_defcflag;
  		/* Make sure zsparam will see changes. */
  		tp->t_ospeed = 0;
- 
- 		/* Turn on interrupts when zsparam writes the chip. */
- 		cs->cs_creg[1] = cs->cs_preg[1] = ZSWR1_RIE | ZSWR1_SIE;
- 
  		(void) zsparam(tp, &t);
  
  		s = splzs();
--- 324,329 ----
***************
*** 826,832 ****
  
  	cs->cs_rr0_mask = cs->cs_rr0_cts | cs->cs_rr0_dcd;
  	tmp15 = cs->cs_preg[15];
! #if 1
  	if (ISSET(cs->cs_rr0_mask, ZSRR0_DCD))
  		SET(tmp15, ZSWR15_DCD_IE);
  	else
--- 826,832 ----
  
  	cs->cs_rr0_mask = cs->cs_rr0_cts | cs->cs_rr0_dcd;
  	tmp15 = cs->cs_preg[15];
! #if 0
  	if (ISSET(cs->cs_rr0_mask, ZSRR0_DCD))
  		SET(tmp15, ZSWR15_DCD_IE);
  	else
***************
*** 924,938 ****
  	/*
  	 * 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. Do this only if we have enabled interrupts on
! 	 * this pin. mac68k and macppc serial ports might have a clock on
! 	 * DCD, and so it makes no sense to pass the clock state further up
! 	 * the tty system.
! 	 */
! 	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) {
--- 924,932 ----
  	/*
  	 * 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.
! 	 */
! 	(void) (*linesw[tp->t_line].l_modem)(tp, ISSET(cs->cs_rr0, ZSRR0_DCD));
  
  	if (!ISSET(cflag, CHWFLOW)) {
  		if (zst->zst_tx_stopped) {