linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] ACPI: parse the SPCR table
@ 2016-02-29 12:02 Aleksey Makarov
  2016-02-29 12:02 ` [PATCH v4 1/4] ACPI: parse SPCR and enable matching console Aleksey Makarov
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-02-29 12:02 UTC (permalink / raw)
  To: linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Aleksey Makarov,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv

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

Introduce a new function acpi_console_check().  At the uart port
registration, this function checks if the ACPI SPCR table specifies
its argument of type struct uart_port to be a console
and if so calls add_preferred_console().

Use SPCR to tell if SBSA serial driver should use 32-bit access to registers.

Based on the work by Leif Lindholm [3]

Should be applied to next-20160229.

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

v4:
- 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/1455559532-8305-1-git-send-email-aleksey.makarov@linaro.org

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/1455299022-11641-1-git-send-email-aleksey.makarov@linaro.org
- 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/1453722324-22407-1-git-send-email-aleksey.makarov@linaro.org

[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/1441716217-23786-1-git-send-email-leif.lindholm@linaro.org

Aleksey Makarov (4):
  ACPI: parse SPCR and enable matching console
  ACPI: enable ACPI_SPCR_TABLE on ARM64
  ACPI: add definitions of DBG2 subtypes
  serial: pl011: use ACPI SPCR to setup 32-bit access

 arch/arm64/Kconfig               |   1 +
 drivers/acpi/Kconfig             |   3 +
 drivers/acpi/Makefile            |   1 +
 drivers/acpi/spcr.c              | 138 +++++++++++++++++++++++++++++++++++++++
 drivers/tty/serial/amba-pl011.c  |   2 +
 drivers/tty/serial/serial_core.c |  14 +++-
 include/acpi/actbl2.h            |   5 ++
 include/linux/acpi.h             |  15 +++++
 8 files changed, 177 insertions(+), 2 deletions(-)
 create mode 100644 drivers/acpi/spcr.c

-- 
2.7.1

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

* [PATCH v4 1/4] ACPI: parse SPCR and enable matching console
  2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
@ 2016-02-29 12:02 ` Aleksey Makarov
  2016-02-29 13:29   ` Andy Shevchenko
  2016-03-17 17:20   ` Timur Tabi
  2016-02-29 12:02 ` [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64 Aleksey Makarov
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-02-29 12:02 UTC (permalink / raw)
  To: linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Aleksey Makarov,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv, Len Brown, Jiri Slaby

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

Parse this table and check if any registered console match the
description.  If it does, enable that console.

Introduce a new function acpi_console_check().  At the uart port
registration, this function checks if the ACPI SPCR table specifies
its argument of type struct uart_port to be a console
and if so calls add_preferred_console().

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

Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
---
 drivers/acpi/Kconfig             |   3 +
 drivers/acpi/Makefile            |   1 +
 drivers/acpi/spcr.c              | 116 +++++++++++++++++++++++++++++++++++++++
 drivers/tty/serial/serial_core.c |  14 ++++-
 include/linux/acpi.h             |  10 ++++
 5 files changed, 142 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..c460cb1
--- /dev/null
+++ b/drivers/acpi/spcr.c
@@ -0,0 +1,116 @@
+/*
+ * 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>
+
+static char *options;
+static struct acpi_generic_address address;
+
+static int __init parse_spcr_init(void)
+{
+	struct acpi_table_spcr *table;
+	acpi_size table_size;
+	acpi_status status;
+	int err = 0;
+
+	status = acpi_get_table_with_size(ACPI_SIG_SPCR, 0,
+					  (struct acpi_table_header **)&table,
+					  &table_size);
+
+	if (ACPI_FAILURE(status)) {
+		pr_err("could not get the table\n");
+		return -ENOENT;
+	}
+
+	if (table->header.revision < 2) {
+		err = -EINVAL;
+		pr_err("wrong table version\n");
+		goto done;
+	}
+
+	switch (table->baud_rate) {
+	case 3:
+		options = "9600";
+		break;
+	case 4:
+		options = "19200";
+		break;
+	case 6:
+		options = "57600";
+		break;
+	case 7:
+		options = "115200";
+		break;
+	default:
+		options = "";
+		break;
+	}
+
+	address = table->serial_port;
+
+done:
+	early_acpi_os_unmap_memory((void __iomem *)table, table_size);
+	return err;
+}
+
+/*
+ * This function calls __init parse_spcr_init() so it needs __ref.
+ * It is referenced by the arch_inicall() macros so it will be called
+ * at initialization and the 'parsed' variable will be set.
+ * So it's safe to make it __ref.
+ */
+static int __ref parse_spcr(void)
+{
+	static bool parsed;
+	static int parse_error;
+
+	if (!parsed) {
+		parse_error = parse_spcr_init();
+		parsed = true;
+	}
+
+	return parse_error;
+}
+
+arch_initcall(parse_spcr);
+
+/**
+ * acpi_console_check - Check if uart matches the console specified by SPCR.
+ *
+ * @uport:	uart port to check
+ *
+ * This function checks if the ACPI SPCR table specifies @uport to be a console
+ * and if so calls add_preferred_console()
+ *
+ * Return: a non-error value if the console matches.
+ */
+bool acpi_console_check(struct uart_port *uport)
+{
+	if (acpi_disabled || console_set_on_cmdline || parse_spcr() < 0)
+		return false;
+
+	if ((address.space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY &&
+	     address.address == (u64)uport->mapbase) ||
+	    (address.space_id == ACPI_ADR_SPACE_SYSTEM_IO &&
+	     address.address == (u64)uport->iobase)) {
+		pr_info("adding preferred console [%s%d]\n", uport->cons->name,
+			uport->line);
+		add_preferred_console(uport->cons->name, uport->line, options);
+		return true;
+	}
+
+	return false;
+}
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index a126a60..459ab54 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -34,6 +34,7 @@
 #include <linux/serial_core.h>
 #include <linux/delay.h>
 #include <linux/mutex.h>
+#include <linux/acpi.h>
 
 #include <asm/irq.h>
 #include <asm/uaccess.h>
@@ -2654,8 +2655,17 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
 		spin_lock_init(&uport->lock);
 		lockdep_set_class(&uport->lock, &port_lock_key);
 	}
-	if (uport->cons && uport->dev)
-		of_console_check(uport->dev->of_node, uport->cons->name, uport->line);
+
+	/*
+	 * Support both open FW and ACPI access to console definitions.
+	 * Both of_console_check() and acpi_console_check() will call
+	 * add_preferred_console() if a console definition is found.
+	 */
+	if (uport->cons && uport->dev) {
+		if (!acpi_console_check(uport))
+			of_console_check(uport->dev->of_node, uport->cons->name,
+					 uport->line);
+	}
 
 	uart_configure_port(drv, state, uport);
 
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 06ed7e5..ea0c297 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1004,4 +1004,14 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
 #define acpi_probe_device_table(t)	({ int __r = 0; __r;})
 #endif
 
+struct uart_port;
+#ifdef CONFIG_ACPI_SPCR_TABLE
+bool acpi_console_check(struct uart_port *uport);
+#else
+static inline bool acpi_console_check(struct uart_port *uport)
+{
+	return FALSE;
+}
+#endif
+
 #endif	/*_LINUX_ACPI_H*/
-- 
2.7.1

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

* [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64
  2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
  2016-02-29 12:02 ` [PATCH v4 1/4] ACPI: parse SPCR and enable matching console Aleksey Makarov
@ 2016-02-29 12:02 ` Aleksey Makarov
  2016-03-01 15:27   ` Peter Hurley
  2016-03-17 17:20   ` Timur Tabi
  2016-02-29 12:02 ` [PATCH v4 3/4] ACPI: add definitions of DBG2 subtypes Aleksey Makarov
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-02-29 12:02 UTC (permalink / raw)
  To: linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Aleksey Makarov,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv, Catalin Marinas,
	Will Deacon

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

Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
---
 arch/arm64/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 9dc5209..544af2e 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
-- 
2.7.1

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

* [PATCH v4 3/4] ACPI: add definitions of DBG2 subtypes
  2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
  2016-02-29 12:02 ` [PATCH v4 1/4] ACPI: parse SPCR and enable matching console Aleksey Makarov
  2016-02-29 12:02 ` [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64 Aleksey Makarov
@ 2016-02-29 12:02 ` Aleksey Makarov
  2016-02-29 12:02 ` [PATCH v4 4/4] serial: pl011: use ACPI SPCR to setup 32-bit access Aleksey Makarov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-02-29 12:02 UTC (permalink / raw)
  To: linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Aleksey Makarov,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv, Robert Moore,
	Rafael J. Wysocki, Len Brown, devel

The recent version of Microsoft Debug Port Table 2 (DBG2) [1]
specifies additional serial debug port subtypes.  These constants
are also referred by Serial Port Console Redirection Table (SPCR) [2]

Add these constants.

[1] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639131(v=vs.85).aspx
[2] https://msdn.microsoft.com/en-us/library/windows/hardware/dn639132(v=vs.85).aspx

Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
---
 include/acpi/actbl2.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index a4ef625..652f747 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -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.1

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

* [PATCH v4 4/4] serial: pl011: use ACPI SPCR to setup 32-bit access
  2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
                   ` (2 preceding siblings ...)
  2016-02-29 12:02 ` [PATCH v4 3/4] ACPI: add definitions of DBG2 subtypes Aleksey Makarov
@ 2016-02-29 12:02 ` Aleksey Makarov
  2016-03-01 15:27 ` [PATCH v4 0/4] ACPI: parse the SPCR table Peter Hurley
  2016-03-01 15:31 ` Peter Hurley
  5 siblings, 0 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-02-29 12:02 UTC (permalink / raw)
  To: linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Aleksey Makarov,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv, Len Brown, Jiri Slaby

Some implementations of ARM SBSA serial port hardware require that access
to the registers should be 32-bit.  Unfortunately, the only way for
the driver to tell if it's the case is to use the data from ACPI SPCR/DBG2
tables.  In this case the value of the 'Interface Type' field of the SPCR
table is ACPI_DBG2_ARM_SBSA_32BIT.

How this value is described in the DBG2 spec:
"(deprecated) ARM SBSA (2.x only) Generic UART supporting only
32-bit accesses"

Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
---
 drivers/acpi/spcr.c             | 22 ++++++++++++++++++++++
 drivers/tty/serial/amba-pl011.c |  2 ++
 include/linux/acpi.h            |  5 +++++
 3 files changed, 29 insertions(+)

diff --git a/drivers/acpi/spcr.c b/drivers/acpi/spcr.c
index c460cb1..f2e81af 100644
--- a/drivers/acpi/spcr.c
+++ b/drivers/acpi/spcr.c
@@ -18,6 +18,7 @@
 
 static char *options;
 static struct acpi_generic_address address;
+static bool sbsa_32_bit;
 
 static int __init parse_spcr_init(void)
 {
@@ -60,6 +61,7 @@ static int __init parse_spcr_init(void)
 	}
 
 	address = table->serial_port;
+	sbsa_32_bit = table->interface_type == ACPI_DBG2_ARM_SBSA_32BIT;
 
 done:
 	early_acpi_os_unmap_memory((void __iomem *)table, table_size);
@@ -114,3 +116,23 @@ bool acpi_console_check(struct uart_port *uport)
 
 	return false;
 }
+
+/**
+ * acpi_console_sbsa_32bit - Tell if SPCR specifies 32-bit SBSA.
+ *
+ * Some implementations of ARM SBSA serial port hardware require that access
+ * to the registers should be 32-bit.  Unfortunately, the only way for
+ * the driver to tell if it's the case is to use the data from ACPI SPCR/DBG2
+ * tables.  In this case the value of the 'Interface Type' field of the SPCR
+ * table is ACPI_DBG2_ARM_SBSA_32BIT.
+ *
+ * Return: true if access should be 32-bit wide.
+ */
+bool acpi_console_sbsa_32bit(void)
+{
+	if (acpi_disabled || parse_spcr() < 0)
+		return false;
+
+	return sbsa_32_bit;
+}
+EXPORT_SYMBOL(acpi_console_sbsa_32bit);
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 500232a..d9ca3a4 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2541,6 +2541,8 @@ static int sbsa_uart_probe(struct platform_device *pdev)
 		baudrate = 115200;
 	}
 
+	vendor_sbsa.access_32b = acpi_console_sbsa_32bit();
+
 	portnr = pl011_find_free_port();
 	if (portnr < 0)
 		return portnr;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ea0c297..da1eb23 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1007,11 +1007,16 @@ static inline struct fwnode_handle *acpi_get_next_subnode(struct device *dev,
 struct uart_port;
 #ifdef CONFIG_ACPI_SPCR_TABLE
 bool acpi_console_check(struct uart_port *uport);
+bool acpi_console_sbsa_32bit(void);
 #else
 static inline bool acpi_console_check(struct uart_port *uport)
 {
 	return FALSE;
 }
+static inline bool acpi_console_sbsa_32bit(void)
+{
+	return false;
+}
 #endif
 
 #endif	/*_LINUX_ACPI_H*/
-- 
2.7.1

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

* Re: [PATCH v4 1/4] ACPI: parse SPCR and enable matching console
  2016-02-29 12:02 ` [PATCH v4 1/4] ACPI: parse SPCR and enable matching console Aleksey Makarov
@ 2016-02-29 13:29   ` Andy Shevchenko
  2016-02-29 13:47     ` Aleksey Makarov
  2016-03-17 17:20   ` Timur Tabi
  1 sibling, 1 reply; 18+ messages in thread
From: Andy Shevchenko @ 2016-02-29 13:29 UTC (permalink / raw)
  To: Aleksey Makarov
  Cc: linux-acpi, linux-serial, linux-kernel, linux-arm Mailing List,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv, Len Brown, Jiri Slaby

On Mon, Feb 29, 2016 at 2:02 PM, Aleksey Makarov
<aleksey.makarov@linaro.org> 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.
>
> Parse this table and check if any registered console match the
> description.  If it does, enable that console.
>
> Introduce a new function acpi_console_check().  At the uart port
> registration, this function checks if the ACPI SPCR table specifies
> its argument of type struct uart_port to be a console
> and if so calls add_preferred_console().

> +       if (ACPI_FAILURE(status)) {
> +               pr_err("could not get the table\n");

Is it worse to have on error level? Is it possible to have firmware
without this table? I think it would be a normal case for non-arm
world.
I'm also not sure if this message useful even on warn level.

> +               return -ENOENT;
> +       }
> +
> +       if (table->header.revision < 2) {
> +               err = -EINVAL;
> +               pr_err("wrong table version\n");

And this one quite good to have, indeed.

> + * acpi_console_check - Check if uart matches the console specified by SPCR.
> + *
> + * @uport:     uart port to check
> + *

Since you use sections, you may add:
+ * Description:

> + * This function checks if the ACPI SPCR table specifies @uport to be a console
> + * and if so calls add_preferred_console()
> + *
> + * Return: a non-error value if the console matches.

> @@ -2654,8 +2655,17 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
>                 spin_lock_init(&uport->lock);
>                 lockdep_set_class(&uport->lock, &port_lock_key);
>         }
> -       if (uport->cons && uport->dev)
> -               of_console_check(uport->dev->of_node, uport->cons->name, uport->line);
> +
> +       /*
> +        * Support both open FW and ACPI access to console definitions.
> +        * Both of_console_check() and acpi_console_check() will call
> +        * add_preferred_console() if a console definition is found.
> +        */
> +       if (uport->cons && uport->dev) {
> +               if (!acpi_console_check(uport))

if (cond1) {
 if (cond2) {
...
 }
}

is equivalent to
if (cond1 && cond2) {
...
}

> +                       of_console_check(uport->dev->of_node, uport->cons->name,
> +                                        uport->line);
> +       }



-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v4 1/4] ACPI: parse SPCR and enable matching console
  2016-02-29 13:29   ` Andy Shevchenko
@ 2016-02-29 13:47     ` Aleksey Makarov
  0 siblings, 0 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-02-29 13:47 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-acpi, linux-serial, linux-kernel, linux-arm Mailing List,
	Russell King, Greg Kroah-Hartman, Rafael J . Wysocki,
	Leif Lindholm, Graeme Gregory, Al Stone, Christopher Covington,
	Yury Norov, Peter Hurley, Zheng, Lv, Len Brown, Jiri Slaby

Hi Andy, 

Thank you for review.

On 02/29/2016 04:29 PM, Andy Shevchenko wrote:
> On Mon, Feb 29, 2016 at 2:02 PM, Aleksey Makarov
> <aleksey.makarov@linaro.org> 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.
>>
>> Parse this table and check if any registered console match the
>> description.  If it does, enable that console.
>>
>> Introduce a new function acpi_console_check().  At the uart port
>> registration, this function checks if the ACPI SPCR table specifies
>> its argument of type struct uart_port to be a console
>> and if so calls add_preferred_console().
> 
>> +       if (ACPI_FAILURE(status)) {
>> +               pr_err("could not get the table\n");
> 
> Is it worse to have on error level? Is it possible to have firmware
> without this table? I think it would be a normal case for non-arm
> world.
> I'm also not sure if this message useful even on warn level.

I will delete the message in the next version, thank you.

>> +               return -ENOENT;
>> +       }
>> +
>> +       if (table->header.revision < 2) {
>> +               err = -EINVAL;
>> +               pr_err("wrong table version\n");
> 
> And this one quite good to have, indeed.
> 
>> + * acpi_console_check - Check if uart matches the console specified by SPCR.
>> + *
>> + * @uport:     uart port to check
>> + *
> 
> Since you use sections, you may add:
> + * Description:

According to kernel-doc-nano-HOWTO.txt "Description: " is optional.

>> + * This function checks if the ACPI SPCR table specifies @uport to be a console
>> + * and if so calls add_preferred_console()
>> + *
>> + * Return: a non-error value if the console matches.
> 
>> @@ -2654,8 +2655,17 @@ int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
>>                 spin_lock_init(&uport->lock);
>>                 lockdep_set_class(&uport->lock, &port_lock_key);
>>         }
>> -       if (uport->cons && uport->dev)
>> -               of_console_check(uport->dev->of_node, uport->cons->name, uport->line);
>> +
>> +       /*
>> +        * Support both open FW and ACPI access to console definitions.
>> +        * Both of_console_check() and acpi_console_check() will call
>> +        * add_preferred_console() if a console definition is found.
>> +        */
>> +       if (uport->cons && uport->dev) {
>> +               if (!acpi_console_check(uport))
> 
> if (cond1) {
>  if (cond2) {
> ...
>  }
> }
> 
> is equivalent to
> if (cond1 && cond2) {
> ...
> }

It is, but it's a style decision.  I would prefer to leave it as is because it emphasizes that
after meeting some condition we first call acpi_console_check() and then of_console_check().

Thank you
Aleksey Makarov

> 
>> +                       of_console_check(uport->dev->of_node, uport->cons->name,
>> +                                        uport->line);
>> +       }
> 
> 
> 

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
                   ` (3 preceding siblings ...)
  2016-02-29 12:02 ` [PATCH v4 4/4] serial: pl011: use ACPI SPCR to setup 32-bit access Aleksey Makarov
@ 2016-03-01 15:27 ` Peter Hurley
  2016-03-01 15:31 ` Peter Hurley
  5 siblings, 0 replies; 18+ messages in thread
From: Peter Hurley @ 2016-03-01 15:27 UTC (permalink / raw)
  To: Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv

It's customary to cc reviewers of your previous series.
Please review my comments to v3.

Regards,
Peter Hurley

On 02/29/2016 04:02 AM, 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.
> 
> Introduce a new function acpi_console_check().  At the uart port
> registration, this function checks if the ACPI SPCR table specifies
> its argument of type struct uart_port to be a console
> and if so calls add_preferred_console().
> 
> Use SPCR to tell if SBSA serial driver should use 32-bit access to registers.
> 
> Based on the work by Leif Lindholm [3]
> 
> Should be applied to next-20160229.
> 
> Tested on QEMU.  SPCR support is included in QEMU's ARM mach-virt
> since 2.4 release.
> 
> v4:
> - 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/1455559532-8305-1-git-send-email-aleksey.makarov@linaro.org
> 
> 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/1455299022-11641-1-git-send-email-aleksey.makarov@linaro.org
> - 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/1453722324-22407-1-git-send-email-aleksey.makarov@linaro.org
> 
> [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/1441716217-23786-1-git-send-email-leif.lindholm@linaro.org
> 
> Aleksey Makarov (4):
>   ACPI: parse SPCR and enable matching console
>   ACPI: enable ACPI_SPCR_TABLE on ARM64
>   ACPI: add definitions of DBG2 subtypes
>   serial: pl011: use ACPI SPCR to setup 32-bit access
> 
>  arch/arm64/Kconfig               |   1 +
>  drivers/acpi/Kconfig             |   3 +
>  drivers/acpi/Makefile            |   1 +
>  drivers/acpi/spcr.c              | 138 +++++++++++++++++++++++++++++++++++++++
>  drivers/tty/serial/amba-pl011.c  |   2 +
>  drivers/tty/serial/serial_core.c |  14 +++-
>  include/acpi/actbl2.h            |   5 ++
>  include/linux/acpi.h             |  15 +++++
>  8 files changed, 177 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/acpi/spcr.c
> 

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

* Re: [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64
  2016-02-29 12:02 ` [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64 Aleksey Makarov
@ 2016-03-01 15:27   ` Peter Hurley
  2016-03-01 17:35     ` Aleksey Makarov
  2016-03-17 17:20   ` Timur Tabi
  1 sibling, 1 reply; 18+ messages in thread
From: Peter Hurley @ 2016-03-01 15:27 UTC (permalink / raw)
  To: Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv, Catalin Marinas, Will Deacon

On 02/29/2016 04:02 AM, Aleksey Makarov wrote:
> SBBR mentions SPCR as a mandatory ACPI table.
> So enable it for ARM64

Why is this opt-in per-arch?


> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
> ---
>  arch/arm64/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 9dc5209..544af2e 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
> 

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
                   ` (4 preceding siblings ...)
  2016-03-01 15:27 ` [PATCH v4 0/4] ACPI: parse the SPCR table Peter Hurley
@ 2016-03-01 15:31 ` Peter Hurley
  2016-03-03 11:59   ` Aleksey Makarov
  5 siblings, 1 reply; 18+ messages in thread
From: Peter Hurley @ 2016-03-01 15:31 UTC (permalink / raw)
  To: Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv

On 02/29/2016 04:02 AM, 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.
> 
> Introduce a new function acpi_console_check().  At the uart port
> registration, this function checks if the ACPI SPCR table specifies
> its argument of type struct uart_port to be a console
> and if so calls add_preferred_console().

How will a user enable an earlycon on the same console as the SPCR
console if there is no DBG2 table?


> Use SPCR to tell if SBSA serial driver should use 32-bit access to registers.
> 
> Based on the work by Leif Lindholm [3]
> 
> Should be applied to next-20160229.
> 
> Tested on QEMU.  SPCR support is included in QEMU's ARM mach-virt
> since 2.4 release.
> 
> v4:
> - 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/1455559532-8305-1-git-send-email-aleksey.makarov@linaro.org
> 
> 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/1455299022-11641-1-git-send-email-aleksey.makarov@linaro.org
> - 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/1453722324-22407-1-git-send-email-aleksey.makarov@linaro.org
> 
> [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/1441716217-23786-1-git-send-email-leif.lindholm@linaro.org
> 
> Aleksey Makarov (4):
>   ACPI: parse SPCR and enable matching console
>   ACPI: enable ACPI_SPCR_TABLE on ARM64
>   ACPI: add definitions of DBG2 subtypes
>   serial: pl011: use ACPI SPCR to setup 32-bit access
> 
>  arch/arm64/Kconfig               |   1 +
>  drivers/acpi/Kconfig             |   3 +
>  drivers/acpi/Makefile            |   1 +
>  drivers/acpi/spcr.c              | 138 +++++++++++++++++++++++++++++++++++++++
>  drivers/tty/serial/amba-pl011.c  |   2 +
>  drivers/tty/serial/serial_core.c |  14 +++-
>  include/acpi/actbl2.h            |   5 ++
>  include/linux/acpi.h             |  15 +++++
>  8 files changed, 177 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/acpi/spcr.c
> 

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

* Re: [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64
  2016-03-01 15:27   ` Peter Hurley
@ 2016-03-01 17:35     ` Aleksey Makarov
  0 siblings, 0 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-03-01 17:35 UTC (permalink / raw)
  To: Peter Hurley, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv, Catalin Marinas, Will Deacon



On 03/01/2016 06:27 PM, Peter Hurley wrote:
> On 02/29/2016 04:02 AM, Aleksey Makarov wrote:
>> SBBR mentions SPCR as a mandatory ACPI table.
>> So enable it for ARM64
> 
> Why is this opt-in per-arch?

It could depend only on CONFIG_ACPI.
I will do that in the next version, thank you

>> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>
>> ---
>>  arch/arm64/Kconfig | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 9dc5209..544af2e 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
>>
> 

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-03-01 15:31 ` Peter Hurley
@ 2016-03-03 11:59   ` Aleksey Makarov
  2016-03-03 15:35     ` Peter Hurley
  0 siblings, 1 reply; 18+ messages in thread
From: Aleksey Makarov @ 2016-03-03 11:59 UTC (permalink / raw)
  To: Peter Hurley, Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv



On 03/01/2016 06:31 PM, Peter Hurley wrote:
> On 02/29/2016 04:02 AM, 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.
>>
>> Introduce a new function acpi_console_check().  At the uart port
>> registration, this function checks if the ACPI SPCR table specifies
>> its argument of type struct uart_port to be a console
>> and if so calls add_preferred_console().
> 
> How will a user enable an earlycon on the same console as the SPCR
> console if there is no DBG2 table?

...
[    0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
[    0.000000] bootconsole [pl11] enabled
...
[    0.000000] Kernel command line:  root=/dev/vda1 rw systemd.show_status=no acpi=force earlycon=pl011,0x9000000
...
[    0.318248] ACPI: SPCR: adding preferred console [ttyAMA0]
[    0.318736] ARMH0011:00: ttyAMA0 at MMIO 0x9000000 (irq = 5, base_baud = 0) is a SBSA
[    0.319502] console [ttyAMA0] enabled
[    0.319502] console [ttyAMA0] enabled
[    0.319933] bootconsole [pl11] disabled
[    0.319933] bootconsole [pl11] disabled
...

Why?

> 
> 
>> Use SPCR to tell if SBSA serial driver should use 32-bit access to registers.
>>
>> Based on the work by Leif Lindholm [3]
>>
>> Should be applied to next-20160229.
>>
>> Tested on QEMU.  SPCR support is included in QEMU's ARM mach-virt
>> since 2.4 release.
>>
>> v4:
>> - 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/1455559532-8305-1-git-send-email-aleksey.makarov@linaro.org
>>
>> 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/1455299022-11641-1-git-send-email-aleksey.makarov@linaro.org
>> - 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/1453722324-22407-1-git-send-email-aleksey.makarov@linaro.org
>>
>> [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/1441716217-23786-1-git-send-email-leif.lindholm@linaro.org
>>
>> Aleksey Makarov (4):
>>   ACPI: parse SPCR and enable matching console
>>   ACPI: enable ACPI_SPCR_TABLE on ARM64
>>   ACPI: add definitions of DBG2 subtypes
>>   serial: pl011: use ACPI SPCR to setup 32-bit access
>>
>>  arch/arm64/Kconfig               |   1 +
>>  drivers/acpi/Kconfig             |   3 +
>>  drivers/acpi/Makefile            |   1 +
>>  drivers/acpi/spcr.c              | 138 +++++++++++++++++++++++++++++++++++++++
>>  drivers/tty/serial/amba-pl011.c  |   2 +
>>  drivers/tty/serial/serial_core.c |  14 +++-
>>  include/acpi/actbl2.h            |   5 ++
>>  include/linux/acpi.h             |  15 +++++
>>  8 files changed, 177 insertions(+), 2 deletions(-)
>>  create mode 100644 drivers/acpi/spcr.c
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-03-03 11:59   ` Aleksey Makarov
@ 2016-03-03 15:35     ` Peter Hurley
  2016-03-04 11:53       ` Aleksey Makarov
  0 siblings, 1 reply; 18+ messages in thread
From: Peter Hurley @ 2016-03-03 15:35 UTC (permalink / raw)
  To: Aleksey Makarov, Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv

On 03/03/2016 03:59 AM, Aleksey Makarov wrote:
> 
> 
> On 03/01/2016 06:31 PM, Peter Hurley wrote:
>> On 02/29/2016 04:02 AM, 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.
>>>
>>> Introduce a new function acpi_console_check().  At the uart port
>>> registration, this function checks if the ACPI SPCR table specifies
>>> its argument of type struct uart_port to be a console
>>> and if so calls add_preferred_console().
>>
>> How will a user enable an earlycon on the same console as the SPCR
>> console if there is no DBG2 table?
> 
> ...
> [    0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
> [    0.000000] bootconsole [pl11] enabled
> ...
> [    0.000000] Kernel command line:  root=/dev/vda1 rw systemd.show_status=no acpi=force earlycon=pl011,0x9000000
> ...
> [    0.318248] ACPI: SPCR: adding preferred console [ttyAMA0]
> [    0.318736] ARMH0011:00: ttyAMA0 at MMIO 0x9000000 (irq = 5, base_baud = 0) is a SBSA
> [    0.319502] console [ttyAMA0] enabled
> [    0.319502] console [ttyAMA0] enabled
> [    0.319933] bootconsole [pl11] disabled
> [    0.319933] bootconsole [pl11] disabled
> ...
> 
> Why?

That's pretty disingenuous; via command line?

By that measure, none of your patches are required because a user
can already start both console and earlycon without them.

With the console location specified in the SPCR, earlycon should
be opt-in on the command-line simply with "earlycon" command-line
parameter.

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-03-03 15:35     ` Peter Hurley
@ 2016-03-04 11:53       ` Aleksey Makarov
  2016-03-04 15:47         ` Peter Hurley
  0 siblings, 1 reply; 18+ messages in thread
From: Aleksey Makarov @ 2016-03-04 11:53 UTC (permalink / raw)
  To: Peter Hurley, Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv



On 03/03/2016 06:35 PM, Peter Hurley wrote:
> On 03/03/2016 03:59 AM, Aleksey Makarov wrote:
>>
>>
>> On 03/01/2016 06:31 PM, Peter Hurley wrote:
>>> On 02/29/2016 04:02 AM, 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.
>>>>
>>>> Introduce a new function acpi_console_check().  At the uart port
>>>> registration, this function checks if the ACPI SPCR table specifies
>>>> its argument of type struct uart_port to be a console
>>>> and if so calls add_preferred_console().
>>>
>>> How will a user enable an earlycon on the same console as the SPCR
>>> console if there is no DBG2 table?
>>
>> ...
>> [    0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
>> [    0.000000] bootconsole [pl11] enabled
>> ...
>> [    0.000000] Kernel command line:  root=/dev/vda1 rw systemd.show_status=no acpi=force earlycon=pl011,0x9000000
>> ...
>> [    0.318248] ACPI: SPCR: adding preferred console [ttyAMA0]
>> [    0.318736] ARMH0011:00: ttyAMA0 at MMIO 0x9000000 (irq = 5, base_baud = 0) is a SBSA
>> [    0.319502] console [ttyAMA0] enabled
>> [    0.319502] console [ttyAMA0] enabled
>> [    0.319933] bootconsole [pl11] disabled
>> [    0.319933] bootconsole [pl11] disabled
>> ...
>>
>> Why?
> 
> That's pretty disingenuous; via command line?
> 
> By that measure, none of your patches are required because a user
> can already start both console and earlycon without them.
> 
> With the console location specified in the SPCR, earlycon should
> be opt-in on the command-line simply with "earlycon" command-line
> parameter.

Yes.  That's why we have SPCR *and* DBG2. 
DBG2 specifies where we should run earlycon.

>>> How will a user enable an earlycon on the same console as the SPCR
>>> console if there is no DBG2 table?

In no way.  You need DBG2 to run earlycon.

(If you don't want to specify it's address etc explicitly)

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-03-04 11:53       ` Aleksey Makarov
@ 2016-03-04 15:47         ` Peter Hurley
  2016-03-11 16:25           ` Aleksey Makarov
  0 siblings, 1 reply; 18+ messages in thread
From: Peter Hurley @ 2016-03-04 15:47 UTC (permalink / raw)
  To: Aleksey Makarov, Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv

On 03/04/2016 03:53 AM, Aleksey Makarov wrote:
> 
> 
> On 03/03/2016 06:35 PM, Peter Hurley wrote:
>> On 03/03/2016 03:59 AM, Aleksey Makarov wrote:
>>>
>>>
>>> On 03/01/2016 06:31 PM, Peter Hurley wrote:
>>>> On 02/29/2016 04:02 AM, 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.
>>>>>
>>>>> Introduce a new function acpi_console_check().  At the uart port
>>>>> registration, this function checks if the ACPI SPCR table specifies
>>>>> its argument of type struct uart_port to be a console
>>>>> and if so calls add_preferred_console().
>>>>
>>>> How will a user enable an earlycon on the same console as the SPCR
>>>> console if there is no DBG2 table?
>>>
>>> ...
>>> [    0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
>>> [    0.000000] bootconsole [pl11] enabled
>>> ...
>>> [    0.000000] Kernel command line:  root=/dev/vda1 rw systemd.show_status=no acpi=force earlycon=pl011,0x9000000
>>> ...
>>> [    0.318248] ACPI: SPCR: adding preferred console [ttyAMA0]
>>> [    0.318736] ARMH0011:00: ttyAMA0 at MMIO 0x9000000 (irq = 5, base_baud = 0) is a SBSA
>>> [    0.319502] console [ttyAMA0] enabled
>>> [    0.319502] console [ttyAMA0] enabled
>>> [    0.319933] bootconsole [pl11] disabled
>>> [    0.319933] bootconsole [pl11] disabled
>>> ...
>>>
>>> Why?
>>
>> That's pretty disingenuous; via command line?
>>
>> By that measure, none of your patches are required because a user
>> can already start both console and earlycon without them.
>>
>> With the console location specified in the SPCR, earlycon should
>> be opt-in on the command-line simply with "earlycon" command-line
>> parameter.
> 
> Yes.  That's why we have SPCR *and* DBG2. 
> DBG2 specifies where we should run earlycon.
> 
>>>> How will a user enable an earlycon on the same console as the SPCR
>>>> console if there is no DBG2 table?
> 
> In no way.  You need DBG2 to run earlycon.

And that's an entirely arbitrary decision being made by you.
Which I think is unnecessarily limited.


> (If you don't want to specify it's address etc explicitly)

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

* Re: [PATCH v4 0/4] ACPI: parse the SPCR table
  2016-03-04 15:47         ` Peter Hurley
@ 2016-03-11 16:25           ` Aleksey Makarov
  0 siblings, 0 replies; 18+ messages in thread
From: Aleksey Makarov @ 2016-03-11 16:25 UTC (permalink / raw)
  To: Peter Hurley, Aleksey Makarov, linux-acpi
  Cc: linux-serial, linux-kernel, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Zheng, Lv

Hi Peter,

You are right, SPCR console should support earlycon.
I will send next version that will try to follow your recommendations in 
a week, after I return from vacations.

As we discussed with Christopher, "serial: pl011: use SPCR to setup 
32-bit access" will be dropped.

Thank you
Aleksey Makarov

On 04.03.2016 22:47, Peter Hurley wrote:
> On 03/04/2016 03:53 AM, Aleksey Makarov wrote:
>>
>>
>> On 03/03/2016 06:35 PM, Peter Hurley wrote:
>>> On 03/03/2016 03:59 AM, Aleksey Makarov wrote:
>>>>
>>>>
>>>> On 03/01/2016 06:31 PM, Peter Hurley wrote:
>>>>> On 02/29/2016 04:02 AM, 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.
>>>>>>
>>>>>> Introduce a new function acpi_console_check().  At the uart port
>>>>>> registration, this function checks if the ACPI SPCR table specifies
>>>>>> its argument of type struct uart_port to be a console
>>>>>> and if so calls add_preferred_console().
>>>>>
>>>>> How will a user enable an earlycon on the same console as the SPCR
>>>>> console if there is no DBG2 table?
>>>>
>>>> ...
>>>> [    0.000000] earlycon: pl11 at MMIO 0x0000000009000000 (options '')
>>>> [    0.000000] bootconsole [pl11] enabled
>>>> ...
>>>> [    0.000000] Kernel command line:  root=/dev/vda1 rw systemd.show_status=no acpi=force earlycon=pl011,0x9000000
>>>> ...
>>>> [    0.318248] ACPI: SPCR: adding preferred console [ttyAMA0]
>>>> [    0.318736] ARMH0011:00: ttyAMA0 at MMIO 0x9000000 (irq = 5, base_baud = 0) is a SBSA
>>>> [    0.319502] console [ttyAMA0] enabled
>>>> [    0.319502] console [ttyAMA0] enabled
>>>> [    0.319933] bootconsole [pl11] disabled
>>>> [    0.319933] bootconsole [pl11] disabled
>>>> ...
>>>>
>>>> Why?
>>>
>>> That's pretty disingenuous; via command line?
>>>
>>> By that measure, none of your patches are required because a user
>>> can already start both console and earlycon without them.
>>>
>>> With the console location specified in the SPCR, earlycon should
>>> be opt-in on the command-line simply with "earlycon" command-line
>>> parameter.
>>
>> Yes.  That's why we have SPCR *and* DBG2.
>> DBG2 specifies where we should run earlycon.
>>
>>>>> How will a user enable an earlycon on the same console as the SPCR
>>>>> console if there is no DBG2 table?
>>
>> In no way.  You need DBG2 to run earlycon.
>
> And that's an entirely arbitrary decision being made by you.
> Which I think is unnecessarily limited.
>
>
>> (If you don't want to specify it's address etc explicitly)
>
>

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

* Re: [PATCH v4 1/4] ACPI: parse SPCR and enable matching console
  2016-02-29 12:02 ` [PATCH v4 1/4] ACPI: parse SPCR and enable matching console Aleksey Makarov
  2016-02-29 13:29   ` Andy Shevchenko
@ 2016-03-17 17:20   ` Timur Tabi
  1 sibling, 0 replies; 18+ messages in thread
From: Timur Tabi @ 2016-03-17 17:20 UTC (permalink / raw)
  To: Aleksey Makarov
  Cc: linux-acpi, linux-serial, lkml, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Peter Hurley, Zheng, Lv, Len Brown, Jiri Slaby

On Mon, Feb 29, 2016 at 6:02 AM, Aleksey Makarov
<aleksey.makarov@linaro.org> 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.
>
> Parse this table and check if any registered console match the
> description.  If it does, enable that console.
>
> Introduce a new function acpi_console_check().  At the uart port
> registration, this function checks if the ACPI SPCR table specifies
> its argument of type struct uart_port to be a console
> and if so calls add_preferred_console().
>
> [1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0044a/index.html
> [2] http://msdn.microsoft.com/en-us/library/windows/hardware/dn639131(v=vs.85).aspx
>
> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>

Tested-by: Timur Tabi <timur@codeaurora.org>

I know another version of patch is coming, but I tested this version
and it works.

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

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

* Re: [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64
  2016-02-29 12:02 ` [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64 Aleksey Makarov
  2016-03-01 15:27   ` Peter Hurley
@ 2016-03-17 17:20   ` Timur Tabi
  1 sibling, 0 replies; 18+ messages in thread
From: Timur Tabi @ 2016-03-17 17:20 UTC (permalink / raw)
  To: Aleksey Makarov
  Cc: linux-acpi, linux-serial, lkml, linux-arm-kernel, Russell King,
	Greg Kroah-Hartman, Rafael J . Wysocki, Leif Lindholm,
	Graeme Gregory, Al Stone, Christopher Covington, Yury Norov,
	Peter Hurley, Zheng, Lv, Catalin Marinas, Will Deacon

On Mon, Feb 29, 2016 at 6:02 AM, Aleksey Makarov
<aleksey.makarov@linaro.org> wrote:
> SBBR mentions SPCR as a mandatory ACPI table.
> So enable it for ARM64
>
> Signed-off-by: Aleksey Makarov <aleksey.makarov@linaro.org>

Tested-by: Timur Tabi <timur@codeaurora.org>

I know another version of patch is coming, but I tested this version
and it works.

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

end of thread, other threads:[~2016-03-17 17:20 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-29 12:02 [PATCH v4 0/4] ACPI: parse the SPCR table Aleksey Makarov
2016-02-29 12:02 ` [PATCH v4 1/4] ACPI: parse SPCR and enable matching console Aleksey Makarov
2016-02-29 13:29   ` Andy Shevchenko
2016-02-29 13:47     ` Aleksey Makarov
2016-03-17 17:20   ` Timur Tabi
2016-02-29 12:02 ` [PATCH v4 2/4] ACPI: enable ACPI_SPCR_TABLE on ARM64 Aleksey Makarov
2016-03-01 15:27   ` Peter Hurley
2016-03-01 17:35     ` Aleksey Makarov
2016-03-17 17:20   ` Timur Tabi
2016-02-29 12:02 ` [PATCH v4 3/4] ACPI: add definitions of DBG2 subtypes Aleksey Makarov
2016-02-29 12:02 ` [PATCH v4 4/4] serial: pl011: use ACPI SPCR to setup 32-bit access Aleksey Makarov
2016-03-01 15:27 ` [PATCH v4 0/4] ACPI: parse the SPCR table Peter Hurley
2016-03-01 15:31 ` Peter Hurley
2016-03-03 11:59   ` Aleksey Makarov
2016-03-03 15:35     ` Peter Hurley
2016-03-04 11:53       ` Aleksey Makarov
2016-03-04 15:47         ` Peter Hurley
2016-03-11 16:25           ` Aleksey Makarov

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