linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/Kconfig: Add config for specifying BASE_BAUD
       [not found] <20180307232410.248434-1-djkurtz@chromium.org>
@ 2018-03-07 23:24 ` Daniel Kurtz
  2018-03-12 16:54   ` Andy Shevchenko
  2018-03-07 23:24 ` [PATCH 2/2] x86/Kconfig: Add config to allow not defining old serial ports Daniel Kurtz
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Kurtz @ 2018-03-07 23:24 UTC (permalink / raw)
  Cc: adurbin, Daniel Kurtz, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Greg Kroah-Hartman, Kate Stewart, Philippe Ombredanne,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

Not all x86 CPUs have UARTs that use a baud reference clock (BASE_BAUD) of
115200 = 1843200 / 16.  For example, the UARTs on AMD Carrizo and later
use a fixed input clock of 48000000, and hence require BASE_BAUD=3000000.

The BASE_BAUD value is used by the generic earlycon driver to compute the
UART clock used early in boot before the real serial drivers have a
chance to load and read their input clock configuration from ACPI.

Add a Kconfig option to override this default hard coded value.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 arch/x86/Kconfig              | 9 +++++++++
 arch/x86/include/asm/serial.h | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index eb7f43f23521..0a258bb30159 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -454,6 +454,15 @@ config INTEL_RDT
 
 	  Say N if unsure.
 
+config X86_SERIAL_BASE_BAUD
+	int "UART input clock for platform 8250/16550 serial ports"
+	default "115200"
+	help
+	  This specifies the default frequency for the reference clock of the
+	  serial ports.  For many systems this is 1843200 / 16, which is the
+	  default, but may need to be changed to get earlycon to work on
+	  some hardware, such as those that use AMD Carrizo or later SoCs.
+
 if X86_32
 config X86_BIGSMP
 	bool "Support for big SMP systems with more than 8 CPUs"
diff --git a/arch/x86/include/asm/serial.h b/arch/x86/include/asm/serial.h
index ece8299d2695..c28151090b51 100644
--- a/arch/x86/include/asm/serial.h
+++ b/arch/x86/include/asm/serial.h
@@ -9,7 +9,11 @@
  * clock, since the 16550A is capable of handling a top speed of 1.5
  * megabits/second; but this requires a faster clock.
  */
+#ifdef CONFIG_X86_SERIAL_BASE_BAUD
+#define BASE_BAUD CONFIG_X86_SERIAL_BASE_BAUD
+#else
 #define BASE_BAUD (1843200/16)
+#endif
 
 /* Standard COM flags (except for COM4, because of the 8514 problem) */
 #ifdef CONFIG_SERIAL_8250_DETECT_IRQ
-- 
2.16.2.395.g2e18187dfd-goog

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

* [PATCH 2/2] x86/Kconfig: Add config to allow not defining old serial ports
       [not found] <20180307232410.248434-1-djkurtz@chromium.org>
  2018-03-07 23:24 ` [PATCH 1/2] x86/Kconfig: Add config for specifying BASE_BAUD Daniel Kurtz
@ 2018-03-07 23:24 ` Daniel Kurtz
  2018-03-08  1:49   ` Randy Dunlap
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Kurtz @ 2018-03-07 23:24 UTC (permalink / raw)
  Cc: adurbin, Daniel Kurtz, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Kate Stewart, Philippe Ombredanne, Greg Kroah-Hartman,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

The old_serial_port global array in 8250_core is supposed to hold an entry
for each serial port on the system that cannot be discovered via a
standard enumeration mechanism (aka ACPI/PCI/DTS).  The array is populated
at compile-time from the value specified in the SERIAL_PORT_DFNS macro.
This macro is defined in arch/serial.h.

For x86, this macro is currently unconditionally initialized to supply
four ioport UARTs (0x3F8, 0x2F8, 0x3E8, 0x2E8).

However, not all x86 CPUs have these four ioport UARTs.  For example, the
UARTs on AMD Carrizo and later are separate memory mapped Designware IP
blocks.

Fairly early in boot the console_initcall univ8250_console_init iterates
over this array and installs these old UARTs into the global array
serial8250_ports.  Further, it attemptes to register them for use as
the console.  In other words, if, for example, the kernel commandline has
console=ttyS0, the console will be switched over to one of these
non-existent UARTs.  Only later, when the real UART drivers are probed
and their devices are instantiated will the console switch back over to
the proper UART.

This is most noticeable when using earlycon, since part of the serial
console log will appear to disappear (when the bogus old takes over) and
then re-appear (when the real UART finally gets registered for the
console).

Add a Kconfig option to allow overriding this default hard coded value
for arch/x86 devices that do not have such serial ports.

Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
---
 arch/x86/Kconfig              | 11 +++++++++++
 arch/x86/include/asm/serial.h |  4 ++++
 2 files changed, 15 insertions(+)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0a258bb30159..7501cd776cfc 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -463,6 +463,17 @@ config X86_SERIAL_BASE_BAUD
 	  default, but may need to be changed to get earlycon to work on
 	  some hardware, such as those that use AMD Carrizo or later SoCs.
 
+config X86_SERIAL_DEFINE_OLD_SERIAL_PORTS
+	bool "Define un-enumerable serial ports"
+	default y
+	help
+	  Say Y here if you want the kernel to assume the precense of built-in
+	  serial ports that do not have a standard enumeration mechanism.
+	  Platforms that can find all serial ports via mechanisms like ACPI or
+	  PCI can set this to N.
+
+	  If unsure, say Y.
+
 if X86_32
 config X86_BIGSMP
 	bool "Support for big SMP systems with more than 8 CPUs"
diff --git a/arch/x86/include/asm/serial.h b/arch/x86/include/asm/serial.h
index c28151090b51..e86304c2bfae 100644
--- a/arch/x86/include/asm/serial.h
+++ b/arch/x86/include/asm/serial.h
@@ -24,11 +24,15 @@
 # define STD_COM4_FLAGS	(UPF_BOOT_AUTOCONF |	0		| 0		)
 #endif
 
+#ifdef CONFIG_X86_SERIAL_DEFINE_OLD_SERIAL_PORTS
 #define SERIAL_PORT_DFNS								\
 	/* UART		CLK		PORT	IRQ	FLAGS			    */	\
 	{ .uart = 0,	BASE_BAUD,	0x3F8,	4,	STD_COMX_FLAGS	}, /* ttyS0 */	\
 	{ .uart = 0,	BASE_BAUD,	0x2F8,	3,	STD_COMX_FLAGS	}, /* ttyS1 */	\
 	{ .uart = 0,	BASE_BAUD,	0x3E8,	4,	STD_COMX_FLAGS	}, /* ttyS2 */	\
 	{ .uart = 0,	BASE_BAUD,	0x2E8,	3,	STD_COM4_FLAGS	}, /* ttyS3 */
+#else
+#define SERIAL_PORT_DFNS
+#endif
 
 #endif /* _ASM_X86_SERIAL_H */
-- 
2.16.2.395.g2e18187dfd-goog

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

* Re: [PATCH 2/2] x86/Kconfig: Add config to allow not defining old serial ports
  2018-03-07 23:24 ` [PATCH 2/2] x86/Kconfig: Add config to allow not defining old serial ports Daniel Kurtz
@ 2018-03-08  1:49   ` Randy Dunlap
  0 siblings, 0 replies; 4+ messages in thread
From: Randy Dunlap @ 2018-03-08  1:49 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: adurbin, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Kate Stewart, Philippe Ombredanne, Greg Kroah-Hartman,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

On 03/07/2018 03:24 PM, Daniel Kurtz wrote:
> The old_serial_port global array in 8250_core is supposed to hold an entry
> for each serial port on the system that cannot be discovered via a
> standard enumeration mechanism (aka ACPI/PCI/DTS).  The array is populated
> at compile-time from the value specified in the SERIAL_PORT_DFNS macro.
> This macro is defined in arch/serial.h.
> 
> For x86, this macro is currently unconditionally initialized to supply
> four ioport UARTs (0x3F8, 0x2F8, 0x3E8, 0x2E8).
> 
> However, not all x86 CPUs have these four ioport UARTs.  For example, the
> UARTs on AMD Carrizo and later are separate memory mapped Designware IP
> blocks.
> 
> Fairly early in boot the console_initcall univ8250_console_init iterates
> over this array and installs these old UARTs into the global array
> serial8250_ports.  Further, it attemptes to register them for use as
> the console.  In other words, if, for example, the kernel commandline has
> console=ttyS0, the console will be switched over to one of these
> non-existent UARTs.  Only later, when the real UART drivers are probed
> and their devices are instantiated will the console switch back over to
> the proper UART.
> 
> This is most noticeable when using earlycon, since part of the serial
> console log will appear to disappear (when the bogus old takes over) and
> then re-appear (when the real UART finally gets registered for the
> console).
> 
> Add a Kconfig option to allow overriding this default hard coded value
> for arch/x86 devices that do not have such serial ports.
> 
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> ---
>  arch/x86/Kconfig              | 11 +++++++++++
>  arch/x86/include/asm/serial.h |  4 ++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 0a258bb30159..7501cd776cfc 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -463,6 +463,17 @@ config X86_SERIAL_BASE_BAUD
>  	  default, but may need to be changed to get earlycon to work on
>  	  some hardware, such as those that use AMD Carrizo or later SoCs.
>  
> +config X86_SERIAL_DEFINE_OLD_SERIAL_PORTS
> +	bool "Define un-enumerable serial ports"
> +	default y
> +	help
> +	  Say Y here if you want the kernel to assume the precense of built-in

	                                                  presence

> +	  serial ports that do not have a standard enumeration mechanism.
> +	  Platforms that can find all serial ports via mechanisms like ACPI or
> +	  PCI can set this to N.
> +
> +	  If unsure, say Y.
> +
>  if X86_32
>  config X86_BIGSMP
>  	bool "Support for big SMP systems with more than 8 CPUs"



-- 
~Randy

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

* Re: [PATCH 1/2] x86/Kconfig: Add config for specifying BASE_BAUD
  2018-03-07 23:24 ` [PATCH 1/2] x86/Kconfig: Add config for specifying BASE_BAUD Daniel Kurtz
@ 2018-03-12 16:54   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2018-03-12 16:54 UTC (permalink / raw)
  To: Daniel Kurtz
  Cc: Aaron Durbin, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	Greg Kroah-Hartman, Kate Stewart, Philippe Ombredanne,
	open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

On Thu, Mar 8, 2018 at 1:24 AM, Daniel Kurtz <djkurtz@chromium.org> wrote:
> Not all x86 CPUs have UARTs that use a baud reference clock (BASE_BAUD) of
> 115200 = 1843200 / 16.  For example, the UARTs on AMD Carrizo and later
> use a fixed input clock of 48000000, and hence require BASE_BAUD=3000000.
>
> The BASE_BAUD value is used by the generic earlycon driver to compute the
> UART clock used early in boot before the real serial drivers have a
> chance to load and read their input clock configuration from ACPI.
>
> Add a Kconfig option to override this default hard coded value.

This makes a deviation that prevents to have less kernels to cover
most of x86 cases.

Now we have the following:
 - x86-32 (covers i686)
 - x86-64 (covers x86_64)
 - quark (covers 1 core i586 TSC type of platforms)

In almost all above cases the 1843200 is used as UART clock.
(Exceptions are some of Intel MID devices)

Besides that I told you already the alternatives to mitigate the issue
(in order from preferable to non-preferable):

- since it's ACPI based platform, provide an SPCR table (problem solved!)
- fix your crap firmware to be compatible (even DT drivers are using
the same clock rate!)
- add a specific ->setup() callback for your crap hardware (see
drivers/tty/serial/amba-pl011.c as an example)

NAK.

>
> Signed-off-by: Daniel Kurtz <djkurtz@chromium.org>
> ---
>  arch/x86/Kconfig              | 9 +++++++++
>  arch/x86/include/asm/serial.h | 4 ++++
>  2 files changed, 13 insertions(+)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index eb7f43f23521..0a258bb30159 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -454,6 +454,15 @@ config INTEL_RDT
>
>           Say N if unsure.
>
> +config X86_SERIAL_BASE_BAUD
> +       int "UART input clock for platform 8250/16550 serial ports"
> +       default "115200"
> +       help
> +         This specifies the default frequency for the reference clock of the
> +         serial ports.  For many systems this is 1843200 / 16, which is the
> +         default, but may need to be changed to get earlycon to work on
> +         some hardware, such as those that use AMD Carrizo or later SoCs.
> +
>  if X86_32
>  config X86_BIGSMP
>         bool "Support for big SMP systems with more than 8 CPUs"
> diff --git a/arch/x86/include/asm/serial.h b/arch/x86/include/asm/serial.h
> index ece8299d2695..c28151090b51 100644
> --- a/arch/x86/include/asm/serial.h
> +++ b/arch/x86/include/asm/serial.h
> @@ -9,7 +9,11 @@
>   * clock, since the 16550A is capable of handling a top speed of 1.5
>   * megabits/second; but this requires a faster clock.
>   */
> +#ifdef CONFIG_X86_SERIAL_BASE_BAUD
> +#define BASE_BAUD CONFIG_X86_SERIAL_BASE_BAUD
> +#else
>  #define BASE_BAUD (1843200/16)
> +#endif
>
>  /* Standard COM flags (except for COM4, because of the 8514 problem) */
>  #ifdef CONFIG_SERIAL_8250_DETECT_IRQ
> --
> 2.16.2.395.g2e18187dfd-goog
>



-- 
With Best Regards,
Andy Shevchenko

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

end of thread, other threads:[~2018-03-12 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20180307232410.248434-1-djkurtz@chromium.org>
2018-03-07 23:24 ` [PATCH 1/2] x86/Kconfig: Add config for specifying BASE_BAUD Daniel Kurtz
2018-03-12 16:54   ` Andy Shevchenko
2018-03-07 23:24 ` [PATCH 2/2] x86/Kconfig: Add config to allow not defining old serial ports Daniel Kurtz
2018-03-08  1:49   ` Randy Dunlap

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).