Skip to contentSkip to conversation

serial/sysrq: Cleanup ifdeffery

PATCH In review Dmitry Safonov 6 participants 71 messages Dec 13, 2019 – Dec 17, 2019

Subsystems (27)
lore
Share & tools
lore
#0 lore raw

cover serial/sysrq: Cleanup ifdeffery

The original purpose of the patches set was to add a way to enable sysrq on a uart where currently it can be constantly either on or off (CONFIG_MAGIC_SYSRQ_SERIAL), see the last patch:
"serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE"

But to do that, I had to add uart_try_toggle_sysrq() and I didn't want to bloat serial_core.h even more. So, I did cleanup by removing SUPPORT_SYSRQ resulting in a nice diff-stat and lesser ifdeffery.

Most patches are one-liners, I decided to keep them separated per-driver to let reviewers easier follow the purpose.

Cc Greg Kroah-Hartman <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc Vasiliy Khoruzhick <[email protected]>
Cc linux-serial at vger.kernel.org

Dmitry Safonov (58):
sysrq: Remove sysrq_handler_registered
serial: Move sysrq members above
serial_core: Un-ifdef sysrq SUPPORT_SYSRQ
tty/serial: Migrate aspeed_vuart to use has_sysrq tty/serial: Migrate 8250_fsl to use has_sysrq tty/serial: Migrate bcm63xx_uart to use has_sysrq tty/serial: Migrate 8250_omap to use has_sysrq tty/serial: Migrate 8250_port to use has_sysrq tty/serial: Migrate amba-pl01* to use has_sysrq tty/serial: Migrate apbuart to use has_sysrq tty/serial: Migrate arc_uart to use has_sysrq tty/serial: Migrate atmel_serial to use has_sysrq tty/serial: Migrate clps711x to use has_sysrq tty/serial: Migrate cpm_uart to use has_sysrq tty/serial: Migrate dz to use has_sysrq
tty/serial: Migrate efm32-uart to use has_sysrq tty/serial: Migrate fsl_linflexuart to use has_sysrq tty/serial: Migrate fsl_lpuart to use has_sysrq tty/serial: Migrate imx to use has_sysrq
tty/serial: Migrate ip22zilog to use has_sysrq tty/serial: Migrate meson_uart to use has_sysrq tty/serial: Migrate milbeaut_usio to use has_sysrq tty/serial: Migrate mpc52xx_uart to use has_sysrq tty/serial: Don't zero port->sysrq
tty/serial: Migrate msm_serial to use has_sysrq tty/serial: Migrate mux to use has_sysrq
tty/serial: Migrate mxs-auart to use has_sysrq tty/serial: Migrate omap-serial to use has_sysrq tty/serial: Migrate pch_uart to use has_sysrq tty/serial: Don't check port->sysrq
tty/serial: Migrate pmac_zilog to use has_sysrq tty/serial: Migrate pnx8xxx_uart to use has_sysrq serial/f81534: Don't check port->sysrq
tty/serial: Migrate pxa to use has_sysrq
tty/serial: Migrate qcom_geni_serial to use has_sysrq tty/serial: Migrate sa1100 to use has_sysrq
tty/serial: Migrate samsung_tty to use has_sysrq tty/serial: Migrate sb1250-duart to use has_sysrq tty/serial: Migrate sccnxp to use has_sysrq
tty/serial: Migrate serial_txx9 to use has_sysrq tty/serial: Migrate sh-sci to use has_sysrq
tty/serial: Migrate sprd_serial to use has_sysrq tty/serial: Migrate st-asc to use has_sysrq
tty/serial: Migrate stm32-usart to use has_sysrq tty/serial: Migrate sunhv to use has_sysrq
tty/serial: Migrate sunsab to use has_sysrq
tty/serial: Migrate sunsu to use has_sysrq
tty/serial: Migrate sunzilog to use has_sysrq serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ
tty/serial: Migrate vr41xx_siu to use has_sysrq tty/serial: Migrate vt8500_serial to use has_sysrq tty/serial: Migrate xilinx_uartps to use has_sysrq tty/serial: Migrate zs to use has_sysrq
serial_core: Remove SUPPORT_SYSRQ ifdeffery
usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled
serial_core: Move sysrq functions from header file sysctl/sysrq: Remove __sysrq_enabled copy
serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE

 arch/powerpc/kernel/legacy_serial.c         |   4 +-
 drivers/tty/serial/8250/8250_aspeed_vuart.c |   5 +-
 drivers/tty/serial/8250/8250_fsl.c          |   4 -
 drivers/tty/serial/8250/8250_of.c           |   4 +-
 drivers/tty/serial/8250/8250_omap.c         |   5 +-
 drivers/tty/serial/8250/8250_port.c         |   5 +-
 drivers/tty/serial/amba-pl010.c             |   5 +-
 drivers/tty/serial/amba-pl011.c             |   6 +-
 drivers/tty/serial/apbuart.c                |   5 +-
 drivers/tty/serial/arc_uart.c               |   5 +-
 drivers/tty/serial/atmel_serial.c           |   9 +-
 drivers/tty/serial/bcm63xx_uart.c           |   5 +-
 drivers/tty/serial/clps711x.c               |   5 +-
 drivers/tty/serial/cpm_uart/cpm_uart_core.c |   9 +-
 drivers/tty/serial/dz.c                     |   5 +-
 drivers/tty/serial/efm32-uart.c             |   5 +-
 drivers/tty/serial/fsl_linflexuart.c        |   8 +-
 drivers/tty/serial/fsl_lpuart.c             |   9 +-
 drivers/tty/serial/imx.c                    |   7 +-
 drivers/tty/serial/ip22zilog.c              |   7 +-
 drivers/tty/serial/meson_uart.c             |   5 +-
 drivers/tty/serial/milbeaut_usio.c          |   5 +-
 drivers/tty/serial/mpc52xx_uart.c           |  11 +-
 drivers/tty/serial/msm_serial.c             |   5 +-
 drivers/tty/serial/mux.c                    |   5 +-
 drivers/tty/serial/mxs-auart.c              |   5 +-
 drivers/tty/serial/omap-serial.c            |   5 +-
 drivers/tty/serial/pch_uart.c               |  12 +-
 drivers/tty/serial/pmac_zilog.c             |   5 +-
 drivers/tty/serial/pnx8xxx_uart.c           |   7 +-
 drivers/tty/serial/pxa.c                    |   5 +-
 drivers/tty/serial/qcom_geni_serial.c       |   5 +-
 drivers/tty/serial/sa1100.c                 |   7 +-
 drivers/tty/serial/samsung_tty.c            |   5 +-
 drivers/tty/serial/sb1250-duart.c           |   5 +-
 drivers/tty/serial/sccnxp.c                 |   5 +-
 drivers/tty/serial/serial_core.c            | 123 ++++++++++++++++++++
 drivers/tty/serial/serial_txx9.c            |   5 +-
 drivers/tty/serial/sh-sci.c                 |  10 +-
 drivers/tty/serial/sprd_serial.c            |   5 +-
 drivers/tty/serial/st-asc.c                 |   5 +-
 drivers/tty/serial/stm32-usart.c            |   5 +-
 drivers/tty/serial/sunhv.c                  |   5 +-
 drivers/tty/serial/sunsab.c                 |   5 +-
 drivers/tty/serial/sunsu.c                  |   5 +-
 drivers/tty/serial/sunzilog.c               |   6 +-
 drivers/tty/serial/ucc_uart.c               |   2 -
 drivers/tty/serial/vr41xx_siu.c             |   5 +-
 drivers/tty/serial/vt8500_serial.c          |   5 +-
 drivers/tty/serial/xilinx_uartps.c          |   5 +-
 drivers/tty/serial/zs.c                     |   5 +-
 drivers/tty/sysrq.c                         |  16 +--
 drivers/usb/serial/f81534.c                 |   6 +-
 drivers/usb/serial/generic.c                |  10 +-
 include/linux/serial_core.h                 |  92 ++-------------
 include/linux/sysrq.h                       |   1 +
 kernel/sysctl.c                             |  41 ++++---
 lib/Kconfig.debug                           |   8 ++
 58 files changed, 238 insertions(+), 346 deletions(-)
Signature · 1 line
2.24.0
#1 lore raw

PATCH 1/58 sysrq: Remove sysrq_handler_registered

sysrq_toggle_support() can be called in parallel, in return calling input_(un)register_handler(), which fortunately is safe to call in parallel and regardless of registered/unregistered status of sysrq_handler.
Remove sysrq_handler_registered as it doesn't have any function there and may confuse reader about possible race.

---
 drivers/tty/sysrq.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/tty/sysrq.c +1 -8
index 573b2055173c..1d4f317a0e42 100644
@@ -967,8 +967,6 @@ static struct input_handler sysrq_handler = {
 	.id_table	= sysrq_ids,
 };
 
-static bool sysrq_handler_registered;
-
 static inline void sysrq_register_handler(void)
 {
 	int error;
@@ -978,16 +976,11 @@ static inline void sysrq_register_handler(void)
 	error = input_register_handler(&sysrq_handler);
 	if (error)
 		pr_err("Failed to register input handler, error %d", error);
-	else
-		sysrq_handler_registered = true;
 }
 
 static inline void sysrq_unregister_handler(void)
 {
-	if (sysrq_handler_registered) {
-		input_unregister_handler(&sysrq_handler);
-		sysrq_handler_registered = false;
-	}
+	input_unregister_handler(&sysrq_handler);
 }
 
 static int sysrq_reset_seq_param_set(const char *buffer,
Signature · 1 line
2.24.0
#2 lore raw

PATCH 2/58 serial: Move sysrq members above

In reply to Dmitry Safonov

At the current place members those follow are:
: upf_t flags;
: upstat_t status;
: int hw_stopped;
: unsigned int mctrl;
: unsigned int timeout;
: unsigned int type;
: const struct uart_ops *ops;

Together, they give (*ops) 8-byte align on 64-bit platforms. And sysrq_ch introduces 4-byte padding.

On the other side, above:
: struct device *dev;
: unsigned char hub6;
: unsigned char suspended;
: unsigned char unused[2];
: const char *name;

Adds another 4-byte padding.

Moving sysrq members just before hub6 allows to save 8 bytes per-uart_port on 64-bit platforms:
On my gcc, x86_64 sizeof(struct uart_port) goes from 528 to 520.

---
 include/linux/serial_core.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
include/linux/serial_core.h +6 -5
index 2b78cc734719..bbbe57bf5163 100644
@@ -161,11 +161,6 @@ struct uart_port {
 	struct uart_icount	icount;			/* statistics */
 
 	struct console		*cons;			/* struct console, if any */
-#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
-	unsigned long		sysrq;			/* sysrq timeout */
-	unsigned int		sysrq_ch;		/* char for sysrq */
-#endif
-
 	/* flags must be updated while holding port mutex */
 	upf_t			flags;
 
@@ -244,6 +239,12 @@ struct uart_port {
 	resource_size_t		mapbase;		/* for ioremap */
 	resource_size_t		mapsize;
 	struct device		*dev;			/* parent device */
+
+#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
+	unsigned long		sysrq;			/* sysrq timeout */
+	unsigned int		sysrq_ch;		/* char for sysrq */
+#endif
+
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
 	unsigned char		unused[2];
Signature · 1 line
2.24.0
#3 lore raw

Re: [PATCH 02/58] serial: Move sysrq members above

Quoted 47 lines · Dmitry Safonov

At the current place members those follow are:
: upf_t flags;
: upstat_t status;
: int hw_stopped;
: unsigned int mctrl;
: unsigned int timeout;
: unsigned int type;
: const struct uart_ops *ops;

Together, they give (*ops) 8-byte align on 64-bit platforms. And sysrq_ch introduces 4-byte padding.

On the other side, above:
: struct device *dev;
: unsigned char hub6;
: unsigned char suspended;
: unsigned char unused[2];
: const char *name;

Adds another 4-byte padding.

Moving sysrq members just before hub6 allows to save 8 bytes per-uart_port on 64-bit platforms:
On my gcc, x86_64 sizeof(struct uart_port) goes from 528 to 520.

---
 include/linux/serial_core.h | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
include/linux/serial_core.h +0 -5
index 2b78cc734719..bbbe57bf5163 100644
@@ -161,11 +161,6 @@ struct uart_port {
 	struct uart_icount	icount;			/* statistics */
 
 	struct console		*cons;			/* struct console, if any */
-#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
-	unsigned long		sysrq;			/* sysrq timeout */
-	unsigned int		sysrq_ch;		/* char for sysrq */
-#endif
-
 	/* flags must be updated while holding port mutex */
 	upf_t			flags;
 

include/linux/serial_core.h struct uart_port { · line 246

Quoted 8 lines
include/linux/serial_core.h +5 -0
@@ -244,6 +239,12 @@ struct uart_port {
 	resource_size_t		mapbase;		/* for ioremap */
 	resource_size_t		mapsize;
 	struct device		*dev;			/* parent device */
+
+#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
+	unsigned long		sysrq;			/* sysrq timeout */
+	unsigned int		sysrq_ch;		/* char for sysrq */
+#endif

Let's just always have these 2 fields in the structure, no need for a #ifdef at all, right? There is no real "savings" from removing them (8 bytes for a structure that is maybe created 2-4 times per machine?)

That way it would keep any of this mess of if the SUPPORT_SYSRQ is enabled or not to keep everything in sync.

thanks,

greg k-h

#4 lore raw

PATCH 3/58 serial_core: Un-ifdef sysrq SUPPORT_SYSRQ

In reply to Dmitry Safonov

The SUPPORT_SYSRQ is messy: every .c source should define it before including "serial_core.h" if sysrq is supported or struct uart_port will differ in sizes. Also this prevents moving to serial_core.c functions:
uart_handle_sysrq_char(), uart_prepare_sysrq_char(), uart_unlock_and_check_sysrq().

It doesn't save many bytes in the structure, and a better way to reduce it's size would be making rs485 and iso7816 pointers.

Introduce has_sysrq member to be used by serial line drivers further.

---
 include/linux/serial_core.h | 77 +++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 34 deletions(-)
include/linux/serial_core.h +43 -34
index bbbe57bf5163..5f761c399282 100644
@@ -240,14 +240,13 @@ struct uart_port {
 	resource_size_t		mapsize;
 	struct device		*dev;			/* parent device */
 
-#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
 	unsigned long		sysrq;			/* sysrq timeout */
 	unsigned int		sysrq_ch;		/* char for sysrq */
-#endif
+	unsigned char		has_sysrq;
 
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
-	unsigned char		unused[2];
+	unsigned char		unused;
 	const char		*name;			/* port name */
 	struct attribute_group	*attr_group;		/* port specific attributes */
 	const struct attribute_group **tty_groups;	/* all attributes (serial core use only) */
@@ -461,31 +460,46 @@ extern void uart_handle_cts_change(struct uart_port *uport,
 extern void uart_insert_char(struct uart_port *port, unsigned int status,
 		 unsigned int overrun, unsigned int ch, unsigned int flag);
 
-#if defined(SUPPORT_SYSRQ) && defined(CONFIG_MAGIC_SYSRQ_SERIAL)
 static inline int
 uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 {
-	if (port->sysrq) {
-		if (ch && time_before(jiffies, port->sysrq)) {
-			handle_sysrq(ch);
-			port->sysrq = 0;
-			return 1;
-		}
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
+		return 0;
+
+	if (!port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		handle_sysrq(ch);
 		port->sysrq = 0;
+		return 1;
 	}
+	port->sysrq = 0;
+
 	return 0;
 }
 static inline int
 uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
 {
-	if (port->sysrq) {
-		if (ch && time_before(jiffies, port->sysrq)) {
-			port->sysrq_ch = ch;
-			port->sysrq = 0;
-			return 1;
-		}
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
+		return 0;
+
+	if (!port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		port->sysrq_ch = ch;
 		port->sysrq = 0;
+		return 1;
 	}
+	port->sysrq = 0;
+
 	return 0;
 }
 static inline void
@@ -493,6 +507,11 @@ uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
 {
 	int sysrq_ch;
 
+	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ)) {
+		spin_unlock_irqrestore(&port->lock, irqflags);
+		return;
+	}
+
 	sysrq_ch = port->sysrq_ch;
 	port->sysrq_ch = 0;
 
@@ -501,17 +520,6 @@ uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
 	if (sysrq_ch)
 		handle_sysrq(sysrq_ch);
 }
-#else
-static inline int
-uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) { return 0; }
-static inline int
-uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) { return 0; }
-static inline void
-uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
-{
-	spin_unlock_irqrestore(&port->lock, irqflags);
-}
-#endif
 
 /*
  * We do the SysRQ and SAK checking like this...
@@ -523,15 +531,16 @@ static inline int uart_handle_break(struct uart_port *port)
 	if (port->handle_break)
 		port->handle_break(port);
 
-#ifdef SUPPORT_SYSRQ
-	if (port->cons && port->cons->index == port->line) {
-		if (!port->sysrq) {
-			port->sysrq = jiffies + HZ*5;
-			return 1;
+	if (port->has_sysrq || IS_ENABLED(SUPPORT_SYSRQ)) {
+		if (port->cons && port->cons->index == port->line) {
+			if (!port->sysrq) {
+				port->sysrq = jiffies + HZ*5;
+				return 1;
+			}
+			port->sysrq = 0;
 		}
-		port->sysrq = 0;
 	}
-#endif
+
 	if (port->flags & UPF_SAK)
 		do_SAK(state->port.tty);
 	return 0;
Signature · 1 line
2.24.0
#5 lore raw

Re: [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ

Quoted 6 lines · Dmitry Safonov

The SUPPORT_SYSRQ is messy: every .c source should define it before including "serial_core.h" if sysrq is supported or struct uart_port will differ in sizes. Also this prevents moving to serial_core.c functions:
uart_handle_sysrq_char(), uart_prepare_sysrq_char(), uart_unlock_and_check_sysrq().

Quoted 6 lines

It doesn't save many bytes in the structure, and a better way to reduce it's size would be making rs485 and iso7816 pointers.

Introduce has_sysrq member to be used by serial line drivers further.

Ah, you did what I asked here in patch 3. Nevermind on my comments on patch 2 :)

looks good, thanks!

greg k-h

#6 lore raw

Re: [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ

In reply to Dmitry Safonov
Quoted 8 lines · Dmitry Safonov

The SUPPORT_SYSRQ is messy: every .c source should define it before including "serial_core.h" if sysrq is supported or struct uart_port will differ in sizes. Also this prevents moving to serial_core.c functions:
uart_handle_sysrq_char(), uart_prepare_sysrq_char(), uart_unlock_and_check_sysrq().

It doesn't save many bytes in the structure, and a better way to reduce it's size would be making rs485 and iso7816 pointers.

Yes, the whole thing needs some work with the tool 'pahole' to fix it up.

thanks,

greg k-h

#7 lore raw

Re: [PATCH 03/58] serial_core: Un-ifdef sysrq SUPPORT_SYSRQ

In reply to Dmitry Safonov
Quoted 23 lines · Dmitry Safonov

The SUPPORT_SYSRQ is messy: every .c source should define it before including "serial_core.h" if sysrq is supported or struct uart_port will differ in sizes. Also this prevents moving to serial_core.c functions:
uart_handle_sysrq_char(), uart_prepare_sysrq_char(), uart_unlock_and_check_sysrq().

It doesn't save many bytes in the structure, and a better way to reduce it's size would be making rs485 and iso7816 pointers.

Introduce has_sysrq member to be used by serial line drivers further.

---
 include/linux/serial_core.h | 77 +++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 34 deletions(-)
include/linux/serial_core.h +0 -0
index bbbe57bf5163..5f761c399282 100644
@@ -240,14 +240,13 @@ struct uart_port {
 	resource_size_t		mapsize;
 	struct device		*dev;			/* parent device */

include/linux/serial_core.h struct uart_port { · line 250

Quoted 10 lines
include/linux/serial_core.h +1 -3
 
-#if defined(CONFIG_SERIAL_CORE_CONSOLE) || defined(SUPPORT_SYSRQ)
 	unsigned long		sysrq;			/* sysrq timeout */
 	unsigned int		sysrq_ch;		/* char for sysrq */
-#endif
+	unsigned char		has_sysrq;
 
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
-	unsigned char		unused[2];

Ugh, the samsung driver was using both of these fields to overload things for it's own use :(

It's not your fault, I'll go fix up that driver first before applying this one.

bah, what a horrid hack they did...

greg k-h

#8 lore raw

PATCH 4/58 tty/serial: Migrate aspeed_vuart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Andrew Jeffery <[email protected]>
Cc Joel Stanley <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-aspeed at lists.ozlabs.org
---
 drivers/tty/serial/8250/8250_aspeed_vuart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/8250/8250_aspeed_vuart.c +1 -4
index 6e67fd89445a..d657aa14c3e4 100644
@@ -5,10 +5,6 @@
  *    Copyright (C) 2016 Jeremy Kerr <[email protected]>, IBM Corp.
  *    Copyright (C) 2006 Arnd Bergmann <[email protected]>, IBM Corp.
  */
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/device.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
@@ -406,6 +402,7 @@ static int aspeed_vuart_probe(struct platform_device *pdev)
 	port.port.unthrottle = aspeed_vuart_unthrottle;
 	port.port.status = UPSTAT_SYNC_FIFO;
 	port.port.dev = &pdev->dev;
+	port.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
 	rc = sysfs_create_group(&vuart->dev->kobj, &aspeed_vuart_attr_group);
 	if (rc < 0)
Signature · 1 line
2.24.0
Acked-by on v1 4/58
#9 lore raw

Re: [PATCH 04/58] tty/serial: Migrate aspeed_vuart to use has_sysrq

Quoted 6 lines · Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

Quoted 8 lines

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

#10 lore raw

PATCH 5/58 tty/serial: Migrate 8250_fsl to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Benjamin Herrenschmidt <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Michael Ellerman <[email protected]>
---
 arch/powerpc/kernel/legacy_serial.c | 4 +++-
 drivers/tty/serial/8250/8250_fsl.c  | 4 ----
 drivers/tty/serial/8250/8250_of.c   | 4 +++-
 3 files changed, 6 insertions(+), 6 deletions(-)
arch/powerpc/kernel/legacy_serial.c +3 -1
index 7cea5978f21f..f061e06e9f51 100644
@@ -479,8 +479,10 @@ static void __init fixup_port_irq(int index,
 	port->irq = virq;
 
 #ifdef CONFIG_SERIAL_8250_FSL
-	if (of_device_is_compatible(np, "fsl,ns16550"))
+	if (of_device_is_compatible(np, "fsl,ns16550")) {
 		port->handle_irq = fsl8250_handle_irq;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
+	}
 #endif
 }
 
drivers/tty/serial/8250/8250_fsl.c +0 -4
index aa0e216d5ead..0d0c80905c58 100644
@@ -1,8 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_reg.h>
 #include <linux/serial_8250.h>
 
drivers/tty/serial/8250/8250_of.c +3 -1
index 92fbf46ce3bd..531ad67395e0 100644
@@ -222,8 +222,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
 
 	if (IS_ENABLED(CONFIG_SERIAL_8250_FSL) &&
 	    (of_device_is_compatible(np, "fsl,ns16550") ||
-	     of_device_is_compatible(np, "fsl,16550-FIFO64")))
+	     of_device_is_compatible(np, "fsl,16550-FIFO64"))) {
 		port->handle_irq = fsl8250_handle_irq;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
+	}
 
 	return 0;
 err_unprepare:
Signature · 1 line
2.24.0
#11 lore raw

PATCH 6/58 tty/serial: Migrate bcm63xx_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/bcm63xx_uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/bcm63xx_uart.c +1 -4
index b7adc6127b3d..5674da2b76f0 100644
@@ -10,10 +10,6 @@
  * my board.
  */
 
-#if defined(CONFIG_SERIAL_BCM63XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/init.h>
@@ -858,6 +854,7 @@ static int bcm_uart_probe(struct platform_device *pdev)
 	port->fifosize = 16;
 	port->uartclk = clk_get_rate(clk) / 2;
 	port->line = pdev->id;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_BCM63XX_CONSOLE);
 	clk_put(clk);
 
 	ret = uart_add_one_port(&bcm_uart_driver, port);
Signature · 1 line
2.24.0
#12 lore raw

PATCH 7/58 tty/serial: Migrate 8250_omap to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/8250/8250_omap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/8250/8250_omap.c +1 -4
index 836e736ae188..1ee7b89817dd 100644
@@ -8,10 +8,6 @@
  *
  */
 
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/io.h>
@@ -1192,6 +1188,7 @@ static int omap8250_probe(struct platform_device *pdev)
 	up.port.throttle = omap_8250_throttle;
 	up.port.unthrottle = omap_8250_unthrottle;
 	up.port.rs485_config = omap_8250_rs485_config;
+	up.port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
 	ret = of_alias_get_id(np, "serial");
 	if (ret < 0) {
Signature · 1 line
2.24.0
#13 lore raw

PATCH 8/58 tty/serial: Migrate 8250_port to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/8250/8250_port.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/8250/8250_port.c +1 -4
index 90655910b0c7..8243f280a2ec 100644
@@ -11,10 +11,6 @@
  *  membase is an 'ioremapped' cookie.
  */
 
-#if defined(CONFIG_SERIAL_8250_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/ioport.h>
@@ -3055,6 +3051,7 @@ void serial8250_init_port(struct uart_8250_port *up)
 
 	spin_lock_init(&port->lock);
 	port->ops = &serial8250_pops;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE);
 
 	up->cur_iotype = 0xFF;
 }
Signature · 1 line
2.24.0
#14 lore raw

PATCH 9/58 tty/serial: Migrate amba-pl01* to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/amba-pl010.c | 5 +----
 drivers/tty/serial/amba-pl011.c | 6 +-----
 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/tty/serial/amba-pl010.c +1 -4
index 2c37d11726ab..3284f34e9dfe 100644
@@ -15,10 +15,6 @@
  * and hooked into this driver.
  */
 
-#if defined(CONFIG_SERIAL_AMBA_PL010_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -728,6 +724,7 @@ static int pl010_probe(struct amba_device *dev, const struct amba_id *id)
 	uap->port.iotype = UPIO_MEM;
 	uap->port.irq = dev->irq[0];
 	uap->port.fifosize = 16;
+	uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_AMBA_PL010_CONSOLE);
 	uap->port.ops = &amba_pl010_pops;
 	uap->port.flags = UPF_BOOT_AUTOCONF;
 	uap->port.line = i;
drivers/tty/serial/amba-pl011.c +1 -5
index 4b28134d596a..952483ec8ea1 100644
@@ -16,11 +16,6 @@
  * and hooked into this driver.
  */
 
-
-#if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -2579,6 +2574,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
 	uap->port.mapbase = mmiobase->start;
 	uap->port.membase = base;
 	uap->port.fifosize = uap->fifosize;
+	uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_AMBA_PL011_CONSOLE);
 	uap->port.flags = UPF_BOOT_AUTOCONF;
 	uap->port.line = index;
 
Signature · 1 line
2.24.0
#15 lore raw

PATCH 10/58 tty/serial: Migrate apbuart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/apbuart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/apbuart.c +1 -4
index 60cd133ffbbc..e8d56e899ec7 100644
@@ -11,10 +11,6 @@
  *  Copyright (C) 2009 Kristoffer Glembo <[email protected]>, Aeroflex Gaisler AB
  */
 
-#if defined(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
@@ -626,6 +622,7 @@ static int __init grlib_apbuart_configure(void)
 		port->irq = 0;
 		port->iotype = UPIO_MEM;
 		port->ops = &grlib_apbuart_ops;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE);
 		port->flags = UPF_BOOT_AUTOCONF;
 		port->line = line;
 		port->uartclk = *freq_hz;
Signature · 1 line
2.24.0
#16 lore raw

PATCH 11/58 tty/serial: Migrate arc_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/arc_uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/arc_uart.c +1 -4
index d904a3a345e7..17c3fc398fc6 100644
@@ -21,10 +21,6 @@
  *  -check if sysreq works
  */
 
-#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -625,6 +621,7 @@ static int arc_serial_probe(struct platform_device *pdev)
 	port->flags = UPF_BOOT_AUTOCONF;
 	port->line = dev_id;
 	port->ops = &arc_serial_pops;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ARC_CONSOLE);
 
 	port->fifosize = ARC_UART_TX_FIFO_SIZE;
 
Signature · 1 line
2.24.0
#17 lore raw

PATCH 12/58 tty/serial: Migrate atmel_serial to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

While at it, remove forward-declaration of atmel_console - it wasn't needed even at the moment the driver was first time introduced:
commit 1e6c9c2878c9 ("[ARM] 3242/2: AT91RM9200 support for 2.6 (Serial)")

Cc Alexandre Belloni <[email protected]>
Cc Ludovic Desroches <[email protected]>
Cc Richard Genoud <[email protected]>
---
 drivers/tty/serial/atmel_serial.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/tty/serial/atmel_serial.c +1 -8
index a8dc8af83f39..4020fc8ceb49 100644
@@ -51,10 +51,6 @@
 #define ATMEL_RTS_HIGH_OFFSET	16
 #define ATMEL_RTS_LOW_OFFSET	20
 
-#if defined(CONFIG_SERIAL_ATMEL_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 #include "serial_mctrl_gpio.h"
@@ -196,10 +192,6 @@ struct atmel_uart_port {
 static struct atmel_uart_port atmel_ports[ATMEL_MAX_UART];
 static DECLARE_BITMAP(atmel_ports_in_use, ATMEL_MAX_UART);
 
-#ifdef SUPPORT_SYSRQ
-static struct console atmel_console;
-#endif
-
 #if defined(CONFIG_OF)
 static const struct of_device_id atmel_serial_dt_ids[] = {
 	{ .compatible = "atmel,at91rm9200-usart-serial" },
@@ -2877,6 +2869,7 @@ static int atmel_serial_probe(struct platform_device *pdev)
 	atmel_port = &atmel_ports[ret];
 	atmel_port->backup_imr = 0;
 	atmel_port->uart.line = ret;
+	atmel_port->uart.has_sysrq = IS_ENABLED(CONFIG_SERIAL_ATMEL_CONSOLE);
 	atmel_serial_probe_fifos(atmel_port, pdev);
 
 	atomic_set(&atmel_port->tasklet_shutdown, 0);
Signature · 7 lines
2.24.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#18 lore raw

PATCH 13/58 tty/serial: Migrate clps711x to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/clps711x.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/clps711x.c +1 -4
index 061590795680..95abc6faa3d5 100644
@@ -8,10 +8,6 @@
  *  Copyright (C) 2000 Deep Blue Solutions Ltd.
  */
 
-#if defined(CONFIG_SERIAL_CLPS711X_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/device.h>
 #include <linux/console.h>
@@ -479,6 +475,7 @@ static int uart_clps711x_probe(struct platform_device *pdev)
 	s->port.mapbase		= res->start;
 	s->port.type		= PORT_CLPS711X;
 	s->port.fifosize	= 16;
+	s->port.has_sysrq	= IS_ENABLED(CONFIG_SERIAL_CLPS711X_CONSOLE);
 	s->port.flags		= UPF_SKIP_TEST | UPF_FIXED_TYPE;
 	s->port.uartclk		= clk_get_rate(uart_clk);
 	s->port.ops		= &uart_clps711x_ops;
Signature · 1 line
2.24.0
#19 lore raw

PATCH 14/58 tty/serial: Migrate cpm_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/cpm_uart/cpm_uart_core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/tty/serial/cpm_uart/cpm_uart_core.c +2 -7
index de6d02f7abe2..19d5a4cf29a6 100644
@@ -40,10 +40,6 @@
 #include <asm/fs_pd.h>
 #include <asm/udbg.h>
 
-#if defined(CONFIG_SERIAL_CPM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/kernel.h>
 
@@ -347,9 +343,7 @@ static void cpm_uart_int_rx(struct uart_port *port)
 		/* ASSUMPTION: it contains nothing valid */
 		i = 0;
 	}
-#ifdef SUPPORT_SYSRQ
 	port->sysrq = 0;
-#endif
 	goto error_return;
 }
 
@@ -1204,7 +1198,8 @@ static int cpm_uart_init_port(struct device_node *np,
 	pinfo->port.uartclk = ppc_proc_freq;
 	pinfo->port.mapbase = (unsigned long)mem;
 	pinfo->port.type = PORT_CPM;
-	pinfo->port.ops = &cpm_uart_pops,
+	pinfo->port.ops = &cpm_uart_pops;
+	pinfo->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_CPM_CONSOLE);
 	pinfo->port.iotype = UPIO_MEM;
 	pinfo->port.fifosize = pinfo->tx_nrfifos * pinfo->tx_fifosize;
 	spin_lock_init(&pinfo->port.lock);
Signature · 1 line
2.24.0
#20 lore raw

PATCH 15/58 tty/serial: Migrate dz to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc "Maciej W. Rozycki" <[email protected]>
---
 drivers/tty/serial/dz.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/dz.c +1 -4
index 7b57e840e255..6192ed011bc3 100644
@@ -29,10 +29,6 @@
 
 #undef DEBUG_DZ
 
-#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/bitops.h>
 #include <linux/compiler.h>
 #include <linux/console.h>
@@ -787,6 +783,7 @@ static void __init dz_init_ports(void)
 		uport->ops	= &dz_ops;
 		uport->line	= line;
 		uport->mapbase	= base;
+		uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_DZ_CONSOLE);
 	}
 }
 
Signature · 1 line
2.24.0
#21 lore raw

PATCH 16/58 tty/serial: Migrate efm32-uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc "Uwe Kleine-König" <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
---
 drivers/tty/serial/efm32-uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/efm32-uart.c +1 -4
index d6b5e5463746..2ac87128d7fd 100644
@@ -1,8 +1,4 @@
 // SPDX-License-Identifier: GPL-2.0
-#if defined(CONFIG_SERIAL_EFM32_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/io.h>
@@ -748,6 +744,7 @@ static int efm32_uart_probe(struct platform_device *pdev)
 	efm_port->port.type = PORT_EFMUART;
 	efm_port->port.iotype = UPIO_MEM32;
 	efm_port->port.fifosize = 2;
+	efm_port->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_EFM32_UART_CONSOLE);
 	efm_port->port.ops = &efm32_uart_pops;
 	efm_port->port.flags = UPF_BOOT_AUTOCONF;
 
Signature · 1 line
2.24.0
#22 lore raw

PATCH 17/58 tty/serial: Migrate fsl_linflexuart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/fsl_linflexuart.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/tty/serial/fsl_linflexuart.c +1 -7
index 205c31a61684..3e28be402aef 100644
@@ -6,11 +6,6 @@
  * Copyright 2017-2019 NXP
  */
 
-#if defined(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE) && \
-	defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/console.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -279,10 +274,8 @@ static irqreturn_t linflex_rxint(int irq, void *dev_id)
 		if (brk) {
 			uart_handle_break(sport);
 		} else {
-#ifdef SUPPORT_SYSRQ
 			if (uart_handle_sysrq_char(sport, (unsigned char)rx))
 				continue;
-#endif
 			tty_insert_flip_char(port, rx, flg);
 		}
 	}
@@ -863,6 +856,7 @@ static int linflex_probe(struct platform_device *pdev)
 	sport->irq = platform_get_irq(pdev, 0);
 	sport->ops = &linflex_pops;
 	sport->flags = UPF_BOOT_AUTOCONF;
+	sport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_FSL_LINFLEXUART_CONSOLE);
 
 	linflex_ports[sport->line] = sport;
 
Signature · 1 line
2.24.0
#23 lore raw

PATCH 18/58 tty/serial: Migrate fsl_lpuart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/fsl_lpuart.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/tty/serial/fsl_lpuart.c +1 -8
index 4e128d19e0ad..76c69d255d92 100644
@@ -5,10 +5,6 @@
  *  Copyright 2012-2014 Freescale Semiconductor, Inc.
  */
 
-#if defined(CONFIG_SERIAL_FSL_LPUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/dma-mapping.h>
@@ -864,9 +860,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
 			if (sr & UARTSR1_OR)
 				flg = TTY_OVERRUN;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		tty_insert_flip_char(port, rx, flg);
@@ -946,9 +940,7 @@ static void lpuart32_rxint(struct lpuart_port *sport)
 			if (sr & UARTSTAT_OR)
 				flg = TTY_OVERRUN;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		tty_insert_flip_char(port, rx, flg);
@@ -2461,6 +2453,7 @@ static int lpuart_probe(struct platform_device *pdev)
 		sport->port.ops = &lpuart32_pops;
 	else
 		sport->port.ops = &lpuart_pops;
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_FSL_LPUART_CONSOLE);
 	sport->port.flags = UPF_BOOT_AUTOCONF;
 
 	if (lpuart_is_32(sport))
Signature · 1 line
2.24.0
#24 lore raw

PATCH 19/58 tty/serial: Migrate imx to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
---
 drivers/tty/serial/imx.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/tty/serial/imx.c +1 -6
index a9e20e6c63ad..83c6e2ac0e8d 100644
@@ -8,10 +8,6 @@
  * Copyright (C) 2004 Pengutronix
  */
 
-#if defined(CONFIG_SERIAL_IMX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -779,9 +775,7 @@ static irqreturn_t imx_uart_rxint(int irq, void *dev_id)
 			if (rx & URXD_OVRRUN)
 				flg = TTY_OVERRUN;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		if (sport->port.ignore_status_mask & URXD_DUMMY_READ)
@@ -2231,6 +2225,7 @@ static int imx_uart_probe(struct platform_device *pdev)
 	sport->port.iotype = UPIO_MEM;
 	sport->port.irq = rxirq;
 	sport->port.fifosize = 32;
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE);
 	sport->port.ops = &imx_uart_pops;
 	sport->port.rs485_config = imx_uart_rs485_config;
 	sport->port.flags = UPF_BOOT_AUTOCONF;
Signature · 1 line
2.24.0
#25 lore raw

PATCH 20/58 tty/serial: Migrate ip22zilog to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/ip22zilog.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/tty/serial/ip22zilog.c +3 -4
index 8c810733df3d..86fff69d7e7c 100644
@@ -38,10 +38,6 @@
 #include <asm/sgi/hpc3.h>
 #include <asm/sgi/ip22.h>
 
-#if defined(CONFIG_SERIAL_IP22_ZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 #include "ip22zilog.h"
@@ -1080,6 +1076,7 @@ static struct uart_driver ip22zilog_reg = {
 
 static void __init ip22zilog_prepare(void)
 {
+	unsigned char sysrq_on = IS_ENABLED(CONFIG_SERIAL_IP22_ZILOG_CONSOLE);
 	struct uart_ip22zilog_port *up;
 	struct zilog_layout *rp;
 	int channel, chip;
@@ -1115,6 +1112,7 @@ static void __init ip22zilog_prepare(void)
 		up[(chip * 2) + 0].port.irq = zilog_irq;
 		up[(chip * 2) + 0].port.uartclk = ZS_CLOCK;
 		up[(chip * 2) + 0].port.fifosize = 1;
+		up[(chip * 2) + 0].port.has_sysrq = sysrq_on;
 		up[(chip * 2) + 0].port.ops = &ip22zilog_pops;
 		up[(chip * 2) + 0].port.type = PORT_IP22ZILOG;
 		up[(chip * 2) + 0].port.flags = 0;
@@ -1126,6 +1124,7 @@ static void __init ip22zilog_prepare(void)
 		up[(chip * 2) + 1].port.irq = zilog_irq;
 		up[(chip * 2) + 1].port.uartclk = ZS_CLOCK;
 		up[(chip * 2) + 1].port.fifosize = 1;
+		up[(chip * 2) + 1].port.has_sysrq = sysrq_on;
 		up[(chip * 2) + 1].port.ops = &ip22zilog_pops;
 		up[(chip * 2) + 1].port.type = PORT_IP22ZILOG;
 		up[(chip * 2) + 1].port.line = (chip * 2) + 1;
Signature · 1 line
2.24.0
#26 lore raw

PATCH 21/58 tty/serial: Migrate meson_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/meson_uart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/meson_uart.c +1 -4
index fbc5bc022a39..12e15358554c 100644
@@ -5,10 +5,6 @@
  * Copyright (C) 2014 Carlo Caione <[email protected]>
  */
 
-#if defined(CONFIG_SERIAL_MESON_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -703,6 +699,7 @@ static int meson_uart_probe(struct platform_device *pdev)
 	port->mapsize = resource_size(res_mem);
 	port->irq = res_irq->start;
 	port->flags = UPF_BOOT_AUTOCONF | UPF_LOW_LATENCY;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MESON_CONSOLE);
 	port->dev = &pdev->dev;
 	port->line = pdev->id;
 	port->type = PORT_MESON;
Signature · 1 line
2.24.0
#27 lore raw

PATCH 22/58 tty/serial: Migrate milbeaut_usio to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/milbeaut_usio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/milbeaut_usio.c +1 -4
index 949ab7efc4fc..8f2cab7f66ad 100644
@@ -3,10 +3,6 @@
  * Copyright (C) 2018 Socionext Inc.
  */
 
-#if defined(CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/module.h>
@@ -537,6 +533,7 @@ static int mlb_usio_probe(struct platform_device *pdev)
 	port->irq = mlb_usio_irq[index][RX];
 	port->uartclk = clk_get_rate(clk);
 	port->fifosize = 128;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MILBEAUT_USIO_CONSOLE);
 	port->iotype = UPIO_MEM32;
 	port->flags = UPF_BOOT_AUTOCONF | UPF_SPD_VHI;
 	port->line = index;
Signature · 1 line
2.24.0
#28 lore raw

PATCH 23/58 tty/serial: Migrate mpc52xx_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/mpc52xx_uart.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/tty/serial/mpc52xx_uart.c +1 -6
index 3a75ee08d619..ba1fddb6801c 100644
@@ -44,10 +44,6 @@
 #include <asm/mpc52xx.h>
 #include <asm/mpc52xx_psc.h>
 
-#if defined(CONFIG_SERIAL_MPC52xx_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 
@@ -1382,12 +1378,10 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
 		ch = psc_ops->read_char(port);
 
 		/* Handle sysreq char */
-#ifdef SUPPORT_SYSRQ
 		if (uart_handle_sysrq_char(port, ch)) {
 			port->sysrq = 0;
 			continue;
 		}
-#endif
 
 		/* Store it */
 
@@ -1770,6 +1764,7 @@ static int mpc52xx_uart_of_probe(struct platform_device *op)
 	spin_lock_init(&port->lock);
 	port->uartclk = uartclk;
 	port->fifosize	= 512;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MPC52xx_CONSOLE);
 	port->iotype	= UPIO_MEM;
 	port->flags	= UPF_BOOT_AUTOCONF |
 			  (uart_console(port) ? 0 : UPF_IOREMAP);
Signature · 1 line
2.24.0
#29 lore raw

PATCH 24/58 tty/serial: Don't zero port->sysrq

In reply to Dmitry Safonov

uart_handle_sysrq_char() already does it.

---
 drivers/tty/serial/mpc52xx_uart.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/mpc52xx_uart.c +1 -3
index ba1fddb6801c..af1700445251 100644
@@ -1378,10 +1378,8 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port)
 		ch = psc_ops->read_char(port);
 
 		/* Handle sysreq char */
-		if (uart_handle_sysrq_char(port, ch)) {
-			port->sysrq = 0;
+		if (uart_handle_sysrq_char(port, ch))
 			continue;
-		}
 
 		/* Store it */
 
Signature · 1 line
2.24.0
#30 lore raw

PATCH 25/58 tty/serial: Migrate msm_serial to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/msm_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/msm_serial.c +1 -4
index 1cbae0768b1f..375d6d3f17b2 100644
@@ -7,10 +7,6 @@
  * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
  */
 
-#if defined(CONFIG_SERIAL_MSM_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-# define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/atomic.h>
 #include <linux/dma-mapping.h>
@@ -1801,6 +1797,7 @@ static int msm_serial_probe(struct platform_device *pdev)
 	if (unlikely(irq < 0))
 		return -ENXIO;
 	port->irq = irq;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MSM_CONSOLE);
 
 	platform_set_drvdata(pdev, port);
 
Signature · 1 line
2.24.0
#31 lore raw

PATCH 26/58 tty/serial: Migrate mux to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/mux.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/mux.c +1 -4
index 00ce31e8d19a..2a9953211a2a 100644
@@ -25,11 +25,7 @@
 #include <asm/irq.h>
 #include <asm/parisc-device.h>
 
-#if defined(CONFIG_SERIAL_MUX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #include <linux/sysrq.h>
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 
 #define MUX_OFFSET 0x800
@@ -483,6 +479,7 @@ static int __init mux_probe(struct parisc_device *dev)
 		port->ops	= &mux_pops;
 		port->flags	= UPF_BOOT_AUTOCONF;
 		port->line	= port_cnt;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MUX_CONSOLE);
 
 		/* The port->timeout needs to match what is present in
 		 * uart_wait_until_sent in serial_core.c.  Otherwise
Signature · 1 line
2.24.0
#32 lore raw

PATCH 27/58 tty/serial: Migrate mxs-auart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
---
 drivers/tty/serial/mxs-auart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/mxs-auart.c +1 -4
index e34525970682..b4f835e7de23 100644
@@ -12,10 +12,6 @@
  * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
  */
 
-#if defined(CONFIG_SERIAL_MXS_AUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -1693,6 +1689,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
 	s->port.fifosize = MXS_AUART_FIFO_SIZE;
 	s->port.uartclk = clk_get_rate(s->clk);
 	s->port.type = PORT_IMX;
+	s->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_MXS_AUART_CONSOLE);
 
 	mxs_init_regs(s);
 
Signature · 1 line
2.24.0
#33 lore raw

PATCH 28/58 tty/serial: Migrate omap-serial to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/omap-serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/omap-serial.c +1 -4
index 6420ae581a80..53b38a226f26 100644
@@ -16,10 +16,6 @@
  * this driver as required for the omap-platform.
  */
 
-#if defined(CONFIG_SERIAL_OMAP_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -1680,6 +1676,7 @@ static int serial_omap_probe(struct platform_device *pdev)
 	up->port.regshift = 2;
 	up->port.fifosize = 64;
 	up->port.ops = &serial_omap_pops;
+	up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_OMAP_CONSOLE);
 
 	if (pdev->dev.of_node)
 		ret = of_alias_get_id(pdev->dev.of_node, "serial");
Signature · 1 line
2.24.0
#34 lore raw

PATCH 29/58 tty/serial: Migrate pch_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/pch_uart.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/tty/serial/pch_uart.c +1 -5
index c16234bca78f..c625bf7b8a92 100644
@@ -2,9 +2,6 @@
 /*
  *Copyright (C) 2011 LAPIS Semiconductor Co., Ltd.
  */
-#if defined(CONFIG_SERIAL_PCH_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
 #include <linux/kernel.h>
 #include <linux/serial_reg.h>
 #include <linux/slab.h>
@@ -587,12 +584,10 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf,
 			if (uart_handle_break(port))
 				continue;
 		}
-#ifdef SUPPORT_SYSRQ
 		if (port->sysrq) {
 			if (uart_handle_sysrq_char(port, rbr))
 				continue;
 		}
-#endif
 
 		buf[i++] = rbr;
 	}
@@ -1796,6 +1791,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev,
 	priv->port.flags = UPF_BOOT_AUTOCONF;
 	priv->port.fifosize = fifosize;
 	priv->port.line = board->line_no;
+	priv->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PCH_UART_CONSOLE);
 	priv->trigger = PCH_UART_HAL_TRIGGER_M;
 
 	snprintf(priv->irq_name, IRQ_NAME_SIZE,
Signature · 1 line
2.24.0
#35 lore raw

PATCH 30/58 tty/serial: Don't check port->sysrq

In reply to Dmitry Safonov

uart_handle_sysrq_char() already handles it.

---
 drivers/tty/serial/pch_uart.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/pch_uart.c +2 -4
index c625bf7b8a92..0a96217dba67 100644
@@ -584,10 +584,8 @@ static int pch_uart_hal_read(struct eg20t_port *priv, unsigned char *buf,
 			if (uart_handle_break(port))
 				continue;
 		}
-		if (port->sysrq) {
-			if (uart_handle_sysrq_char(port, rbr))
-				continue;
-		}
+		if (uart_handle_sysrq_char(port, rbr))
+			continue;
 
 		buf[i++] = rbr;
 	}
Signature · 1 line
2.24.0
#36 lore raw

PATCH 31/58 tty/serial: Migrate pmac_zilog to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Benjamin Herrenschmidt <[email protected]>
Cc Michael Ellerman <[email protected]>
Cc Paul Mackerras <[email protected]>
---
 drivers/tty/serial/pmac_zilog.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/pmac_zilog.c +1 -4
index bcb5bf70534e..ba65a3bbd72a 100644
@@ -61,10 +61,6 @@
 #define of_machine_is_compatible(x) (0)
 #endif
 
-#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial.h>
 #include <linux/serial_core.h>
 
@@ -1721,6 +1717,7 @@ static int __init pmz_init_port(struct uart_pmac_port *uap)
 	uap->control_reg   = uap->port.membase;
 	uap->data_reg      = uap->control_reg + 4;
 	uap->port_type     = 0;
+	uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PMACZILOG_CONSOLE);
 
 	pmz_convert_to_zs(uap, CS8, 0, 9600);
 
Signature · 1 line
2.24.0
#37 lore raw

PATCH 32/58 tty/serial: Migrate pnx8xxx_uart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/pnx8xxx_uart.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/tty/serial/pnx8xxx_uart.c +1 -6
index 223a9499104e..972d94e8d32b 100644
@@ -10,10 +10,6 @@
  * Copyright (C) 2000 Deep Blue Solutions Ltd.
  */
 
-#if defined(CONFIG_SERIAL_PNX8XXX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -220,9 +216,7 @@ static void pnx8xxx_rx_chars(struct pnx8xxx_port *sport)
 			else if (status & FIFO_TO_SM(PNX8XXX_UART_FIFO_RXFE))
 				flg = TTY_FRAME;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		if (uart_handle_sysrq_char(&sport->port, ch))
@@ -800,6 +794,7 @@ static int pnx8xxx_serial_probe(struct platform_device *pdev)
 			if (pnx8xxx_ports[i].port.mapbase != res->start)
 				continue;
 
+			pnx8xxx_ports[i].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PNX8XXX_CONSOLE);
 			pnx8xxx_ports[i].port.dev = &pdev->dev;
 			uart_add_one_port(&pnx8xxx_reg, &pnx8xxx_ports[i].port);
 			platform_set_drvdata(pdev, &pnx8xxx_ports[i]);
Signature · 1 line
2.24.0
#38 lore raw

PATCH 33/58 serial/f81534: Don't check port->sysrq

In reply to Dmitry Safonov

usb_serial_handle_sysrq_char() already checks it.

---
 drivers/usb/serial/f81534.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/serial/f81534.c +2 -4
index 2b39bda035c7..67a8e343eba1 100644
@@ -1238,10 +1238,8 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
 			schedule_work(&port_priv->lsr_work);
 		}
 
-		if (port->port.console && port->sysrq) {
-			if (usb_serial_handle_sysrq_char(port, data[i]))
-				continue;
-		}
+		if (usb_serial_handle_sysrq_char(port, data[i]))
+			continue;
 
 		tty_insert_flip_char(&port->port, data[i], tty_flag);
 	}
Signature · 1 line
2.24.0
maintainer
#39 lore raw

Re: [PATCH 33/58] serial/f81534: Don't check port->sysrq

Quoted 12 lines · Dmitry Safonov

usb_serial_handle_sysrq_char() already checks it.

---
 drivers/usb/serial/f81534.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/serial/f81534.c +0 -0
index 2b39bda035c7..67a8e343eba1 100644

drivers/usb/serial/f81534.c static void f81534_process_per_serial_block(struct usb_serial_port *port, · line 1242

Quoted 9 lines
drivers/usb/serial/f81534.c +2 -4
@@ -1238,10 +1238,8 @@ static void f81534_process_per_serial_block(struct usb_serial_port *port,
 			schedule_work(&port_priv->lsr_work);
 		}
 
-		if (port->port.console && port->sysrq) {
-			if (usb_serial_handle_sysrq_char(port, data[i]))
-				continue;
-		}
+		if (usb_serial_handle_sysrq_char(port, data[i]))
+			continue;

This is unrelated to the rest of the series.

Please break all usb-serial patches out of this series and submit them to me and the usb list for review.

Johan

#40 lore raw

Re: [PATCH 33/58] serial/f81534: Don't check port->sysrq

Hi Johan,

Quoted 9 lines · Johan Hovold

drivers/usb/serial/f81534.c static void f81534_process_per_serial_block(struct usb_serial_port *port, · line 1242

Quoted 6 lines · Dmitry Safonov
drivers/usb/serial/f81534.c +2 -4
-		if (port->port.console && port->sysrq) {
-			if (usb_serial_handle_sysrq_char(port, data[i]))
-				continue;
-		}
+		if (usb_serial_handle_sysrq_char(port, data[i]))
+			continue;

This is unrelated to the rest of the series.

Right, will drop it from v2.

Quoted 3 lines

Please break all usb-serial patches out of this series and submit them to me and the usb list for review.

Thanks,
Dmitry

#41 lore raw

PATCH 34/58 tty/serial: Migrate pxa to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/pxa.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/pxa.c +1 -4
index 4932b674f7ef..41319ef96fa6 100644
@@ -19,10 +19,6 @@
  */
 
 
-#if defined(CONFIG_SERIAL_PXA_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/console.h>
@@ -879,6 +875,7 @@ static int serial_pxa_probe(struct platform_device *dev)
 	sport->port.dev = &dev->dev;
 	sport->port.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
 	sport->port.uartclk = clk_get_rate(sport->clk);
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PXA_CONSOLE);
 
 	ret = serial_pxa_probe_dt(dev, sport);
 	if (ret > 0)
Signature · 1 line
2.24.0
#42 lore raw

PATCH 35/58 tty/serial: Migrate qcom_geni_serial to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/qcom_geni_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/qcom_geni_serial.c +1 -4
index ff63728a95f4..c41c766d6c7c 100644
@@ -1,10 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (c) 2017-2018, The Linux foundation. All rights reserved.
 
-#if defined(CONFIG_SERIAL_QCOM_GENI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-# define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/io.h>
@@ -1308,6 +1304,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 	uport->irq = irq;
+	uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE);
 
 	irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
 	ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
Signature · 1 line
2.24.0
#43 lore raw

PATCH 36/58 tty/serial: Migrate sa1100 to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sa1100.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/tty/serial/sa1100.c +1 -6
index 8e618129e65c..75c2a22895f9 100644
@@ -7,10 +7,6 @@
  *  Copyright (C) 2000 Deep Blue Solutions Ltd.
  */
 
-#if defined(CONFIG_SERIAL_SA1100_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -214,9 +210,7 @@ sa1100_rx_chars(struct sa1100_port *sport)
 			else if (status & UTSR1_TO_SM(UTSR1_FRE))
 				flg = TTY_FRAME;
 
-#ifdef SUPPORT_SYSRQ
 			sport->port.sysrq = 0;
-#endif
 		}
 
 		if (uart_handle_sysrq_char(&sport->port, ch))
@@ -860,6 +854,7 @@ static int sa1100_serial_resume(struct platform_device *dev)
 static int sa1100_serial_add_one_port(struct sa1100_port *sport, struct platform_device *dev)
 {
 	sport->port.dev = &dev->dev;
+	sport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SA1100_CONSOLE);
 
 	// mctrl_gpio_init() requires that the GPIO driver supports interrupts,
 	// but we need to support GPIO drivers for hardware that has no such
Signature · 1 line
2.24.0
#44 lore raw

PATCH 37/58 tty/serial: Migrate samsung_tty to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/samsung_tty.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/samsung_tty.c +1 -4
index 83fd51607741..9770fe29ae86 100644
@@ -21,10 +21,6 @@
  * BJD, 04-Nov-2004
 */
 
-#if defined(CONFIG_SERIAL_SAMSUNG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/dmaengine.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
@@ -1909,6 +1905,7 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 		ourport->port.fifosize = ourport->drv_data->fifosize[index];
 	else if (ourport->info->fifosize)
 		ourport->port.fifosize = ourport->info->fifosize;
+	ourport->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SAMSUNG_CONSOLE);
 
 	/*
 	 * DMA transfers must be aligned at least to cache line size,
Signature · 1 line
2.24.0
#45 lore raw

PATCH 38/58 tty/serial: Migrate sb1250-duart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sb1250-duart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sb1250-duart.c +1 -4
index 329aced26bd8..cb8185bffe42 100644
@@ -15,10 +15,6 @@
  *	"BCM1250/BCM1125/BCM1125H User Manual", Broadcom Corporation
  */
 
-#if defined(CONFIG_SERIAL_SB1250_DUART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/compiler.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -813,6 +809,7 @@ static void __init sbd_probe_duarts(void)
 			uport->ops	= &sbd_ops;
 			uport->line	= line;
 			uport->mapbase	= SBD_CHANREGS(line);
+			uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SB1250_DUART_CONSOLE);
 		}
 	}
 }
Signature · 1 line
2.24.0
#46 lore raw

PATCH 39/58 tty/serial: Migrate sccnxp to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sccnxp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sccnxp.c +1 -4
index d2b77aae42ae..10cc16a71f26 100644
@@ -7,10 +7,6 @@
  *  Based on sc26xx.c, by Thomas Bogendörfer ([email protected])
  */
 
-#if defined(CONFIG_SERIAL_SCCNXP_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
@@ -1000,6 +996,7 @@ static int sccnxp_probe(struct platform_device *pdev)
 		s->port[i].regshift	= s->pdata.reg_shift;
 		s->port[i].uartclk	= uartclk;
 		s->port[i].ops		= &sccnxp_ops;
+		s->port[i].has_sysrq = IS_ENABLED(CONFIG_SERIAL_SCCNXP_CONSOLE);
 		uart_add_one_port(&s->uart, &s->port[i]);
 		/* Set direction to input */
 		if (s->chip->flags & SCCNXP_HAVE_IO)
Signature · 1 line
2.24.0
#47 lore raw

PATCH 40/58 tty/serial: Migrate serial_txx9 to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/serial_txx9.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/serial_txx9.c +1 -4
index d22ccb32aa9b..b4d89e31730e 100644
@@ -12,10 +12,6 @@
  *  Serial driver for TX3927/TX4927/TX4925/TX4938 internal SIO controller
  */
 
-#if defined(CONFIG_SERIAL_TXX9_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
@@ -1095,6 +1091,7 @@ static int serial_txx9_probe(struct platform_device *dev)
 		port.flags	= p->flags;
 		port.mapbase	= p->mapbase;
 		port.dev	= &dev->dev;
+		port.has_sysrq	= IS_ENABLED(CONFIG_SERIAL_TXX9_CONSOLE);
 		ret = serial_txx9_register_port(&port);
 		if (ret < 0) {
 			dev_err(&dev->dev, "unable to register port at index %d "
Signature · 1 line
2.24.0
#48 lore raw

PATCH 41/58 tty/serial: Migrate sh-sci to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sh-sci.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/tty/serial/sh-sci.c +2 -8
index 58bf9d496ba5..9b4ff872e297 100644
@@ -15,10 +15,6 @@
  *   Modified to support SH7300 SCIF. Takashi Kusuda (Jun 2003).
  *   Removed SH7300 support (Jul 2007).
  */
-#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #undef DEBUG
 
 #include <linux/clk.h>
@@ -2887,6 +2883,7 @@ static int sci_init_single(struct platform_device *dev,
 	port->ops	= &sci_uart_ops;
 	port->iotype	= UPIO_MEM;
 	port->line	= index;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SH_SCI_CONSOLE);
 
 	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (res == NULL)
@@ -3015,12 +3012,9 @@ static void serial_console_write(struct console *co, const char *s,
 	unsigned long flags;
 	int locked = 1;
 
-#if defined(SUPPORT_SYSRQ)
 	if (port->sysrq)
 		locked = 0;
-	else
-#endif
-	if (oops_in_progress)
+	else if (oops_in_progress)
 		locked = spin_trylock_irqsave(&port->lock, flags);
 	else
 		spin_lock_irqsave(&port->lock, flags);
Signature · 1 line
2.24.0
#49 lore raw

PATCH 42/58 tty/serial: Migrate sprd_serial to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Baolin Wang <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Orson Zhai <[email protected]>
---
 drivers/tty/serial/sprd_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sprd_serial.c +1 -4
index 31df23502562..0c3b7420b01e 100644
@@ -3,10 +3,6 @@
  * Copyright (C) 2012-2015 Spreadtrum Communications Inc.
  */
 
-#if defined(CONFIG_SERIAL_SPRD_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -1227,6 +1223,7 @@ static int sprd_probe(struct platform_device *pdev)
 	up->fifosize = SPRD_FIFO_SIZE;
 	up->ops = &serial_sprd_ops;
 	up->flags = UPF_BOOT_AUTOCONF;
+	up->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SPRD_CONSOLE);
 
 	ret = sprd_clk_init(up);
 	if (ret)
Signature · 1 line
2.24.0
reviewer Acked-by on v1 42/58
#50 lore raw

Re: [PATCH 42/58] tty/serial: Migrate sprd_serial to use has_sysrq

Quoted 7 lines · Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

Quoted 7 lines

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc Baolin Wang <[email protected]>
Cc Chunyan Zhang <[email protected]>
Cc Orson Zhai <[email protected]>
Quoted 30 lines
---
 drivers/tty/serial/sprd_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sprd_serial.c +1 -5
index 31df23502562..0c3b7420b01e 100644
@@ -3,10 +3,6 @@
  * Copyright (C) 2012-2015 Spreadtrum Communications Inc.
  */
 
-#if defined(CONFIG_SERIAL_SPRD_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -1227,6 +1223,7 @@ static int sprd_probe(struct platform_device *pdev)
        up->fifosize = SPRD_FIFO_SIZE;
        up->ops = &serial_sprd_ops;
        up->flags = UPF_BOOT_AUTOCONF;
+       up->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SPRD_CONSOLE);
 
        ret = sprd_clk_init(up);
        if (ret)
--

2.24.0

#51 lore raw

PATCH 43/58 tty/serial: Migrate st-asc to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/st-asc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/st-asc.c +1 -4
index 7971997cdead..fb6bbb5e2234 100644
@@ -5,10 +5,6 @@
  * Copyright (C) 2003-2013 STMicroelectronics (R&D) Limited
  */
 
-#if defined(CONFIG_SERIAL_ST_ASC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/module.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -730,6 +726,7 @@ static int asc_init_port(struct asc_port *ascport,
 	port->fifosize	= ASC_FIFO_SIZE;
 	port->dev	= &pdev->dev;
 	port->irq	= platform_get_irq(pdev, 0);
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	port->membase = devm_ioremap_resource(&pdev->dev, res);
Signature · 7 lines
2.24.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#52 lore raw

PATCH 44/58 tty/serial: Migrate stm32-usart to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/stm32-usart.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/stm32-usart.c +1 -4
index 2f72514d63ed..5e93e8d40f59 100644
@@ -8,10 +8,6 @@
  * Inspired by st-asc.c from STMicroelectronics (c)
  */
 
-#if defined(CONFIG_SERIAL_STM32_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/clk.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -926,6 +922,7 @@ static int stm32_init_port(struct stm32_port *stm32port,
 	port->ops	= &stm32_uart_ops;
 	port->dev	= &pdev->dev;
 	port->fifosize	= stm32port->info->cfg.fifosize;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_STM32_CONSOLE);
 
 	ret = platform_get_irq(pdev, 0);
 	if (ret <= 0)
Signature · 1 line
2.24.0
#53 lore raw

PATCH 45/58 tty/serial: Migrate sunhv to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sunhv.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sunhv.c +1 -4
index f8503f8fc44e..eafada8fb6fa 100644
@@ -25,10 +25,6 @@
 #include <asm/irq.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -552,6 +548,7 @@ static int hv_probe(struct platform_device *op)
 
 	sunhv_port = port;
 
+	port->has_sysrq = 1;
 	port->line = 0;
 	port->ops = &sunhv_pops;
 	port->type = PORT_SUNHV;
Signature · 1 line
2.24.0
#54 lore raw

PATCH 46/58 tty/serial: Migrate sunsab to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sunsab.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sunsab.c +1 -4
index 72131b5e132e..1eb703c980e0 100644
@@ -40,10 +40,6 @@
 #include <asm/prom.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_SERIAL_SUNSAB_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -985,6 +981,7 @@ static int sunsab_init_one(struct uart_sunsab_port *up,
 
 	up->port.fifosize = SAB82532_XMIT_FIFO_SIZE;
 	up->port.iotype = UPIO_MEM;
+	up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNSAB_CONSOLE);
 
 	writeb(SAB82532_IPC_IC_ACT_LOW, &up->regs->w.ipc);
 
Signature · 1 line
2.24.0
#55 lore raw

PATCH 47/58 tty/serial: Migrate sunsu to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sunsu.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/sunsu.c +1 -4
index 4db6aaa330b2..8ce9a7a256e5 100644
@@ -44,10 +44,6 @@
 #include <asm/prom.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_SERIAL_SUNSU_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -1475,6 +1471,7 @@ static int su_probe(struct platform_device *op)
 
 	up->port.type = PORT_UNKNOWN;
 	up->port.uartclk = (SU_BASE_BAUD * 16);
+	up->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNSU_CONSOLE);
 
 	err = 0;
 	if (up->su_type = SU_PORT_KBD || up->su_type = SU_PORT_MS) {
Signature · 1 line
2.24.0
#56 lore raw

PATCH 48/58 tty/serial: Migrate sunzilog to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/sunzilog.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/sunzilog.c +2 -4
index bc7af8b08a72..103ab8c556e7 100644
@@ -40,10 +40,6 @@
 #include <asm/prom.h>
 #include <asm/setup.h>
 
-#if defined(CONFIG_SERIAL_SUNZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/serial_core.h>
 #include <linux/sunserialcore.h>
 
@@ -1444,6 +1440,7 @@ static int zs_probe(struct platform_device *op)
 	up[0].port.line = (inst * 2) + 0;
 	up[0].port.dev = &op->dev;
 	up[0].flags |= SUNZILOG_FLAG_IS_CHANNEL_A;
+	up[0].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNZILOG_CONSOLE);
 	if (keyboard_mouse)
 		up[0].flags |= SUNZILOG_FLAG_CONS_KEYB;
 	sunzilog_init_hw(&up[0]);
@@ -1461,6 +1458,7 @@ static int zs_probe(struct platform_device *op)
 	up[1].port.line = (inst * 2) + 1;
 	up[1].port.dev = &op->dev;
 	up[1].flags |= 0;
+	up[1].port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_SUNZILOG_CONSOLE);
 	if (keyboard_mouse)
 		up[1].flags |= SUNZILOG_FLAG_CONS_MOUSE;
 	sunzilog_init_hw(&up[1]);
Signature · 1 line
2.24.0
#57 lore raw

PATCH 49/58 serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ

In reply to Dmitry Safonov

ucc_uart doesn't seem to support console over itself, so maybe it can be deleted with uart_handle_sysrq_char() from the file.

---
 drivers/tty/serial/ucc_uart.c | 2 --
 1 file changed, 2 deletions(-)
drivers/tty/serial/ucc_uart.c +0 -2
index a0555ae2b1ef..ff7784047156 100644
@@ -551,9 +551,7 @@ static void qe_uart_int_rx(struct uart_qe_port *qe_port)
 	/* Overrun does not affect the current character ! */
 	if (status & BD_SC_OV)
 		tty_insert_flip_char(tport, 0, TTY_OVERRUN);
-#ifdef SUPPORT_SYSRQ
 	port->sysrq = 0;
-#endif
 	goto error_return;
 }
 
Signature · 1 line
2.24.0
#58 lore raw

PATCH 50/58 tty/serial: Migrate vr41xx_siu to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/vr41xx_siu.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/vr41xx_siu.c +1 -4
index 6d106e33f842..eeb4b6568776 100644
@@ -7,10 +7,6 @@
  *  Based on drivers/serial/8250.c, by Russell King.
  */
 
-#if defined(CONFIG_SERIAL_VR41XX_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/console.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -869,6 +865,7 @@ static int siu_probe(struct platform_device *dev)
 		port = &siu_uart_ports[i];
 		port->ops = &siu_uart_ops;
 		port->dev = &dev->dev;
+		port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_VR41XX_CONSOLE);
 
 		retval = uart_add_one_port(&siu_uart_driver, port);
 		if (retval < 0) {
Signature · 1 line
2.24.0
#59 lore raw

PATCH 51/58 tty/serial: Migrate vt8500_serial to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/vt8500_serial.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/vt8500_serial.c +1 -4
index 3d58e9b34553..764e992438b2 100644
@@ -7,10 +7,6 @@
  * Author: Robert Love <[email protected]>
  */
 
-#if defined(CONFIG_SERIAL_VT8500_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-# define SUPPORT_SYSRQ
-#endif
-
 #include <linux/hrtimer.h>
 #include <linux/delay.h>
 #include <linux/io.h>
@@ -703,6 +699,7 @@ static int vt8500_serial_probe(struct platform_device *pdev)
 	vt8500_port->uart.line = port;
 	vt8500_port->uart.dev = &pdev->dev;
 	vt8500_port->uart.flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF;
+	vt8500_port->uart.has_sysrq = IS_ENABLED(CONFIG_SERIAL_VT8500_CONSOLE);
 
 	/* Serial core uses the magic "16" everywhere - adjust for it */
 	vt8500_port->uart.uartclk = 16 * clk_get_rate(vt8500_port->clk) /
Signature · 1 line
2.24.0
#60 lore raw

PATCH 52/58 tty/serial: Migrate xilinx_uartps to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

---
 drivers/tty/serial/xilinx_uartps.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/xilinx_uartps.c +1 -4
index 4e55bc327a54..2b5606469bed 100644
@@ -9,10 +9,6 @@
  * in the code.
  */
 
-#if defined(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/platform_device.h>
 #include <linux/serial.h>
 #include <linux/console.h>
@@ -1634,6 +1630,7 @@ static int cdns_uart_probe(struct platform_device *pdev)
 	port->flags	= UPF_BOOT_AUTOCONF;
 	port->ops	= &cdns_uart_ops;
 	port->fifosize	= CDNS_UART_FIFO_SIZE;
+	port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_XILINX_PS_UART_CONSOLE);
 
 	/*
 	 * Register the port.
Signature · 1 line
2.24.0
#61 lore raw

PATCH 53/58 tty/serial: Migrate zs to use has_sysrq

In reply to Dmitry Safonov

The SUPPORT_SYSRQ ifdeffery is not nice as:
- May create misunderstanding about sizeof(struct uart_port) between different objects
- Prevents moving functions from serial_core.h
- Reduces readability (well, it's ifdeffery - it's hard to follow)

In order to remove SUPPORT_SYSRQ, has_sysrq variable has been added. Initialise it in driver's probe and remove ifdeffery.

Cc "Maciej W. Rozycki" <[email protected]>
---
 drivers/tty/serial/zs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/zs.c +1 -4
index b03d3e458ea2..1467952da3f6 100644
@@ -44,10 +44,6 @@
  * complicated and prevents the use of some automatic modes of operation.
  */
 
-#if defined(CONFIG_SERIAL_ZS_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
 #include <linux/bug.h>
 #include <linux/console.h>
 #include <linux/delay.h>
@@ -1106,6 +1102,7 @@ static int __init zs_probe_sccs(void)
 			zport->scc	= &zs_sccs[chip];
 			zport->clk_mode	= 16;
 
+			uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ZS_CONSOLE);
 			uport->irq	= zs_parms.irq[chip];
 			uport->uartclk	= ZS_CLOCK;
 			uport->fifosize	= 1;
Signature · 1 line
2.24.0
#62 lore raw

PATCH 54/58 serial_core: Remove SUPPORT_SYSRQ ifdeffery

In reply to Dmitry Safonov

No one defines it anymore.

---
 include/linux/serial_core.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
include/linux/serial_core.h +4 -10
index 5f761c399282..9cf1682dc580 100644
@@ -466,10 +466,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
 		return 0;
 
-	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
-		return 0;
-
-	if (!port->sysrq)
+	if (!port->has_sysrq || !port->sysrq)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
@@ -487,10 +484,7 @@ uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
 	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
 		return 0;
 
-	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ))
-		return 0;
-
-	if (!port->sysrq)
+	if (!port->has_sysrq || !port->sysrq)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
@@ -507,7 +501,7 @@ uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
 {
 	int sysrq_ch;
 
-	if (!port->has_sysrq && !IS_ENABLED(SUPPORT_SYSRQ)) {
+	if (!port->has_sysrq) {
 		spin_unlock_irqrestore(&port->lock, irqflags);
 		return;
 	}
@@ -531,7 +525,7 @@ static inline int uart_handle_break(struct uart_port *port)
 	if (port->handle_break)
 		port->handle_break(port);
 
-	if (port->has_sysrq || IS_ENABLED(SUPPORT_SYSRQ)) {
+	if (port->has_sysrq) {
 		if (port->cons && port->cons->index == port->line) {
 			if (!port->sysrq) {
 				port->sysrq = jiffies + HZ*5;
Signature · 1 line
2.24.0
#63 lore raw

Re: [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery

Quoted 6 lines · Dmitry Safonov

No one defines it anymore.

---
 include/linux/serial_core.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

I've applied this series up to here, skipping the usb-serial driver patch that Johan called out.

Can you rebase your series and resend the remaining based on my tty-next tree, after these patches move there (give them 24 hours to get through 0-day testing.)

thanks,

greg k-h

#64 lore raw

Re: [PATCH 54/58] serial_core: Remove SUPPORT_SYSRQ ifdeffery

Quoted 8 lines · Greg Kroah-Hartman
Quoted 6 lines · Dmitry Safonov

No one defines it anymore.

---
 include/linux/serial_core.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
Quoted 6 lines

I've applied this series up to here, skipping the usb-serial driver patch that Johan called out.

Can you rebase your series and resend the remaining based on my tty-next tree, after these patches move there (give them 24 hours to get through 0-day testing.)

Thanks much, Greg, will do!

Thanks,
Dmitry

#65 lore raw

PATCH 55/58 usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled

In reply to Dmitry Safonov

While at it, remove ifdeffery around usb_serial_handle_sysrq_char() as it doesn't save much from .text anyway.

---
 drivers/usb/serial/generic.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/usb/serial/generic.c +3 -7
index 1be8bea372a2..37361031402e 100644
@@ -571,7 +571,6 @@ int usb_serial_generic_get_icount(struct tty_struct *tty,
 }
 EXPORT_SYMBOL_GPL(usb_serial_generic_get_icount);
 
-#ifdef CONFIG_MAGIC_SYSRQ
 int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
 {
 	if (port->sysrq && port->port.console) {
@@ -584,16 +583,13 @@ int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
 	}
 	return 0;
 }
-#else
-int usb_serial_handle_sysrq_char(struct usb_serial_port *port, unsigned int ch)
-{
-	return 0;
-}
-#endif
 EXPORT_SYMBOL_GPL(usb_serial_handle_sysrq_char);
 
 int usb_serial_handle_break(struct usb_serial_port *port)
 {
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ))
+		return 0;
+
 	if (!port->sysrq) {
 		port->sysrq = jiffies + HZ*5;
 		return 1;
Signature · 1 line
2.24.0
#66 lore raw

PATCH 56/58 serial_core: Move sysrq functions from header file

In reply to Dmitry Safonov

It's not worth to have them in every serial driver and I'm about to add another one.

---
 drivers/tty/serial/serial_core.c | 83 +++++++++++++++++++++++++++++++
 include/linux/serial_core.h      | 84 ++------------------------------
 2 files changed, 88 insertions(+), 79 deletions(-)
drivers/tty/serial/serial_core.c +83 -0
index b0a6eb106edb..ef43c168e848 100644
@@ -3080,6 +3080,89 @@ void uart_insert_char(struct uart_port *port, unsigned int status,
 }
 EXPORT_SYMBOL_GPL(uart_insert_char);
 
+int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
+{
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq || !port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		handle_sysrq(ch);
+		port->sysrq = 0;
+		return 1;
+	}
+	port->sysrq = 0;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(uart_handle_sysrq_char);
+
+int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
+{
+	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
+		return 0;
+
+	if (!port->has_sysrq || !port->sysrq)
+		return 0;
+
+	if (ch && time_before(jiffies, port->sysrq)) {
+		port->sysrq_ch = ch;
+		port->sysrq = 0;
+		return 1;
+	}
+	port->sysrq = 0;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(uart_prepare_sysrq_char);
+
+void uart_unlock_and_check_sysrq(struct uart_port *port, unsigned long irqflags)
+{
+	int sysrq_ch;
+
+	if (!port->has_sysrq) {
+		spin_unlock_irqrestore(&port->lock, irqflags);
+		return;
+	}
+
+	sysrq_ch = port->sysrq_ch;
+	port->sysrq_ch = 0;
+
+	spin_unlock_irqrestore(&port->lock, irqflags);
+
+	if (sysrq_ch)
+		handle_sysrq(sysrq_ch);
+}
+EXPORT_SYMBOL_GPL(uart_unlock_and_check_sysrq);
+
+/*
+ * We do the SysRQ and SAK checking like this...
+ */
+int uart_handle_break(struct uart_port *port)
+{
+	struct uart_state *state = port->state;
+
+	if (port->handle_break)
+		port->handle_break(port);
+
+	if (port->has_sysrq) {
+		if (port->cons && port->cons->index == port->line) {
+			if (!port->sysrq) {
+				port->sysrq = jiffies + HZ*5;
+				return 1;
+			}
+			port->sysrq = 0;
+		}
+	}
+
+	if (port->flags & UPF_SAK)
+		do_SAK(state->port.tty);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(uart_handle_break);
+
 EXPORT_SYMBOL(uart_write_wakeup);
 EXPORT_SYMBOL(uart_register_driver);
 EXPORT_SYMBOL(uart_unregister_driver);
include/linux/serial_core.h +5 -79

90 lines not on this page · raw message

Signature · 1 line
2.24.0
#67 lore raw

PATCH 57/58 sysctl/sysrq: Remove __sysrq_enabled copy

In reply to Dmitry Safonov

Many embedded boards have a disconnected TTL level serial which can generate some garbage that can lead to spurious false sysrq detects.

Currently, sysrq can be either completely disabled for serial console or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since
commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port")

At Arista, we have such boards that can generate BREAK and random garbage. While disabling sysrq for serial console would solve the problem with spurious false sysrq triggers, it's also desirable to have a way to enable sysrq back.

Having the way to enable sysrq was beneficial to debug lockups with a manual investigation in field and on the other side preventing false sysrq detections.

As a preparation to add sysrq_toggle_support() call into uart, remove a private copy of sysrq_enabled from sysctl - it should reflect the actual status of sysrq.

Furthermore, the private copy isn't correct already in case sysrq_always_enabled is true. So, remove __sysrq_enabled and use a getter-helper for sysrq enabled status.

Cc Iurii Zaikin <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc Luis Chamberlain <[email protected]>
Cc Kees Cook <[email protected]>
---
 drivers/tty/sysrq.c   |  7 +++++++
 include/linux/sysrq.h |  1 +
 kernel/sysctl.c       | 41 ++++++++++++++++++++++-------------------
 3 files changed, 30 insertions(+), 19 deletions(-)
drivers/tty/sysrq.c +7 -0
index 1d4f317a0e42..c21067765091 100644
@@ -73,6 +73,13 @@ static bool sysrq_on_mask(int mask)
 	       (sysrq_enabled & mask);
 }
 
+int sysrq_get_mask(void)
+{
+	if (sysrq_always_enabled)
+		return 1;
+	return sysrq_enabled;
+}
+
 static int __init sysrq_always_enabled_setup(char *str)
 {
 	sysrq_always_enabled = true;
include/linux/sysrq.h +1 -0
index 8c71874e8485..4a0b351fa2d3 100644
@@ -50,6 +50,7 @@ int unregister_sysrq_key(int key, struct sysrq_key_op *op);
 struct sysrq_key_op *__sysrq_get_key_op(int key);
 
 int sysrq_toggle_support(int enable_mask);
+int sysrq_get_mask(void);
 
 #else
 
kernel/sysctl.c +22 -19

60 lines not on this page · raw message

Signature · 1 line
2.24.0
#68 lore raw

PATCH 58/58 serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE

In reply to Dmitry Safonov

Many embedded boards have a disconnected TTL level serial which can generate some garbage that can lead to spurious false sysrq detects.

Currently, sysrq can be either completely disabled for serial console or always disabled (with CONFIG_MAGIC_SYSRQ_SERIAL), since
commit 732dbf3a6104 ("serial: do not accept sysrq characters via serial port")

At Arista, we have such boards that can generate BREAK and random garbage. While disabling sysrq for serial console would solve the problem with spurious false sysrq triggers, it's also desirable to have a way to enable sysrq back.

As a measure of balance between on and off options, add MAGIC_SYSRQ_SERIAL_SEQUENCE which is a string sequence that can enable sysrq if it follows BREAK on a serial line. The longer the string - the less likely it may be in the garbage.

Having the way to enable sysrq was beneficial to debug lockups with a manual investigation in field and on the other side preventing false sysrq detections.

---
 drivers/tty/serial/serial_core.c | 52 ++++++++++++++++++++++++++++----
 include/linux/serial_core.h      |  2 +-
 lib/Kconfig.debug                |  8 +++++
 3 files changed, 55 insertions(+), 7 deletions(-)
drivers/tty/serial/serial_core.c +46 -6
index ef43c168e848..4570c99a137a 100644
@@ -3080,6 +3080,38 @@ void uart_insert_char(struct uart_port *port, unsigned int status,
 }
 EXPORT_SYMBOL_GPL(uart_insert_char);
 
+const char sysrq_toggle_seq[] = CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE;
+
+static void uart_sysrq_on(struct work_struct *w)
+{
+	sysrq_toggle_support(1);
+	pr_info("SysRq is enabled by magic sequience on serial\n");
+}
+static DECLARE_WORK(sysrq_enable_work, uart_sysrq_on);
+
+static int uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch)
+{
+	if (sysrq_toggle_seq[0] == '\0')
+		return 0;
+
+	BUILD_BUG_ON(ARRAY_SIZE(sysrq_toggle_seq) >= sizeof(port->sysrq_seq)*U8_MAX);
+	if (sysrq_toggle_seq[port->sysrq_seq] != ch) {
+		port->sysrq_seq = 0;
+		return 0;
+	}
+
+	/* Without the last \0 */
+	if (++port->sysrq_seq < (ARRAY_SIZE(sysrq_toggle_seq) - 1)) {
+		port->sysrq = jiffies + HZ*5;
+		return 1;
+	}
+
+	schedule_work(&sysrq_enable_work);
+
+	port->sysrq = 0;
+	return 1;
+}
+
 int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 {
 	if (!IS_ENABLED(CONFIG_MAGIC_SYSRQ_SERIAL))
@@ -3089,9 +3121,13 @@ int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
-		handle_sysrq(ch);
-		port->sysrq = 0;
-		return 1;
+		if (sysrq_get_mask()) {
+			handle_sysrq(ch);
+			port->sysrq = 0;
+			return 1;
+		}
+		if (uart_try_toggle_sysrq(port, ch))
+			return 1;
 	}
 	port->sysrq = 0;
 
@@ -3108,9 +3144,13 @@ int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch)
 		return 0;
 
 	if (ch && time_before(jiffies, port->sysrq)) {
-		port->sysrq_ch = ch;
-		port->sysrq = 0;
-		return 1;
+		if (sysrq_get_mask()) {
+			port->sysrq_ch = ch;
+			port->sysrq = 0;
+			return 1;
+		}
+		if (uart_try_toggle_sysrq(port, ch))
+			return 1;
 	}
 	port->sysrq = 0;
 
include/linux/serial_core.h +1 -1
index 255e86a474e9..1f4443db5474 100644
@@ -243,10 +243,10 @@ struct uart_port {
 	unsigned long		sysrq;			/* sysrq timeout */
 	unsigned int		sysrq_ch;		/* char for sysrq */
 	unsigned char		has_sysrq;
+	unsigned char		sysrq_seq;		/* index in sysrq_toggle_seq */
 
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		suspended;
-	unsigned char		unused;
 	const char		*name;			/* port name */
 	struct attribute_group	*attr_group;		/* port specific attributes */
 	const struct attribute_group **tty_groups;	/* all attributes (serial core use only) */
lib/Kconfig.debug +8 -0
index d1842fe756d5..babc464ce14a 100644
@@ -431,6 +431,14 @@ config MAGIC_SYSRQ_SERIAL
 	  This option allows you to decide whether you want to enable the
 	  magic SysRq key.
 
+config MAGIC_SYSRQ_SERIAL_SEQUENCE
+	string "Char sequence that enables magic SysRq over serial"
+	depends on MAGIC_SYSRQ_SERIAL
+	default ""
+	help
+	  Specifies a sequence of characters that can follow BREAK to enable
+	  SysRq on a serial console.
+
 config DEBUG_FS
 	bool "Debug Filesystem"
 	help
Signature · 1 line
2.24.0
#69 lore raw
In reply to Dmitry Safonov

Le 13/12/2019 ? 01:05, Dmitry Safonov a ?crit?:

Quoted 68 lines

The original purpose of the patches set was to add a way to enable sysrq on a uart where currently it can be constantly either on or off (CONFIG_MAGIC_SYSRQ_SERIAL), see the last patch:
"serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE"

But to do that, I had to add uart_try_toggle_sysrq() and I didn't want to bloat serial_core.h even more. So, I did cleanup by removing SUPPORT_SYSRQ resulting in a nice diff-stat and lesser ifdeffery.

Most patches are one-liners, I decided to keep them separated per-driver to let reviewers easier follow the purpose.

Cc Greg Kroah-Hartman <[email protected]>
Cc Jiri Slaby <[email protected]>
Cc Vasiliy Khoruzhick <[email protected]>
Cc linux-serial at vger.kernel.org

Dmitry Safonov (58):
sysrq: Remove sysrq_handler_registered
serial: Move sysrq members above
serial_core: Un-ifdef sysrq SUPPORT_SYSRQ tty/serial: Migrate aspeed_vuart to use has_sysrq tty/serial: Migrate 8250_fsl to use has_sysrq tty/serial: Migrate bcm63xx_uart to use has_sysrq tty/serial: Migrate 8250_omap to use has_sysrq tty/serial: Migrate 8250_port to use has_sysrq tty/serial: Migrate amba-pl01* to use has_sysrq tty/serial: Migrate apbuart to use has_sysrq tty/serial: Migrate arc_uart to use has_sysrq tty/serial: Migrate atmel_serial to use has_sysrq tty/serial: Migrate clps711x to use has_sysrq tty/serial: Migrate cpm_uart to use has_sysrq tty/serial: Migrate dz to use has_sysrq tty/serial: Migrate efm32-uart to use has_sysrq tty/serial: Migrate fsl_linflexuart to use has_sysrq tty/serial: Migrate fsl_lpuart to use has_sysrq tty/serial: Migrate imx to use has_sysrq tty/serial: Migrate ip22zilog to use has_sysrq tty/serial: Migrate meson_uart to use has_sysrq tty/serial: Migrate milbeaut_usio to use has_sysrq tty/serial: Migrate mpc52xx_uart to use has_sysrq tty/serial: Don't zero port->sysrq tty/serial: Migrate msm_serial to use has_sysrq tty/serial: Migrate mux to use has_sysrq tty/serial: Migrate mxs-auart to use has_sysrq tty/serial: Migrate omap-serial to use has_sysrq tty/serial: Migrate pch_uart to use has_sysrq tty/serial: Don't check port->sysrq tty/serial: Migrate pmac_zilog to use has_sysrq tty/serial: Migrate pnx8xxx_uart to use has_sysrq serial/f81534: Don't check port->sysrq tty/serial: Migrate pxa to use has_sysrq tty/serial: Migrate qcom_geni_serial to use has_sysrq tty/serial: Migrate sa1100 to use has_sysrq tty/serial: Migrate samsung_tty to use has_sysrq tty/serial: Migrate sb1250-duart to use has_sysrq tty/serial: Migrate sccnxp to use has_sysrq tty/serial: Migrate serial_txx9 to use has_sysrq tty/serial: Migrate sh-sci to use has_sysrq tty/serial: Migrate sprd_serial to use has_sysrq tty/serial: Migrate st-asc to use has_sysrq tty/serial: Migrate stm32-usart to use has_sysrq tty/serial: Migrate sunhv to use has_sysrq tty/serial: Migrate sunsab to use has_sysrq tty/serial: Migrate sunsu to use has_sysrq tty/serial: Migrate sunzilog to use has_sysrq serial/ucc_uart: Remove ifdef SUPPORT_SYSRQ tty/serial: Migrate vr41xx_siu to use has_sysrq

Quoted 8 lines

tty/serial: Migrate vt8500_serial to use has_sysrq tty/serial: Migrate xilinx_uartps to use has_sysrq tty/serial: Migrate zs to use has_sysrq
serial_core: Remove SUPPORT_SYSRQ ifdeffery
usb/serial: Don't handle break when CONFIG_MAGIC_SYSRQ is disabled
serial_core: Move sysrq functions from header file sysctl/sysrq: Remove __sysrq_enabled copy
serial/sysrq: Add MAGIC_SYSRQ_SERIAL_SEQUENCE

powerpc patchwork didn't get the full series, see
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=148198

Can't find them on linux-serial patchwork either
(https://patches.linaro.org/project/linux-serial/list/)

It is impossible to review/test powerpc bits without the first patches of the series, where can the entire series be found ?

Christophe

Quoted 61 lines
  arch/powerpc/kernel/legacy_serial.c         |   4 +-
  drivers/tty/serial/8250/8250_aspeed_vuart.c |   5 +-
  drivers/tty/serial/8250/8250_fsl.c          |   4 -
  drivers/tty/serial/8250/8250_of.c           |   4 +-
  drivers/tty/serial/8250/8250_omap.c         |   5 +-
  drivers/tty/serial/8250/8250_port.c         |   5 +-
  drivers/tty/serial/amba-pl010.c             |   5 +-
  drivers/tty/serial/amba-pl011.c             |   6 +-
  drivers/tty/serial/apbuart.c                |   5 +-
  drivers/tty/serial/arc_uart.c               |   5 +-
  drivers/tty/serial/atmel_serial.c           |   9 +-
  drivers/tty/serial/bcm63xx_uart.c           |   5 +-
  drivers/tty/serial/clps711x.c               |   5 +-
  drivers/tty/serial/cpm_uart/cpm_uart_core.c |   9 +-
  drivers/tty/serial/dz.c                     |   5 +-
  drivers/tty/serial/efm32-uart.c             |   5 +-
  drivers/tty/serial/fsl_linflexuart.c        |   8 +-
  drivers/tty/serial/fsl_lpuart.c             |   9 +-
  drivers/tty/serial/imx.c                    |   7 +-
  drivers/tty/serial/ip22zilog.c              |   7 +-
  drivers/tty/serial/meson_uart.c             |   5 +-
  drivers/tty/serial/milbeaut_usio.c          |   5 +-
  drivers/tty/serial/mpc52xx_uart.c           |  11 +-
  drivers/tty/serial/msm_serial.c             |   5 +-
  drivers/tty/serial/mux.c                    |   5 +-
  drivers/tty/serial/mxs-auart.c              |   5 +-
  drivers/tty/serial/omap-serial.c            |   5 +-
  drivers/tty/serial/pch_uart.c               |  12 +-
  drivers/tty/serial/pmac_zilog.c             |   5 +-
  drivers/tty/serial/pnx8xxx_uart.c           |   7 +-
  drivers/tty/serial/pxa.c                    |   5 +-
  drivers/tty/serial/qcom_geni_serial.c       |   5 +-
  drivers/tty/serial/sa1100.c                 |   7 +-
  drivers/tty/serial/samsung_tty.c            |   5 +-
  drivers/tty/serial/sb1250-duart.c           |   5 +-
  drivers/tty/serial/sccnxp.c                 |   5 +-
  drivers/tty/serial/serial_core.c            | 123 ++++++++++++++++++++
  drivers/tty/serial/serial_txx9.c            |   5 +-
  drivers/tty/serial/sh-sci.c                 |  10 +-
  drivers/tty/serial/sprd_serial.c            |   5 +-
  drivers/tty/serial/st-asc.c                 |   5 +-
  drivers/tty/serial/stm32-usart.c            |   5 +-
  drivers/tty/serial/sunhv.c                  |   5 +-
  drivers/tty/serial/sunsab.c                 |   5 +-
  drivers/tty/serial/sunsu.c                  |   5 +-
  drivers/tty/serial/sunzilog.c               |   6 +-
  drivers/tty/serial/ucc_uart.c               |   2 -
  drivers/tty/serial/vr41xx_siu.c             |   5 +-
  drivers/tty/serial/vt8500_serial.c          |   5 +-
  drivers/tty/serial/xilinx_uartps.c          |   5 +-
  drivers/tty/serial/zs.c                     |   5 +-
  drivers/tty/sysrq.c                         |  16 +--
  drivers/usb/serial/f81534.c                 |   6 +-
  drivers/usb/serial/generic.c                |  10 +-
  include/linux/serial_core.h                 |  92 ++-------------
  include/linux/sysrq.h                       |   1 +
  kernel/sysctl.c                             |  41 ++++---
  lib/Kconfig.debug                           |   8 ++
  58 files changed, 238 insertions(+), 346 deletions(-)
#70 lore raw

Hi Christophe,

Quoted 1 line · Christophe Leroy

Le 13/12/2019 ? 01:05, Dmitry Safonov a ?crit?:

[..]

Quoted 3 lines

powerpc patchwork didn't get the full series, see
https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=148198

Yes, I was under impression that architecture mail-lists want related patches. But now I see that from the patchwork point of view it's better to have the whole series in inbox.

Quoted 2 lines

Can't find them on linux-serial patchwork either
(https://patches.linaro.org/project/linux-serial/list/)

I'm not sure - maybe the frequency of checking is low? I see all patches in linux-serial ml:
https://marc.info/?l=linux-serial&r=1&b=201912&w=2

Quoted 2 lines

It is impossible to review/test powerpc bits without the first patches of the series, where can the entire series be found ?

Sorry for the inconvenience.
I can resend without Cc'ing all people just to ppc mail-list if that works for you. Or you can clone it directly from my github:
https://github.com/0x7f454c46/linux/tree/sysrq-serial-seq-v1

Thanks,
Dmitry