[rtems commit] leon, apbuart: Optimized RX processing in ISR

Daniel Hellstrom danielh at rtems.org
Tue May 2 10:38:43 UTC 2017


Module:    rtems
Branch:    master
Commit:    6860ddb6e86cb78a8d02bac4121f63097b5104e7
Changeset: http://git.rtems.org/rtems/commit/?id=6860ddb6e86cb78a8d02bac4121f63097b5104e7

Author:    Martin Aberg <maberg at gaisler.com>
Date:      Tue Mar 14 17:27:57 2017 +0100

leon, apbuart: Optimized RX processing in ISR

Limit the number of calls to termios rtems_termios_enqueue_raw_characters() by
reading out the RX FIFO on stack and then call termios only once.

---

 c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c | 25 +++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index 6591cd8..a52c360 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -806,7 +806,7 @@ static void apbuart_cons_isr(void *arg)
 	struct apbuart_priv *uart = condev_get_priv(condev);
 	struct apbuart_regs *regs = uart->regs;
 	unsigned int status;
-	char data;
+	char buf[33];
 	int cnt;
 
 	if (uart->mode == TERMIOS_TASK_DRIVEN) {
@@ -824,13 +824,22 @@ static void apbuart_cons_isr(void *arg)
 			rtems_termios_rxirq_occured(tty);
 		}
 	} else {
-		/* Get all received characters */
-		while ((status=regs->status) & APBUART_STATUS_DR) {
-			/* Data has arrived, get new data */
-			data = regs->data;
-
-			/* Tell termios layer about new character */
-			rtems_termios_enqueue_raw_characters(tty, &data, 1);
+		/*
+		 * Get all new characters from APBUART RX (FIFO) and store them
+		 * on the stack. Then tell termios about the new characters.
+		 * Maximum APBUART RX FIFO size is 32 characters.
+		 */
+		cnt = 0;
+		while (
+			((status=regs->status) & APBUART_STATUS_DR) &&
+			(cnt < sizeof(buf))
+		) {
+			buf[cnt] = regs->data;
+			cnt++;
+		}
+		if (0 < cnt) {
+			/* Tell termios layer about new characters */
+			rtems_termios_enqueue_raw_characters(tty, &buf[0], cnt);
 		}
 	}
 




More information about the vc mailing list