linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] serial: 8250: Let drivers request full 16550A feature probing
@ 2022-09-20 23:35 Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 1/3] " Maciej W. Rozycki
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2022-09-20 23:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Josh Triplett, Anders Blomdell, linux-serial, linux-kernel, stable

Hi,

 This is v2 of the series, addressing a small issue pointed out in the 
original submission and adds a third patch to switch to using BIT_ULL.  
See individual changes for further details.  The original cover letter 
follows.

 A recent change has added a SERIAL_8250_16550A_VARIANTS option, which 
lets one request the 8250 driver not to probe for 16550A device features 
so as to reduce the driver's device startup time in virtual machines.  
This has turned out problematic to a more recent update for the OxSemi 
Tornado series PCIe devices, whose new baud rate generator handling code 
actually requires switching hardware into the enhanced mode for correct 
operation, which actually requires 16550A device features to have been 
probed for.

 This small patch series fixes the issue by letting individual device 
subdrivers to request full 16550A device feature probing by means of a 
flag regardless of the SERIAL_8250_16550A_VARIANTS setting chosen.

 The changes have been verified with an OXPCIe952 device, in the native 
UART mode and a 64-bit RISC-V system as well as in the legacy UART mode 
and a 32-bit x86 system.

 Credit to Anders for reporting this issue and then working through the 
resolution.

  Maciej

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/3] serial: 8250: Let drivers request full 16550A feature probing
  2022-09-20 23:35 [PATCH v2 0/3] serial: 8250: Let drivers request full 16550A feature probing Maciej W. Rozycki
@ 2022-09-20 23:35 ` Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 2/3] serial: 8250: Request full 16550A feature probing for OxSemi PCIe devices Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 3/3] serial: 8250: Switch UART port flags to using BIT_ULL Maciej W. Rozycki
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2022-09-20 23:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Josh Triplett, Anders Blomdell, linux-serial, linux-kernel, stable

A SERIAL_8250_16550A_VARIANTS configuration option has been recently 
defined that lets one request the 8250 driver not to probe for 16550A 
device features so as to reduce the driver's device startup time in 
virtual machines.

Some actual hardware devices require these features to have been fully 
determined however for their driver to work correctly, so define a flag 
to let drivers request full 16550A feature probing on a device-by-device 
basis if required regardless of the SERIAL_8250_16550A_VARIANTS option 
setting chosen.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Reported-by: Anders Blomdell <anders.blomdell@control.lth.se>
Fixes: dc56ecb81a0a ("serial: 8250: Support disabling mdelay-filled probes of 16550A variants")
Cc: stable@vger.kernel.org # v5.6+
---
Changes from v1:

- Use `u64' rather than `__u64' as the data type.
---
 drivers/tty/serial/8250/8250_port.c |    3 ++-
 include/linux/serial_core.h         |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

linux-serial-8250-full-probe.diff
Index: linux-macro/drivers/tty/serial/8250/8250_port.c
===================================================================
--- linux-macro.orig/drivers/tty/serial/8250/8250_port.c
+++ linux-macro/drivers/tty/serial/8250/8250_port.c
@@ -1021,7 +1021,8 @@ static void autoconfig_16550a(struct uar
 	up->port.type = PORT_16550A;
 	up->capabilities |= UART_CAP_FIFO;
 
-	if (!IS_ENABLED(CONFIG_SERIAL_8250_16550A_VARIANTS))
+	if (!IS_ENABLED(CONFIG_SERIAL_8250_16550A_VARIANTS) &&
+	    !(up->port.flags & UPF_FULL_PROBE))
 		return;
 
 	/*
Index: linux-macro/include/linux/serial_core.h
===================================================================
--- linux-macro.orig/include/linux/serial_core.h
+++ linux-macro/include/linux/serial_core.h
@@ -414,7 +414,7 @@ struct uart_icount {
 	__u32	buf_overrun;
 };
 
-typedef unsigned int __bitwise upf_t;
+typedef u64 __bitwise upf_t;
 typedef unsigned int __bitwise upstat_t;
 
 struct uart_port {
@@ -522,6 +522,7 @@ struct uart_port {
 #define UPF_FIXED_PORT		((__force upf_t) (1 << 29))
 #define UPF_DEAD		((__force upf_t) (1 << 30))
 #define UPF_IOREMAP		((__force upf_t) (1 << 31))
+#define UPF_FULL_PROBE		((__force upf_t) (1ULL << 32))
 
 #define __UPF_CHANGE_MASK	0x17fff
 #define UPF_CHANGE_MASK		((__force upf_t) __UPF_CHANGE_MASK)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] serial: 8250: Request full 16550A feature probing for OxSemi PCIe devices
  2022-09-20 23:35 [PATCH v2 0/3] serial: 8250: Let drivers request full 16550A feature probing Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 1/3] " Maciej W. Rozycki
@ 2022-09-20 23:35 ` Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 3/3] serial: 8250: Switch UART port flags to using BIT_ULL Maciej W. Rozycki
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2022-09-20 23:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Josh Triplett, Anders Blomdell, linux-serial, linux-kernel, stable

Oxford Semiconductor PCIe (Tornado) 950 serial port devices need to 
operate in the enhanced mode via the EFR register for the Divide-by-M 
N/8 baud rate generator prescaler to be used in their native UART mode.  
Otherwise the prescaler is fixed at 1 causing grossly incorrect baud 
rates to be programmed.

Accessing the EFR register requires 16550A features to have been probed 
for, so request this to happen regardless of SERIAL_8250_16550A_VARIANTS 
by setting UPF_FULL_PROBE in port flags.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Reported-by: Anders Blomdell <anders.blomdell@control.lth.se>
Fixes: 366f6c955d4d ("serial: 8250: Add proper clock handling for OxSemi PCIe devices")
Cc: stable@vger.kernel.org # v5.19+
---
No change from v1.
---
 drivers/tty/serial/8250/8250_pci.c |    5 +++++
 1 file changed, 5 insertions(+)

linux-serial-8250-oxsemi-efr.diff
Index: linux-macro/drivers/tty/serial/8250/8250_pci.c
===================================================================
--- linux-macro.orig/drivers/tty/serial/8250/8250_pci.c
+++ linux-macro/drivers/tty/serial/8250/8250_pci.c
@@ -1232,6 +1232,10 @@ static void pci_oxsemi_tornado_set_mctrl
 	serial8250_do_set_mctrl(port, mctrl);
 }
 
+/*
+ * We require EFR features for clock programming, so set UPF_FULL_PROBE
+ * for full probing regardless of CONFIG_SERIAL_8250_16550A_VARIANTS setting.
+ */
 static int pci_oxsemi_tornado_setup(struct serial_private *priv,
 				    const struct pciserial_board *board,
 				    struct uart_8250_port *up, int idx)
@@ -1239,6 +1243,7 @@ static int pci_oxsemi_tornado_setup(stru
 	struct pci_dev *dev = priv->dev;
 
 	if (pci_oxsemi_tornado_p(dev)) {
+		up->port.flags |= UPF_FULL_PROBE;
 		up->port.get_divisor = pci_oxsemi_tornado_get_divisor;
 		up->port.set_divisor = pci_oxsemi_tornado_set_divisor;
 		up->port.set_mctrl = pci_oxsemi_tornado_set_mctrl;

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] serial: 8250: Switch UART port flags to using BIT_ULL
  2022-09-20 23:35 [PATCH v2 0/3] serial: 8250: Let drivers request full 16550A feature probing Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 1/3] " Maciej W. Rozycki
  2022-09-20 23:35 ` [PATCH v2 2/3] serial: 8250: Request full 16550A feature probing for OxSemi PCIe devices Maciej W. Rozycki
@ 2022-09-20 23:35 ` Maciej W. Rozycki
  2 siblings, 0 replies; 4+ messages in thread
From: Maciej W. Rozycki @ 2022-09-20 23:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: Josh Triplett, Anders Blomdell, linux-serial, linux-kernel, stable

Use BIT_ULL rather than encoding bits explicitly where applicable with 
UART port flags.  This makes a (__force upf_t) cast redundant, but keep 
it for visual consistency with the flags defined in terms of userspace 
macros.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
New change in v2.
---
 include/linux/serial_core.h |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

linux-serial-8250-upf-bit-ull.diff
Index: linux-macro/include/linux/serial_core.h
===================================================================
--- linux-macro.orig/include/linux/serial_core.h
+++ linux-macro/include/linux/serial_core.h
@@ -505,24 +505,24 @@ struct uart_port {
 #define UPF_BUGGY_UART		((__force upf_t) ASYNC_BUGGY_UART     /* 14 */ )
 #define UPF_MAGIC_MULTIPLIER	((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ )
 
-#define UPF_NO_THRE_TEST	((__force upf_t) (1 << 19))
+#define UPF_NO_THRE_TEST	((__force upf_t) BIT_ULL(19))
 /* Port has hardware-assisted h/w flow control */
-#define UPF_AUTO_CTS		((__force upf_t) (1 << 20))
-#define UPF_AUTO_RTS		((__force upf_t) (1 << 21))
+#define UPF_AUTO_CTS		((__force upf_t) BIT_ULL(20))
+#define UPF_AUTO_RTS		((__force upf_t) BIT_ULL(21))
 #define UPF_HARD_FLOW		((__force upf_t) (UPF_AUTO_CTS | UPF_AUTO_RTS))
 /* Port has hardware-assisted s/w flow control */
-#define UPF_SOFT_FLOW		((__force upf_t) (1 << 22))
-#define UPF_CONS_FLOW		((__force upf_t) (1 << 23))
-#define UPF_SHARE_IRQ		((__force upf_t) (1 << 24))
-#define UPF_EXAR_EFR		((__force upf_t) (1 << 25))
-#define UPF_BUG_THRE		((__force upf_t) (1 << 26))
+#define UPF_SOFT_FLOW		((__force upf_t) BIT_ULL(22))
+#define UPF_CONS_FLOW		((__force upf_t) BIT_ULL(23))
+#define UPF_SHARE_IRQ		((__force upf_t) BIT_ULL(24))
+#define UPF_EXAR_EFR		((__force upf_t) BIT_ULL(25))
+#define UPF_BUG_THRE		((__force upf_t) BIT_ULL(26))
 /* The exact UART type is known and should not be probed.  */
-#define UPF_FIXED_TYPE		((__force upf_t) (1 << 27))
-#define UPF_BOOT_AUTOCONF	((__force upf_t) (1 << 28))
-#define UPF_FIXED_PORT		((__force upf_t) (1 << 29))
-#define UPF_DEAD		((__force upf_t) (1 << 30))
-#define UPF_IOREMAP		((__force upf_t) (1 << 31))
-#define UPF_FULL_PROBE		((__force upf_t) (1ULL << 32))
+#define UPF_FIXED_TYPE		((__force upf_t) BIT_ULL(27))
+#define UPF_BOOT_AUTOCONF	((__force upf_t) BIT_ULL(28))
+#define UPF_FIXED_PORT		((__force upf_t) BIT_ULL(29))
+#define UPF_DEAD		((__force upf_t) BIT_ULL(30))
+#define UPF_IOREMAP		((__force upf_t) BIT_ULL(31))
+#define UPF_FULL_PROBE		((__force upf_t) BIT_ULL(32))
 
 #define __UPF_CHANGE_MASK	0x17fff
 #define UPF_CHANGE_MASK		((__force upf_t) __UPF_CHANGE_MASK)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-20 23:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20 23:35 [PATCH v2 0/3] serial: 8250: Let drivers request full 16550A feature probing Maciej W. Rozycki
2022-09-20 23:35 ` [PATCH v2 1/3] " Maciej W. Rozycki
2022-09-20 23:35 ` [PATCH v2 2/3] serial: 8250: Request full 16550A feature probing for OxSemi PCIe devices Maciej W. Rozycki
2022-09-20 23:35 ` [PATCH v2 3/3] serial: 8250: Switch UART port flags to using BIT_ULL Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).