diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-10-16 04:26:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-16 12:43:04 -0400 |
commit | 2090ab05fe4bc6b70e7245a9d3ea37afc49150ad (patch) | |
tree | bf4eb4e552dd4706b4efacae4810fb964a9d17f6 | |
parent | e5f717812982c7b2a20d5f2d897f7cce6db9c5e6 (diff) |
tty: bring the old cris driver back somewhere into the realm of new tty buffering
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Mikael Starvik <starvik@axis.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/serial/crisv10.c | 67 |
1 files changed, 12 insertions, 55 deletions
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c index 312bef6bd583..7e8724d3571f 100644 --- a/drivers/serial/crisv10.c +++ b/drivers/serial/crisv10.c | |||
@@ -514,6 +514,8 @@ struct tty_driver *serial_driver; | |||
514 | * TTY_THRESHOLD_THROTTLE/UNTHROTTLE=128 | 514 | * TTY_THRESHOLD_THROTTLE/UNTHROTTLE=128 |
515 | * BUF_SIZE can't be > 128 | 515 | * BUF_SIZE can't be > 128 |
516 | */ | 516 | */ |
517 | #define CRIS_BUF_SIZE 512 | ||
518 | |||
517 | /* Currently 16 descriptors x 128 bytes = 2048 bytes */ | 519 | /* Currently 16 descriptors x 128 bytes = 2048 bytes */ |
518 | #define SERIAL_DESCR_BUF_SIZE 256 | 520 | #define SERIAL_DESCR_BUF_SIZE 256 |
519 | 521 | ||
@@ -2497,55 +2499,18 @@ static void flush_to_flip_buffer(struct e100_serial *info) | |||
2497 | return; | 2499 | return; |
2498 | } | 2500 | } |
2499 | 2501 | ||
2500 | length = tty->flip.count; | 2502 | while ((buffer = info->first_recv_buffer) != NULL) { |
2501 | /* Don't flip more than the ldisc has room for. | ||
2502 | * The return value from ldisc.receive_room(tty) - might not be up to | ||
2503 | * date, the previous flip of up to TTY_FLIPBUF_SIZE might be on the | ||
2504 | * processed and not accounted for yet. | ||
2505 | * Since we use DMA, 1 SERIAL_DESCR_BUF_SIZE could be on the way. | ||
2506 | * Lets buffer data here and let flow control take care of it. | ||
2507 | * Since we normally flip large chunks, the ldisc don't react | ||
2508 | * with throttle until too late if we flip to much. | ||
2509 | */ | ||
2510 | max_flip_size = tty->ldisc.receive_room(tty); | ||
2511 | if (max_flip_size < 0) | ||
2512 | max_flip_size = 0; | ||
2513 | if (max_flip_size <= (TTY_FLIPBUF_SIZE + /* Maybe not accounted for */ | ||
2514 | length + info->recv_cnt + /* We have this queued */ | ||
2515 | 2*SERIAL_DESCR_BUF_SIZE + /* This could be on the way */ | ||
2516 | TTY_THRESHOLD_THROTTLE)) { /* Some slack */ | ||
2517 | /* check TTY_THROTTLED first so it indicates our state */ | ||
2518 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) { | ||
2519 | DFLOW(DEBUG_LOG(info->line,"flush_to_flip throttles room %lu\n", max_flip_size)); | ||
2520 | rs_throttle(tty); | ||
2521 | } | ||
2522 | #if 0 | ||
2523 | else if (max_flip_size <= (TTY_FLIPBUF_SIZE + /* Maybe not accounted for */ | ||
2524 | length + info->recv_cnt + /* We have this queued */ | ||
2525 | SERIAL_DESCR_BUF_SIZE + /* This could be on the way */ | ||
2526 | TTY_THRESHOLD_THROTTLE)) { /* Some slack */ | ||
2527 | DFLOW(DEBUG_LOG(info->line,"flush_to_flip throttles again! %lu\n", max_flip_size)); | ||
2528 | rs_throttle(tty); | ||
2529 | } | ||
2530 | #endif | ||
2531 | } | ||
2532 | |||
2533 | if (max_flip_size > TTY_FLIPBUF_SIZE) | ||
2534 | max_flip_size = TTY_FLIPBUF_SIZE; | ||
2535 | |||
2536 | while ((buffer = info->first_recv_buffer) && length < max_flip_size) { | ||
2537 | unsigned int count = buffer->length; | 2503 | unsigned int count = buffer->length; |
2538 | 2504 | ||
2539 | if (length + count > max_flip_size) | 2505 | count = tty_buffer_request_room(tty, count); |
2540 | count = max_flip_size - length; | 2506 | if (count == 0) /* Throttle ?? */ |
2507 | break; | ||
2541 | 2508 | ||
2542 | memcpy(tty->flip.char_buf_ptr + length, buffer->buffer, count); | 2509 | if (count > 1) |
2543 | memset(tty->flip.flag_buf_ptr + length, TTY_NORMAL, count); | 2510 | tty_insert_flip_strings(tty, buffer->buffer, count - 1); |
2544 | tty->flip.flag_buf_ptr[length] = buffer->error; | 2511 | tty_insert_flip_char(tty, buffer->buffer[count-1], buffer->error); |
2545 | 2512 | ||
2546 | length += count; | ||
2547 | info->recv_cnt -= count; | 2513 | info->recv_cnt -= count; |
2548 | DFLIP(DEBUG_LOG(info->line,"flip: %i\n", length)); | ||
2549 | 2514 | ||
2550 | if (count == buffer->length) { | 2515 | if (count == buffer->length) { |
2551 | info->first_recv_buffer = buffer->next; | 2516 | info->first_recv_buffer = buffer->next; |
@@ -2560,14 +2525,6 @@ static void flush_to_flip_buffer(struct e100_serial *info) | |||
2560 | if (!info->first_recv_buffer) | 2525 | if (!info->first_recv_buffer) |
2561 | info->last_recv_buffer = NULL; | 2526 | info->last_recv_buffer = NULL; |
2562 | 2527 | ||
2563 | tty->flip.count = length; | ||
2564 | DFLIP(if (tty->ldisc.chars_in_buffer(tty) > 3500) { | ||
2565 | DEBUG_LOG(info->line, "ldisc %lu\n", | ||
2566 | tty->ldisc.chars_in_buffer(tty)); | ||
2567 | DEBUG_LOG(info->line, "flip.count %lu\n", | ||
2568 | tty->flip.count); | ||
2569 | } | ||
2570 | ); | ||
2571 | restore_flags(flags); | 2528 | restore_flags(flags); |
2572 | 2529 | ||
2573 | DFLIP( | 2530 | DFLIP( |
@@ -2722,17 +2679,17 @@ struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info) | |||
2722 | printk("!NO TTY!\n"); | 2679 | printk("!NO TTY!\n"); |
2723 | return info; | 2680 | return info; |
2724 | } | 2681 | } |
2725 | if (tty->flip.count >= TTY_FLIPBUF_SIZE - TTY_THRESHOLD_THROTTLE) { | 2682 | if (tty->flip.count >= CRIS_BUF_SIZE - TTY_THRESHOLD_THROTTLE) { |
2726 | /* check TTY_THROTTLED first so it indicates our state */ | 2683 | /* check TTY_THROTTLED first so it indicates our state */ |
2727 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) { | 2684 | if (!test_and_set_bit(TTY_THROTTLED, &tty->flags)) { |
2728 | DFLOW(DEBUG_LOG(info->line, "rs_throttle flip.count: %i\n", tty->flip.count)); | 2685 | DFLOW(DEBUG_LOG(info->line, "rs_throttle flip.count: %i\n", tty->flip.count)); |
2729 | rs_throttle(tty); | 2686 | rs_throttle(tty); |
2730 | } | 2687 | } |
2731 | } | 2688 | } |
2732 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | 2689 | if (tty->flip.count >= CRIS_BUF_SIZE) { |
2733 | DEBUG_LOG(info->line, "force FLIP! %i\n", tty->flip.count); | 2690 | DEBUG_LOG(info->line, "force FLIP! %i\n", tty->flip.count); |
2734 | tty->flip.work.func((void *) tty); | 2691 | tty->flip.work.func((void *) tty); |
2735 | if (tty->flip.count >= TTY_FLIPBUF_SIZE) { | 2692 | if (tty->flip.count >= CRIS_BUF_SIZE) { |
2736 | DEBUG_LOG(info->line, "FLIP FULL! %i\n", tty->flip.count); | 2693 | DEBUG_LOG(info->line, "FLIP FULL! %i\n", tty->flip.count); |
2737 | return info; /* if TTY_DONT_FLIP is set */ | 2694 | return info; /* if TTY_DONT_FLIP is set */ |
2738 | } | 2695 | } |