diff mbox

sunsab: Fix detection of BREAK on sunsab serial console

Message ID 201408031601.53597.cat.schulze@alice-dsl.net
State Accepted
Delegated to: David Miller
Headers show

Commit Message

Christopher Alexander Tobias Schulze Aug. 3, 2014, 2:01 p.m. UTC
From: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>

Fix detection of BREAK on sunsab serial console: BREAK detection was only
performed when there were also serial characters received simultaneously.
To handle all BREAKs correctly, the check for BREAK and the corresponding
call to uart_handle_break() must also be done if count == 0, therefore
duplicate this code fragment and pull it out of the loop over the received
characters.

Patch applies to 3.16-rc6.

Signed-off-by: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>

---

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Aug. 5, 2014, 12:06 a.m. UTC | #1
From: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>
Date: Sun, 3 Aug 2014 16:01:53 +0200

> From: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>
> 
> Fix detection of BREAK on sunsab serial console: BREAK detection was only
> performed when there were also serial characters received simultaneously.
> To handle all BREAKs correctly, the check for BREAK and the corresponding
> call to uart_handle_break() must also be done if count == 0, therefore
> duplicate this code fragment and pull it out of the loop over the received
> characters.
> 
> Signed-off-by: Christopher Alexander Tobias Schulze <cat.schulze@alice-dsl.net>

Applied and queued up for -stable, thanks.

But this function needs more work.  For one thing, it needs to
resample the status registers to update the stat->foo values each loop
iteration, otherwise it will report break, overflow, etc. over and over
again until we get the next interrupt.

Serial chips seem to handle bare-break characters differently.  The 8250
seems to indicate "data ready" in it's status register in such cases
(and I suppose provides a zero character byte), whereas SAB seems to not
put any bytes in it's FIFO in this situation.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff -Naupr linux-3.16-rc6-orig/drivers/tty/serial/sunsab.c linux-3.16-rc6-patched/drivers/tty/serial/sunsab.c
--- linux-3.16-rc6-orig/drivers/tty/serial/sunsab.c	2014-07-27 11:50:32.000000000 +0200
+++ linux-3.16-rc6-patched/drivers/tty/serial/sunsab.c	2014-08-03 15:59:41.000000000 +0200
@@ -157,6 +157,15 @@  receive_chars(struct uart_sunsab_port *u
 	    (up->port.line == up->port.cons->index))
 		saw_console_brk = 1;
 
+	if (count == 0) {
+		if (unlikely(stat->sreg.isr1 & SAB82532_ISR1_BRK)) {
+			stat->sreg.isr0 &= ~(SAB82532_ISR0_PERR |
+					     SAB82532_ISR0_FERR);
+			up->port.icount.brk++;
+			uart_handle_break(&up->port);
+		}
+	}
+
 	for (i = 0; i < count; i++) {
 		unsigned char ch = buf[i], flag;