2016-03-31 13:43:04

by Aleksey Makarov

[permalink] [raw]
Subject: [PATCH v7 0/5] ACPI: parse the SPCR table

'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
Console Redirection Table) [2] as a mandatory ACPI table that
specifies the configuration of serial console.

Move "earlycon" early_param handling to earlycon.c to parse this option once

*** PATCH "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
*** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next

Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
for the next patch. It is taken from ACPICA series [3], but it has not appeared
in linux-next yet.

Parse SPCR table, setup earlycon and add register specified console.

Enable parsing this table on ARM64. Earlycon should be set up
as early as possible. ACPI boot tables are mapped in
arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
and that's where we parse spcr. So it has to be opted-in per-arch.

Implement console_match() for pl011.

Based on the work by Leif Lindholm [4]
Thanks to Peter Hurley for explaining how this should work.

Should be applied to next-20160331.

Tested on QEMU. SPCR support is included in QEMU's ARM mach-virt
since 2.4 release.

v7:
- add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
to serial"
- call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
(Rafael J. Wysocki)
- fix a few minor issues (Rafael J. Wysocki)

v6:
https://lkml.kernel.org/g/[email protected]
- add documentation for parse_spcr() functioin (Yury Norov)
- don't initialize err variable (Yury Norov)
- add __initdata for the earlycon_init_is_deferred flag variable
- rename the function exported in "of/serial: move earlycon early_param handling
to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
- defer initialization of DT earlycon until DT/ACPI decision is made
(Rob Herring, Peter Hurley)
- use snprintf instead of sprintf (Andy Shevchenko)
- drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley). This means that
SPCR earlycon will not work on the kernels before 4.6

v5:
https://lkml.kernel.org/g/[email protected]
- drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
it is ugly. Also because Christopher Covington came with a better solution [5]
- remove error message when the table is not provided by ACPI (Andy Shevchenko)
- rewrite spcr.c following the suggestions by Peter Hurley
- add console_match() for pl011 in a separate patch
- add EARLYCON_DECLARE for pl011 in a separate patch
- add patch "of/serial: move earlycon early_param handling to serial" from
the GDB2 series

v4:
https://lkml.kernel.org/g/[email protected]
- drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
ACPI developers work on a new API and asked not to do that.
Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
and cache the result. (Lv Zheng)
- fix some style issues (Yury Norov)

v3:
https://lkml.kernel.org/g/[email protected]

Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:

- drop acpi_match() member of struct console
- drop implementations of this member for pl011 and 8250
- drop the patch that renames some vars in printk.c as it is not needed anymore
- drop patch that introduces system wide acpi_table_parse2().
Instead introduce a custom acpi_table_parse_spcr() in spcr.c

Instead of introducing a new match_acpi() member of struct console,
this patchset introduces a new function acpi_console_check().
This function is called when a new uart is registered at serial_core.c
the same way OF code checks for console. If the registered uart is the
console specified by SPCR table, this function calls add_preferred_console()

The restrictions of this approach are:

- only serial consoles can be set up
- only consoles specified by the memory/io address can be set up
(SPCR can specify devices by PCI id/PCI address)

v2:
https://lkml.kernel.org/g/[email protected]
- don't use SPCR if user specified console in command line
- fix initialization order of newcon->index = 0
- rename some variables at printk.c (Joe Perches, Peter Hurley)
- enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
- remove the retry loop for console registering (Peter Hurley).
Instead, obtain SPCR with acpi_get_table(). That works after
call to acpi_early_init() i. e. in any *_initcall()
- describe design decision behind introducing acpi_match() (Peter Hurley)
- fix compilation for x86 + ACPI (Graeme Gregory)
- introduce DBG2 constants in a separate patch (Andy Shevchenko)
- fix a typo in DBG2 constants (Andy Shevchenko)
- add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
- add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
- add documentation for functions
- add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
accessor functions (Christopher Covington)
- change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
- introduce acpi_table_parse2() in a separate patch
- fix fetching the SPCR table early (Mark Salter)
- add a patch from Mark Salter that introduces support for matching 8250-based
consoles

v1:
https://lkml.kernel.org/g/[email protected]

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
[2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
[3] https://lkml.kernel.org/g/[email protected]
[4] https://lkml.kernel.org/g/[email protected]
[5] https://lkml.kernel.org/g/[email protected]

Aleksey Makarov (4):
ACPICA: Headers: Add new constants for the DBG2 ACPI table
ACPI: parse SPCR and enable matching console
ARM64: ACPI: enable ACPI_SPCR_TABLE
serial: pl011: add console matching function

Leif Lindholm (1):
of/serial: move earlycon early_param handling to serial

arch/arm64/Kconfig | 1 +
arch/arm64/kernel/acpi.c | 11 +++-
drivers/acpi/Kconfig | 3 ++
drivers/acpi/Makefile | 1 +
drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++
drivers/of/fdt.c | 11 +---
drivers/tty/serial/amba-pl011.c | 56 ++++++++++++++++++++
drivers/tty/serial/earlycon.c | 19 ++++++-
include/acpi/actbl2.h | 7 ++-
include/linux/acpi.h | 6 +++
include/linux/of_fdt.h | 2 +
include/linux/serial_core.h | 6 +++
12 files changed, 220 insertions(+), 14 deletions(-)
create mode 100644 drivers/acpi/spcr.c

--
2.7.4


2016-03-31 13:43:17

by Aleksey Makarov

[permalink] [raw]
Subject: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial

From: Leif Lindholm <[email protected]>

We have multiple "earlycon" early_param handlers - merge the DT one into
the main earlycon one. It's a cleanup that also will be useful
to defer setting up DT console until ACPI/DT decision is made.

Rename the exported function to avoid clashing with the function from
arch/microblaze/kernel/prom.c

Signed-off-by: Leif Lindholm <[email protected]>
Signed-off-by: Aleksey Makarov <[email protected]>
Acked-by: Rob Herring <[email protected]>
---
drivers/of/fdt.c | 11 +----------
drivers/tty/serial/earlycon.c | 2 +-
include/linux/of_fdt.h | 2 ++
3 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3349d2a..b50f775 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -805,7 +805,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)

#ifdef CONFIG_SERIAL_EARLYCON

-static int __init early_init_dt_scan_chosen_serial(void)
+int __init early_init_dt_scan_chosen_stdout(void)
{
int offset;
const char *p, *q, *options = NULL;
@@ -849,15 +849,6 @@ static int __init early_init_dt_scan_chosen_serial(void)
}
return -ENODEV;
}
-
-static int __init setup_of_earlycon(char *buf)
-{
- if (buf)
- return 0;
-
- return early_init_dt_scan_chosen_serial();
-}
-early_param("earlycon", setup_of_earlycon);
#endif

/**
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 067783f..7aae655 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -209,7 +209,7 @@ static int __init param_setup_earlycon(char *buf)
* don't generate a warning from parse_early_params() in that case
*/
if (!buf || !buf[0])
- return 0;
+ return early_init_dt_scan_chosen_stdout();

err = setup_earlycon(buf);
if (err == -ENOENT || err == -EALREADY)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 2fbe868..5cfe322 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -63,6 +63,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
int depth, void *data);
extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
int depth, void *data);
+extern int early_init_dt_scan_chosen_stdout(void);
extern void early_init_fdt_scan_reserved_mem(void);
extern void early_init_fdt_reserve_self(void);
extern void early_init_dt_add_memory_arch(u64 base, u64 size);
@@ -91,6 +92,7 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *);
extern u64 of_flat_dt_translate_address(unsigned long node);
extern void of_fdt_limit_memory(int limit);
#else /* CONFIG_OF_FLATTREE */
+static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; }
static inline void early_init_fdt_scan_reserved_mem(void) {}
static inline void early_init_fdt_reserve_self(void) {}
static inline const char *of_flat_dt_get_machine_name(void) { return NULL; }
--
2.7.4

2016-03-31 13:43:36

by Aleksey Makarov

[permalink] [raw]
Subject: [PATCH v7 3/5] ACPI: parse SPCR and enable matching console

'ARM Server Base Boot Requiremets' [1] mentions SPCR (Serial Port
Console Redirection Table) [2] as a mandatory ACPI table that
specifies the configuration of serial console.

Defer initialization of DT earlycon until ACPI/DT decision is made.

Parse the ACPI SPCR table, setup earlycon if required,
enable specified console.

Thanks to Peter Hurley for explaining how this should work.

[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
[2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx

Signed-off-by: Aleksey Makarov <[email protected]>
---
drivers/acpi/Kconfig | 3 ++
drivers/acpi/Makefile | 1 +
drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++++
drivers/tty/serial/earlycon.c | 19 +++++++-
include/linux/acpi.h | 6 +++
include/linux/serial_core.h | 6 +++
6 files changed, 144 insertions(+), 2 deletions(-)
create mode 100644 drivers/acpi/spcr.c

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 65fb483..5611eb6 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -77,6 +77,9 @@ config ACPI_DEBUGGER_USER

endif

+config ACPI_SPCR_TABLE
+ bool
+
config ACPI_SLEEP
bool
depends on SUSPEND || HIBERNATION
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 7395928..f70ae14 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -82,6 +82,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
obj-$(CONFIG_ACPI_BGRT) += bgrt.o
obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o
+obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o
obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o

# processor has its own "processor." module_param namespace
diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
new file mode 100644
index 0000000..68ffc33
--- /dev/null
+++ b/drivers/acpi/spcr.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2012, Intel Corporation
+ * Copyright (c) 2015, Red Hat, Inc.
+ * Copyright (c) 2015, 2016 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#define pr_fmt(fmt) "ACPI: SPCR: " fmt
+
+#include <linux/acpi.h>
+#include <linux/console.h>
+#include <linux/kernel.h>
+#include <linux/serial_core.h>
+
+/**
+ * parse_spcr() - parse ACPI SPCR table and add preferred console
+ *
+ * @earlycon: set up earlycon for the console specified by the table
+ *
+ * For the architectures with support for ACPI, CONFIG_ACPI_SPCR_TABLE may be
+ * defined to parse ACPI SPCR table. As a result of the parsing preferred
+ * console is registered and if @earlycon is true, earlycon is set up.
+ *
+ * When CONFIG_ACPI_SPCR_TABLE is defined, this function should should be called
+ * from arch inintialization code as soon as the DT/ACPI decision is made.
+ *
+ */
+int __init parse_spcr(bool earlycon)
+{
+ static char opts[64];
+ struct acpi_table_spcr *table;
+ acpi_size table_size;
+ acpi_status status;
+ char *uart;
+ char *iotype;
+ int baud_rate;
+ int err;
+
+ if (acpi_disabled)
+ return -ENODEV;
+
+ status = acpi_get_table_with_size(ACPI_SIG_SPCR, 0,
+ (struct acpi_table_header **)&table,
+ &table_size);
+
+ if (ACPI_FAILURE(status))
+ return -ENOENT;
+
+ if (table->header.revision < 2) {
+ err = -ENOENT;
+ pr_err("wrong table version\n");
+ goto done;
+ }
+
+ iotype = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ?
+ "mmio" : "io";
+
+ switch (table->interface_type) {
+ case ACPI_DBG2_ARM_SBSA_32BIT:
+ iotype = "mmio32";
+ /* fall through */
+ case ACPI_DBG2_ARM_PL011:
+ case ACPI_DBG2_ARM_SBSA_GENERIC:
+ case ACPI_DBG2_BCM2835:
+ uart = "pl011";
+ break;
+ case ACPI_DBG2_16550_COMPATIBLE:
+ case ACPI_DBG2_16550_SUBSET:
+ uart = "uart";
+ break;
+ default:
+ err = -ENOENT;
+ goto done;
+ }
+
+ switch (table->baud_rate) {
+ case 3:
+ baud_rate = 9600;
+ break;
+ case 4:
+ baud_rate = 19200;
+ break;
+ case 6:
+ baud_rate = 57600;
+ break;
+ case 7:
+ baud_rate = 115200;
+ break;
+ default:
+ err = -ENOENT;
+ goto done;
+ }
+
+ snprintf(opts, sizeof(opts), "%s,%s,0x%llx,%d", uart, iotype,
+ table->serial_port.address, baud_rate);
+
+ pr_info("console: %s", opts);
+
+ if (earlycon)
+ setup_earlycon(opts);
+
+ err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
+
+done:
+ early_acpi_os_unmap_memory((void __iomem *)table, table_size);
+ return err;
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7aae655..ea00b9f 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -21,6 +21,7 @@
#include <linux/sizes.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
+#include <linux/acpi.h>

#ifdef CONFIG_FIX_EARLYCON_MEM
#include <asm/fixmap.h>
@@ -199,6 +200,14 @@ int __init setup_earlycon(char *buf)
return -ENOENT;
}

+/*
+ * When CONFIG_ACPI_SPCR_TABLE is defined, "earlycon" without parameters in
+ * command line does not start DT earlycon immediately, instead it defers
+ * starting it until DT/ACPI decision is made. At that time if ACPI is enabled
+ * call parse_spcr(), else call early_init_dt_scan_chosen_stdout()
+ */
+bool earlycon_init_is_deferred __initdata;
+
/* early_param wrapper for setup_earlycon() */
static int __init param_setup_earlycon(char *buf)
{
@@ -208,8 +217,14 @@ static int __init param_setup_earlycon(char *buf)
* Just 'earlycon' is a valid param for devicetree earlycons;
* don't generate a warning from parse_early_params() in that case
*/
- if (!buf || !buf[0])
- return early_init_dt_scan_chosen_stdout();
+ if (!buf || !buf[0]) {
+ if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) {
+ earlycon_init_is_deferred = true;
+ return 0;
+ } else {
+ return early_init_dt_scan_chosen_stdout();
+ }
+ }

err = setup_earlycon(buf);
if (err == -ENOENT || err == -EALREADY)
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 06ed7e5..1095ed6 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1004,4 +1004,10 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
#define acpi_probe_device_table(t) ({ int __r = 0; __r;})
#endif

+#ifdef CONFIG_ACPI_SPCR_TABLE
+int parse_spcr(bool earlycon);
+#else
+static inline int parse_spcr(bool earlycon) { return 0; }
+#endif
+
#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index cbfcf38..de6750f 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -363,6 +363,12 @@ extern int of_setup_earlycon(const struct earlycon_id *match,
unsigned long node,
const char *options);

+#ifdef CONFIG_SERIAL_EARLYCON
+extern bool earlycon_init_is_deferred __initdata;
+#else
+static const bool earlycon_init_is_deferred;
+#endif
+
struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c);
int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
--
2.7.4

2016-03-31 13:43:56

by Aleksey Makarov

[permalink] [raw]
Subject: [PATCH v7 5/5] serial: pl011: add console matching function

This patch adds function pl011_console_match() that implements
method match of struct console. It allows to match consoles against
data specified in a string, for example taken from command line or
compiled by ACPI SPCR table handler.

Signed-off-by: Aleksey Makarov <[email protected]>
---
drivers/tty/serial/amba-pl011.c | 56 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 7c198e0..4139b64 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2287,12 +2287,68 @@ static int __init pl011_console_setup(struct console *co, char *options)
return uart_set_options(&uap->port, co, baud, parity, bits, flow);
}

+/**
+ * pl011_console_match - non-standard console matching
+ * @co: registering console
+ * @name: name from console command line
+ * @idx: index from console command line
+ * @options: ptr to option string from console command line
+ *
+ * Only attempts to match console command lines of the form:
+ * console=pl011,mmio|mmio32,<addr>[,<options>]
+ * console=pl011,0x<addr>[,<options>]
+ * This form is used to register an initial earlycon boot console and
+ * replace it with the amba_console at pl011 driver init.
+ *
+ * Performs console setup for a match (as required by interface)
+ * If no <options> are specified, then assume the h/w is already setup.
+ *
+ * Returns 0 if console matches; otherwise non-zero to use default matching
+ */
+static int __init pl011_console_match(struct console *co, char *name, int idx,
+ char *options)
+{
+ char match[] = "pl011"; /* pl011-specific earlycon name */
+ unsigned char iotype;
+ unsigned long addr;
+ int i;
+
+ if (strncmp(name, match, 5) != 0)
+ return -ENODEV;
+
+ if (uart_parse_earlycon(options, &iotype, &addr, &options))
+ return -ENODEV;
+
+ /* try to match the port specified on the command line */
+ for (i = 0; i < ARRAY_SIZE(amba_ports); i++) {
+ struct uart_port *port;
+
+ if (!amba_ports[i])
+ continue;
+
+ port = &amba_ports[i]->port;
+
+ if (port->iotype != iotype)
+ continue;
+ if ((iotype == UPIO_MEM || iotype == UPIO_MEM32) &&
+ (port->mapbase != addr))
+ continue;
+
+ co->index = i;
+ port->cons = co;
+ return pl011_console_setup(co, options);
+ }
+
+ return -ENODEV;
+}
+
static struct uart_driver amba_reg;
static struct console amba_console = {
.name = "ttyAMA",
.write = pl011_console_write,
.device = uart_console_device,
.setup = pl011_console_setup,
+ .match = pl011_console_match,
.flags = CON_PRINTBUFFER,
.index = -1,
.data = &amba_reg,
--
2.7.4

2016-03-31 13:43:11

by Aleksey Makarov

[permalink] [raw]
Subject: [PATCH v7 2/5] ACPICA: Headers: Add new constants for the DBG2 ACPI table

ACPICA commit 1607b69238df9c1b2940262a17aa94ec49033278

Link: https://github.com/acpica/acpica/commit/1607b692
Signed-off-by: Aleksey Makarov <[email protected]>.
Signed-off-by: Bob Moore <[email protected]>
Signed-off-by: Lv Zheng <[email protected]>
---

DO NOT MERGE

This patch is from pending ACPICA series [1]. It is needed by the next patch,
but has not been merged to linux-next yet.

[1] https://lkml.kernel.org/g/[email protected]

include/acpi/actbl2.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index a4ef625..7702b27 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -321,7 +321,7 @@ struct acpi_csrt_descriptor {
* DBG2 - Debug Port Table 2
* Version 0 (Both main table and subtables)
*
- * Conforms to "Microsoft Debug Port Table 2 (DBG2)", May 22 2012.
+ * Conforms to "Microsoft Debug Port Table 2 (DBG2)", December 10, 2015
*
******************************************************************************/

@@ -371,6 +371,11 @@ struct acpi_dbg2_device {

#define ACPI_DBG2_16550_COMPATIBLE 0x0000
#define ACPI_DBG2_16550_SUBSET 0x0001
+#define ACPI_DBG2_ARM_PL011 0x0003
+#define ACPI_DBG2_ARM_SBSA_32BIT 0x000D
+#define ACPI_DBG2_ARM_SBSA_GENERIC 0x000E
+#define ACPI_DBG2_ARM_DCC 0x000F
+#define ACPI_DBG2_BCM2835 0x0010

#define ACPI_DBG2_1394_STANDARD 0x0000

--
2.7.4

2016-03-31 13:45:44

by Aleksey Makarov

[permalink] [raw]
Subject: [PATCH v7 4/5] ARM64: ACPI: enable ACPI_SPCR_TABLE

SBBR mentions SPCR as a mandatory ACPI table. So enable it for ARM64

Earlycon should be set up as early as possible. ACPI boot tables are
mapped in arch/arm64/kernel/acpi.c:acpi_boot_table_init() that
is called from setup_arch() and that's where we parse SPCR.
So it has to be opted-in per-arch.

When ACPI_SPCR_TABLE is defined initialization of DT earlycon is
deferred until the DT/ACPI decision is done. Initialize DT earlycon
if ACPI is disabled.

Signed-off-by: Aleksey Makarov <[email protected]>
---
arch/arm64/Kconfig | 1 +
arch/arm64/kernel/acpi.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 07b6a16..c77b4b2 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -3,6 +3,7 @@ config ARM64
select ACPI_CCA_REQUIRED if ACPI
select ACPI_GENERIC_GSI if ACPI
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
+ select ACPI_SPCR_TABLE if ACPI
select ARCH_HAS_DEVMEM_IS_ALLOWED
select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
select ARCH_HAS_ELF_RANDOMIZE
diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index d1ce8e2..f331ebb 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -24,6 +24,7 @@
#include <linux/memblock.h>
#include <linux/of_fdt.h>
#include <linux/smp.h>
+#include <linux/serial_core.h>

#include <asm/cputype.h>
#include <asm/cpu_ops.h>
@@ -189,7 +190,7 @@ void __init acpi_boot_table_init(void)
*/
if (param_acpi_off ||
(!param_acpi_force && of_scan_flat_dt(dt_scan_depth1_nodes, NULL)))
- return;
+ goto done;

/*
* ACPI is disabled at this point. Enable it in order to parse
@@ -209,6 +210,14 @@ void __init acpi_boot_table_init(void)
if (!param_acpi_force)
disable_acpi();
}
+
+done:
+ if (acpi_disabled) {
+ if (earlycon_init_is_deferred)
+ early_init_dt_scan_chosen_stdout();
+ } else {
+ parse_spcr(earlycon_init_is_deferred);
+ }
}

#ifdef CONFIG_ACPI_APEI
--
2.7.4

2016-03-31 16:32:09

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial

On Thu, Mar 31, 2016 at 04:40:23PM +0300, Aleksey Makarov wrote:
> From: Leif Lindholm <[email protected]>
>
> We have multiple "earlycon" early_param handlers - merge the DT one into
> the main earlycon one. It's a cleanup that also will be useful
> to defer setting up DT console until ACPI/DT decision is made.
>
> Rename the exported function to avoid clashing with the function from
> arch/microblaze/kernel/prom.c
>
> Signed-off-by: Leif Lindholm <[email protected]>
> Signed-off-by: Aleksey Makarov <[email protected]>
> Acked-by: Rob Herring <[email protected]>
> ---
> drivers/of/fdt.c | 11 +----------
> drivers/tty/serial/earlycon.c | 2 +-
> include/linux/of_fdt.h | 2 ++
> 3 files changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3349d2a..b50f775 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -805,7 +805,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
>
> #ifdef CONFIG_SERIAL_EARLYCON
>
> -static int __init early_init_dt_scan_chosen_serial(void)
> +int __init early_init_dt_scan_chosen_stdout(void)
> {
> int offset;
> const char *p, *q, *options = NULL;
> @@ -849,15 +849,6 @@ static int __init early_init_dt_scan_chosen_serial(void)
> }
> return -ENODEV;
> }
> -
> -static int __init setup_of_earlycon(char *buf)
> -{
> - if (buf)
> - return 0;
> -
> - return early_init_dt_scan_chosen_serial();
> -}
> -early_param("earlycon", setup_of_earlycon);
> #endif
>
> /**
> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index 067783f..7aae655 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -209,7 +209,7 @@ static int __init param_setup_earlycon(char *buf)
> * don't generate a warning from parse_early_params() in that case
> */
> if (!buf || !buf[0])
> - return 0;
> + return early_init_dt_scan_chosen_stdout();
>
> err = setup_earlycon(buf);
> if (err == -ENOENT || err == -EALREADY)
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index 2fbe868..5cfe322 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -63,6 +63,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
> int depth, void *data);
> extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
> int depth, void *data);
> +extern int early_init_dt_scan_chosen_stdout(void);
> extern void early_init_fdt_scan_reserved_mem(void);
> extern void early_init_fdt_reserve_self(void);
> extern void early_init_dt_add_memory_arch(u64 base, u64 size);
> @@ -91,6 +92,7 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *);
> extern u64 of_flat_dt_translate_address(unsigned long node);
> extern void of_fdt_limit_memory(int limit);
> #else /* CONFIG_OF_FLATTREE */
> +static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; }

Doesn't this change the default logic? Today you are returning 0 if you
don't have this config option set, and now you return -ENODEV, did you
test this out?

thanks,

greg k-h

2016-03-31 17:06:48

by Aleksey Makarov

[permalink] [raw]
Subject: Re: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial



On 03/31/2016 07:32 PM, Greg Kroah-Hartman wrote:
> On Thu, Mar 31, 2016 at 04:40:23PM +0300, Aleksey Makarov wrote:
>> From: Leif Lindholm <[email protected]>
>>
>> We have multiple "earlycon" early_param handlers - merge the DT one into
>> the main earlycon one. It's a cleanup that also will be useful
>> to defer setting up DT console until ACPI/DT decision is made.
>>
>> Rename the exported function to avoid clashing with the function from
>> arch/microblaze/kernel/prom.c
>>
>> Signed-off-by: Leif Lindholm <[email protected]>
>> Signed-off-by: Aleksey Makarov <[email protected]>
>> Acked-by: Rob Herring <[email protected]>
>> ---
>> drivers/of/fdt.c | 11 +----------
>> drivers/tty/serial/earlycon.c | 2 +-
>> include/linux/of_fdt.h | 2 ++
>> 3 files changed, 4 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> index 3349d2a..b50f775 100644
>> --- a/drivers/of/fdt.c
>> +++ b/drivers/of/fdt.c
>> @@ -805,7 +805,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
>>
>> #ifdef CONFIG_SERIAL_EARLYCON
>>
>> -static int __init early_init_dt_scan_chosen_serial(void)
>> +int __init early_init_dt_scan_chosen_stdout(void)
>> {
>> int offset;
>> const char *p, *q, *options = NULL;
>> @@ -849,15 +849,6 @@ static int __init early_init_dt_scan_chosen_serial(void)
>> }
>> return -ENODEV;
>> }
>> -
>> -static int __init setup_of_earlycon(char *buf)
>> -{
>> - if (buf)
>> - return 0;
>> -
>> - return early_init_dt_scan_chosen_serial();
>> -}
>> -early_param("earlycon", setup_of_earlycon);
>> #endif
>>
>> /**
>> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
>> index 067783f..7aae655 100644
>> --- a/drivers/tty/serial/earlycon.c
>> +++ b/drivers/tty/serial/earlycon.c
>> @@ -209,7 +209,7 @@ static int __init param_setup_earlycon(char *buf)
>> * don't generate a warning from parse_early_params() in that case
>> */
>> if (!buf || !buf[0])
>> - return 0;
>> + return early_init_dt_scan_chosen_stdout();
>>
>> err = setup_earlycon(buf);
>> if (err == -ENOENT || err == -EALREADY)
>> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
>> index 2fbe868..5cfe322 100644
>> --- a/include/linux/of_fdt.h
>> +++ b/include/linux/of_fdt.h
>> @@ -63,6 +63,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
>> int depth, void *data);
>> extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
>> int depth, void *data);
>> +extern int early_init_dt_scan_chosen_stdout(void);
>> extern void early_init_fdt_scan_reserved_mem(void);
>> extern void early_init_fdt_reserve_self(void);
>> extern void early_init_dt_add_memory_arch(u64 base, u64 size);
>> @@ -91,6 +92,7 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *);
>> extern u64 of_flat_dt_translate_address(unsigned long node);
>> extern void of_fdt_limit_memory(int limit);
>> #else /* CONFIG_OF_FLATTREE */
>> +static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; }
>
> Doesn't this change the default logic? Today you are returning 0 if you
> don't have this config option set,

I am not sure I understand this. Which return value do you mean?

1. early_init_dt_scan_chosen_stdout()

Today if CONFIG_OF_FLATTREE is not set then early_init_dt_scan_chosen_stdout() does not exist.

2. param_setup_earlycon()

Today we have 2 handlers for "earlycon" option. One (in fdt.c) is for the option without args,
and another (earlycon.c) always expects agrs. But both return 0 for the opposite cases becasue they
can not check what another hander returns.

Now we have just one handler and it can return correct value.

> and now you return -ENODEV, did you
> test this out?

Yes, I tested it.

Thank you
Aleksey Makarov

>
> thanks,
>
> greg k-h
>

2016-03-31 17:37:35

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial

On Thu, Mar 31, 2016 at 08:04:20PM +0300, Aleksey Makarov wrote:
>
>
> On 03/31/2016 07:32 PM, Greg Kroah-Hartman wrote:
> > On Thu, Mar 31, 2016 at 04:40:23PM +0300, Aleksey Makarov wrote:
> >> From: Leif Lindholm <[email protected]>
> >>
> >> We have multiple "earlycon" early_param handlers - merge the DT one into
> >> the main earlycon one. It's a cleanup that also will be useful
> >> to defer setting up DT console until ACPI/DT decision is made.
> >>
> >> Rename the exported function to avoid clashing with the function from
> >> arch/microblaze/kernel/prom.c
> >>
> >> Signed-off-by: Leif Lindholm <[email protected]>
> >> Signed-off-by: Aleksey Makarov <[email protected]>
> >> Acked-by: Rob Herring <[email protected]>
> >> ---
> >> drivers/of/fdt.c | 11 +----------
> >> drivers/tty/serial/earlycon.c | 2 +-
> >> include/linux/of_fdt.h | 2 ++
> >> 3 files changed, 4 insertions(+), 11 deletions(-)
> >>
> >> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> >> index 3349d2a..b50f775 100644
> >> --- a/drivers/of/fdt.c
> >> +++ b/drivers/of/fdt.c
> >> @@ -805,7 +805,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
> >>
> >> #ifdef CONFIG_SERIAL_EARLYCON
> >>
> >> -static int __init early_init_dt_scan_chosen_serial(void)
> >> +int __init early_init_dt_scan_chosen_stdout(void)
> >> {
> >> int offset;
> >> const char *p, *q, *options = NULL;
> >> @@ -849,15 +849,6 @@ static int __init early_init_dt_scan_chosen_serial(void)
> >> }
> >> return -ENODEV;
> >> }
> >> -
> >> -static int __init setup_of_earlycon(char *buf)
> >> -{
> >> - if (buf)
> >> - return 0;
> >> -
> >> - return early_init_dt_scan_chosen_serial();
> >> -}
> >> -early_param("earlycon", setup_of_earlycon);
> >> #endif
> >>
> >> /**
> >> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> >> index 067783f..7aae655 100644
> >> --- a/drivers/tty/serial/earlycon.c
> >> +++ b/drivers/tty/serial/earlycon.c
> >> @@ -209,7 +209,7 @@ static int __init param_setup_earlycon(char *buf)
> >> * don't generate a warning from parse_early_params() in that case
> >> */
> >> if (!buf || !buf[0])
> >> - return 0;
> >> + return early_init_dt_scan_chosen_stdout();
> >>
> >> err = setup_earlycon(buf);
> >> if (err == -ENOENT || err == -EALREADY)
> >> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> >> index 2fbe868..5cfe322 100644
> >> --- a/include/linux/of_fdt.h
> >> +++ b/include/linux/of_fdt.h
> >> @@ -63,6 +63,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
> >> int depth, void *data);
> >> extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
> >> int depth, void *data);
> >> +extern int early_init_dt_scan_chosen_stdout(void);
> >> extern void early_init_fdt_scan_reserved_mem(void);
> >> extern void early_init_fdt_reserve_self(void);
> >> extern void early_init_dt_add_memory_arch(u64 base, u64 size);
> >> @@ -91,6 +92,7 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *);
> >> extern u64 of_flat_dt_translate_address(unsigned long node);
> >> extern void of_fdt_limit_memory(int limit);
> >> #else /* CONFIG_OF_FLATTREE */
> >> +static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; }
> >
> > Doesn't this change the default logic? Today you are returning 0 if you
> > don't have this config option set,
>
> I am not sure I understand this. Which return value do you mean?
>
> 1. early_init_dt_scan_chosen_stdout()
>
> Today if CONFIG_OF_FLATTREE is not set then early_init_dt_scan_chosen_stdout() does not exist.

It "exists" in that you return -ENODEV, right? Look at the place where
you called this function, previously you returned 0, now you return this
function call's return value.

> 2. param_setup_earlycon()
>
> Today we have 2 handlers for "earlycon" option. One (in fdt.c) is for the option without args,
> and another (earlycon.c) always expects agrs. But both return 0 for the opposite cases becasue they
> can not check what another hander returns.
>
> Now we have just one handler and it can return correct value.

I don't understand.

> > and now you return -ENODEV, did you
> > test this out?
>
> Yes, I tested it.

On what platforms? With what configurations?

thanks,

greg k-h

2016-03-31 18:24:04

by Aleksey Makarov

[permalink] [raw]
Subject: Re: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial



On 03/31/2016 08:37 PM, Greg Kroah-Hartman wrote:
> On Thu, Mar 31, 2016 at 08:04:20PM +0300, Aleksey Makarov wrote:
>>
>>
>> On 03/31/2016 07:32 PM, Greg Kroah-Hartman wrote:
>>> On Thu, Mar 31, 2016 at 04:40:23PM +0300, Aleksey Makarov wrote:
>>>> From: Leif Lindholm <[email protected]>
>>>>
>>>> We have multiple "earlycon" early_param handlers - merge the DT one into
>>>> the main earlycon one. It's a cleanup that also will be useful
>>>> to defer setting up DT console until ACPI/DT decision is made.
>>>>
>>>> Rename the exported function to avoid clashing with the function from
>>>> arch/microblaze/kernel/prom.c
>>>>
>>>> Signed-off-by: Leif Lindholm <[email protected]>
>>>> Signed-off-by: Aleksey Makarov <[email protected]>
>>>> Acked-by: Rob Herring <[email protected]>
>>>> ---
>>>> drivers/of/fdt.c | 11 +----------
>>>> drivers/tty/serial/earlycon.c | 2 +-
>>>> include/linux/of_fdt.h | 2 ++
>>>> 3 files changed, 4 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>>>> index 3349d2a..b50f775 100644
>>>> --- a/drivers/of/fdt.c
>>>> +++ b/drivers/of/fdt.c
>>>> @@ -805,7 +805,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
>>>>
>>>> #ifdef CONFIG_SERIAL_EARLYCON
>>>>
>>>> -static int __init early_init_dt_scan_chosen_serial(void)
>>>> +int __init early_init_dt_scan_chosen_stdout(void)
>>>> {
>>>> int offset;
>>>> const char *p, *q, *options = NULL;
>>>> @@ -849,15 +849,6 @@ static int __init early_init_dt_scan_chosen_serial(void)
>>>> }
>>>> return -ENODEV;
>>>> }
>>>> -
>>>> -static int __init setup_of_earlycon(char *buf)
>>>> -{
>>>> - if (buf)
>>>> - return 0;
>>>> -
>>>> - return early_init_dt_scan_chosen_serial();
>>>> -}
>>>> -early_param("earlycon", setup_of_earlycon);
>>>> #endif
>>>>
>>>> /**
>>>> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
>>>> index 067783f..7aae655 100644
>>>> --- a/drivers/tty/serial/earlycon.c
>>>> +++ b/drivers/tty/serial/earlycon.c
>>>> @@ -209,7 +209,7 @@ static int __init param_setup_earlycon(char *buf)
>>>> * don't generate a warning from parse_early_params() in that case
>>>> */
>>>> if (!buf || !buf[0])
>>>> - return 0;
>>>> + return early_init_dt_scan_chosen_stdout();
>>>>
>>>> err = setup_earlycon(buf);
>>>> if (err == -ENOENT || err == -EALREADY)
>>>> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
>>>> index 2fbe868..5cfe322 100644
>>>> --- a/include/linux/of_fdt.h
>>>> +++ b/include/linux/of_fdt.h
>>>> @@ -63,6 +63,7 @@ extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
>>>> int depth, void *data);
>>>> extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
>>>> int depth, void *data);
>>>> +extern int early_init_dt_scan_chosen_stdout(void);
>>>> extern void early_init_fdt_scan_reserved_mem(void);
>>>> extern void early_init_fdt_reserve_self(void);
>>>> extern void early_init_dt_add_memory_arch(u64 base, u64 size);
>>>> @@ -91,6 +92,7 @@ extern void early_get_first_memblock_info(void *, phys_addr_t *);
>>>> extern u64 of_flat_dt_translate_address(unsigned long node);
>>>> extern void of_fdt_limit_memory(int limit);
>>>> #else /* CONFIG_OF_FLATTREE */
>>>> +static inline int early_init_dt_scan_chosen_stdout(void) { return -ENODEV; }
>>>
>>> Doesn't this change the default logic? Today you are returning 0 if you
>>> don't have this config option set,
>>
>> I am not sure I understand this. Which return value do you mean?
>>
>> 1. early_init_dt_scan_chosen_stdout()
>>
>> Today if CONFIG_OF_FLATTREE is not set then early_init_dt_scan_chosen_stdout() does not exist.
>
> It "exists" in that you return -ENODEV, right? Look at the place where
> you called this function,

It's param_setup_earlycon() so see below for explanations.

> previously you returned 0, now you return this
> function call's return value.
>
>> 2. param_setup_earlycon()
>>
>> Today we have 2 handlers for "earlycon" option. One (in fdt.c) is for the option without args,
>> and another (earlycon.c) always expects agrs. But both return 0 for the opposite cases becasue they
>> can not check what another hander returns.
>>
>> Now we have just one handler and it can return correct value.
>
> I don't understand.

This patch deletes early_param("earlycon", setup_of_earlycon) from fdt.c and
keeps early_param("earlycon", param_setup_earlycon) in earlycon.c.

Assume "earlycon" kernel command line parameter was passed without arguments.

Before this patch:

early_init_dt_scan_chosen_stdout() is called from setup_of_earlycon()
where its return value is returned to parse_early_param()

After this patch:

early_init_dt_scan_chosen_stdout() is called from param_setup_earlycon()
so we should return its return value from param_setup_earlycon() if we want
to pass it to parse_early_param().

>>> and now you return -ENODEV, did you
>>> test this out?
>>
>> Yes, I tested it.
>
> On what platforms? With what configurations?

platform: QEMU
configuration options: with/without acpi, dt
command line options: with/without "earlycon", "earlycon=..."

Thank you
Aleksey Makarov

2016-04-04 21:07:42

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial

On 03/31/2016 06:40 AM, Aleksey Makarov wrote:
> From: Leif Lindholm <[email protected]>
>
> We have multiple "earlycon" early_param handlers - merge the DT one into
> the main earlycon one. It's a cleanup that also will be useful
> to defer setting up DT console until ACPI/DT decision is made.
>
> Rename the exported function to avoid clashing with the function from
> arch/microblaze/kernel/prom.c

Reviewed-by: Peter Hurley <[email protected]>

2016-04-04 21:08:51

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v7 5/5] serial: pl011: add console matching function

On 03/31/2016 06:40 AM, Aleksey Makarov wrote:
> This patch adds function pl011_console_match() that implements
> method match of struct console. It allows to match consoles against
> data specified in a string, for example taken from command line or
> compiled by ACPI SPCR table handler.

Reviewed-by: Peter Hurley <[email protected]>

2016-04-04 21:23:52

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v7 3/5] ACPI: parse SPCR and enable matching console

On 03/31/2016 06:40 AM, Aleksey Makarov wrote:
> 'ARM Server Base Boot Requiremets' [1] mentions SPCR (Serial Port
> Console Redirection Table) [2] as a mandatory ACPI table that
> specifies the configuration of serial console.
>
> Defer initialization of DT earlycon until ACPI/DT decision is made.
>
> Parse the ACPI SPCR table, setup earlycon if required,
> enable specified console.
>
> Thanks to Peter Hurley for explaining how this should work.
>
> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx

So for the code:

Reviewed-by: Peter Hurley <[email protected]>



However, I still have concerns regarding the license of this code
as GPL, when the Microsoft patent notice in [2] above only provides
two license options, neither of which are referred to in the
drivers/acpi/spcr.c file header and neither of which (I believe) are
GPL compatible.



> Signed-off-by: Aleksey Makarov <[email protected]>
> ---
> drivers/acpi/Kconfig | 3 ++
> drivers/acpi/Makefile | 1 +
> drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++++
> drivers/tty/serial/earlycon.c | 19 +++++++-
> include/linux/acpi.h | 6 +++
> include/linux/serial_core.h | 6 +++
> 6 files changed, 144 insertions(+), 2 deletions(-)
> create mode 100644 drivers/acpi/spcr.c
>
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index 65fb483..5611eb6 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -77,6 +77,9 @@ config ACPI_DEBUGGER_USER
>
> endif
>
> +config ACPI_SPCR_TABLE
> + bool
> +
> config ACPI_SLEEP
> bool
> depends on SUSPEND || HIBERNATION
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 7395928..f70ae14 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -82,6 +82,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
> obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
> obj-$(CONFIG_ACPI_BGRT) += bgrt.o
> obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o
> +obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o
> obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o
>
> # processor has its own "processor." module_param namespace
> diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
> new file mode 100644
> index 0000000..68ffc33
> --- /dev/null
> +++ b/drivers/acpi/spcr.c
> @@ -0,0 +1,111 @@
> +/*
> + * Copyright (c) 2012, Intel Corporation
> + * Copyright (c) 2015, Red Hat, Inc.
> + * Copyright (c) 2015, 2016 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#define pr_fmt(fmt) "ACPI: SPCR: " fmt
> +
> +#include <linux/acpi.h>
> +#include <linux/console.h>
> +#include <linux/kernel.h>
> +#include <linux/serial_core.h>
> +
> +/**
> + * parse_spcr() - parse ACPI SPCR table and add preferred console
> + *
> + * @earlycon: set up earlycon for the console specified by the table
> + *
> + * For the architectures with support for ACPI, CONFIG_ACPI_SPCR_TABLE may be
> + * defined to parse ACPI SPCR table. As a result of the parsing preferred
> + * console is registered and if @earlycon is true, earlycon is set up.
> + *
> + * When CONFIG_ACPI_SPCR_TABLE is defined, this function should should be called
> + * from arch inintialization code as soon as the DT/ACPI decision is made.
> + *
> + */
> +int __init parse_spcr(bool earlycon)
> +{
> + static char opts[64];
> + struct acpi_table_spcr *table;
> + acpi_size table_size;
> + acpi_status status;
> + char *uart;
> + char *iotype;
> + int baud_rate;
> + int err;
> +
> + if (acpi_disabled)
> + return -ENODEV;
> +
> + status = acpi_get_table_with_size(ACPI_SIG_SPCR, 0,
> + (struct acpi_table_header **)&table,
> + &table_size);
> +
> + if (ACPI_FAILURE(status))
> + return -ENOENT;
> +
> + if (table->header.revision < 2) {
> + err = -ENOENT;
> + pr_err("wrong table version\n");
> + goto done;
> + }
> +
> + iotype = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ?
> + "mmio" : "io";
> +
> + switch (table->interface_type) {
> + case ACPI_DBG2_ARM_SBSA_32BIT:
> + iotype = "mmio32";
> + /* fall through */
> + case ACPI_DBG2_ARM_PL011:
> + case ACPI_DBG2_ARM_SBSA_GENERIC:
> + case ACPI_DBG2_BCM2835:
> + uart = "pl011";
> + break;
> + case ACPI_DBG2_16550_COMPATIBLE:
> + case ACPI_DBG2_16550_SUBSET:
> + uart = "uart";
> + break;
> + default:
> + err = -ENOENT;
> + goto done;
> + }
> +
> + switch (table->baud_rate) {
> + case 3:
> + baud_rate = 9600;
> + break;
> + case 4:
> + baud_rate = 19200;
> + break;
> + case 6:
> + baud_rate = 57600;
> + break;
> + case 7:
> + baud_rate = 115200;
> + break;
> + default:
> + err = -ENOENT;
> + goto done;
> + }
> +
> + snprintf(opts, sizeof(opts), "%s,%s,0x%llx,%d", uart, iotype,
> + table->serial_port.address, baud_rate);
> +
> + pr_info("console: %s", opts);
> +
> + if (earlycon)
> + setup_earlycon(opts);
> +
> + err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
> +
> +done:
> + early_acpi_os_unmap_memory((void __iomem *)table, table_size);
> + return err;
> +}
> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index 7aae655..ea00b9f 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -21,6 +21,7 @@
> #include <linux/sizes.h>
> #include <linux/of.h>
> #include <linux/of_fdt.h>
> +#include <linux/acpi.h>
>
> #ifdef CONFIG_FIX_EARLYCON_MEM
> #include <asm/fixmap.h>
> @@ -199,6 +200,14 @@ int __init setup_earlycon(char *buf)
> return -ENOENT;
> }
>
> +/*
> + * When CONFIG_ACPI_SPCR_TABLE is defined, "earlycon" without parameters in
> + * command line does not start DT earlycon immediately, instead it defers
> + * starting it until DT/ACPI decision is made. At that time if ACPI is enabled
> + * call parse_spcr(), else call early_init_dt_scan_chosen_stdout()
> + */
> +bool earlycon_init_is_deferred __initdata;
> +
> /* early_param wrapper for setup_earlycon() */
> static int __init param_setup_earlycon(char *buf)
> {
> @@ -208,8 +217,14 @@ static int __init param_setup_earlycon(char *buf)
> * Just 'earlycon' is a valid param for devicetree earlycons;
> * don't generate a warning from parse_early_params() in that case
> */
> - if (!buf || !buf[0])
> - return early_init_dt_scan_chosen_stdout();
> + if (!buf || !buf[0]) {
> + if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) {
> + earlycon_init_is_deferred = true;
> + return 0;
> + } else {
> + return early_init_dt_scan_chosen_stdout();
> + }
> + }
>
> err = setup_earlycon(buf);
> if (err == -ENOENT || err == -EALREADY)
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 06ed7e5..1095ed6 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -1004,4 +1004,10 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
> #define acpi_probe_device_table(t) ({ int __r = 0; __r;})
> #endif
>
> +#ifdef CONFIG_ACPI_SPCR_TABLE
> +int parse_spcr(bool earlycon);
> +#else
> +static inline int parse_spcr(bool earlycon) { return 0; }
> +#endif
> +
> #endif /*_LINUX_ACPI_H*/
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index cbfcf38..de6750f 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -363,6 +363,12 @@ extern int of_setup_earlycon(const struct earlycon_id *match,
> unsigned long node,
> const char *options);
>
> +#ifdef CONFIG_SERIAL_EARLYCON
> +extern bool earlycon_init_is_deferred __initdata;
> +#else
> +static const bool earlycon_init_is_deferred;
> +#endif
> +
> struct uart_port *uart_get_console(struct uart_port *ports, int nr,
> struct console *c);
> int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
>

2016-04-05 16:27:54

by Mark Salter

[permalink] [raw]
Subject: Re: [PATCH v7 0/5] ACPI: parse the SPCR table

Could you CC me on future postings of this series, please?

So v3 fixed a problem where platforms using 8250 didn't work.
Then in v5, that fix was lost so 8250 no longer works.

--Mark


On Thu, 2016-03-31 at 16:40 +0300, Aleksey Makarov wrote:
> 'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
> Console Redirection Table) [2] as a mandatory ACPI table that
> specifies the configuration of serial console.
>
> Move "earlycon" early_param handling to earlycon.c to parse this option once
>
> *** PATCH  "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
> *** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next
>
> Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
> for the next patch.  It is taken from ACPICA series [3], but it has not appeared
> in linux-next yet.
>
> Parse SPCR table, setup earlycon and add register specified console.
>
> Enable parsing this table on ARM64.  Earlycon should be set up
> as early as possible.  ACPI boot tables are mapped in
> arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
> and that's where we parse spcr.  So it has to be opted-in per-arch.
>
> Implement console_match() for pl011.
>
> Based on the work by Leif Lindholm [4]
> Thanks to Peter Hurley for explaining how this should work.
>
> Should be applied to next-20160331.
>
> Tested on QEMU.  SPCR support is included in QEMU's ARM mach-virt
> since 2.4 release.
>
> v7:
> - add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
>   to serial"
> - call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
>   (Rafael J. Wysocki)
> - fix a few minor issues (Rafael J. Wysocki)
>
> v6:
> https://lkml.kernel.org/g/[email protected]
> - add documentation for parse_spcr() functioin (Yury Norov)
> - don't initialize err variable (Yury Norov)
> - add __initdata for the earlycon_init_is_deferred flag variable
> - rename the function exported in "of/serial: move earlycon early_param handling
>   to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
> - defer initialization of DT earlycon until DT/ACPI decision is made
>   (Rob Herring, Peter Hurley)
> - use snprintf instead of sprintf (Andy Shevchenko)
> - drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
>   equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley).  This means that
>   SPCR earlycon will not work on the kernels before 4.6
>
> v5:
> https://lkml.kernel.org/g/[email protected]
> - drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
>   it is ugly. Also because Christopher Covington came with a better solution [5]
> - remove error message when the table is not provided by ACPI (Andy Shevchenko)
> - rewrite spcr.c following the suggestions by Peter Hurley
> - add console_match() for pl011 in a separate patch
> - add EARLYCON_DECLARE for pl011 in a separate patch
> - add patch "of/serial: move earlycon early_param handling to serial" from
>   the GDB2 series
>
> v4:
> https://lkml.kernel.org/g/[email protected]
> - drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
>   ACPI developers work on a new API and asked not to do that.
>   Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
>   and cache the result. (Lv Zheng)
> - fix some style issues (Yury Norov)
>
> v3:
> https://lkml.kernel.org/g/[email protected]
>
> Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:
>
> - drop acpi_match() member of struct console
> - drop implementations of this member for pl011 and 8250
> - drop the patch that renames some vars in printk.c as it is not needed anymore
> - drop patch that introduces system wide acpi_table_parse2().
>   Instead introduce a custom acpi_table_parse_spcr() in spcr.c
>
> Instead of introducing a new match_acpi() member of struct console,
> this patchset introduces a new function acpi_console_check().
> This function is called when a new uart is registered at serial_core.c
> the same way OF code checks for console.  If the registered uart is the
> console specified by SPCR table, this function calls add_preferred_console()
>
> The restrictions of this approach are:
>
> - only serial consoles can be set up
> - only consoles specified by the memory/io address can be set up
>   (SPCR can specify devices by PCI id/PCI address)
>
> v2:
> https://lkml.kernel.org/g/[email protected]
> - don't use SPCR if user specified console in command line
> - fix initialization order of newcon->index = 0
> - rename some variables at printk.c (Joe Perches, Peter Hurley)
> - enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
> - remove the retry loop for console registering (Peter Hurley).
>   Instead, obtain SPCR with acpi_get_table().  That works after
>   call to acpi_early_init() i. e. in any *_initcall()
> - describe design decision behind introducing acpi_match() (Peter Hurley)
> - fix compilation for x86 + ACPI (Graeme Gregory)
> - introduce DBG2 constants in a separate patch (Andy Shevchenko)
> - fix a typo in DBG2 constants (Andy Shevchenko)
> - add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
> - add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
> - add documentation for functions
> - add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
>   accessor functions (Christopher Covington)
> - change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
> - introduce acpi_table_parse2() in a separate patch
> - fix fetching the SPCR table early (Mark Salter)
> - add a patch from Mark Salter that introduces support for matching 8250-based
>   consoles
>
> v1:
> https://lkml.kernel.org/g/[email protected]
>
> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
> [3] https://lkml.kernel.org/g/[email protected]
> [4] https://lkml.kernel.org/g/[email protected]
> [5] https://lkml.kernel.org/g/[email protected]
>
> Aleksey Makarov (4):
>   ACPICA: Headers: Add new constants for the DBG2 ACPI table
>   ACPI: parse SPCR and enable matching console
>   ARM64: ACPI: enable ACPI_SPCR_TABLE
>   serial: pl011: add console matching function
>
> Leif Lindholm (1):
>   of/serial: move earlycon early_param handling to serial
>
>  arch/arm64/Kconfig              |   1 +
>  arch/arm64/kernel/acpi.c        |  11 +++-
>  drivers/acpi/Kconfig            |   3 ++
>  drivers/acpi/Makefile           |   1 +
>  drivers/acpi/spcr.c             | 111 ++++++++++++++++++++++++++++++++++++++++
>  drivers/of/fdt.c                |  11 +---
>  drivers/tty/serial/amba-pl011.c |  56 ++++++++++++++++++++
>  drivers/tty/serial/earlycon.c   |  19 ++++++-
>  include/acpi/actbl2.h           |   7 ++-
>  include/linux/acpi.h            |   6 +++
>  include/linux/of_fdt.h          |   2 +
>  include/linux/serial_core.h     |   6 +++
>  12 files changed, 220 insertions(+), 14 deletions(-)
>  create mode 100644 drivers/acpi/spcr.c
>

2016-04-06 10:26:44

by Aleksey Makarov

[permalink] [raw]
Subject: Re: [PATCH v7 0/5] ACPI: parse the SPCR table



On 04/05/2016 07:27 PM, Mark Salter wrote:
> Could you CC me on future postings of this series, please?
>
> So v3 fixed a problem where platforms using 8250 didn't work.
> Then in v5, that fix was lost so 8250 no longer works.

That fix was dropped because now this is implemented differently.
Now the code uses the existing match() member of struct console.
It has already been implemented for 8250.
Probably SPCR table specifies incorrect data.
It was reported that D02 board has similar issue.

Thank you
Aleksey Makarov

>
> --Mark
>
>
> On Thu, 2016-03-31 at 16:40 +0300, Aleksey Makarov wrote:
>> 'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
>> Console Redirection Table) [2] as a mandatory ACPI table that
>> specifies the configuration of serial console.
>>
>> Move "earlycon" early_param handling to earlycon.c to parse this option once
>>
>> *** PATCH "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
>> *** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next
>>
>> Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
>> for the next patch. It is taken from ACPICA series [3], but it has not appeared
>> in linux-next yet.
>>
>> Parse SPCR table, setup earlycon and add register specified console.
>>
>> Enable parsing this table on ARM64. Earlycon should be set up
>> as early as possible. ACPI boot tables are mapped in
>> arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
>> and that's where we parse spcr. So it has to be opted-in per-arch.
>>
>> Implement console_match() for pl011.
>>
>> Based on the work by Leif Lindholm [4]
>> Thanks to Peter Hurley for explaining how this should work.
>>
>> Should be applied to next-20160331.
>>
>> Tested on QEMU. SPCR support is included in QEMU's ARM mach-virt
>> since 2.4 release.
>>
>> v7:
>> - add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
>> to serial"
>> - call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
>> (Rafael J. Wysocki)
>> - fix a few minor issues (Rafael J. Wysocki)
>>
>> v6:
>> https://lkml.kernel.org/g/[email protected]
>> - add documentation for parse_spcr() functioin (Yury Norov)
>> - don't initialize err variable (Yury Norov)
>> - add __initdata for the earlycon_init_is_deferred flag variable
>> - rename the function exported in "of/serial: move earlycon early_param handling
>> to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
>> - defer initialization of DT earlycon until DT/ACPI decision is made
>> (Rob Herring, Peter Hurley)
>> - use snprintf instead of sprintf (Andy Shevchenko)
>> - drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
>> equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley). This means that
>> SPCR earlycon will not work on the kernels before 4.6
>>
>> v5:
>> https://lkml.kernel.org/g/[email protected]
>> - drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
>> it is ugly. Also because Christopher Covington came with a better solution [5]
>> - remove error message when the table is not provided by ACPI (Andy Shevchenko)
>> - rewrite spcr.c following the suggestions by Peter Hurley
>> - add console_match() for pl011 in a separate patch
>> - add EARLYCON_DECLARE for pl011 in a separate patch
>> - add patch "of/serial: move earlycon early_param handling to serial" from
>> the GDB2 series
>>
>> v4:
>> https://lkml.kernel.org/g/[email protected]
>> - drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
>> ACPI developers work on a new API and asked not to do that.
>> Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
>> and cache the result. (Lv Zheng)
>> - fix some style issues (Yury Norov)
>>
>> v3:
>> https://lkml.kernel.org/g/[email protected]
>>
>> Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:
>>
>> - drop acpi_match() member of struct console
>> - drop implementations of this member for pl011 and 8250
>> - drop the patch that renames some vars in printk.c as it is not needed anymore
>> - drop patch that introduces system wide acpi_table_parse2().
>> Instead introduce a custom acpi_table_parse_spcr() in spcr.c
>>
>> Instead of introducing a new match_acpi() member of struct console,
>> this patchset introduces a new function acpi_console_check().
>> This function is called when a new uart is registered at serial_core.c
>> the same way OF code checks for console. If the registered uart is the
>> console specified by SPCR table, this function calls add_preferred_console()
>>
>> The restrictions of this approach are:
>>
>> - only serial consoles can be set up
>> - only consoles specified by the memory/io address can be set up
>> (SPCR can specify devices by PCI id/PCI address)
>>
>> v2:
>> https://lkml.kernel.org/g/[email protected]
>> - don't use SPCR if user specified console in command line
>> - fix initialization order of newcon->index = 0
>> - rename some variables at printk.c (Joe Perches, Peter Hurley)
>> - enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
>> - remove the retry loop for console registering (Peter Hurley).
>> Instead, obtain SPCR with acpi_get_table(). That works after
>> call to acpi_early_init() i. e. in any *_initcall()
>> - describe design decision behind introducing acpi_match() (Peter Hurley)
>> - fix compilation for x86 + ACPI (Graeme Gregory)
>> - introduce DBG2 constants in a separate patch (Andy Shevchenko)
>> - fix a typo in DBG2 constants (Andy Shevchenko)
>> - add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
>> - add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
>> - add documentation for functions
>> - add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
>> accessor functions (Christopher Covington)
>> - change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
>> - introduce acpi_table_parse2() in a separate patch
>> - fix fetching the SPCR table early (Mark Salter)
>> - add a patch from Mark Salter that introduces support for matching 8250-based
>> consoles
>>
>> v1:
>> https://lkml.kernel.org/g/[email protected]
>>
>> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
>> [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
>> [3] https://lkml.kernel.org/g/[email protected]
>> [4] https://lkml.kernel.org/g/[email protected]
>> [5] https://lkml.kernel.org/g/[email protected]
>>
>> Aleksey Makarov (4):
>> ACPICA: Headers: Add new constants for the DBG2 ACPI table
>> ACPI: parse SPCR and enable matching console
>> ARM64: ACPI: enable ACPI_SPCR_TABLE
>> serial: pl011: add console matching function
>>
>> Leif Lindholm (1):
>> of/serial: move earlycon early_param handling to serial
>>
>> arch/arm64/Kconfig | 1 +
>> arch/arm64/kernel/acpi.c | 11 +++-
>> drivers/acpi/Kconfig | 3 ++
>> drivers/acpi/Makefile | 1 +
>> drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++
>> drivers/of/fdt.c | 11 +---
>> drivers/tty/serial/amba-pl011.c | 56 ++++++++++++++++++++
>> drivers/tty/serial/earlycon.c | 19 ++++++-
>> include/acpi/actbl2.h | 7 ++-
>> include/linux/acpi.h | 6 +++
>> include/linux/of_fdt.h | 2 +
>> include/linux/serial_core.h | 6 +++
>> 12 files changed, 220 insertions(+), 14 deletions(-)
>> create mode 100644 drivers/acpi/spcr.c
>>
>

2016-04-06 10:33:37

by Aleksey Makarov

[permalink] [raw]
Subject: Re: [PATCH v7 3/5] ACPI: parse SPCR and enable matching console

Hi Rafael,

May I ask for review/ACK for this new version please?

Thank you
Aleksey Makarov

On 03/31/2016 04:40 PM, Aleksey Makarov wrote:
> 'ARM Server Base Boot Requiremets' [1] mentions SPCR (Serial Port
> Console Redirection Table) [2] as a mandatory ACPI table that
> specifies the configuration of serial console.
>
> Defer initialization of DT earlycon until ACPI/DT decision is made.
>
> Parse the ACPI SPCR table, setup earlycon if required,
> enable specified console.
>
> Thanks to Peter Hurley for explaining how this should work.
>
> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
>
> Signed-off-by: Aleksey Makarov <[email protected]>
> ---
> drivers/acpi/Kconfig | 3 ++
> drivers/acpi/Makefile | 1 +
> drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++++
> drivers/tty/serial/earlycon.c | 19 +++++++-
> include/linux/acpi.h | 6 +++
> include/linux/serial_core.h | 6 +++
> 6 files changed, 144 insertions(+), 2 deletions(-)
> create mode 100644 drivers/acpi/spcr.c
>
> diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
> index 65fb483..5611eb6 100644
> --- a/drivers/acpi/Kconfig
> +++ b/drivers/acpi/Kconfig
> @@ -77,6 +77,9 @@ config ACPI_DEBUGGER_USER
>
> endif
>
> +config ACPI_SPCR_TABLE
> + bool
> +
> config ACPI_SLEEP
> bool
> depends on SUSPEND || HIBERNATION
> diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
> index 7395928..f70ae14 100644
> --- a/drivers/acpi/Makefile
> +++ b/drivers/acpi/Makefile
> @@ -82,6 +82,7 @@ obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o
> obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
> obj-$(CONFIG_ACPI_BGRT) += bgrt.o
> obj-$(CONFIG_ACPI_CPPC_LIB) += cppc_acpi.o
> +obj-$(CONFIG_ACPI_SPCR_TABLE) += spcr.o
> obj-$(CONFIG_ACPI_DEBUGGER_USER) += acpi_dbg.o
>
> # processor has its own "processor." module_param namespace
> diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
> new file mode 100644
> index 0000000..68ffc33
> --- /dev/null
> +++ b/drivers/acpi/spcr.c
> @@ -0,0 +1,111 @@
> +/*
> + * Copyright (c) 2012, Intel Corporation
> + * Copyright (c) 2015, Red Hat, Inc.
> + * Copyright (c) 2015, 2016 Linaro Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + */
> +
> +#define pr_fmt(fmt) "ACPI: SPCR: " fmt
> +
> +#include <linux/acpi.h>
> +#include <linux/console.h>
> +#include <linux/kernel.h>
> +#include <linux/serial_core.h>
> +
> +/**
> + * parse_spcr() - parse ACPI SPCR table and add preferred console
> + *
> + * @earlycon: set up earlycon for the console specified by the table
> + *
> + * For the architectures with support for ACPI, CONFIG_ACPI_SPCR_TABLE may be
> + * defined to parse ACPI SPCR table. As a result of the parsing preferred
> + * console is registered and if @earlycon is true, earlycon is set up.
> + *
> + * When CONFIG_ACPI_SPCR_TABLE is defined, this function should should be called
> + * from arch inintialization code as soon as the DT/ACPI decision is made.
> + *
> + */
> +int __init parse_spcr(bool earlycon)
> +{
> + static char opts[64];
> + struct acpi_table_spcr *table;
> + acpi_size table_size;
> + acpi_status status;
> + char *uart;
> + char *iotype;
> + int baud_rate;
> + int err;
> +
> + if (acpi_disabled)
> + return -ENODEV;
> +
> + status = acpi_get_table_with_size(ACPI_SIG_SPCR, 0,
> + (struct acpi_table_header **)&table,
> + &table_size);
> +
> + if (ACPI_FAILURE(status))
> + return -ENOENT;
> +
> + if (table->header.revision < 2) {
> + err = -ENOENT;
> + pr_err("wrong table version\n");
> + goto done;
> + }
> +
> + iotype = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ?
> + "mmio" : "io";
> +
> + switch (table->interface_type) {
> + case ACPI_DBG2_ARM_SBSA_32BIT:
> + iotype = "mmio32";
> + /* fall through */
> + case ACPI_DBG2_ARM_PL011:
> + case ACPI_DBG2_ARM_SBSA_GENERIC:
> + case ACPI_DBG2_BCM2835:
> + uart = "pl011";
> + break;
> + case ACPI_DBG2_16550_COMPATIBLE:
> + case ACPI_DBG2_16550_SUBSET:
> + uart = "uart";
> + break;
> + default:
> + err = -ENOENT;
> + goto done;
> + }
> +
> + switch (table->baud_rate) {
> + case 3:
> + baud_rate = 9600;
> + break;
> + case 4:
> + baud_rate = 19200;
> + break;
> + case 6:
> + baud_rate = 57600;
> + break;
> + case 7:
> + baud_rate = 115200;
> + break;
> + default:
> + err = -ENOENT;
> + goto done;
> + }
> +
> + snprintf(opts, sizeof(opts), "%s,%s,0x%llx,%d", uart, iotype,
> + table->serial_port.address, baud_rate);
> +
> + pr_info("console: %s", opts);
> +
> + if (earlycon)
> + setup_earlycon(opts);
> +
> + err = add_preferred_console(uart, 0, opts + strlen(uart) + 1);
> +
> +done:
> + early_acpi_os_unmap_memory((void __iomem *)table, table_size);
> + return err;
> +}
> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index 7aae655..ea00b9f 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -21,6 +21,7 @@
> #include <linux/sizes.h>
> #include <linux/of.h>
> #include <linux/of_fdt.h>
> +#include <linux/acpi.h>
>
> #ifdef CONFIG_FIX_EARLYCON_MEM
> #include <asm/fixmap.h>
> @@ -199,6 +200,14 @@ int __init setup_earlycon(char *buf)
> return -ENOENT;
> }
>
> +/*
> + * When CONFIG_ACPI_SPCR_TABLE is defined, "earlycon" without parameters in
> + * command line does not start DT earlycon immediately, instead it defers
> + * starting it until DT/ACPI decision is made. At that time if ACPI is enabled
> + * call parse_spcr(), else call early_init_dt_scan_chosen_stdout()
> + */
> +bool earlycon_init_is_deferred __initdata;
> +
> /* early_param wrapper for setup_earlycon() */
> static int __init param_setup_earlycon(char *buf)
> {
> @@ -208,8 +217,14 @@ static int __init param_setup_earlycon(char *buf)
> * Just 'earlycon' is a valid param for devicetree earlycons;
> * don't generate a warning from parse_early_params() in that case
> */
> - if (!buf || !buf[0])
> - return early_init_dt_scan_chosen_stdout();
> + if (!buf || !buf[0]) {
> + if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) {
> + earlycon_init_is_deferred = true;
> + return 0;
> + } else {
> + return early_init_dt_scan_chosen_stdout();
> + }
> + }
>
> err = setup_earlycon(buf);
> if (err == -ENOENT || err == -EALREADY)
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 06ed7e5..1095ed6 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -1004,4 +1004,10 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
> #define acpi_probe_device_table(t) ({ int __r = 0; __r;})
> #endif
>
> +#ifdef CONFIG_ACPI_SPCR_TABLE
> +int parse_spcr(bool earlycon);
> +#else
> +static inline int parse_spcr(bool earlycon) { return 0; }
> +#endif
> +
> #endif /*_LINUX_ACPI_H*/
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index cbfcf38..de6750f 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -363,6 +363,12 @@ extern int of_setup_earlycon(const struct earlycon_id *match,
> unsigned long node,
> const char *options);
>
> +#ifdef CONFIG_SERIAL_EARLYCON
> +extern bool earlycon_init_is_deferred __initdata;
> +#else
> +static const bool earlycon_init_is_deferred;
> +#endif
> +
> struct uart_port *uart_get_console(struct uart_port *ports, int nr,
> struct console *c);
> int uart_parse_earlycon(char *p, unsigned char *iotype, unsigned long *addr,
>

2016-04-06 10:53:01

by Graeme Gregory

[permalink] [raw]
Subject: Re: [PATCH v7 0/5] ACPI: parse the SPCR table

On Wed, Apr 06, 2016 at 01:24:12PM +0300, Aleksey Makarov wrote:
>
>
> On 04/05/2016 07:27 PM, Mark Salter wrote:
> > Could you CC me on future postings of this series, please?
> >
> > So v3 fixed a problem where platforms using 8250 didn't work.
> > Then in v5, that fix was lost so 8250 no longer works.
>
> That fix was dropped because now this is implemented differently.
> Now the code uses the existing match() member of struct console.
> It has already been implemented for 8250.
> Probably SPCR table specifies incorrect data.
> It was reported that D02 board has similar issue.
>

The D02 issue referred to is the 8250 implementation they used has 32bit
only MMIO access which there is no manner to represent in SPCR. It also
doesn't use the "standard" 16550 clock rate so supplying a baud rate
makes it change to a random baud rate.

We may need two 8250 subset entries, one just means no clock given, and
one no clock given + mmio32 only.

Graeme


> Thank you
> Aleksey Makarov
>
> >
> > --Mark
> >
> >
> > On Thu, 2016-03-31 at 16:40 +0300, Aleksey Makarov wrote:
> >> 'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
> >> Console Redirection Table) [2] as a mandatory ACPI table that
> >> specifies the configuration of serial console.
> >>
> >> Move "earlycon" early_param handling to earlycon.c to parse this option once
> >>
> >> *** PATCH "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
> >> *** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next
> >>
> >> Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
> >> for the next patch. It is taken from ACPICA series [3], but it has not appeared
> >> in linux-next yet.
> >>
> >> Parse SPCR table, setup earlycon and add register specified console.
> >>
> >> Enable parsing this table on ARM64. Earlycon should be set up
> >> as early as possible. ACPI boot tables are mapped in
> >> arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
> >> and that's where we parse spcr. So it has to be opted-in per-arch.
> >>
> >> Implement console_match() for pl011.
> >>
> >> Based on the work by Leif Lindholm [4]
> >> Thanks to Peter Hurley for explaining how this should work.
> >>
> >> Should be applied to next-20160331.
> >>
> >> Tested on QEMU. SPCR support is included in QEMU's ARM mach-virt
> >> since 2.4 release.
> >>
> >> v7:
> >> - add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
> >> to serial"
> >> - call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
> >> (Rafael J. Wysocki)
> >> - fix a few minor issues (Rafael J. Wysocki)
> >>
> >> v6:
> >> https://lkml.kernel.org/g/[email protected]
> >> - add documentation for parse_spcr() functioin (Yury Norov)
> >> - don't initialize err variable (Yury Norov)
> >> - add __initdata for the earlycon_init_is_deferred flag variable
> >> - rename the function exported in "of/serial: move earlycon early_param handling
> >> to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
> >> - defer initialization of DT earlycon until DT/ACPI decision is made
> >> (Rob Herring, Peter Hurley)
> >> - use snprintf instead of sprintf (Andy Shevchenko)
> >> - drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
> >> equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley). This means that
> >> SPCR earlycon will not work on the kernels before 4.6
> >>
> >> v5:
> >> https://lkml.kernel.org/g/[email protected]
> >> - drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
> >> it is ugly. Also because Christopher Covington came with a better solution [5]
> >> - remove error message when the table is not provided by ACPI (Andy Shevchenko)
> >> - rewrite spcr.c following the suggestions by Peter Hurley
> >> - add console_match() for pl011 in a separate patch
> >> - add EARLYCON_DECLARE for pl011 in a separate patch
> >> - add patch "of/serial: move earlycon early_param handling to serial" from
> >> the GDB2 series
> >>
> >> v4:
> >> https://lkml.kernel.org/g/[email protected]
> >> - drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
> >> ACPI developers work on a new API and asked not to do that.
> >> Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
> >> and cache the result. (Lv Zheng)
> >> - fix some style issues (Yury Norov)
> >>
> >> v3:
> >> https://lkml.kernel.org/g/[email protected]
> >>
> >> Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:
> >>
> >> - drop acpi_match() member of struct console
> >> - drop implementations of this member for pl011 and 8250
> >> - drop the patch that renames some vars in printk.c as it is not needed anymore
> >> - drop patch that introduces system wide acpi_table_parse2().
> >> Instead introduce a custom acpi_table_parse_spcr() in spcr.c
> >>
> >> Instead of introducing a new match_acpi() member of struct console,
> >> this patchset introduces a new function acpi_console_check().
> >> This function is called when a new uart is registered at serial_core.c
> >> the same way OF code checks for console. If the registered uart is the
> >> console specified by SPCR table, this function calls add_preferred_console()
> >>
> >> The restrictions of this approach are:
> >>
> >> - only serial consoles can be set up
> >> - only consoles specified by the memory/io address can be set up
> >> (SPCR can specify devices by PCI id/PCI address)
> >>
> >> v2:
> >> https://lkml.kernel.org/g/[email protected]
> >> - don't use SPCR if user specified console in command line
> >> - fix initialization order of newcon->index = 0
> >> - rename some variables at printk.c (Joe Perches, Peter Hurley)
> >> - enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
> >> - remove the retry loop for console registering (Peter Hurley).
> >> Instead, obtain SPCR with acpi_get_table(). That works after
> >> call to acpi_early_init() i. e. in any *_initcall()
> >> - describe design decision behind introducing acpi_match() (Peter Hurley)
> >> - fix compilation for x86 + ACPI (Graeme Gregory)
> >> - introduce DBG2 constants in a separate patch (Andy Shevchenko)
> >> - fix a typo in DBG2 constants (Andy Shevchenko)
> >> - add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
> >> - add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
> >> - add documentation for functions
> >> - add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
> >> accessor functions (Christopher Covington)
> >> - change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
> >> - introduce acpi_table_parse2() in a separate patch
> >> - fix fetching the SPCR table early (Mark Salter)
> >> - add a patch from Mark Salter that introduces support for matching 8250-based
> >> consoles
> >>
> >> v1:
> >> https://lkml.kernel.org/g/[email protected]
> >>
> >> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> >> [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
> >> [3] https://lkml.kernel.org/g/[email protected]
> >> [4] https://lkml.kernel.org/g/[email protected]
> >> [5] https://lkml.kernel.org/g/[email protected]
> >>
> >> Aleksey Makarov (4):
> >> ACPICA: Headers: Add new constants for the DBG2 ACPI table
> >> ACPI: parse SPCR and enable matching console
> >> ARM64: ACPI: enable ACPI_SPCR_TABLE
> >> serial: pl011: add console matching function
> >>
> >> Leif Lindholm (1):
> >> of/serial: move earlycon early_param handling to serial
> >>
> >> arch/arm64/Kconfig | 1 +
> >> arch/arm64/kernel/acpi.c | 11 +++-
> >> drivers/acpi/Kconfig | 3 ++
> >> drivers/acpi/Makefile | 1 +
> >> drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++
> >> drivers/of/fdt.c | 11 +---
> >> drivers/tty/serial/amba-pl011.c | 56 ++++++++++++++++++++
> >> drivers/tty/serial/earlycon.c | 19 ++++++-
> >> include/acpi/actbl2.h | 7 ++-
> >> include/linux/acpi.h | 6 +++
> >> include/linux/of_fdt.h | 2 +
> >> include/linux/serial_core.h | 6 +++
> >> 12 files changed, 220 insertions(+), 14 deletions(-)
> >> create mode 100644 drivers/acpi/spcr.c
> >>
> >
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2016-04-06 14:18:27

by Mark Salter

[permalink] [raw]
Subject: Re: [PATCH v7 0/5] ACPI: parse the SPCR table

On Wed, 2016-04-06 at 11:52 +0100, Graeme Gregory wrote:
> On Wed, Apr 06, 2016 at 01:24:12PM +0300, Aleksey Makarov wrote:
> >
> >
> >
> > On 04/05/2016 07:27 PM, Mark Salter wrote:
> > >
> > > Could you CC me on future postings of this series, please?
> > >
> > > So v3 fixed a problem where platforms using 8250 didn't work.
> > > Then in v5, that fix was lost so 8250 no longer works.
> > That fix was dropped because now this is implemented differently.  
> > Now the code uses the existing match() member of struct console.
> > It has already been implemented for 8250.  
> > Probably SPCR table specifies incorrect data.
> > It was reported that D02 board has similar issue.
> >
> The D02 issue referred to is the 8250 implementation they used has 32bit
> only MMIO access which there is no manner to represent in SPCR. It also
> doesn't use the "standard" 16550 clock rate so supplying a baud rate
> makes it change to a random baud rate.

So, the problem with Mustang and m400 was the mmio vs mmio32. Right now,
the kernel only supports mmio32 in the 8250_dw.c driver when probed with
ACPI. Other x86 machines just use legacy 8250 ports which don't need
entries in the DSDT and use legacy io. The 8250_dw driver does support
non-standard clocks specified in the DSDT. That works fine for Mustang
and m400.

So with this quick hack, v7 is working with Mustang/m400:

diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
index 68ffc33..dade9de 100644
--- a/drivers/acpi/spcr.c
+++ b/drivers/acpi/spcr.c
@@ -37,6 +37,7 @@ int __init parse_spcr(bool earlycon)
  acpi_status status;
  char *uart;
  char *iotype;
+ int mmio;
  int baud_rate;
  int err;
 
@@ -56,8 +57,8 @@ int __init parse_spcr(bool earlycon)
  goto done;
  }
 
- iotype = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ?
- "mmio" : "io";
+ mmio = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY;
+ iotype = mmio ? "mmio" : "io";
 
  switch (table->interface_type) {
  case ACPI_DBG2_ARM_SBSA_32BIT:
@@ -71,6 +72,8 @@ int __init parse_spcr(bool earlycon)
  case ACPI_DBG2_16550_COMPATIBLE:
  case ACPI_DBG2_16550_SUBSET:
  uart = "uart";
+ if (mmio)
+ iotype = "mmio32";
  break;
  default:
  err = -ENOENT;

>
> We may need two 8250 subset entries, one just means no clock given, and
> one no clock given + mmio32 only.
>
> Graeme
>
>
> >
> > Thank you
> > Aleksey Makarov
> >
> > >
> > >
> > > --Mark
> > >
> > >
> > > On Thu, 2016-03-31 at 16:40 +0300, Aleksey Makarov wrote:
> > > >
> > > > 'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
> > > > Console Redirection Table) [2] as a mandatory ACPI table that
> > > > specifies the configuration of serial console.
> > > >
> > > > Move "earlycon" early_param handling to earlycon.c to parse this option once
> > > >
> > > > *** PATCH  "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
> > > > *** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next
> > > >
> > > > Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
> > > > for the next patch.  It is taken from ACPICA series [3], but it has not appeared
> > > > in linux-next yet.
> > > >
> > > > Parse SPCR table, setup earlycon and add register specified console.
> > > >
> > > > Enable parsing this table on ARM64.  Earlycon should be set up
> > > > as early as possible.  ACPI boot tables are mapped in
> > > > arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
> > > > and that's where we parse spcr.  So it has to be opted-in per-arch.
> > > >
> > > > Implement console_match() for pl011.
> > > >
> > > > Based on the work by Leif Lindholm [4]
> > > > Thanks to Peter Hurley for explaining how this should work.
> > > >
> > > > Should be applied to next-20160331.
> > > >
> > > > Tested on QEMU.  SPCR support is included in QEMU's ARM mach-virt
> > > > since 2.4 release.
> > > >
> > > > v7:
> > > > - add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
> > > >   to serial"
> > > > - call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
> > > >   (Rafael J. Wysocki)
> > > > - fix a few minor issues (Rafael J. Wysocki)
> > > >
> > > > v6:
> > > > https://lkml.kernel.org/g/[email protected]
> > > > - add documentation for parse_spcr() functioin (Yury Norov)
> > > > - don't initialize err variable (Yury Norov)
> > > > - add __initdata for the earlycon_init_is_deferred flag variable
> > > > - rename the function exported in "of/serial: move earlycon early_param handling
> > > >   to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
> > > > - defer initialization of DT earlycon until DT/ACPI decision is made
> > > >   (Rob Herring, Peter Hurley)
> > > > - use snprintf instead of sprintf (Andy Shevchenko)
> > > > - drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
> > > >   equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley).  This means that
> > > >   SPCR earlycon will not work on the kernels before 4.6
> > > >
> > > > v5:
> > > > https://lkml.kernel.org/g/[email protected]
> > > > - drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
> > > >   it is ugly. Also because Christopher Covington came with a better solution [5]
> > > > - remove error message when the table is not provided by ACPI (Andy Shevchenko)
> > > > - rewrite spcr.c following the suggestions by Peter Hurley
> > > > - add console_match() for pl011 in a separate patch
> > > > - add EARLYCON_DECLARE for pl011 in a separate patch
> > > > - add patch "of/serial: move earlycon early_param handling to serial" from
> > > >   the GDB2 series
> > > >
> > > > v4:
> > > > https://lkml.kernel.org/g/[email protected]
> > > > - drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
> > > >   ACPI developers work on a new API and asked not to do that.
> > > >   Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
> > > >   and cache the result. (Lv Zheng)
> > > > - fix some style issues (Yury Norov)
> > > >
> > > > v3:
> > > > https://lkml.kernel.org/g/[email protected]
> > > >
> > > > Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:
> > > >
> > > > - drop acpi_match() member of struct console
> > > > - drop implementations of this member for pl011 and 8250
> > > > - drop the patch that renames some vars in printk.c as it is not needed anymore
> > > > - drop patch that introduces system wide acpi_table_parse2().
> > > >   Instead introduce a custom acpi_table_parse_spcr() in spcr.c
> > > >
> > > > Instead of introducing a new match_acpi() member of struct console,
> > > > this patchset introduces a new function acpi_console_check().
> > > > This function is called when a new uart is registered at serial_core.c
> > > > the same way OF code checks for console.  If the registered uart is the
> > > > console specified by SPCR table, this function calls add_preferred_console()
> > > >
> > > > The restrictions of this approach are:
> > > >
> > > > - only serial consoles can be set up
> > > > - only consoles specified by the memory/io address can be set up
> > > >   (SPCR can specify devices by PCI id/PCI address)
> > > >
> > > > v2:
> > > > https://lkml.kernel.org/g/[email protected]
> > > > - don't use SPCR if user specified console in command line
> > > > - fix initialization order of newcon->index = 0
> > > > - rename some variables at printk.c (Joe Perches, Peter Hurley)
> > > > - enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
> > > > - remove the retry loop for console registering (Peter Hurley).
> > > >   Instead, obtain SPCR with acpi_get_table().  That works after
> > > >   call to acpi_early_init() i. e. in any *_initcall()
> > > > - describe design decision behind introducing acpi_match() (Peter Hurley)
> > > > - fix compilation for x86 + ACPI (Graeme Gregory)
> > > > - introduce DBG2 constants in a separate patch (Andy Shevchenko)
> > > > - fix a typo in DBG2 constants (Andy Shevchenko)
> > > > - add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
> > > > - add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
> > > > - add documentation for functions
> > > > - add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
> > > >   accessor functions (Christopher Covington)
> > > > - change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
> > > > - introduce acpi_table_parse2() in a separate patch
> > > > - fix fetching the SPCR table early (Mark Salter)
> > > > - add a patch from Mark Salter that introduces support for matching 8250-based
> > > >   consoles
> > > >
> > > > v1:
> > > > https://lkml.kernel.org/g/[email protected]
> > > >
> > > > [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> > > > [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
> > > > [3] https://lkml.kernel.org/g/[email protected]
> > > > [4] https://lkml.kernel.org/g/[email protected]
> > > > [5] https://lkml.kernel.org/g/[email protected]
> > > >
> > > > Aleksey Makarov (4):
> > > >   ACPICA: Headers: Add new constants for the DBG2 ACPI table
> > > >   ACPI: parse SPCR and enable matching console
> > > >   ARM64: ACPI: enable ACPI_SPCR_TABLE
> > > >   serial: pl011: add console matching function
> > > >
> > > > Leif Lindholm (1):
> > > >   of/serial: move earlycon early_param handling to serial
> > > >
> > > >  arch/arm64/Kconfig              |   1 +
> > > >  arch/arm64/kernel/acpi.c        |  11 +++-
> > > >  drivers/acpi/Kconfig            |   3 ++
> > > >  drivers/acpi/Makefile           |   1 +
> > > >  drivers/acpi/spcr.c             | 111 ++++++++++++++++++++++++++++++++++++++++
> > > >  drivers/of/fdt.c                |  11 +---
> > > >  drivers/tty/serial/amba-pl011.c |  56 ++++++++++++++++++++
> > > >  drivers/tty/serial/earlycon.c   |  19 ++++++-
> > > >  include/acpi/actbl2.h           |   7 ++-
> > > >  include/linux/acpi.h            |   6 +++
> > > >  include/linux/of_fdt.h          |   2 +
> > > >  include/linux/serial_core.h     |   6 +++
> > > >  12 files changed, 220 insertions(+), 14 deletions(-)
> > > >  create mode 100644 drivers/acpi/spcr.c
> > > >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > [email protected]
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2016-04-06 16:27:37

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v7 0/5] ACPI: parse the SPCR table

On 04/06/2016 07:18 AM, Mark Salter wrote:
> On Wed, 2016-04-06 at 11:52 +0100, Graeme Gregory wrote:
>> On Wed, Apr 06, 2016 at 01:24:12PM +0300, Aleksey Makarov wrote:
>>>
>>>
>>>
>>> On 04/05/2016 07:27 PM, Mark Salter wrote:
>>>>
>>>> Could you CC me on future postings of this series, please?
>>>>
>>>> So v3 fixed a problem where platforms using 8250 didn't work.
>>>> Then in v5, that fix was lost so 8250 no longer works.
>>> That fix was dropped because now this is implemented differently.
>>> Now the code uses the existing match() member of struct console.
>>> It has already been implemented for 8250.
>>> Probably SPCR table specifies incorrect data.
>>> It was reported that D02 board has similar issue.
>>>
>> The D02 issue referred to is the 8250 implementation they used has 32bit
>> only MMIO access which there is no manner to represent in SPCR. It also
>> doesn't use the "standard" 16550 clock rate so supplying a baud rate
>> makes it change to a random baud rate.
>
> So, the problem with Mustang and m400 was the mmio vs mmio32.

Bummer. Maybe that firmware can use a different DBG2 port designation to
indicate it's a DesignWare 8250 (or generically 32-bit mmio).


> Right now,
> the kernel only supports mmio32 in the 8250_dw.c driver when probed with
> ACPI.

While that's true specifically for DesignWare 8250 + ACPI, that's not
true for _all_ 8250 + ACPI.


> Other x86 machines just use legacy 8250 ports which don't need
> entries in the DSDT and use legacy io.

I find that statement hard to believe. I know for a fact ia64 servers didn't,
so the assertion that SPCR + 16550 + MMIO automatically means 32-bit data width
seems unlikely.

In fact, I suspect the opposite is true; that before these arm64 designs,
SPCR + 16550 + MMIO automatically meant 8-bit data width, which is why it's
unspecified in the SPCR table.

Regards,
Peter Hurley


> The 8250_dw driver does support
> non-standard clocks specified in the DSDT. That works fine for Mustang
> and m400.
>
> So with this quick hack, v7 is working with Mustang/m400:
>
> diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
> index 68ffc33..dade9de 100644
> --- a/drivers/acpi/spcr.c
> +++ b/drivers/acpi/spcr.c
> @@ -37,6 +37,7 @@ int __init parse_spcr(bool earlycon)
> acpi_status status;
> char *uart;
> char *iotype;
> + int mmio;
> int baud_rate;
> int err;
>
> @@ -56,8 +57,8 @@ int __init parse_spcr(bool earlycon)
> goto done;
> }
>
> - iotype = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ?
> - "mmio" : "io";
> + mmio = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY;
> + iotype = mmio ? "mmio" : "io";
>
> switch (table->interface_type) {
> case ACPI_DBG2_ARM_SBSA_32BIT:
> @@ -71,6 +72,8 @@ int __init parse_spcr(bool earlycon)
> case ACPI_DBG2_16550_COMPATIBLE:
> case ACPI_DBG2_16550_SUBSET:
> uart = "uart";
> + if (mmio)
> + iotype = "mmio32";
> break;
> default:
> err = -ENOENT;
>
>>
>> We may need two 8250 subset entries, one just means no clock given, and
>> one no clock given + mmio32 only.
>>
>> Graeme
>>
>>
>>>
>>> Thank you
>>> Aleksey Makarov
>>>
>>>>
>>>>
>>>> --Mark
>>>>
>>>>
>>>> On Thu, 2016-03-31 at 16:40 +0300, Aleksey Makarov wrote:
>>>>>
>>>>> 'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
>>>>> Console Redirection Table) [2] as a mandatory ACPI table that
>>>>> specifies the configuration of serial console.
>>>>>
>>>>> Move "earlycon" early_param handling to earlycon.c to parse this option once
>>>>>
>>>>> *** PATCH "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
>>>>> *** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next
>>>>>
>>>>> Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
>>>>> for the next patch. It is taken from ACPICA series [3], but it has not appeared
>>>>> in linux-next yet.
>>>>>
>>>>> Parse SPCR table, setup earlycon and add register specified console.
>>>>>
>>>>> Enable parsing this table on ARM64. Earlycon should be set up
>>>>> as early as possible. ACPI boot tables are mapped in
>>>>> arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
>>>>> and that's where we parse spcr. So it has to be opted-in per-arch.
>>>>>
>>>>> Implement console_match() for pl011.
>>>>>
>>>>> Based on the work by Leif Lindholm [4]
>>>>> Thanks to Peter Hurley for explaining how this should work.
>>>>>
>>>>> Should be applied to next-20160331.
>>>>>
>>>>> Tested on QEMU. SPCR support is included in QEMU's ARM mach-virt
>>>>> since 2.4 release.
>>>>>
>>>>> v7:
>>>>> - add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
>>>>> to serial"
>>>>> - call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
>>>>> (Rafael J. Wysocki)
>>>>> - fix a few minor issues (Rafael J. Wysocki)
>>>>>
>>>>> v6:
>>>>> https://lkml.kernel.org/g/[email protected]
>>>>> - add documentation for parse_spcr() functioin (Yury Norov)
>>>>> - don't initialize err variable (Yury Norov)
>>>>> - add __initdata for the earlycon_init_is_deferred flag variable
>>>>> - rename the function exported in "of/serial: move earlycon early_param handling
>>>>> to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
>>>>> - defer initialization of DT earlycon until DT/ACPI decision is made
>>>>> (Rob Herring, Peter Hurley)
>>>>> - use snprintf instead of sprintf (Andy Shevchenko)
>>>>> - drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
>>>>> equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley). This means that
>>>>> SPCR earlycon will not work on the kernels before 4.6
>>>>>
>>>>> v5:
>>>>> https://lkml.kernel.org/g/[email protected]
>>>>> - drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
>>>>> it is ugly. Also because Christopher Covington came with a better solution [5]
>>>>> - remove error message when the table is not provided by ACPI (Andy Shevchenko)
>>>>> - rewrite spcr.c following the suggestions by Peter Hurley
>>>>> - add console_match() for pl011 in a separate patch
>>>>> - add EARLYCON_DECLARE for pl011 in a separate patch
>>>>> - add patch "of/serial: move earlycon early_param handling to serial" from
>>>>> the GDB2 series
>>>>>
>>>>> v4:
>>>>> https://lkml.kernel.org/g/[email protected]
>>>>> - drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
>>>>> ACPI developers work on a new API and asked not to do that.
>>>>> Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
>>>>> and cache the result. (Lv Zheng)
>>>>> - fix some style issues (Yury Norov)
>>>>>
>>>>> v3:
>>>>> https://lkml.kernel.org/g/[email protected]
>>>>>
>>>>> Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:
>>>>>
>>>>> - drop acpi_match() member of struct console
>>>>> - drop implementations of this member for pl011 and 8250
>>>>> - drop the patch that renames some vars in printk.c as it is not needed anymore
>>>>> - drop patch that introduces system wide acpi_table_parse2().
>>>>> Instead introduce a custom acpi_table_parse_spcr() in spcr.c
>>>>>
>>>>> Instead of introducing a new match_acpi() member of struct console,
>>>>> this patchset introduces a new function acpi_console_check().
>>>>> This function is called when a new uart is registered at serial_core.c
>>>>> the same way OF code checks for console. If the registered uart is the
>>>>> console specified by SPCR table, this function calls add_preferred_console()
>>>>>
>>>>> The restrictions of this approach are:
>>>>>
>>>>> - only serial consoles can be set up
>>>>> - only consoles specified by the memory/io address can be set up
>>>>> (SPCR can specify devices by PCI id/PCI address)
>>>>>
>>>>> v2:
>>>>> https://lkml.kernel.org/g/[email protected]
>>>>> - don't use SPCR if user specified console in command line
>>>>> - fix initialization order of newcon->index = 0
>>>>> - rename some variables at printk.c (Joe Perches, Peter Hurley)
>>>>> - enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
>>>>> - remove the retry loop for console registering (Peter Hurley).
>>>>> Instead, obtain SPCR with acpi_get_table(). That works after
>>>>> call to acpi_early_init() i. e. in any *_initcall()
>>>>> - describe design decision behind introducing acpi_match() (Peter Hurley)
>>>>> - fix compilation for x86 + ACPI (Graeme Gregory)
>>>>> - introduce DBG2 constants in a separate patch (Andy Shevchenko)
>>>>> - fix a typo in DBG2 constants (Andy Shevchenko)
>>>>> - add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
>>>>> - add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
>>>>> - add documentation for functions
>>>>> - add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
>>>>> accessor functions (Christopher Covington)
>>>>> - change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
>>>>> - introduce acpi_table_parse2() in a separate patch
>>>>> - fix fetching the SPCR table early (Mark Salter)
>>>>> - add a patch from Mark Salter that introduces support for matching 8250-based
>>>>> consoles
>>>>>
>>>>> v1:
>>>>> https://lkml.kernel.org/g/[email protected]
>>>>>
>>>>> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
>>>>> [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
>>>>> [3] https://lkml.kernel.org/g/[email protected]
>>>>> [4] https://lkml.kernel.org/g/[email protected]
>>>>> [5] https://lkml.kernel.org/g/[email protected]
>>>>>
>>>>> Aleksey Makarov (4):
>>>>> ACPICA: Headers: Add new constants for the DBG2 ACPI table
>>>>> ACPI: parse SPCR and enable matching console
>>>>> ARM64: ACPI: enable ACPI_SPCR_TABLE
>>>>> serial: pl011: add console matching function
>>>>>
>>>>> Leif Lindholm (1):
>>>>> of/serial: move earlycon early_param handling to serial
>>>>>
>>>>> arch/arm64/Kconfig | 1 +
>>>>> arch/arm64/kernel/acpi.c | 11 +++-
>>>>> drivers/acpi/Kconfig | 3 ++
>>>>> drivers/acpi/Makefile | 1 +
>>>>> drivers/acpi/spcr.c | 111 ++++++++++++++++++++++++++++++++++++++++
>>>>> drivers/of/fdt.c | 11 +---
>>>>> drivers/tty/serial/amba-pl011.c | 56 ++++++++++++++++++++
>>>>> drivers/tty/serial/earlycon.c | 19 ++++++-
>>>>> include/acpi/actbl2.h | 7 ++-
>>>>> include/linux/acpi.h | 6 +++
>>>>> include/linux/of_fdt.h | 2 +
>>>>> include/linux/serial_core.h | 6 +++
>>>>> 12 files changed, 220 insertions(+), 14 deletions(-)
>>>>> create mode 100644 drivers/acpi/spcr.c
>>>>>
>>> _______________________________________________
>>> linux-arm-kernel mailing list
>>> [email protected]
>>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

2016-04-06 19:00:20

by Mark Salter

[permalink] [raw]
Subject: Re: [PATCH v7 0/5] ACPI: parse the SPCR table

On Wed, 2016-04-06 at 09:27 -0700, Peter Hurley wrote:
> On 04/06/2016 07:18 AM, Mark Salter wrote:
> >
> > On Wed, 2016-04-06 at 11:52 +0100, Graeme Gregory wrote:
> > >
> > > On Wed, Apr 06, 2016 at 01:24:12PM +0300, Aleksey Makarov wrote:
> > > >
> > > >
> > > >
> > > >
> > > > On 04/05/2016 07:27 PM, Mark Salter wrote:
> > > > >
> > > > >
> > > > > Could you CC me on future postings of this series, please?
> > > > >
> > > > > So v3 fixed a problem where platforms using 8250 didn't work.
> > > > > Then in v5, that fix was lost so 8250 no longer works.
> > > > That fix was dropped because now this is implemented differently.  
> > > > Now the code uses the existing match() member of struct console.
> > > > It has already been implemented for 8250.  
> > > > Probably SPCR table specifies incorrect data.
> > > > It was reported that D02 board has similar issue.
> > > >
> > > The D02 issue referred to is the 8250 implementation they used has 32bit
> > > only MMIO access which there is no manner to represent in SPCR. It also
> > > doesn't use the "standard" 16550 clock rate so supplying a baud rate
> > > makes it change to a random baud rate.
> > So, the problem with Mustang and m400 was the mmio vs mmio32.
> Bummer. Maybe that firmware can use a different DBG2 port designation to
> indicate it's a DesignWare 8250 (or generically 32-bit mmio).
>
> >
> > Right now,
> > the kernel only supports mmio32 in the 8250_dw.c driver when probed with
> > ACPI.
> While that's true specifically for DesignWare 8250 + ACPI, that's not
> true for _all_ 8250 + ACPI.
>
> >
> > Other x86 machines just use legacy 8250 ports which don't need
> > entries in the DSDT and use legacy io.
> I find that statement hard to believe. I know for a fact ia64 servers didn't,
> so the assertion that SPCR + 16550 + MMIO automatically means 32-bit data width
> seems unlikely.

You're right. Other than DesignWare, 8250 ports can be descibed with PNP IDs
which is the bit I was missing. And all of those assume 8-bit width. So it
seems a DBG2 port designation for 8250 with 32-bit mmio is needed.

>
> In fact, I suspect the opposite is true; that before these arm64 designs,
> SPCR + 16550 + MMIO automatically meant 8-bit data width, which is why it's
> unspecified in the SPCR table.
>
> Regards,
> Peter Hurley
>
>
> >
> > The 8250_dw driver does support
> > non-standard clocks specified in the DSDT. That works fine for Mustang
> > and m400.
> >
> > So with this quick hack, v7 is working with Mustang/m400:
> >
> > diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
> > index 68ffc33..dade9de 100644
> > --- a/drivers/acpi/spcr.c
> > +++ b/drivers/acpi/spcr.c
> > @@ -37,6 +37,7 @@ int __init parse_spcr(bool earlycon)
> >   acpi_status status;
> >   char *uart;
> >   char *iotype;
> > + int mmio;
> >   int baud_rate;
> >   int err;
> >  
> > @@ -56,8 +57,8 @@ int __init parse_spcr(bool earlycon)
> >   goto done;
> >   }
> >  
> > - iotype = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY ?
> > - "mmio" : "io";
> > + mmio = table->serial_port.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY;
> > + iotype = mmio ? "mmio" : "io";
> >  
> >   switch (table->interface_type) {
> >   case ACPI_DBG2_ARM_SBSA_32BIT:
> > @@ -71,6 +72,8 @@ int __init parse_spcr(bool earlycon)
> >   case ACPI_DBG2_16550_COMPATIBLE:
> >   case ACPI_DBG2_16550_SUBSET:
> >   uart = "uart";
> > + if (mmio)
> > + iotype = "mmio32";
> >   break;
> >   default:
> >   err = -ENOENT;
> >
> > >
> > >
> > > We may need two 8250 subset entries, one just means no clock given, and
> > > one no clock given + mmio32 only.
> > >
> > > Graeme
> > >
> > >
> > > >
> > > >
> > > > Thank you
> > > > Aleksey Makarov
> > > >
> > > > >
> > > > >
> > > > >
> > > > > --Mark
> > > > >
> > > > >
> > > > > On Thu, 2016-03-31 at 16:40 +0300, Aleksey Makarov wrote:
> > > > > >
> > > > > >
> > > > > > 'ARM Server Base Boot Requirements' [1] mentions SPCR (Serial Port
> > > > > > Console Redirection Table) [2] as a mandatory ACPI table that
> > > > > > specifies the configuration of serial console.
> > > > > >
> > > > > > Move "earlycon" early_param handling to earlycon.c to parse this option once
> > > > > >
> > > > > > *** PATCH  "ACPICA: Headers: Add new constants for the DBG2 ACPI table"
> > > > > > *** IS JUST TO ENABLE BUILDING THE PATCHSET ON linux-next
> > > > > >
> > > > > > Patch "ACPICA: Headers: Add new constants for the DBG2 ACPI table" is required
> > > > > > for the next patch.  It is taken from ACPICA series [3], but it has not appeared
> > > > > > in linux-next yet.
> > > > > >
> > > > > > Parse SPCR table, setup earlycon and add register specified console.
> > > > > >
> > > > > > Enable parsing this table on ARM64.  Earlycon should be set up
> > > > > > as early as possible.  ACPI boot tables are mapped in
> > > > > > arch/arm64/kernel/acpi.c:acpi_boot_table_init() called from setup_arch()
> > > > > > and that's where we parse spcr.  So it has to be opted-in per-arch.
> > > > > >
> > > > > > Implement console_match() for pl011.
> > > > > >
> > > > > > Based on the work by Leif Lindholm [4]
> > > > > > Thanks to Peter Hurley for explaining how this should work.
> > > > > >
> > > > > > Should be applied to next-20160331.
> > > > > >
> > > > > > Tested on QEMU.  SPCR support is included in QEMU's ARM mach-virt
> > > > > > since 2.4 release.
> > > > > >
> > > > > > v7:
> > > > > > - add Acked-by: Rob Herring for "of/serial: move earlycon early_param handling
> > > > > >   to serial"
> > > > > > - call DT earlycon initialization from the arch ACPI code, not from parse_spcr()
> > > > > >   (Rafael J. Wysocki)
> > > > > > - fix a few minor issues (Rafael J. Wysocki)
> > > > > >
> > > > > > v6:
> > > > > > https://lkml.kernel.org/g/[email protected]
> > > > > > - add documentation for parse_spcr() functioin (Yury Norov)
> > > > > > - don't initialize err variable (Yury Norov)
> > > > > > - add __initdata for the earlycon_init_is_deferred flag variable
> > > > > > - rename the function exported in "of/serial: move earlycon early_param handling
> > > > > >   to serial" to avoid clash with the function from arch/microblaze/kernel/prom.c
> > > > > > - defer initialization of DT earlycon until DT/ACPI decision is made
> > > > > >   (Rob Herring, Peter Hurley)
> > > > > > - use snprintf instead of sprintf (Andy Shevchenko)
> > > > > > - drop patch that adds EARLYCON_DECLARE for pl011 as EARLYCON_DECLARE is
> > > > > >   equivalent to OF_EARLYCON_DECLARE for 4.6+ (Peter Hurley).  This means that
> > > > > >   SPCR earlycon will not work on the kernels before 4.6
> > > > > >
> > > > > > v5:
> > > > > > https://lkml.kernel.org/g/[email protected]
> > > > > > - drop patch "serial: pl011: use ACPI SPCR to setup 32-bit access" because
> > > > > >   it is ugly. Also because Christopher Covington came with a better solution [5]
> > > > > > - remove error message when the table is not provided by ACPI (Andy Shevchenko)
> > > > > > - rewrite spcr.c following the suggestions by Peter Hurley
> > > > > > - add console_match() for pl011 in a separate patch
> > > > > > - add EARLYCON_DECLARE for pl011 in a separate patch
> > > > > > - add patch "of/serial: move earlycon early_param handling to serial" from
> > > > > >   the GDB2 series
> > > > > >
> > > > > > v4:
> > > > > > https://lkml.kernel.org/g/[email protected]
> > > > > > - drop patch "ACPI: change __init to __ref for early_acpi_os_unmap_memory()"
> > > > > >   ACPI developers work on a new API and asked not to do that.
> > > > > >   Instead, use acpi_get_table_with_size()/early_acpi_os_unmap_memory() once
> > > > > >   and cache the result. (Lv Zheng)
> > > > > > - fix some style issues (Yury Norov)
> > > > > >
> > > > > > v3:
> > > > > > https://lkml.kernel.org/g/[email protected]
> > > > > >
> > > > > > Greg Kroah-Hartman did not like v2 so I have rewritten this patchset:
> > > > > >
> > > > > > - drop acpi_match() member of struct console
> > > > > > - drop implementations of this member for pl011 and 8250
> > > > > > - drop the patch that renames some vars in printk.c as it is not needed anymore
> > > > > > - drop patch that introduces system wide acpi_table_parse2().
> > > > > >   Instead introduce a custom acpi_table_parse_spcr() in spcr.c
> > > > > >
> > > > > > Instead of introducing a new match_acpi() member of struct console,
> > > > > > this patchset introduces a new function acpi_console_check().
> > > > > > This function is called when a new uart is registered at serial_core.c
> > > > > > the same way OF code checks for console.  If the registered uart is the
> > > > > > console specified by SPCR table, this function calls add_preferred_console()
> > > > > >
> > > > > > The restrictions of this approach are:
> > > > > >
> > > > > > - only serial consoles can be set up
> > > > > > - only consoles specified by the memory/io address can be set up
> > > > > >   (SPCR can specify devices by PCI id/PCI address)
> > > > > >
> > > > > > v2:
> > > > > > https://lkml.kernel.org/g/[email protected]
> > > > > > - don't use SPCR if user specified console in command line
> > > > > > - fix initialization order of newcon->index = 0
> > > > > > - rename some variables at printk.c (Joe Perches, Peter Hurley)
> > > > > > - enable ACPI_SPCR_TABLE in a separate patch (Andy Shevchenko)
> > > > > > - remove the retry loop for console registering (Peter Hurley).
> > > > > >   Instead, obtain SPCR with acpi_get_table().  That works after
> > > > > >   call to acpi_early_init() i. e. in any *_initcall()
> > > > > > - describe design decision behind introducing acpi_match() (Peter Hurley)
> > > > > > - fix compilation for x86 + ACPI (Graeme Gregory)
> > > > > > - introduce DBG2 constants in a separate patch (Andy Shevchenko)
> > > > > > - fix a typo in DBG2 constants (Andy Shevchenko)
> > > > > > - add ACPI_DBG2_ARM_SBSA_32BIT constant (Christopher Covington)
> > > > > > - add support for ACPI_DBG2_ARM_SBSA_* consoles (Christopher Covington)
> > > > > > - add documentation for functions
> > > > > > - add a patch that uses SPCR to find if SBSA serial driver should use 32-bit
> > > > > >   accessor functions (Christopher Covington)
> > > > > > - change __init to __ref for early_acpi_os_unmap_memory() in a separate patch
> > > > > > - introduce acpi_table_parse2() in a separate patch
> > > > > > - fix fetching the SPCR table early (Mark Salter)
> > > > > > - add a patch from Mark Salter that introduces support for matching 8250-based
> > > > > >   consoles
> > > > > >
> > > > > > v1:
> > > > > > https://lkml.kernel.org/g/[email protected]
> > > > > >
> > > > > > [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> > > > > > [2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx
> > > > > > [3] https://lkml.kernel.org/g/[email protected]
> > > > > > [4] https://lkml.kernel.org/g/[email protected]
> > > > > > [5] https://lkml.kernel.org/g/[email protected]
> > > > > >
> > > > > > Aleksey Makarov (4):
> > > > > >   ACPICA: Headers: Add new constants for the DBG2 ACPI table
> > > > > >   ACPI: parse SPCR and enable matching console
> > > > > >   ARM64: ACPI: enable ACPI_SPCR_TABLE
> > > > > >   serial: pl011: add console matching function
> > > > > >
> > > > > > Leif Lindholm (1):
> > > > > >   of/serial: move earlycon early_param handling to serial
> > > > > >
> > > > > >  arch/arm64/Kconfig              |   1 +
> > > > > >  arch/arm64/kernel/acpi.c        |  11 +++-
> > > > > >  drivers/acpi/Kconfig            |   3 ++
> > > > > >  drivers/acpi/Makefile           |   1 +
> > > > > >  drivers/acpi/spcr.c             | 111 ++++++++++++++++++++++++++++++++++++++++
> > > > > >  drivers/of/fdt.c                |  11 +---
> > > > > >  drivers/tty/serial/amba-pl011.c |  56 ++++++++++++++++++++
> > > > > >  drivers/tty/serial/earlycon.c   |  19 ++++++-
> > > > > >  include/acpi/actbl2.h           |   7 ++-
> > > > > >  include/linux/acpi.h            |   6 +++
> > > > > >  include/linux/of_fdt.h          |   2 +
> > > > > >  include/linux/serial_core.h     |   6 +++
> > > > > >  12 files changed, 220 insertions(+), 14 deletions(-)
> > > > > >  create mode 100644 drivers/acpi/spcr.c
> > > > > >
> > > > _______________________________________________
> > > > linux-arm-kernel mailing list
> > > > [email protected]
> > > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2016-04-29 00:42:49

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v7 1/5] of/serial: move earlycon early_param handling to serial

On Thu, Mar 31, 2016 at 04:40:23PM +0300, Aleksey Makarov wrote:
> From: Leif Lindholm <[email protected]>
>
> We have multiple "earlycon" early_param handlers - merge the DT one into
> the main earlycon one. It's a cleanup that also will be useful
> to defer setting up DT console until ACPI/DT decision is made.
>
> Rename the exported function to avoid clashing with the function from
> arch/microblaze/kernel/prom.c
>
> Signed-off-by: Leif Lindholm <[email protected]>
> Signed-off-by: Aleksey Makarov <[email protected]>
> Acked-by: Rob Herring <[email protected]>
> ---
> drivers/of/fdt.c | 11 +----------
> drivers/tty/serial/earlycon.c | 2 +-
> include/linux/of_fdt.h | 2 ++
> 3 files changed, 4 insertions(+), 11 deletions(-)

Acked-by: Greg Kroah-Hartman <[email protected]>

2016-04-29 00:43:11

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH v7 5/5] serial: pl011: add console matching function

On Thu, Mar 31, 2016 at 04:40:27PM +0300, Aleksey Makarov wrote:
> This patch adds function pl011_console_match() that implements
> method match of struct console. It allows to match consoles against
> data specified in a string, for example taken from command line or
> compiled by ACPI SPCR table handler.
>
> Signed-off-by: Aleksey Makarov <[email protected]>
> ---
> drivers/tty/serial/amba-pl011.c | 56 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 56 insertions(+)

Acked-by: Greg Kroah-Hartman <[email protected]>