public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Serial device with very large buffer
@ 2001-02-01 23:20 Alex Belits
  2001-02-01 23:45 ` Alan Cox
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Belits @ 2001-02-01 23:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linus Torvalds


  Greg Pomerantz <gmp@zebware.com> and I have found that Novatel Merlin
for Ricochet PCMCIA card, while looking like otherwise ordinary serial
PCMCIA device, has the receive buffer 576 bytes long. When regular serial
driver reads the arrived data, it often runs out of 512-bytes flip buffer
and discards the rest of the data with rather disastrous consequences for
whatever is expecting it.

  We made a fix that changes the behavior of the driver, so when it fills
the flip buffer while characters are still being read from uart, it flips
the buffer if it's possible or if it's impossible, finishes the loop
without reading the remaining characters.

The patch is:
---8<---
--- linux-2.4.1-orig/drivers/char/serial.c	Wed Dec  6 12:06:18 2000
+++ linux/drivers/char/serial.c	Thu Feb  1 13:14:05 2001
@@ -569,9 +569,16 @@
 
 	icount = &info->state->icount;
 	do {
+		/*
+		 * Check if flip buffer is full -- if it is, try to flip,
+		 * and if flipping got queued, return immediately
+		 */
+		if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
+			tty->flip.tqueue.routine((void *) tty);
+			if (tty->flip.count >= TTY_FLIPBUF_SIZE)
+				return;
+		}
 		ch = serial_inp(info, UART_RX);
-		if (tty->flip.count >= TTY_FLIPBUF_SIZE)
-			goto ignore_char;
 		*tty->flip.char_buf_ptr = ch;
 		icount->rx++;
 		
--->8---

  I also propose to increase the size of flip buffer to 640 bytes (so the
flipping won't occur every time in the middle of the full buffer), however
I understand that it's a rather drastic change for such a simple goal, and
not everyone will agree that it's worth the trouble:

---8<---
--- linux-2.4.1-orig/include/linux/tty.h	Mon Jan 29 23:24:56 2001
+++ linux/include/linux/tty.h	Wed Jan 31 13:06:42 2001
@@ -134,7 +134,7 @@
  * located in the tty structure, and is used as a high speed interface
  * between the tty driver and the tty line discipline.
  */
-#define TTY_FLIPBUF_SIZE 512
+#define TTY_FLIPBUF_SIZE 640
 
 struct tty_flip_buffer {
 	struct tq_struct tqueue;
--->8---

-- 
Alex

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: Serial device with very large buffer
@ 2001-02-02  5:28 Garst R. Reese
  0 siblings, 0 replies; 10+ messages in thread
From: Garst R. Reese @ 2001-02-02  5:28 UTC (permalink / raw)
  To: linux-kernel

How does this relate to IrDA with SIR speed of 115200 and max turnaround
of 500ms?
The max throughput is about 5000 bytes in 500ms.
Garst
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-02-12  7:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-02-01 23:20 Serial device with very large buffer Alex Belits
2001-02-01 23:45 ` Alan Cox
2001-02-01 23:50   ` Alex Belits
2001-02-02  4:56     ` Joe deBlaquiere
2001-02-02  5:22       ` Alex Belits
2001-02-02  5:45         ` Joe deBlaquiere
2001-02-02  6:43           ` Alex Belits
2001-02-09 19:12   ` Pavel Machek
2001-02-12  7:03     ` Alex Belits
  -- strict thread matches above, loose matches on Subject: below --
2001-02-02  5:28 Garst R. Reese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox