History

Merge tag 'tty-5.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty into master

Pull tty/serial driver fixes from Greg KH: :Here are some small tty and serial driver fixes for 5.8-rc6. The largest set of patches in here is a revert of the sysrq changes that went into 5.8-rc1 but turned out to cause a noticable overhead and cpu usage. Other than that, there's a few small serial driver fixes to resolve reported issues, and finally resolving the spinlock init problem on many serial driver consoles. All of these have been in linux-next for a while with no reported issues" * tag 'tty-5.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: serial: core: Initialise spin lock before use in uart_configure_port() serial: mxs-auart: add missed iounmap() in probe failure and remove serial: sh-sci: Initialize spinlock for uart console Revert "tty: xilinx_uartps: Fix missing id assignment to the console" serial: core: drop redundant sysrq checks serial: core: fix sysrq overhead regression Revert "serial: core: Refactor uart_unlock_and_check_sysrq()" tty/serial: fix serial_core.c kernel-doc warnings tty: serial: cpm_uart: Fix behaviour for non existing GPIOs

Linus Torvalds committed 6 years ago

Commit 7531ee32 parents 7e8d2f6 f7430616 files · +134 −108Browse files

Unified · Split

6 files
  1. drivers/tty/serial/cpm_uart/cpm_uart_core.c +8 −1
  2. drivers/tty/serial/mxs-auart.c +8 −4
  3. drivers/tty/serial/serial_core.c +17 −98
  4. drivers/tty/serial/sh-sci.c +3 −0
  5. drivers/tty/serial/xilinx_uartps.c +0 −1
  6. include/linux/serial_core.h +98 −4
drivers/tty/serial/cpm_uart/cpm_uart_core.c+8−1
@@ -1215,7 +1215,12 @@ static int cpm_uart_init_port(struct device_node *np, · 1214 unmodified lines
12151215
12161216 pinfo->gpios[i] = NULL;
12171217
1218− gpiod = devm_gpiod_get_index(dev, NULL, i, GPIOD_ASIS);
1218+ gpiod = devm_gpiod_get_index_optional(dev, NULL, i, GPIOD_ASIS);
1219+
1220+ if (IS_ERR(gpiod)) {
1221+ ret = PTR_ERR(gpiod);
1222+ goto out_irq;
1223+ }
12191224
12201225 if (gpiod) {
12211226 if (i == GPIO_RTS || i == GPIO_DTR)
@@ -1237,6 +1242,8 @@ static int cpm_uart_init_port(struct device_node *np, · 15 unmodified lines
12371242
12381243 return cpm_uart_request_port(&pinfo->port);
12391244
1245+out_irq:
1246+ irq_dispose_mapping(pinfo->port.irq);
12401247 out_pram:
12411248 cpm_uart_unmap_pram(pinfo, pram);
12421249 out_mem:
drivers/tty/serial/mxs-auart.c+8−4
@@ -1698,21 +1698,21 @@ static int mxs_auart_probe(struct platform_device *pdev) · 1697 unmodified lines
16981698 irq = platform_get_irq(pdev, 0);
16991699 if (irq < 0) {
17001700 ret = irq;
1701− goto out_disable_clks;
1701+ goto out_iounmap;
17021702 }
17031703
17041704 s->port.irq = irq;
17051705 ret = devm_request_irq(&pdev->dev, irq, mxs_auart_irq_handle, 0,
17061706 dev_name(&pdev->dev), s);
17071707 if (ret)
1708− goto out_disable_clks;
1708+ goto out_iounmap;
17091709
17101710 platform_set_drvdata(pdev, s);
17111711
17121712 ret = mxs_auart_init_gpios(s, &pdev->dev);
17131713 if (ret) {
17141714 dev_err(&pdev->dev, "Failed to initialize GPIOs.\n");
1715− goto out_disable_clks;
1715+ goto out_iounmap;
17161716 }
17171717
17181718 /*
@@ -1720,7 +1720,7 @@ static int mxs_auart_probe(struct platform_device *pdev) · 1 unmodified line
17201720 */
17211721 ret = mxs_auart_request_gpio_irq(s);
17221722 if (ret)
1723− goto out_disable_clks;
1723+ goto out_iounmap;
17241724
17251725 auart_port[s->port.line] = s;
17261726
@@ -1746,6 +1746,9 @@ out_free_qpio_irq: · 19 unmodified lines
17461746 mxs_auart_free_gpio_irq(s);
17471747 auart_port[pdev->id] = NULL;
17481748
1749+out_iounmap:
1750+ iounmap(s->port.membase);
1751+
17491752 out_disable_clks:
17501753 if (is_asm9260_auart(s)) {
17511754 clk_disable_unprepare(s->clk);
@@ -1761,6 +1764,7 @@ static int mxs_auart_remove(struct platform_device *pdev) · 9 unmodified lines
17611764 uart_remove_one_port(&auart_driver, &s->port);
17621765 auart_port[pdev->id] = NULL;
17631766 mxs_auart_free_gpio_irq(s);
1767+ iounmap(s->port.membase);
17641768 if (is_asm9260_auart(s)) {
17651769 clk_disable_unprepare(s->clk);
17661770 clk_disable_unprepare(s->clk_ahb);
drivers/tty/serial/serial_core.c+17−98
@@ -41,8 +41,6 @@ static struct lock_class_key port_lock_key; · 40 unmodified lines
4141
4242 #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8)
4343
44−#define SYSRQ_TIMEOUT (HZ * 5)
45−
4644 static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
4745 struct ktermios *old_termios);
4846 static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
@@ -1916,6 +1914,12 @@ static inline bool uart_console_enabled(struct uart_port *port) · 1867 unmodified lines
19161914 return uart_console(port) && (port->cons->flags & CON_ENABLED);
19171915 }
19181916
1917+static void __uart_port_spin_lock_init(struct uart_port *port)
1918+{
1919+ spin_lock_init(&port->lock);
1920+ lockdep_set_class(&port->lock, &port_lock_key);
1921+}
1922+
19191923 /*
19201924 * Ensure that the serial console lock is initialised early.
19211925 * If this port is a console, then the spinlock is already initialised.
@@ -1925,8 +1929,7 @@ static inline void uart_port_spin_lock_init(struct uart_port *port) · 3 unmodified lines
19251929 if (uart_console(port))
19261930 return;
19271931
1928− spin_lock_init(&port->lock);
1929− lockdep_set_class(&port->lock, &port_lock_key);
1932+ __uart_port_spin_lock_init(port);
19301933 }
19311934
19321935 #if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(CONFIG_CONSOLE_POLL)
@@ -2372,6 +2375,13 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state, · 439 unmodified lines
23722375 /* Power up port for set_mctrl() */
23732376 uart_change_pm(state, UART_PM_STATE_ON);
23742377
2378+ /*
2379+ * If this driver supports console, and it hasn't been
2380+ * successfully registered yet, initialise spin lock for it.
2381+ */
2382+ if (port->cons && !(port->cons->flags & CON_ENABLED))
2383+ __uart_port_spin_lock_init(port);
2384+
23752385 /*
23762386 * Ensure that the modem control lines are de-activated.
23772387 * keep the DTR setting that is set in uart_set_options()
@@ -3163,7 +3173,7 @@ static DECLARE_WORK(sysrq_enable_work, uart_sysrq_on); · 785 unmodified lines
31633173 * Returns false if @ch is out of enabling sequence and should be
31643174 * handled some other way, true if @ch was consumed.
31653175 */
3166−static bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
3176+bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
31673177 {
31683178 int sysrq_toggle_seq_len = strlen(sysrq_toggle_seq);
31693179
@@ -3186,99 +3196,9 @@ static bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch) · 16 unmodified lines
31863196 port->sysrq = 0;
31873197 return true;
31883198 }
3189−#else
3190−static inline bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
3191−{
3192− return false;
3193−}
3199+EXPORT_SYMBOL_GPL(uart_try_toggle_sysrq);
31943200 #endif
31953201
3196−int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
3197−{
3198− if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
3199− return 0;
3200−
3201− if (!port->has_sysrq || !port->sysrq)
3202− return 0;
3203−
3204− if (ch && time_before(jiffies, port->sysrq)) {
3205− if (sysrq_mask()) {
3206− handle_sysrq(ch);
3207− port->sysrq = 0;
3208− return 1;
3209− }
3210− if (uart_try_toggle_sysrq(port, ch))
3211− return 1;
3212− }
3213− port->sysrq = 0;
3214−
3215− return 0;
3216−}
3217−EXPORT_SYMBOL_GPL(uart_handle_sysrq_char);
3218−
3219−int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
3220−{
3221− if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
3222− return 0;
3223−
3224− if (!port->has_sysrq || !port->sysrq)
3225− return 0;
3226−
3227− if (ch && time_before(jiffies, port->sysrq)) {
3228− if (sysrq_mask()) {
3229− port->sysrq_ch = ch;
3230− port->sysrq = 0;
3231− return 1;
3232− }
3233− if (uart_try_toggle_sysrq(port, ch))
3234− return 1;
3235− }
3236− port->sysrq = 0;
3237−
3238− return 0;
3239−}
3240−EXPORT_SYMBOL_GPL(uart_prepare_sysrq_char);
3241−
3242−void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long flags)
3243−__releases(&port->lock)
3244−{
3245− if (port->has_sysrq) {
3246− int sysrq_ch = port->sysrq_ch;
3247−
3248− port->sysrq_ch = 0;
3249− spin_unlock_irqrestore(&port->lock, flags);
3250− if (sysrq_ch)
3251− handle_sysrq(sysrq_ch);
3252− } else {
3253− spin_unlock_irqrestore(&port->lock, flags);
3254− }
3255−}
3256−EXPORT_SYMBOL_GPL(uart_unlock_and_check_sysrq);
3257−
3258−/*
3259− * We do the SysRQ and SAK checking like this...
3260− */
3261−int uart_handle_break(struct uart_port *port)
3262−{
3263− struct uart_state *state = port->state;
3264−
3265− if (port->handle_break)
3266− port->handle_break(port);
3267−
3268− if (port->has_sysrq && uart_console(port)) {
3269− if (!port->sysrq) {
3270− port->sysrq = jiffies + SYSRQ_TIMEOUT;
3271− return 1;
3272− }
3273− port->sysrq = 0;
3274− }
3275−
3276− if (port->flags & UPF_SAK)
3277− do_SAK(state->port.tty);
3278− return 0;
3279−}
3280−EXPORT_SYMBOL_GPL(uart_handle_break);
3281−
32823202 EXPORT_SYMBOL(uart_write_wakeup);
32833203 EXPORT_SYMBOL(uart_register_driver);
32843204 EXPORT_SYMBOL(uart_unregister_driver);
@@ -3289,8 +3209,7 @@ EXPORT_SYMBOL(uart_remove_one_port); · 4 unmodified lines
32893209
32903210 /**
32913211 * uart_get_rs485_mode() - retrieve rs485 properties for given uart
3292− * @dev: uart device
3293− * @rs485conf: output parameter
3212+ * @port: uart device's target port
32943213 *
32953214 * This function implements the device tree binding described in
32963215 * Documentation/devicetree/bindings/serial/rs485.txt.
drivers/tty/serial/sh-sci.c+3−0
@@ -3301,6 +3301,9 @@ static int sci_probe_single(struct platform_device *dev, · 3300 unmodified lines
33013301 sciport->port.flags |= UPF_HARD_FLOW;
33023302 }
33033303
3304+ if (sci_uart_driver.cons->index == sciport->port.line)
3305+ spin_lock_init(&sciport->port.lock);
3306+
33043307 ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
33053308 if (ret) {
33063309 sci_cleanup_single(sciport);
drivers/tty/serial/xilinx_uartps.c+0−1
@@ -1465,7 +1465,6 @@ static int cdns_uart_probe(struct platform_device *pdev) · 1464 unmodified lines
14651465 cdns_uart_uart_driver.nr = CDNS_UART_NR_PORTS;
14661466 #ifdef CONFIG_SERIAL_XILINX_PS_UART_CONSOLE
14671467 cdns_uart_uart_driver.cons = &cdns_uart_console;
1468− cdns_uart_console.index = id;
14691468 #endif
14701469
14711470 rc = uart_register_driver(&cdns_uart_uart_driver);
include/linux/serial_core.h+98−4
@@ -462,10 +462,104 @@ extern void uart_handle_cts_change(struct uart_port *uport, · 461 unmodified lines
462462 extern void uart_insert_char(struct uart_port *port, unsigned int status,
463463 unsigned int overrun, unsigned int ch, unsigned int flag);
464464
465−extern int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch);
466−extern int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch);
467−extern void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long flags);
468−extern int uart_handle_break(struct uart_port *port);
465+#ifdef CONFIG_MAGIC_SYSRQ_SERIAL
466+#define SYSRQ_TIMEOUT (HZ * 5)
467+
468+bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch);
469+
470+static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
471+{
472+ if (!port->sysrq)
473+ return 0;
474+
475+ if (ch && time_before(jiffies, port->sysrq)) {
476+ if (sysrq_mask()) {
477+ handle_sysrq(ch);
478+ port->sysrq = 0;
479+ return 1;
480+ }
481+ if (uart_try_toggle_sysrq(port, ch))
482+ return 1;
483+ }
484+ port->sysrq = 0;
485+
486+ return 0;
487+}
488+
489+static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
490+{
491+ if (!port->sysrq)
492+ return 0;
493+
494+ if (ch && time_before(jiffies, port->sysrq)) {
495+ if (sysrq_mask()) {
496+ port->sysrq_ch = ch;
497+ port->sysrq = 0;
498+ return 1;
499+ }
500+ if (uart_try_toggle_sysrq(port, ch))
501+ return 1;
502+ }
503+ port->sysrq = 0;
504+
505+ return 0;
506+}
507+
508+static inline void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
509+{
510+ int sysrq_ch;
511+
512+ if (!port->has_sysrq) {
513+ spin_unlock_irqrestore(&port->lock, irqflags);
514+ return;
515+ }
516+
517+ sysrq_ch = port->sysrq_ch;
518+ port->sysrq_ch = 0;
519+
520+ spin_unlock_irqrestore(&port->lock, irqflags);
521+
522+ if (sysrq_ch)
523+ handle_sysrq(sysrq_ch);
524+}
525+#else /* CONFIG_MAGIC_SYSRQ_SERIAL */
526+static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
527+{
528+ return 0;
529+}
530+static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
531+{
532+ return 0;
533+}
534+static inline void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
535+{
536+ spin_unlock_irqrestore(&port->lock, irqflags);
537+}
538+#endif /* CONFIG_MAGIC_SYSRQ_SERIAL */
539+
540+/*
541+ * We do the SysRQ and SAK checking like this...
542+ */
543+static inline int uart_handle_break(struct uart_port *port)
544+{
545+ struct uart_state *state = port->state;
546+
547+ if (port->handle_break)
548+ port->handle_break(port);
549+
550+#ifdef CONFIG_MAGIC_SYSRQ_SERIAL
551+ if (port->has_sysrq && uart_console(port)) {
552+ if (!port->sysrq) {
553+ port->sysrq = jiffies + SYSRQ_TIMEOUT;
554+ return 1;
555+ }
556+ port->sysrq = 0;
557+ }
558+#endif
559+ if (port->flags & UPF_SAK)
560+ do_SAK(state->port.tty);
561+ return 0;
562+}
469563
470564 /*
471565 * UART_ENABLE_MS - determine if port should enable modem status irqs