Skip to content

Commit 9050079

Browse files
Stefan-gabriel Mireagregkh
authored andcommitted
tty: serial: linflexuart: Fix magic SysRq handling
Following an incorrect indentation reported to me by Dan Carpenter, I noticed that the SysRq lines were inherited from the lpuart driver[1] (note how the 'continue' is aligned to 'sport->port.sysrq = 0') and we have never actually tested the SysRq support. 'sport->sysrq = 0' is not necessary neither before nor after 'continue', because sysrq will already be 0 after uart_handle_sysrq_char() will finish. Also, since the LINFlexD driver never called uart_handle_break(), sysrq would have never been set to a nonzero value, so uart_handle_sysrq_char() was not going to do anything. Break conditions are detected based on a null data byte along with a framing error (stop bit sampled to 0). [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/fsl_lpuart.c?h=b3e3bf2ef2c74f5ce5c19510edbbb9bfc1d249c2#n659 Fixes: 09864c1 ("tty: serial: Add linflexuart driver for S32V234") Signed-off-by: Stefan-Gabriel Mirea <[email protected]> Reported-by: kbuild test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 392fb8d commit 9050079

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/tty/serial/fsl_linflexuart.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Freescale linflexuart serial port driver
44
*
55
* Copyright 2012-2016 Freescale Semiconductor, Inc.
6-
* Copyright 2017-2018 NXP
6+
* Copyright 2017-2019 NXP
77
*/
88

99
#if defined(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE) && \
@@ -246,12 +246,14 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
246246
struct tty_port *port = &sport->state->port;
247247
unsigned long flags, status;
248248
unsigned char rx;
249+
bool brk;
249250

250251
spin_lock_irqsave(&sport->lock, flags);
251252

252253
status = readl(sport->membase + UARTSR);
253254
while (status & LINFLEXD_UARTSR_RMB) {
254255
rx = readb(sport->membase + BDRM);
256+
brk = false;
255257
flg = TTY_NORMAL;
256258
sport->icount.rx++;
257259

@@ -261,8 +263,11 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
261263
status |= LINFLEXD_UARTSR_SZF;
262264
if (status & LINFLEXD_UARTSR_BOF)
263265
status |= LINFLEXD_UARTSR_BOF;
264-
if (status & LINFLEXD_UARTSR_FEF)
266+
if (status & LINFLEXD_UARTSR_FEF) {
267+
if (!rx)
268+
brk = true;
265269
status |= LINFLEXD_UARTSR_FEF;
270+
}
266271
if (status & LINFLEXD_UARTSR_PE)
267272
status |= LINFLEXD_UARTSR_PE;
268273
}
@@ -271,13 +276,15 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
271276
sport->membase + UARTSR);
272277
status = readl(sport->membase + UARTSR);
273278

274-
if (uart_handle_sysrq_char(sport, (unsigned char)rx))
275-
continue;
276-
279+
if (brk) {
280+
uart_handle_break(sport);
281+
} else {
277282
#ifdef SUPPORT_SYSRQ
278-
sport->sysrq = 0;
283+
if (uart_handle_sysrq_char(sport, (unsigned char)rx))
284+
continue;
279285
#endif
280-
tty_insert_flip_char(port, rx, flg);
286+
tty_insert_flip_char(port, rx, flg);
287+
}
281288
}
282289

283290
spin_unlock_irqrestore(&sport->lock, flags);

0 commit comments

Comments
 (0)