Subject: Re: /dev/par0 very slow?
To: port-amiga list <port-amiga@netbsd.org>
From: Ingolf Koch <ingolf@knuut.de>
List: port-amiga
Date: 02/27/2000 08:15:55
On Sat, Feb 26, 2000 at 11:49:49PM +0100, Ingolf Koch wrote:
> See the attached patch file. This does not speed things
> up significantly but improves readability a bit.

argl *dontusesuchcomplicatedthingsasattachmentsifitislate*
Here we are...

--- par.c.old	Fri Aug  6 13:23:14 1999
+++ par.c	Fri Feb 25 23:36:05 2000
@@ -510,37 +510,22 @@
 /* stuff below here if for interrupt driven output of data thru
    the parallel port. */
 
-int partimeout_pending;
 int parsend_pending;
 
 void
 parintr(arg)
 	void *arg;
 {
-	int s, mask;
+	int s;
 
-	mask = (int)arg;
 	s = splclock();
 
 #ifdef DEBUG
 	if (pardebug & PDB_INTERRUPT)
-		printf("parintr %s\n", mask ? "FLG" : "tout");
+		printf("parintr\n");
 #endif
-	/*
-	 * if invoked from timeout handler, mask will be 0,
-	 * if from interrupt, it will contain the cia-icr mask,
-	 * which is != 0
-	 */
-	if (mask) {
-		if (partimeout_pending)
-			untimeout(parintr, 0);
-		if (parsend_pending)
-			parsend_pending = 0;
-	}
-
-	/* either way, there won't be a timeout pending any longer */
-	partimeout_pending = 0;
-  
+	parsend_pending = 0;
+
 	wakeup(parintr);
 	splx(s);
 }
@@ -568,9 +553,6 @@
 		((ciab.pra ^ CIAB_PRA_SEL)
 		 & (CIAB_PRA_SEL|CIAB_PRA_BUSY|CIAB_PRA_POUT)));
 #endif
-      /* wait a second, and try again */
-      timeout(parintr, 0, hz);
-      partimeout_pending = 1;
       /* this is essentially a flipflop to have us wait for the
 	 first character being transmitted when trying to transmit
 	 the second, etc. */
@@ -578,16 +560,14 @@
       /* it's quite important that a parallel putc can be
 	 interrupted, given the possibility to lock a printer
 	 in an offline condition.. */
-      if ((error = tsleep(parintr, PCATCH | (PZERO - 1), "parsendch", 0)) > 0)
+      error = tsleep(parintr, PCATCH | (PZERO - 1), "parsendch", hz);
+      if (EWOULDBLOCK == error) error = 0;
+      if (0 < error)
 	{
 #ifdef DEBUG
 	  if (pardebug & PDB_INTERRUPT)
 	    printf ("parsendch interrupted, error = %d\n", error);
 #endif
-	  if (partimeout_pending)
-	    untimeout(parintr, 0);
-
-	  partimeout_pending = 0;
 	}
     }
 
-- 

Ingolf Koch     ICQ#60829470     Beste Kneipe in Jena-Ost
PGP: 0x7B3B5661  213C 828E 0C92 16B5  05D0 4D5B A324 EC04