tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
Subsystems (3)
PATCH 1/1 tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
In set_termios(), interrupts where not disabled if UART_ENABLE_MS() was false.
Tested on at91sam9g35.
--- drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
drivers/tty/serial/atmel_serial.c +42 -1
@@ -527,6 +527,45 @@ static void atmel_enable_ms(struct uart_port *port) }/* +* Disable modem status interrupts +*/ +static void atmel_disable_ms (struct uart_port *port) +{ +struct atmel_uart_port *atmel_port =to_atmel_uart_port (port); +uint32_t idr =0 ; + +/* +* Interrupt should not be disabled twice +*/ +if (!atmel_port->ms_irq_enabled) +return ; + + atmel_port->ms_irq_enabled = false; + +if (atmel_port->gpio_irq[UART_GPIO_CTS ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_CTS ]); +else + idr |=ATMEL_US_CTSIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DSR ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DSR ]); +else + idr |=ATMEL_US_DSRIC ; + +if (atmel_port->gpio_irq[UART_GPIO_RI ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_RI ]); +else + idr |=ATMEL_US_RIIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DCD ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DCD ]); +else + idr |=ATMEL_US_DCDIC ; + +UART_PUT_IDR (port, idr); +} + +/* * Control the transmission of a break signal */ static void atmel_break_ctl (struct uart_port *port,int break_state)
@@ -1993,7 +2032,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,/* CTS flow-control and modem-status interrupts */ if (UART_ENABLE_MS (port, termios->c_cflag)) - port->ops->enable_ms (port); +atmel_enable_ms (port); +else +atmel_disable_ms (port);spin_unlock_irqrestore (&port->lock, flags); }
Signature · 1 line
2.0.0
PATCH 1/1 tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
Quoted 6 lines · Richard Genoud
In
set_termios(), interrupts where not disabled ifUART_ENABLE_MS()was false.Tested on at91sam9g35.
CC stable at vger.kernel.org # >= 3.16
Awesome, thank you.
Quoted 67 lines
Signed-off-by Richard Genoud <[email protected]>--- drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)drivers/tty/serial/atmel_serial.c +42
-1@@ -527,6 +527,45 @@ static void atmel_enable_ms(struct uart_port *port) }/* +* Disable modem status interrupts +*/ +static void atmel_disable_ms (struct uart_port *port) +{ +struct atmel_uart_port *atmel_port =to_atmel_uart_port (port); +uint32_t idr =0 ; + +/* +* Interrupt should not be disabled twice +*/ +if (!atmel_port->ms_irq_enabled) +return ; + + atmel_port->ms_irq_enabled = false; + +if (atmel_port->gpio_irq[UART_GPIO_CTS ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_CTS ]); +else + idr |=ATMEL_US_CTSIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DSR ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DSR ]); +else + idr |=ATMEL_US_DSRIC ; + +if (atmel_port->gpio_irq[UART_GPIO_RI ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_RI ]); +else + idr |=ATMEL_US_RIIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DCD ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DCD ]); +else + idr |=ATMEL_US_DCDIC ; + +UART_PUT_IDR (port, idr); +} + +/* * Control the transmission of a break signal */ static void atmel_break_ctl (struct uart_port *port,int break_state)@@ -1993,7 +2032,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,/* CTS flow-control and modem-status interrupts */ if (UART_ENABLE_MS (port, termios->c_cflag)) - port->ops->enable_ms (port); +atmel_enable_ms (port); +else +atmel_disable_ms (port);spin_unlock_irqrestore (&port->lock, flags); }
PATCH 1/1 tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
In reply to Richard GenoudOn 03/09/2014 18:09, Richard Genoud :
Quoted 63 lines
In
set_termios(), interrupts where not disabled ifUART_ENABLE_MS()was false.Tested on at91sam9g35.
CC stable at vger.kernel.org # >= 3.16Signed-off-by Richard Genoud <[email protected]>--- drivers/tty/serial/atmel_serial.c | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)drivers/tty/serial/atmel_serial.c +39
-0@@ -527,6 +527,45 @@ static void atmel_enable_ms(struct uart_port *port) }/* +* Disable modem status interrupts +*/ +static void atmel_disable_ms (struct uart_port *port) +{ +struct atmel_uart_port *atmel_port =to_atmel_uart_port (port); +uint32_t idr =0 ; + +/* +* Interrupt should not be disabled twice +*/ +if (!atmel_port->ms_irq_enabled) +return ; + + atmel_port->ms_irq_enabled = false; + +if (atmel_port->gpio_irq[UART_GPIO_CTS ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_CTS ]); +else + idr |=ATMEL_US_CTSIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DSR ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DSR ]); +else + idr |=ATMEL_US_DSRIC ; + +if (atmel_port->gpio_irq[UART_GPIO_RI ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_RI ]); +else + idr |=ATMEL_US_RIIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DCD ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DCD ]); +else + idr |=ATMEL_US_DCDIC ; + +UART_PUT_IDR (port, idr); +} + +/* * Control the transmission of a break signal */ static void atmel_break_ctl (struct uart_port *port,int break_state)
drivers/tty/serial/atmel_serial.c static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, · line 2040
Quoted 10 lines
drivers/tty/serial/atmel_serial.c +3
-1@@ -1993,7 +2032,9 @@ static void atmel_set_termios(struct uart_port *port, struct ktermios *termios,/* CTS flow-control and modem-status interrupts */ if (UART_ENABLE_MS (port, termios->c_cflag)) - port->ops->enable_ms (port); +atmel_enable_ms (port); +else +atmel_disable_ms (port);spin_unlock_irqrestore (&port->lock, flags); }
Richard,
Indeed it seems needed:
But BTW, I see just below a call to the atmel_enable_ms() function in atmel_set_ldisc(). My question is, shouldn't we also add this atmel_disable_ms() in the alternative that disables the PPS in this ldisc function?
Thanks, bye,
Signature · 1 line
Nicolas Ferre
PATCH 1/1 tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
Hi Nicolas,
Quoted 5 lines · Nicolas Ferre
On 03/09/2014 18:09, Richard Genoud :
Richard,Indeed it seems needed:
Quoted 7 lines
Acked-by Nicolas Ferre <[email protected]>But BTW, I see just below a call to the
atmel_enable_ms()function inatmel_set_ldisc(). My question is, shouldn't we also add thisatmel_disable_ms()in the alternative that disables the PPS in this ldisc function?
I have that change in another series but it has to wait for:
1. another series that fixes races setting and clearing the controlling tty (and reduces the footprint of tty_mutex)
2. a series built on that which moves tty_lock() out from under tty_mutex when reopening ttys
This allows the tty_lock to be held while closing the tty.
3. a series which removes the ldisc flush from the serial core, among some other locking fixes in the serial core.
This fixes a lock inversion between the termios_rwsem and the port mutex.
All of which enables the set_ldisc() notification to be safely passed termios so it can use UART_ENABLE_MS() and also claim the port mutex to change the UPF_HARDPPS_CD flag, which is currently non-atomic and may corrupt the uart port flags field.
The series also claims the port lock around the *_enable_ms() in the various set_ldisc() handlers to protect the hardware re-programming :)
Right now, all of this is temporarily stuck on the most recent patch series, which hinges on whether the kernel should continue to support non-atomic byte stores.
Regards,
Peter Hurley
PATCH 1/1 tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
On 05/09/2014 13:06, Peter Hurley :
Quoted 11 lines
Hi Nicolas,
Quoted 8 lines · Nicolas Ferre
On 03/09/2014 18:09, Richard Genoud :
Richard,Indeed it seems needed:
Acked-by Nicolas Ferre <[email protected]>
Quoted 6 lines
Quoted 4 lines
But BTW, I see just below a call to the
atmel_enable_ms()function inatmel_set_ldisc(). My question is, shouldn't we also add thisatmel_disable_ms()in the alternative that disables the PPS in this ldisc function?I have that change in another series but it has to wait for:
Given the attractive enhancements that you describe below... I'll wait with pleasure ;-)
Quoted 14 lines
1. another series that fixes races setting and clearing the controlling tty (and reduces the footprint of
tty_mutex)
2. a series built on that which movestty_lock()out from undertty_mutexwhen reopening ttys
This allows thetty_lockto be held while closing the tty.
3. a series which removes the ldisc flush from the serial core, among some other locking fixes in the serial core.
This fixes a lock inversion between thetermios_rwsemand the port mutex.All of which enables the
set_ldisc()notification to be safely passed termios so it can useUART_ENABLE_MS()and also claim the port mutex to change theUPF_HARDPPS_CDflag, which is currently non-atomic and may corrupt the uart port flags field.
Quoted 6 lines
The series also claims the port lock around the
*_enable_ms()in the variousset_ldisc()handlers to protect the hardware re-programming :)Right now, all of this is temporarily stuck on the most recent patch series, which hinges on whether the kernel should continue to support non-atomic byte stores.
Thanks for sharing your plans. Bye,
Signature · 1 line
Nicolas Ferre