Skip to contentSkip to conversation

RIO, SX, driver update.

PATCH In review Rogier Wolff 1 participant 2 messages May 14, 2001 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RIO, SX, driver update.

Hi Linus, Alan,

The patch below implements breaks (correctly) for the RIO and SX cards.

We started out trying to fix one thing, but found that the 2.4.4 rio driver was behind on several patches.

Roger Wolff.
Patrick van de Lageweg.

-----------

Signature · 4 lines
** [email protected] ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
* There are old pilots, and there are bold pilots. 
* There are also old, bald pilots. 
#1 lore raw

Retry. This time with patch....

Roger.

Quoted 6 lines · Rogier Wolff

Hi Linus, Alan,

The patch below implements breaks (correctly) for the RIO and SX cards.

Quoted 7 lines

We started out trying to fix one thing, but found that the 2.4.4 rio driver was behind on several patches.

Roger Wolff.
Patrick van de Lageweg.

-----------

drivers/char/generic_serial.c +17 -5
diff -u -r linux-2.4.4.clean/drivers/char/generic_serial.c linux-2.4.4.rio_close/drivers/char/generic_serial.c
@@ -344,7 +344,7 @@
 	struct gs_port *port = ptr;
 	long end_jiffies;
 	int jiffies_to_transmit, charsleft = 0, rv = 0;
-	int to, rcib;
+	int rcib;
 
 	func_enter();
 
@@ -368,6 +368,7 @@
 		return rv;
 	}
 	/* stop trying: now + twice the time it would normally take +  seconds */
+	if (timeout == 0) timeout = MAX_SCHEDULE_TIMEOUT;
 	end_jiffies  = jiffies; 
 	if (timeout !=  MAX_SCHEDULE_TIMEOUT)
 		end_jiffies += port->baud?(2 * rcib * 10 * HZ / port->baud):0;
@@ -376,11 +377,9 @@
 	gs_dprintk (GS_DEBUG_FLUSH, "now=%lx, end=%lx (%ld).\n", 
 		    jiffies, end_jiffies, end_jiffies-jiffies); 
 
-	to = 100;
 	/* the expression is actually jiffies < end_jiffies, but that won't
 	   work around the wraparound. Tricky eh? */
-	while (to-- &&
-	       (charsleft = gs_real_chars_in_buffer (port->tty)) &&
+	while ((charsleft = gs_real_chars_in_buffer (port->tty)) &&
 	        time_after (end_jiffies, jiffies)) {
 		/* Units check: 
 		   chars * (bits/char) * (jiffies /sec) / (bits/sec) = jiffies!
@@ -1059,6 +1058,19 @@
 	copy_to_user(sp, &sio, sizeof(struct serial_struct));
 }
 
+
+void gs_got_break(struct gs_port *port)
+{
+	if (port->flags & ASYNC_SAK) {
+		do_SAK (port->tty);
+	}
+	*(port->tty->flip.flag_buf_ptr) = TTY_BREAK;
+	port->tty->flip.flag_buf_ptr++;
+	port->tty->flip.char_buf_ptr++;
+	port->tty->flip.count++;
+}
+
+
 EXPORT_SYMBOL(gs_put_char);
 EXPORT_SYMBOL(gs_write);
 EXPORT_SYMBOL(gs_write_room);
@@ -1075,4 +1087,4 @@
 EXPORT_SYMBOL(gs_init_port);
 EXPORT_SYMBOL(gs_setserial);
 EXPORT_SYMBOL(gs_getserial);
-
+EXPORT_SYMBOL(gs_got_break);
drivers/char/rio/linux_compat.h +3 -1
diff -u -r linux-2.4.4.clean/drivers/char/rio/linux_compat.h linux-2.4.4.rio_close/drivers/char/rio/linux_compat.h
@@ -16,11 +16,13 @@
  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <asm/hardirq.h>
+
 
 #define disable(oldspl) save_flags (oldspl)
 #define restore(oldspl) restore_flags (oldspl)
 
-#define sysbrk(x) kmalloc ((x), GFP_KERNEL)
+#define sysbrk(x) kmalloc ((x),in_interrupt()? GFP_ATOMIC : GFP_KERNEL)
 #define sysfree(p,size) kfree ((p))
 
 #define WBYTE(p,v) writeb(v, &p)
drivers/char/rio/rio_linux.c +60 -35

247 lines not on this page · raw message

drivers/char/rio/rio_linux.h +13 -14
diff -u -r linux-2.4.4.clean/drivers/char/rio/rio_linux.h linux-2.4.4.rio_close/drivers/char/rio/rio_linux.h
@@ -95,28 +95,27 @@
 #if 1
 #define rio_spin_lock_irqsave(sem, flags) do { \
 	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlockirqsave: %p %s:%d\n", \
-					sem, __FILE__, __LINE__);\
-        spin_lock_irqsave(sem, flags);\
-        } while (0)
+	                                sem, __FILE__, __LINE__);\
+	spin_lock_irqsave(sem, flags);\
+	} while (0)
 
 #define rio_spin_unlock_irqrestore(sem, flags) do { \
 	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlockirqrestore: %p %s:%d\n",\
-					sem, __FILE__, __LINE__);\
-        spin_unlock_irqrestore(sem, flags);\
-        } while (0)
-
+	                                sem, __FILE__, __LINE__);\
+	spin_unlock_irqrestore(sem, flags);\
+	} while (0)
 
 #define rio_spin_lock(sem) do { \
 	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinlock: %p %s:%d\n",\
-					sem, __FILE__, __LINE__);\
-        spin_lock(sem);\
-        } while (0)
+	                                sem, __FILE__, __LINE__);\
+	spin_lock(sem);\
+	} while (0)
 
 #define rio_spin_unlock(sem) do { \
 	rio_dprintk (RIO_DEBUG_SPINLOCK, "spinunlock: %p %s:%d\n",\
-					sem, __FILE__, __LINE__);\
-        spin_unlock(sem);\
-        } while (0)
+	                                sem, __FILE__, __LINE__);\
+	spin_unlock(sem);\
+	} while (0)
 #else
 #define rio_spin_lock_irqsave(sem, flags) \
             spin_lock_irqsave(sem, flags)
@@ -165,7 +164,7 @@
 #define rio_memcpy_fromio                      memcpy_fromio
 #endif
 
-#define DEBUG
+#define DEBUG 1
 
 
 /* 
drivers/char/rio/rioboot.c +1 -0
diff -u -r linux-2.4.4.clean/drivers/char/rio/rioboot.c linux-2.4.4.rio_close/drivers/char/rio/rioboot.c
@@ -38,6 +38,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
+#include <linux/interrupt.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/string.h>
drivers/char/rio/riocmd.c +7 -3
diff -u -r linux-2.4.4.clean/drivers/char/rio/riocmd.c linux-2.4.4.rio_close/drivers/char/rio/riocmd.c
@@ -474,17 +474,18 @@
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 	switch( RBYTE(PktCmdP->Command) ) {
 		case BREAK_RECEIVED:
-		rio_dprintk (RIO_DEBUG_CMD, "Received a break!\n");
+			rio_dprintk (RIO_DEBUG_CMD, "Received a break!\n");
 			/* If the current line disc. is not multi-threading and
 	   			the current processor is not the default, reset rup_intr
 	   			and return FALSE to ensure that the command packet is
 	   			not freed. */
 			/* Call tmgr HANGUP HERE */
 			/* Fix this later when every thing works !!!! RAMRAJ */
+			gs_got_break (PortP);
 			break;
 
 		case COMPLETE:
-		rio_dprintk (RIO_DEBUG_CMD, "Command complete on phb %d host %d\n",
+			rio_dprintk (RIO_DEBUG_CMD, "Command complete on phb %d host %d\n",
 			     RBYTE(PktCmdP->PhbNum), HostP-p->RIOHosts);
 			subCommand = 1;
 			switch (RBYTE(PktCmdP->SubCommand)) {
@@ -549,6 +550,8 @@
 				*/
 				if (PortP->gs.tty == NULL)
 					break;
+				if (PortP->gs.tty->termios == NULL)
+					break;
 			  
 				if (!(PortP->gs.tty->termios->c_cflag & CLOCAL) &&
 				((PortP->State & (RIO_MOPEN|RIO_WOPEN)))) {
@@ -623,7 +626,8 @@
 	struct CmdBlk *CmdBlkP;
 
 	CmdBlkP = (struct CmdBlk *)sysbrk(sizeof(struct CmdBlk));
-	bzero(CmdBlkP, sizeof(struct CmdBlk));
+	if (CmdBlkP)
+		bzero(CmdBlkP, sizeof(struct CmdBlk));
 
 	return CmdBlkP;
 }
drivers/char/rio/rioinit.c +1 -1
diff -u -r linux-2.4.4.clean/drivers/char/rio/rioinit.c linux-2.4.4.rio_close/drivers/char/rio/rioinit.c
@@ -1446,7 +1446,7 @@
 				}
 				RIODefaultName(p, HostP, rup);
 			}
-			HostP->UnixRups[rup].RupLock = -1;
+			HostP->UnixRups[rup].RupLock = SPIN_LOCK_UNLOCKED;
 		}
 	}
 }
drivers/char/rio/riotable.c +2 -0
diff -u -r linux-2.4.4.clean/drivers/char/rio/riotable.c linux-2.4.4.rio_close/drivers/char/rio/riotable.c
@@ -37,6 +37,8 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/errno.h>
+#include <linux/interrupt.h>
+
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/string.h>
drivers/char/rio/riotty.c +24 -10
diff -u -r linux-2.4.4.clean/drivers/char/rio/riotty.c linux-2.4.4.rio_close/drivers/char/rio/riotty.c
@@ -96,7 +96,7 @@
 #endif
 
 static void RIOClearUp(struct Port *PortP);
-static int RIOShortCommand(struct rio_info *p, struct Port *PortP, 
+int RIOShortCommand(struct rio_info *p, struct Port *PortP, 
 			   int command, int len, int arg);
 
 
@@ -452,8 +452,11 @@
 				PortP->gs.tty->termios->c_state |= WOPEN;
 				*/
 				PortP->State |= RIO_WOPEN;
+				rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+				if (RIODelay (PortP, HUNDRED_MS) == RIO_FAIL)
 #if 0
 				if ( sleep((caddr_t)&tp->tm.c_canqo, TTIPRI|PCATCH))
+#endif
 				{
 					/*
 					** ACTION: verify that this is a good thing
@@ -471,7 +474,6 @@
 					func_exit ();
 					return -EINTR;
 				}
-#endif
 			}
 			PortP->State &= ~RIO_WOPEN;
 		}
@@ -527,8 +529,10 @@
 #endif
 	struct Port *PortP =ptr;	/* pointer to the port structure */
 	int deleted = 0;
-	int	try = 25;
-	int	repeat_this = 0xff;
+	int	try = -1; /* Disable the timeouts by setting them to -1 */
+	int	repeat_this = -1; /* Congrats to those having 15 years of 
+				     uptime! (You get to break the driver.) */
+	long end_time;
 	struct tty_struct * tty;
 	unsigned long flags;
 	int Modem;
@@ -541,6 +545,12 @@
 	/* tp = PortP->TtyP;*/			/* Get tty */
 	tty = PortP->gs.tty;
 	rio_dprintk (RIO_DEBUG_TTY, "TTY is at address 0x%x\n",(int)tty);
+
+	if (PortP->gs.closing_wait) 
+		end_time = jiffies + PortP->gs.closing_wait;
+	else 
+		end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
+
 	Modem = rio_ismodem(tty->device);
 #if 0
 	/* What F.CKING cache? Even then, a higly idle multiprocessor,
@@ -573,7 +583,8 @@
 	** clear the open bits for this device
 	*/
 	PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN);
-
+	PortP->State &= ~RIO_CARR_ON;
+	PortP->ModemState &= ~MSVR1_CD;
 	/*
 	** If the device was open as both a Modem and a tty line
 	** then we need to wimp out here, as the port has not really
@@ -605,7 +616,6 @@
 	*/
 	rio_dprintk (RIO_DEBUG_TTY, "Timeout 1 starts\n");
 
-#if 0
 	if (!deleted)
 	while ( (PortP->InUse != NOT_INUSE) && !p->RIOHalted && 
 		(PortP->TxBufferIn != PortP->TxBufferOut) ) {
@@ -626,7 +636,7 @@
 		}
 		rio_spin_lock_irqsave(&PortP->portSem, flags);
 	}
-#endif
+
 	PortP->TxBufferIn = PortP->TxBufferOut = 0;
 	repeat_this = 0xff;
 
@@ -662,7 +672,7 @@
 	if (!deleted)
 	  while (try && (PortP->PortState & PORT_ISOPEN)) {
 	        try--;
-		if (try == 0) {
+		if (time_after (jiffies, end_time)) {
 		  rio_dprintk (RIO_DEBUG_TTY, "Run out of tries - force the bugger shut!\n" );
 		  RIOPreemptiveCmd(p, PortP,FCLOSE);
 		  break;
@@ -674,7 +684,11 @@
 			RIOClearUp( PortP );
 			goto close_end;
 		}
-		RIODelay_ni(PortP, HUNDRED_MS);
+		if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
+			rio_dprintk (RIO_DEBUG_TTY, "RTA EINTR in delay \n");
+			RIOPreemptiveCmd(p, PortP,FCLOSE);
+			break;
+		}
 	}
 	rio_spin_lock_irqsave(&PortP->portSem, flags);
 	rio_dprintk (RIO_DEBUG_TTY, "Close: try was %d on completion\n", try );
@@ -779,7 +793,7 @@
 ** Other values of len aren't allowed, and will cause
 ** a panic.
 */
-static int RIOShortCommand(struct rio_info *p, struct Port *PortP,
+int RIOShortCommand(struct rio_info *p, struct Port *PortP,
 		int command, int len, int arg)
 {
 	PKT *PacketP;
drivers/char/sx.c +1 -4
diff -u -r linux-2.4.4.clean/drivers/char/sx.c linux-2.4.4.rio_close/drivers/char/sx.c
@@ -918,7 +918,6 @@
 	                       SP_DCEN);
 
 	sx_write_channel_byte (port, hi_break, 
-	                       I_OTHER(port->gs.tty) ? 0:
 	                       (I_IGNBRK(port->gs.tty)?BR_IGN:0 |
 	                        I_BRKINT(port->gs.tty)?BR_INT:0));
 
@@ -1140,9 +1139,7 @@
 		sx_dprintk (SX_DEBUG_MODEMSIGNALS, "got a break.\n");
 
 		sx_write_channel_byte (port, hi_state, hi_state);
-		if (port->gs.flags & ASYNC_SAK) {
-			do_SAK (port->gs.tty);
-		}
+		gs_got_break (port);
 	}
 	if (hi_state & ST_DCD) {
 		hi_state &= ~ST_DCD;
Signature · 4 lines
** [email protected] ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
* There are old pilots, and there are bold pilots. 
* There are also old, bald pilots.