atmel serial reduce trasmitting window & code style patch
PATCH 1/1 atmel serial reduce trasmitting window & code style patch
Hi,
two more patches for atmel serial driver.
Regards
Michael
Inviato da Yahoo! Mail.
La casella di posta intelligente.
http://it.docs.yahoo.com/mail/overview/index.html
Coding style clean-up patch.
--- drivers/serial/atmel_serial.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
drivers/serial/atmel_serial.c +7 -7
@@ -122,7 +122,7 @@ struct atmel_uart_char {u16 ch; }; -#define ATMEL_SERIAL_RINGSIZE 1024 +#define ATMEL_SERIAL_RINGSIZE 1024/* * We wrap our port structure around the generic uart_port.
@@ -394,8 +394,8 @@ static void atmel_rx_chars(struct uart_port *port)/* clear error */ UART_PUT_CR (port,ATMEL_US_RSTSTA ); -if (status &ATMEL_US_RXBRK - && !atmel_port->break_active) { +if (status &ATMEL_US_RXBRK && + !atmel_port->break_active) { atmel_port->break_active =1 ;UART_PUT_IER (port,ATMEL_US_RXBRK ); }else {
@@ -1394,8 +1394,8 @@ console_initcall(atmel_console_init);*/ static int __init atmel_late_console_init (void ) { -if (atmel_default_console_device - && !(atmel_console.flags &CON_ENABLED )) +if (atmel_default_console_device && + !(atmel_console.flags &CON_ENABLED ))register_console (&atmel_console);return 0 ;
@@ -1434,8 +1434,8 @@ static int atmel_serial_suspend(struct platform_device *pdev,struct uart_port *port =platform_get_drvdata (pdev);struct atmel_uart_port *atmel_port =to_atmel_uart_port (port); -if (device_may_wakeup (&pdev->dev) - && !at91_suspend_entering_slow_clock ()) +if (device_may_wakeup (&pdev->dev) && + !at91_suspend_entering_slow_clock ())enable_irq_wake (port->irq);else {uart_suspend_port (&atmel_uart, port);
Signature · 1 line
1.5.2.1.174.gcd03-dirty
Reduce the trasmitting window size to avoid blocking of tasklet because it must handle the receive phase too.
--- drivers/serial/atmel_serial.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/serial/atmel_serial.c +5 -1
@@ -123,6 +123,7 @@ struct atmel_uart_char { };#define ATMEL_SERIAL_RINGSIZE 1024 +#define ATMEL_SERIAL_TXSIZE 32/* * We wrap our port structure around the generic uart_port.
@@ -426,6 +427,7 @@ static void atmel_rx_chars(struct uart_port *port)static void atmel_tx_chars (struct uart_port *port) {struct circ_buf *xmit = &port->info->xmit; +int count =0 ;if (port->x_char &&UART_GET_CSR (port) &ATMEL_US_TXRDY ) {UART_PUT_CHAR (port, port->x_char);
@@ -435,10 +437,12 @@ static void atmel_tx_chars(struct uart_port *port)if (uart_circ_empty (xmit) ||uart_tx_stopped (port))return ; -while (UART_GET_CSR (port) &ATMEL_US_TXRDY ) { +while (UART_GET_CSR (port) &ATMEL_US_TXRDY && + count <ATMEL_SERIAL_TXSIZE ) {UART_PUT_CHAR (port, xmit->buf[xmit->tail]); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); port->icount.tx++; + count++;if (uart_circ_empty (xmit))break ; }
Signature · 1 line
1.5.2.1.174.gcd03-dirty
Quoted 3 lines · On Thu, 3 Apr 2008 10:39:06 +0200 (CEST) Michael Trimarchi…
Coding style clean-up patch.
Signed-off-by michael <[email protected]>
NAK. The existing style looks just fine to me.
If you want to line up the #defines, please just include that change in the other patch. I'll comment on that in a few seconds.
Haavard
Quoted 4 lines · On Thu, 3 Apr 2008 10:39:06 +0200 (CEST) Michael Trimarchi…
Reduce the trasmitting window size to avoid blocking of tasklet because it must handle the receive phase too.
Signed-off-by michael <[email protected]>
Ok, the patch seems to make sense, but your description isn't very good...
* What problem does this patch solve (I think I know it, but I don't want to guess.)
* This patch doesn't really reduce any "TX window" since the window simply didn't exist before (or was infinitely long or whatever.) I think you should mention that this limitation is a new thing.
* Why is 32 a good value?
Also, do we need to reschedule the tasklet if we terminate the loop because of this limit? I think we can get away with not doing it since the interrupt handler will be triggered as soon as we enable the TX interrupt. But perhaps we should avoid enabling the interrupt and schedule the tasklet since we _know_ there's a TX interrupt pending?
Haavard
Hi,
Quoted 2 lines
Ok, the patch seems to make sense, but your description isn't very good...
ok
Quoted 3 lines
* What problem does this patch solve (I think I know it,
but I don't
want to guess.)
I try to resolve this problem:
The serial is set in interrupt mode 9600, and trasmit a lot of data. The serial receive data from another device. The receive buffer is 1024 bytes and the trasmit buffer is an XMIT_SIZE. So when the tasklet start to trasmit, it can loose data.
Quoted 9 lines
* This patch doesn't really reduce any "TX
window" since the window
simply didn't exist before (or was infinitely long
or whatever.) I
think you should mention that this limitation is a new
thing.* Why is 32 a good value?
... I don't know a good value, because the tasklet can be preempted, and the receiving buffer can be fill in background. It is hard to choose a good value...
Quoted 11 lines
Also, do we need to reschedule the tasklet if we terminate the loop
because of this limit? I think we can get away with not doing it since
the interrupt handler will be triggered as soon as we enable the TX
interrupt. But perhaps we should avoid enabling the interrupt and
schedule the tasklet since we _know_ there's a TX interrupt pending?
Ok, you are right, schedule the tasklet is better. I do some test and post another patch.
Michael
Inviato da Yahoo! Mail.
La casella di posta intelligente.
http://it.docs.yahoo.com/mail/overview/index.html
Hi all!
I just inlined your second patch for commenting.
Quoted 1 line · Michael Trimarchi
Hi,
...
Quoted 26 lines
http://it.docs.yahoo.com/mail/overview/index.html
drivers/serial/atmel_serial.c +2
-0@@ -123,6 +123,7 @@ struct atmel_uart_char { };#define ATMEL_SERIAL_RINGSIZE 1024 +#define ATMEL_SERIAL_TXSIZE 32/* * We wrap our port structure around the generic uart_port. @@ -426,6 +427,7 @@ static void atmel_rx_chars(struct uart_port *port)static void atmel_tx_chars (struct uart_port *port) {struct circ_buf *xmit = &port->info->xmit; +int count =0 ;if (port->x_char &&UART_GET_CSR (port) &ATMEL_US_TXRDY ) {UART_PUT_CHAR (port, port->x_char);@@ -435,10 +437,12 @@ static void atmel_tx_chars(struct uart_port *port)if (uart_circ_empty (xmit) ||uart_tx_stopped (port))return ;
drivers/serial/atmel_serial.c static void atmel_tx_chars(struct uart_port *port) · line 448
Quoted 10 lines
drivers/serial/atmel_serial.c +3
-1-while (UART_GET_CSR (port) &ATMEL_US_TXRDY ) { +while (UART_GET_CSR (port) &ATMEL_US_TXRDY && + count <ATMEL_SERIAL_TXSIZE ) {UART_PUT_CHAR (port, xmit->buf[xmit->tail]); xmit->tail = (xmit->tail +1 ) & (UART_XMIT_SIZE -1 ); port->icount.tx++; + count++;if (uart_circ_empty (xmit))break ; }
For me this loop will never run more than 2-3 times.
The CPU is much faster than the serial transmitter, so after 2 loops UART_GET_CSR(port) & ATMEL_US_TXRDY will be false and the loop will exit.
If your patch does something, I can't understand how!
Best regards
Marc
Hi,
Quoted 6 lines
For me this loop will never run more than 2-3 times. The CPU is much faster than the serial transmitter, so after 2 loops
UART_GET_CSR(port)&ATMEL_US_TXRDYwill be false and the loop will exit.
Ok, I do a check, and count the max.
Michael
Inviato da Yahoo! Mail.
La casella di posta intelligente.
http://it.docs.yahoo.com/mail/overview/index.html