diff options
Diffstat (limited to 'debian/patches-rt/0020-serial-8250-implement-write_atomic.patch')
-rw-r--r-- | debian/patches-rt/0020-serial-8250-implement-write_atomic.patch | 150 |
1 files changed, 92 insertions, 58 deletions
diff --git a/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch b/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch index f4617e3a2..1856f3582 100644 --- a/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch +++ b/debian/patches-rt/0020-serial-8250-implement-write_atomic.patch @@ -1,7 +1,7 @@ From: John Ogness <john.ogness@linutronix.de> Date: Tue, 12 Feb 2019 15:29:58 +0100 Subject: [PATCH 20/25] serial: 8250: implement write_atomic -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.17-rt9.tar.xz +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/5.4/older/patches-5.4.3-rt1.tar.xz Implement a non-sleeping NMI-safe write_atomic console function in order to support emergency printk messages. @@ -16,26 +16,61 @@ preempted write_atomic. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- - drivers/tty/serial/8250/8250.h | 4 + drivers/tty/serial/8250/8250.h | 22 +++++ drivers/tty/serial/8250/8250_core.c | 19 +++- - drivers/tty/serial/8250/8250_dma.c | 5 - + drivers/tty/serial/8250/8250_dma.c | 4 drivers/tty/serial/8250/8250_port.c | 154 ++++++++++++++++++++++++++---------- include/linux/serial_8250.h | 5 + - 5 files changed, 139 insertions(+), 48 deletions(-) + 5 files changed, 157 insertions(+), 47 deletions(-) --- a/drivers/tty/serial/8250/8250.h +++ b/drivers/tty/serial/8250/8250.h -@@ -255,3 +255,7 @@ static inline int serial_index(struct ua - { - return port->minor - 64; - } -+ +@@ -96,6 +96,10 @@ struct serial8250_config { + #define SERIAL8250_SHARE_IRQS 0 + #endif + +void set_ier(struct uart_8250_port *up, unsigned char ier); +void clear_ier(struct uart_8250_port *up); +void restore_ier(struct uart_8250_port *up); ++ + #define SERIAL8250_PORT_FLAGS(_base, _irq, _flags) \ + { \ + .iobase = _base, \ +@@ -139,6 +143,15 @@ static inline bool serial8250_set_THRI(s + return true; + } + ++static inline bool serial8250_set_THRI_sier(struct uart_8250_port *up) ++{ ++ if (up->ier & UART_IER_THRI) ++ return false; ++ up->ier |= UART_IER_THRI; ++ set_ier(up, up->ier); ++ return true; ++} ++ + static inline bool serial8250_clear_THRI(struct uart_8250_port *up) + { + if (!(up->ier & UART_IER_THRI)) +@@ -148,6 +161,15 @@ static inline bool serial8250_clear_THRI + return true; + } + ++static inline bool serial8250_clear_THRI_sier(struct uart_8250_port *up) ++{ ++ if (!(up->ier & UART_IER_THRI)) ++ return false; ++ up->ier &= ~UART_IER_THRI; ++ set_ier(up, up->ier); ++ return true; ++} ++ + struct uart_8250_port *serial8250_get_port(int line); + + void serial8250_rpm_get(struct uart_8250_port *p); --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c -@@ -265,7 +265,7 @@ static void serial8250_timeout(struct ti +@@ -266,7 +266,7 @@ static void serial8250_timeout(struct ti static void serial8250_backup_timeout(struct timer_list *t) { struct uart_8250_port *up = from_timer(up, t, timer); @@ -44,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> unsigned long flags; spin_lock_irqsave(&up->port.lock, flags); -@@ -274,10 +274,8 @@ static void serial8250_backup_timeout(st +@@ -275,10 +275,8 @@ static void serial8250_backup_timeout(st * Must disable interrupts or else we risk racing with the interrupt * based handler. */ @@ -57,7 +92,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> iir = serial_in(up, UART_IIR); -@@ -300,7 +298,7 @@ static void serial8250_backup_timeout(st +@@ -301,7 +299,7 @@ static void serial8250_backup_timeout(st serial8250_tx_chars(up); if (up->port.irq) @@ -66,7 +101,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> spin_unlock_irqrestore(&up->port.lock, flags); -@@ -578,6 +576,14 @@ serial8250_register_ports(struct uart_dr +@@ -579,6 +577,14 @@ serial8250_register_ports(struct uart_dr #ifdef CONFIG_SERIAL_8250_CONSOLE @@ -81,7 +116,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> static void univ8250_console_write(struct console *co, const char *s, unsigned int count) { -@@ -663,6 +669,7 @@ static int univ8250_console_match(struct +@@ -664,6 +670,7 @@ static int univ8250_console_match(struct static struct console univ8250_console = { .name = "ttyS", @@ -91,28 +126,27 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> .setup = univ8250_console_setup, --- a/drivers/tty/serial/8250/8250_dma.c +++ b/drivers/tty/serial/8250/8250_dma.c -@@ -36,7 +36,7 @@ static void __dma_tx_complete(void *para +@@ -35,7 +35,7 @@ static void __dma_tx_complete(void *para + ret = serial8250_tx_dma(p); - if (ret) { - p->ier |= UART_IER_THRI; -- serial_port_out(&p->port, UART_IER, p->ier); -+ set_ier(p, p->ier); - } + if (ret) +- serial8250_set_THRI(p); ++ serial8250_set_THRI_sier(p); spin_unlock_irqrestore(&p->port.lock, flags); -@@ -101,8 +101,7 @@ int serial8250_tx_dma(struct uart_8250_p + } +@@ -98,7 +98,7 @@ int serial8250_tx_dma(struct uart_8250_p + dma_async_issue_pending(dma->txchan); if (dma->tx_err) { dma->tx_err = 0; - if (p->ier & UART_IER_THRI) { -- p->ier &= ~UART_IER_THRI; -- serial_out(p, UART_IER, p->ier); -+ set_ier(p, p->ier); - } +- serial8250_clear_THRI(p); ++ serial8250_clear_THRI_sier(p); } return 0; + err: --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c -@@ -731,7 +731,7 @@ static void serial8250_set_sleep(struct +@@ -721,7 +721,7 @@ static void serial8250_set_sleep(struct serial_out(p, UART_EFR, UART_EFR_ECB); serial_out(p, UART_LCR, 0); } @@ -121,7 +155,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> if (p->capabilities & UART_CAP_EFR) { serial_out(p, UART_LCR, UART_LCR_CONF_MODE_B); serial_out(p, UART_EFR, efr); -@@ -1433,7 +1433,7 @@ static void serial8250_stop_rx(struct ua +@@ -1390,7 +1390,7 @@ static void serial8250_stop_rx(struct ua up->ier &= ~(UART_IER_RLSI | UART_IER_RDI); up->port.read_status_mask &= ~UART_LSR_DR; @@ -130,7 +164,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> serial8250_rpm_put(up); } -@@ -1451,7 +1451,7 @@ static void __do_stop_tx_rs485(struct ua +@@ -1408,7 +1408,7 @@ static void __do_stop_tx_rs485(struct ua serial8250_clear_and_reinit_fifos(p); p->ier |= UART_IER_RLSI | UART_IER_RDI; @@ -139,26 +173,26 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } } static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t) -@@ -1504,7 +1504,7 @@ static inline void __do_stop_tx(struct u +@@ -1459,7 +1459,7 @@ static void __stop_tx_rs485(struct uart_ + + static inline void __do_stop_tx(struct uart_8250_port *p) { - if (p->ier & UART_IER_THRI) { - p->ier &= ~UART_IER_THRI; -- serial_out(p, UART_IER, p->ier); -+ set_ier(p, p->ier); +- if (serial8250_clear_THRI(p)) ++ if (serial8250_clear_THRI_sier(p)) serial8250_rpm_put_tx(p); - } } -@@ -1557,7 +1557,7 @@ static inline void __start_tx(struct uar - if (!(up->ier & UART_IER_THRI)) { - up->ier |= UART_IER_THRI; -- serial_port_out(port, UART_IER, up->ier); -+ set_ier(up, up->ier); +@@ -1509,7 +1509,7 @@ static inline void __start_tx(struct uar + if (up->dma && !up->dma->tx_dma(up)) + return; +- if (serial8250_set_THRI(up)) { ++ if (serial8250_set_THRI_sier(up)) { if (up->bugs & UART_BUG_TXEN) { unsigned char lsr; -@@ -1663,7 +1663,7 @@ static void serial8250_disable_ms(struct - return; + +@@ -1616,7 +1616,7 @@ static void serial8250_disable_ms(struct + mctrl_gpio_disable_ms(up->gpios); up->ier &= ~UART_IER_MSI; - serial_port_out(port, UART_IER, up->ier); @@ -166,7 +200,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } static void serial8250_enable_ms(struct uart_port *port) -@@ -1677,7 +1677,7 @@ static void serial8250_enable_ms(struct +@@ -1632,7 +1632,7 @@ static void serial8250_enable_ms(struct up->ier |= UART_IER_MSI; serial8250_rpm_get(up); @@ -175,7 +209,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> serial8250_rpm_put(up); } -@@ -2050,6 +2050,52 @@ static void wait_for_xmitr(struct uart_8 +@@ -1991,6 +1991,52 @@ static void wait_for_xmitr(struct uart_8 } } @@ -228,7 +262,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #ifdef CONFIG_CONSOLE_POLL /* * Console polling routines for writing and reading from the uart while -@@ -2081,18 +2127,10 @@ static int serial8250_get_poll_char(stru +@@ -2022,18 +2068,10 @@ static int serial8250_get_poll_char(stru static void serial8250_put_poll_char(struct uart_port *port, unsigned char c) { @@ -248,7 +282,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> wait_for_xmitr(up, BOTH_EMPTY); /* -@@ -2105,7 +2143,7 @@ static void serial8250_put_poll_char(str +@@ -2046,7 +2084,7 @@ static void serial8250_put_poll_char(str * and restore the IER */ wait_for_xmitr(up, BOTH_EMPTY); @@ -257,7 +291,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> serial8250_rpm_put(up); } -@@ -2417,7 +2455,7 @@ void serial8250_do_shutdown(struct uart_ +@@ -2354,7 +2392,7 @@ void serial8250_do_shutdown(struct uart_ */ spin_lock_irqsave(&port->lock, flags); up->ier = 0; @@ -266,7 +300,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> spin_unlock_irqrestore(&port->lock, flags); synchronize_irq(port->irq); -@@ -2728,7 +2766,7 @@ serial8250_do_set_termios(struct uart_po +@@ -2639,7 +2677,7 @@ serial8250_do_set_termios(struct uart_po if (up->capabilities & UART_CAP_RTOIE) up->ier |= UART_IER_RTOIE; @@ -275,7 +309,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> if (up->capabilities & UART_CAP_EFR) { unsigned char efr = 0; -@@ -3192,7 +3230,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_default +@@ -3103,7 +3141,7 @@ EXPORT_SYMBOL_GPL(serial8250_set_default #ifdef CONFIG_SERIAL_8250_CONSOLE @@ -284,7 +318,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> { struct uart_8250_port *up = up_to_u8250p(port); -@@ -3200,6 +3238,18 @@ static void serial8250_console_putchar(s +@@ -3111,6 +3149,18 @@ static void serial8250_console_putchar(s serial_port_out(port, UART_TX, ch); } @@ -303,7 +337,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* * Restore serial console when h/w power-off detected */ -@@ -3221,6 +3271,42 @@ static void serial8250_console_restore(s +@@ -3132,6 +3182,42 @@ static void serial8250_console_restore(s serial8250_out_MCR(up, UART_MCR_DTR | UART_MCR_RTS); } @@ -346,7 +380,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* * Print a string to the serial port trying not to disturb * any possible real use of the port... -@@ -3232,27 +3318,13 @@ void serial8250_console_write(struct uar +@@ -3143,27 +3229,13 @@ void serial8250_console_write(struct uar { struct uart_port *port = &up->port; unsigned long flags; @@ -376,7 +410,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* check scratch reg to see if port powered off during system sleep */ if (up->canary && (up->canary != serial_port_in(port, UART_SCR))) { -@@ -3260,14 +3332,16 @@ void serial8250_console_write(struct uar +@@ -3171,14 +3243,16 @@ void serial8250_console_write(struct uar up->canary = 0; } @@ -394,7 +428,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> /* * The receive handling will happen properly because the -@@ -3279,8 +3353,7 @@ void serial8250_console_write(struct uar +@@ -3190,8 +3264,7 @@ void serial8250_console_write(struct uar if (up->msr_saved_flags) serial8250_modem_status(up); @@ -404,7 +438,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> serial8250_rpm_put(up); } -@@ -3301,6 +3374,7 @@ static unsigned int probe_baud(struct ua +@@ -3212,6 +3285,7 @@ static unsigned int probe_baud(struct ua int serial8250_console_setup(struct uart_port *port, char *options, bool probe) { @@ -412,7 +446,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> int baud = 9600; int bits = 8; int parity = 'n'; -@@ -3309,6 +3383,8 @@ int serial8250_console_setup(struct uart +@@ -3220,6 +3294,8 @@ int serial8250_console_setup(struct uart if (!port->iobase && !port->membase) return -ENODEV; @@ -431,7 +465,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #include <linux/serial_core.h> #include <linux/serial_reg.h> #include <linux/platform_device.h> -@@ -122,6 +123,8 @@ struct uart_8250_port { +@@ -123,6 +124,8 @@ struct uart_8250_port { #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA unsigned char msr_saved_flags; @@ -440,7 +474,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> struct uart_8250_dma *dma; const struct uart_8250_ops *ops; -@@ -173,6 +176,8 @@ void serial8250_init_port(struct uart_82 +@@ -174,6 +177,8 @@ void serial8250_init_port(struct uart_82 void serial8250_set_defaults(struct uart_8250_port *up); void serial8250_console_write(struct uart_8250_port *up, const char *s, unsigned int count); |