diff -r -u loryg-2.2.16/drivers/char/serial.c linux-2.2.16/drivers/char/serial.c --- loryg-2.2.16/drivers/char/serial.c Wed Jun 7 23:26:42 2000 +++ linux-2.2.16/drivers/char/serial.c Mon Aug 14 12:52:42 2000 @@ -386,7 +386,7 @@ icount = &info->state->icount; do { ch = serial_inp(info, UART_RX); - if (tty->flip.count >= TTY_FLIPBUF_SIZE) + if (tty->flip.count >= tty->flip.flipbuf_size) break; *tty->flip.char_buf_ptr = ch; icount->rx++; @@ -439,7 +439,7 @@ * reported immediately, and doesn't * affect the current character */ - if (tty->flip.count < TTY_FLIPBUF_SIZE) { + if (tty->flip.count < tty->flip.flipbuf_size) { tty->flip.count++; tty->flip.flag_buf_ptr++; tty->flip.char_buf_ptr++; @@ -3137,7 +3137,8 @@ serial_driver.init_termios = tty_std_termios; serial_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; - serial_driver.flags = TTY_DRIVER_REAL_RAW; + serial_driver.flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_SPECIAL_FLIPSIZE; + serial_driver.flip_size = 15000; /* use 60004 bytes */ serial_driver.refcount = &serial_refcount; serial_driver.table = serial_table; serial_driver.termios = serial_termios; Only in linux-2.2.16/drivers/char: serial.c.orig diff -r -u loryg-2.2.16/drivers/char/tty_io.c linux-2.2.16/drivers/char/tty_io.c --- loryg-2.2.16/drivers/char/tty_io.c Wed Jun 7 23:26:42 2000 +++ linux-2.2.16/drivers/char/tty_io.c Mon Aug 14 12:53:42 2000 @@ -52,6 +52,9 @@ * Rewrote init_dev and release_dev to eliminate races. * -- Bill Hawes , June 97 * + * Added support for bigger flipbuf sizes + * -- Pavel Machek , June 99 + * * Added support for a Unix98-style ptmx device. * -- C. Scott Ananian , 14-Jan-1998 */ @@ -115,7 +118,7 @@ */ struct tty_struct * redirect = NULL; -static void initialize_tty_struct(struct tty_struct *tty); +static int initialize_tty_struct(struct tty_struct *tty, int); static ssize_t tty_read(struct file *, char *, size_t, loff_t *); static ssize_t tty_write(struct file *, const char *, size_t, loff_t *); @@ -800,10 +803,14 @@ tp = o_tp = NULL; ltp = o_ltp = NULL; - tty = (struct tty_struct*) get_free_page(GFP_KERNEL); + tty = (struct tty_struct*) kmalloc(sizeof(struct tty_struct), GFP_KERNEL); if(!tty) goto fail_no_mem; - initialize_tty_struct(tty); + memset(tty, 0, sizeof(struct tty_struct)); + if (initialize_tty_struct(tty, driver->flip_size)) { + kfree(tty); + goto fail_no_mem; + } tty->device = device; tty->driver = *driver; @@ -826,10 +833,15 @@ } if (driver->type == TTY_DRIVER_TYPE_PTY) { - o_tty = (struct tty_struct *) get_free_page(GFP_KERNEL); + o_tty = (struct tty_struct *) kmalloc(sizeof(struct tty_struct), GFP_KERNEL); if (!o_tty) goto free_mem_out; - initialize_tty_struct(o_tty); + memset(o_tty, 0, sizeof(struct tty_struct)); + if (initialize_tty_struct(o_tty, 512)) { + kfree(o_tty); + o_tty = NULL; + goto free_mem_out; + } o_tty->device = (kdev_t) MKDEV(driver->other->major, driver->other->minor_start + idx); o_tty->driver = *driver->other; @@ -945,13 +957,16 @@ free_mem_out: if (o_tp) kfree_s(o_tp, sizeof(struct termios)); - if (o_tty) - free_page((unsigned long) o_tty); + if (o_tty) { + kfree(o_tty->flip.char_buf); + kfree(o_tty); + } if (ltp) kfree_s(ltp, sizeof(struct termios)); if (tp) kfree_s(tp, sizeof(struct termios)); - free_page((unsigned long) tty); + kfree(tty->flip.char_buf); + kfree(tty); fail_no_mem: retval = -ENOMEM; @@ -982,7 +997,8 @@ } o_tty->magic = 0; (*o_tty->driver.refcount)--; - free_page((unsigned long) o_tty); + kfree(o_tty->flip.char_buf); + kfree(o_tty); } tty->driver.table[idx] = NULL; @@ -993,7 +1009,8 @@ } tty->magic = 0; (*tty->driver.refcount)--; - free_page((unsigned long) tty); + kfree(tty->flip.char_buf); + kfree(tty); } /* @@ -1865,8 +1882,8 @@ return; } if (tty->flip.buf_num) { - cp = tty->flip.char_buf + TTY_FLIPBUF_SIZE; - fp = tty->flip.flag_buf + TTY_FLIPBUF_SIZE; + cp = tty->flip.char_buf + tty->flip.flipbuf_size; + fp = tty->flip.flag_buf + tty->flip.flipbuf_size; tty->flip.buf_num = 0; save_flags(flags); cli(); @@ -1878,8 +1895,8 @@ tty->flip.buf_num = 1; save_flags(flags); cli(); - tty->flip.char_buf_ptr = tty->flip.char_buf + TTY_FLIPBUF_SIZE; - tty->flip.flag_buf_ptr = tty->flip.flag_buf + TTY_FLIPBUF_SIZE; + tty->flip.char_buf_ptr = tty->flip.char_buf + tty->flip.flipbuf_size; + tty->flip.flag_buf_ptr = tty->flip.flag_buf + tty->flip.flipbuf_size; } count = tty->flip.count; tty->flip.count = 0; @@ -1943,9 +1960,16 @@ /* * This subroutine initializes a tty structure. */ -static void initialize_tty_struct(struct tty_struct *tty) +static int initialize_tty_struct(struct tty_struct *tty, int flip_size) { memset(tty, 0, sizeof(struct tty_struct)); + /* there was notice about buffer overrun in original code -- that's why I do +4 */ + tty->flip.char_buf = kmalloc(flip_size * 4 + 4, GFP_KERNEL); + if (!tty->flip.char_buf) + return -ENOMEM; + + tty->flip.flag_buf = tty->flip.char_buf + flip_size * 2; + tty->flip.flipbuf_size = flip_size; tty->magic = TTY_MAGIC; tty->ldisc = ldiscs[N_TTY]; tty->pgrp = -1; @@ -1959,6 +1983,7 @@ sema_init(&tty->atomic_read, 1); sema_init(&tty->atomic_write, 1); spin_lock_init(&tty->read_lock); + return 0; } /* @@ -1978,10 +2003,14 @@ if (driver->flags & TTY_DRIVER_INSTALLED) return 0; + + if (!(driver->flags & TTY_DRIVER_SPECIAL_FLIPSIZE)) + driver->flip_size = 512; error = register_chrdev(driver->major, driver->name, &tty_fops); - if (error < 0) + if (error < 0) { return error; + } else if(driver->major == 0) driver->major = error; Only in linux-2.2.16/drivers/char: tty_io.c.orig diff -r -u loryg-2.2.16/include/linux/tty.h linux-2.2.16/include/linux/tty.h --- loryg-2.2.16/include/linux/tty.h Thu May 4 02:16:52 2000 +++ linux-2.2.16/include/linux/tty.h Mon Aug 14 12:52:43 2000 @@ -130,9 +130,10 @@ /* * This is the flip buffer used for the tty driver. The buffer is - * located in the tty structure, and is used as a high speed interface - * between the tty driver and the tty line discipline. + * kmalloced, and is used as a high speed interface between tty driver + * and the line discipline. */ +/* HACK for old drivers, don't include this constant in new code */ #define TTY_FLIPBUF_SIZE 512 struct tty_flip_buffer { @@ -142,9 +143,9 @@ unsigned char *flag_buf_ptr; int count; int buf_num; - unsigned char char_buf[2*TTY_FLIPBUF_SIZE]; - char flag_buf[2*TTY_FLIPBUF_SIZE]; - unsigned char slop[4]; /* N.B. bug overwrites buffer by 1 */ + int flipbuf_size; + unsigned char *char_buf; + char *flag_buf; }; /* * The pty uses char_buf and flag_buf as a contiguous buffer diff -r -u loryg-2.2.16/include/linux/tty_driver.h linux-2.2.16/include/linux/tty_driver.h --- loryg-2.2.16/include/linux/tty_driver.h Tue May 11 19:35:45 1999 +++ linux-2.2.16/include/linux/tty_driver.h Mon Aug 14 12:52:43 2000 @@ -176,6 +176,7 @@ */ struct tty_driver *next; struct tty_driver *prev; + int flip_size; }; /* tty driver magic number */ @@ -201,6 +202,8 @@ #define TTY_DRIVER_INSTALLED 0x0001 #define TTY_DRIVER_RESET_TERMIOS 0x0002 #define TTY_DRIVER_REAL_RAW 0x0004 +/* use big flip buffers (up to [30 KB] i.e. [((max kmalloc size) - 4) / 4 )] */ +#define TTY_DRIVER_SPECIAL_FLIPSIZE 0x0010 /* tty driver types */ #define TTY_DRIVER_TYPE_SYSTEM 0x0001