Commit cc58d0a3 authored by Erwan Le Ray's avatar Erwan Le Ray Committed by Greg Kroah-Hartman

serial: stm32: re-introduce an irq flag condition in usart_receive_chars

Re-introduce an irq flag condition in usart_receive_chars.
This condition has been deleted by commit 75f4e830 ("serial: do not
restore interrupt state in sysrq helper").
This code was present to handle threaded case, and has been removed
because it is no more needed in this case. Nevertheless an irq safe lock
is still needed in some cases, when DMA should be stopped to receive errors
or breaks in PIO mode.
This patch is a precursor to the complete rework or stm32 serial driver
DMA implementation.
Signed-off-by: default avatarErwan Le Ray <erwan.leray@foss.st.com>
Link: https://lore.kernel.org/r/20211020150332.10214-2-erwan.leray@foss.st.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9db81eca
...@@ -209,19 +209,22 @@ static unsigned long stm32_usart_get_char(struct uart_port *port, u32 *sr, ...@@ -209,19 +209,22 @@ static unsigned long stm32_usart_get_char(struct uart_port *port, u32 *sr,
return c; return c;
} }
static void stm32_usart_receive_chars(struct uart_port *port, bool threaded) static void stm32_usart_receive_chars(struct uart_port *port, bool irqflag)
{ {
struct tty_port *tport = &port->state->port; struct tty_port *tport = &port->state->port;
struct stm32_port *stm32_port = to_stm32_port(port); struct stm32_port *stm32_port = to_stm32_port(port);
const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs;
unsigned long c; unsigned long c, flags;
u32 sr; u32 sr;
char flag; char flag;
spin_lock(&port->lock); if (irqflag)
spin_lock_irqsave(&port->lock, flags);
else
spin_lock(&port->lock);
while (stm32_usart_pending_rx(port, &sr, &stm32_port->last_res, while (stm32_usart_pending_rx(port, &sr, &stm32_port->last_res,
threaded)) { irqflag)) {
sr |= USART_SR_DUMMY_RX; sr |= USART_SR_DUMMY_RX;
flag = TTY_NORMAL; flag = TTY_NORMAL;
...@@ -275,7 +278,10 @@ static void stm32_usart_receive_chars(struct uart_port *port, bool threaded) ...@@ -275,7 +278,10 @@ static void stm32_usart_receive_chars(struct uart_port *port, bool threaded)
uart_insert_char(port, sr, USART_SR_ORE, c, flag); uart_insert_char(port, sr, USART_SR_ORE, c, flag);
} }
uart_unlock_and_check_sysrq(port); if (irqflag)
uart_unlock_and_check_sysrq_irqrestore(port, irqflag);
else
uart_unlock_and_check_sysrq(port);
tty_flip_buffer_push(tport); tty_flip_buffer_push(tport);
} }
...@@ -496,10 +502,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr) ...@@ -496,10 +502,9 @@ static irqreturn_t stm32_usart_interrupt(int irq, void *ptr)
static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr) static irqreturn_t stm32_usart_threaded_interrupt(int irq, void *ptr)
{ {
struct uart_port *port = ptr; struct uart_port *port = ptr;
struct stm32_port *stm32_port = to_stm32_port(port);
if (stm32_port->rx_ch) /* Receiver timeout irq for DMA RX */
stm32_usart_receive_chars(port, true); stm32_usart_receive_chars(port, false);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment