Re: atari/dev/zs.c interrupt issue

Izumi Tsutsui <[email protected]> Sat, 24 Jan 2009 10:29:46 +0900
Newsgroups gmane.os.netbsd.ports.atari
Message-ID <[email protected]>
Tuomo wrote:

> I tried to transfer some files to my Falcon running NetBSD 5 kernel
> with ppp. I'm using zs0b (ttyA1) device which is standard Falcon
> serial port.
> 
> However I started to see "zs0b: ring overrun" messages early during
> transfer and occasional freezing.

Hmm, what baud rate?  I'm afraid zs can't handle >38400 bps.

> It seems that BASEPRI() is causing this problem and following
> patch cures this issue:
 :

I guess there are too many devices which use sicallback.
As mentioned in machdep.c, most of them should be rewritten
to use the MI softint(9) APIs directly.

Could you try this one instead?
(though I'm not sure this could help overrun issue
 because "shortcut" path is removed in this patch)

It would also be better to use the MI dev/ic/z8530* driver.
(though it isn't so well designed)

---
Index: dev/zs.c
===================================================================
RCS file: /cvsroot/src/sys/arch/atari/dev/zs.c,v
retrieving revision 1.57
diff -u -r1.57 zs.c
--- dev/zs.c	11 Jun 2008 14:35:53 -0000	1.57
+++ dev/zs.c	24 Jan 2009 01:24:35 -0000
@@ -124,7 +124,7 @@
     struct	zs_chanstate	zi_cs[2];  /* chan A and B software state */
 };
 
-static u_char	cb_scheduled = 0;	/* Already asked for callback? */
+static void	*zs_softint_cookie;	/* for callback */
 /*
  * Define the registers for a closed port
  */
@@ -260,8 +260,6 @@
 static void	zs_loadchannelregs __P((volatile struct zschan *, u_char *));
 static void	zs_shutdown __P((struct zs_chanstate *));
 
-static int zsshortcuts;	/* number of "shortcut" software interrupts */
-
 static int
 zsmatch(pdp, cfp, auxp)
 struct device	*pdp;
@@ -353,6 +351,9 @@
 	cs->cs_unit  = 1;
 	cs->cs_zc    = &addr->zs_chan[ZS_CHAN_B];
 
+	zs_softint_cookie = softint_establish(SOFTINT_SERIAL,
+	    (void (*)(void *))zssoft, 0);
+
 	printf(": serial2 on channel a and modem2 on channel b\n");
 }
 
@@ -629,17 +630,9 @@
 	} while(intflags & 4);
 #undef b
 
-	if(intflags & 1) {
-		if(BASEPRI(sr)) {
-			spl1();
-			zsshortcuts++;
-			return(zssoft(sr));
-		}
-		else if(!cb_scheduled) {
-			cb_scheduled++;
-			add_sicallback((si_farg)zssoft, 0, 0);
-		}
-	}
+	if(intflags & 1)
+		softint_schedule(zs_softint_cookie);
+
 	return(intflags & 2);
 }
 
@@ -747,7 +740,6 @@
     register int			get, n, c, cc, unit, s;
  	     int			retval = 0;
 
-    cb_scheduled = 0;
     s = spltty();
     for(cs = zslist; cs != NULL; cs = cs->cs_next) {
 	get = cs->cs_rbget;

---
Izumi Tsutsui