2015-04-08 17:45:50

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 00/13] Earlycon cleanup

Hi Greg, Grant & Rob,

This patch series builds on my earlier "Extensible console matching &
direct earlycon" to add several useful features to earlycon:
* Proper port i/o configuration from DT node with of_serial properties
(such as reg-io-width, reg-shift and reg-offset)
* Proper console name & index initialization from earlycon name
(for both command line and DT-defined earlycons)
* Support for DT 'stdout-path' options pass-through to earlycon setup
* Improved log messages for troubleshooting
* Support for multiple OF earlycon declarations so different
compatible strings can specify the same OF earlycon

* Changes from v1 *

- Rebase on top of device-tree compiler patch submission,
"libfdt: Add fdt_path_offset_namelen()"
- Fixed x86 build breakage, conditionally compile of_setup_earlycon();
Note: this should have already been the case since of_setup_earlycon()
is dead code without CONFIG_OF_EARLY_FLATTREE
- Fixed Geert's suggestion to change the printf specifier for ->mapbase
- Fixed initial console index value for earlycon name without trailing
numerals

* Changes from v2 *

- All earlycon declarations are now in a single table, with a common
framework for devicetree and command line earlycons


Requires: 1) "libfdt: Add fdt_path_offset_namelen()" -- now in
upstream dtc
2) the last patch which adds omap8250 earlycon requires some
kind of fixmap support, such as "ARM: early fixmap support
for earlycon", which has not yet been accepted upstream.

Regards,

Peter Hurley (13):
of: earlycon: Fix 'stdout-path' with ':' path terminator
earlycon: Use common framework for earlycon declarations
serial: earlycon: Fixup earlycon console name and index
of: earlycon: Fixup earlycon console name and index
of: earlycon: Add options string handling
of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
of: earlycon: Initialize port fields from DT properties
of: earlycon: Move address translation to of_setup_earlycon()
serial: earlycon: Common log banner for command line and DT
serial: earlycon: Show the earlycon "driver" in banner
of: earlycon: Log more helpful message if earlycon not found
serial: 8250_early: Use port->regshift
serial: 8250_omap: Add omap8250 earlycon

drivers/of/fdt.c | 28 ++++-----
drivers/of/fdt_address.c | 11 +++-
drivers/tty/serial/8250/8250_early.c | 29 +++++++++-
drivers/tty/serial/amba-pl011.c | 1 -
drivers/tty/serial/arc_uart.c | 1 -
drivers/tty/serial/earlycon.c | 109 ++++++++++++++++++++++++++---------
drivers/tty/serial/msm_serial.c | 2 -
drivers/tty/serial/samsung.c | 6 --
drivers/tty/serial/sprd_serial.c | 2 -
include/asm-generic/vmlinux.lds.h | 8 +--
include/linux/of_fdt.h | 2 +-
include/linux/serial_core.h | 25 ++++----
12 files changed, 151 insertions(+), 73 deletions(-)

--
2.3.5


2015-04-08 17:49:22

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

stdout-path defines ':' as a path terminator and commit 75c28c09af99a
("of: add optional options parameter to of_find_node_by_path()") added
the necessary support to parse paths terminated with ':'.
commit 7914a7c5651a5 ("of: support passing console options with
stdout-path") added options string support to the stdout-path property,
which broke earlycon.

Add the same support to earlycon to process 'stdout-path' properties
which contain an options string.

Requires: "libfdt: Add fdt_path_offset_namelen()"
Cc: Leif Lindholm <[email protected]>
Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 3a896c9..7cef9f9 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -765,7 +765,7 @@ extern struct of_device_id __earlycon_of_table[];
static int __init early_init_dt_scan_chosen_serial(void)
{
int offset;
- const char *p;
+ const char *p, *q;
int l;
const struct of_device_id *match = __earlycon_of_table;
const void *fdt = initial_boot_params;
@@ -782,8 +782,10 @@ static int __init early_init_dt_scan_chosen_serial(void)
if (!p || !l)
return -ENOENT;

+ q = strchrnul(p, ':');
+
/* Get the node specified by stdout-path */
- offset = fdt_path_offset(fdt, p);
+ offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
if (offset < 0)
return -ENODEV;

--
2.3.5

2015-04-08 17:48:31

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 02/13] earlycon: Use common framework for earlycon declarations

Use a single common table of struct earlycon_id for both command line
and devicetree. Re-define OF_EARLYCON_DECLARE() macro to instance a
unique earlycon declaration (the declaration is only guaranteed to be
unique within a compilation unit; separate compilation units must still
use unique earlycon names).

The semantics of OF_EARLYCON_DECLARE() is different; it declares an
earlycon which can matched either on the command line or by devicetree.
EARLYCON_DECLARE() is semantically unchanged; it declares an earlycon
which is matched by command line only. Remove redundant instances of
EARLYCON_DECLARE().

This enables all earlycons to properly initialize struct console
with the appropriate name and index, which improves diagnostics and
enables direct earlycon-to-console handoff.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 15 ++++++++-------
drivers/tty/serial/amba-pl011.c | 1 -
drivers/tty/serial/arc_uart.c | 1 -
drivers/tty/serial/earlycon.c | 10 +---------
drivers/tty/serial/msm_serial.c | 2 --
drivers/tty/serial/samsung.c | 6 ------
drivers/tty/serial/sprd_serial.c | 2 --
include/asm-generic/vmlinux.lds.h | 8 +++-----
include/linux/serial_core.h | 22 +++++++++++++---------
9 files changed, 25 insertions(+), 42 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 7cef9f9..0ec1643 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -760,14 +760,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
#endif /* CONFIG_BLK_DEV_INITRD */

#ifdef CONFIG_SERIAL_EARLYCON
-extern struct of_device_id __earlycon_of_table[];

static int __init early_init_dt_scan_chosen_serial(void)
{
int offset;
const char *p, *q;
int l;
- const struct of_device_id *match = __earlycon_of_table;
+ const struct earlycon_id *match;
const void *fdt = initial_boot_params;

offset = fdt_path_offset(fdt, "/chosen");
@@ -789,18 +788,20 @@ static int __init early_init_dt_scan_chosen_serial(void)
if (offset < 0)
return -ENODEV;

- while (match->compatible[0]) {
+ for (match = __earlycon_table; match < __earlycon_table_end; match++) {
unsigned long addr;
- if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
- match++;
+
+ if (!match->compatible[0])
+ continue;
+
+ if (fdt_node_check_compatible(fdt, offset, match->compatible))
continue;
- }

addr = fdt_translate_address(fdt, offset);
if (!addr)
return -ENXIO;

- of_setup_earlycon(addr, match->data);
+ of_setup_earlycon(addr, match->setup);
return 0;
}
return -ENODEV;
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 5a4e9d5..a73a01f 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2149,7 +2149,6 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
device->con->write = pl011_early_write;
return 0;
}
-EARLYCON_DECLARE(pl011, pl011_early_console_setup);
OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);

#else
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 03ebe40..3a1de5c 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -576,7 +576,6 @@ static int __init arc_early_console_setup(struct earlycon_device *dev,
dev->con->write = arc_early_serial_write;
return 0;
}
-EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
OF_EARLYCON_DECLARE(arc_uart, "snps,arc-uart", arc_early_console_setup);

#endif /* CONFIG_SERIAL_ARC_CONSOLE */
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 5fdc9f3..45c443b 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -19,7 +19,6 @@
#include <linux/io.h>
#include <linux/serial_core.h>
#include <linux/sizes.h>
-#include <linux/mod_devicetable.h>

#ifdef CONFIG_FIX_EARLYCON_MEM
#include <asm/fixmap.h>
@@ -37,13 +36,6 @@ static struct earlycon_device early_console_dev = {
.con = &early_con,
};

-extern struct earlycon_id __earlycon_table[];
-static const struct earlycon_id __earlycon_table_sentinel
- __used __section(__earlycon_table_end);
-
-static const struct of_device_id __earlycon_of_table_sentinel
- __used __section(__earlycon_of_table_end);
-
static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
{
void __iomem *base;
@@ -155,7 +147,7 @@ int __init setup_earlycon(char *buf)
if (early_con.flags & CON_ENABLED)
return -EALREADY;

- for (match = __earlycon_table; match->name[0]; match++) {
+ for (match = __earlycon_table; match < __earlycon_table_end; match++) {
size_t len = strlen(match->name);

if (strncmp(buf, match->name, len))
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index b73889c..855b56c 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -960,7 +960,6 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
device->con->write = msm_serial_early_write;
return 0;
}
-EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
msm_serial_early_console_setup);

@@ -982,7 +981,6 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
device->con->write = msm_serial_early_write_dm;
return 0;
}
-EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
msm_serial_early_console_setup_dm);

diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index cf08876..091171c 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -2460,7 +2460,6 @@ static int __init s3c2410_early_console_setup(struct earlycon_device *device,
}
OF_EARLYCON_DECLARE(s3c2410, "samsung,s3c2410-uart",
s3c2410_early_console_setup);
-EARLYCON_DECLARE(s3c2410, s3c2410_early_console_setup);

/* S3C2412, S3C2440, S3C64xx */
static struct samsung_early_console_data s3c2440_early_console_data = {
@@ -2479,9 +2478,6 @@ OF_EARLYCON_DECLARE(s3c2440, "samsung,s3c2440-uart",
s3c2440_early_console_setup);
OF_EARLYCON_DECLARE(s3c6400, "samsung,s3c6400-uart",
s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2412, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c2440, s3c2440_early_console_setup);
-EARLYCON_DECLARE(s3c6400, s3c2440_early_console_setup);

/* S5PV210, EXYNOS */
static struct samsung_early_console_data s5pv210_early_console_data = {
@@ -2498,8 +2494,6 @@ OF_EARLYCON_DECLARE(s5pv210, "samsung,s5pv210-uart",
s5pv210_early_console_setup);
OF_EARLYCON_DECLARE(exynos4210, "samsung,exynos4210-uart",
s5pv210_early_console_setup);
-EARLYCON_DECLARE(s5pv210, s5pv210_early_console_setup);
-EARLYCON_DECLARE(exynos4210, s5pv210_early_console_setup);
#endif

MODULE_ALIAS("platform:samsung-uart");
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 582d272..1e42574 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -624,8 +624,6 @@ static int __init sprd_early_console_setup(
device->con->write = sprd_early_write;
return 0;
}
-
-EARLYCON_DECLARE(sprd_serial, sprd_early_console_setup);
OF_EARLYCON_DECLARE(sprd_serial, "sprd,sc9836-uart",
sprd_early_console_setup);

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 561daf4..e47fc02 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -154,7 +154,7 @@
#define EARLYCON_TABLE() STRUCT_ALIGN(); \
VMLINUX_SYMBOL(__earlycon_table) = .; \
*(__earlycon_table) \
- *(__earlycon_table_end)
+ VMLINUX_SYMBOL(__earlycon_table_end) = .;
#else
#define EARLYCON_TABLE()
#endif
@@ -175,7 +175,6 @@
#define IOMMU_OF_TABLES() OF_TABLE(CONFIG_OF_IOMMU, iommu)
#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
-#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)

#define KERNEL_DTB() \
STRUCT_ALIGN(); \
@@ -503,6 +502,7 @@
FTRACE_EVENTS() \
TRACE_SYSCALLS() \
KPROBE_BLACKLIST() \
+ EARLYCON_TABLE() \
MEM_DISCARD(init.rodata) \
CLK_OF_TABLES() \
RESERVEDMEM_OF_TABLES() \
@@ -510,9 +510,7 @@
IOMMU_OF_TABLES() \
CPU_METHOD_OF_TABLES() \
KERNEL_DTB() \
- IRQCHIP_OF_MATCH_TABLE() \
- EARLYCON_TABLE() \
- EARLYCON_OF_TABLES()
+ IRQCHIP_OF_MATCH_TABLE()

#define INIT_TEXT \
*(.init.text) \
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 025dad9..b8367c0 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -341,22 +341,26 @@ struct earlycon_device {

struct earlycon_id {
char name[16];
+ char compatible[128];
int (*setup)(struct earlycon_device *, const char *options);
} __aligned(32);

+extern const struct earlycon_id __earlycon_table[];
+extern const struct earlycon_id __earlycon_table_end[];
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn) \
+ static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
+ __used __section(__earlycon_table) \
+ = { .name = __stringify(_name), \
+ .compatible = compat, \
+ .setup = fn }
+
+#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
+
extern int setup_earlycon(char *buf);
extern int of_setup_earlycon(unsigned long addr,
int (*setup)(struct earlycon_device *, const char *));

-#define EARLYCON_DECLARE(_name, func) \
- static const struct earlycon_id __earlycon_##_name \
- __used __section(__earlycon_table) \
- = { .name = __stringify(_name), \
- .setup = func }
-
-#define OF_EARLYCON_DECLARE(name, compat, fn) \
- _OF_DECLARE(earlycon, name, compat, fn, void *)
-
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.3.5

2015-04-08 17:48:29

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 03/13] serial: earlycon: Fixup earlycon console name and index

Properly initialize the struct console 'name' and 'index' fields for
the registering earlycon. For earlycons w/o trailing numerals, the
index is set to 0; otherwise, the index is set to the value of the
trailing numeral. For example, the 'exynos4210' earlycon name == "exynos"
and index == 4210. Earlycons with embedded numerals will have all
non-trailing numerals as part of the name; for example, the 's3c2412'
earlycon name == "s3c" and index == 2412.

This ackward scheme was initially added for the uart8250 earlycon;
adopt this scheme for the other earlycon "drivers".

Introduce earlycon_init() which performs the string scanning and
initializes the name and index fields; encapsulate the other console
field initializations within.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/tty/serial/earlycon.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 45c443b..1bd822c 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -27,9 +27,9 @@
#include <asm/serial.h>

static struct console early_con = {
- .name = "uart", /* 8250 console switch requires this name */
+ .name = "uart", /* fixed up at earlycon registration */
.flags = CON_PRINTBUFFER | CON_BOOT,
- .index = -1,
+ .index = 0,
};

static struct earlycon_device early_console_dev = {
@@ -53,6 +53,25 @@ static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
return base;
}

+static void __init earlycon_init(struct earlycon_device *device,
+ const char *name)
+{
+ struct console *earlycon = device->con;
+ const char *s;
+ size_t len;
+
+ /* scan backwards from end of string for first non-numeral */
+ for (s = name + strlen(name);
+ s > name && s[-1] >= '0' && s[-1] <= '9';
+ s--)
+ ;
+ if (*s)
+ earlycon->index = simple_strtoul(s, NULL, 10);
+ len = s - name;
+ strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
+ earlycon->data = &early_console_dev;
+}
+
static int __init parse_options(struct earlycon_device *device, char *options)
{
struct uart_port *port = &device->port;
@@ -108,7 +127,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
if (port->mapbase)
port->membase = earlycon_map(port->mapbase, 64);

- early_console_dev.con->data = &early_console_dev;
+ earlycon_init(&early_console_dev, match->name);
err = match->setup(&early_console_dev, buf);
if (err < 0)
return err;
--
2.3.5

2015-04-08 17:46:00

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 04/13] of: earlycon: Fixup earlycon console name and index

Use the console name embedded in the OF earlycon table by the
OF_EARLYCON_DECLARE() macro to initialize the struct console 'name'
and 'index' fields.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 2 +-
drivers/tty/serial/earlycon.c | 6 +++---
include/linux/serial_core.h | 3 +--
3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 0ec1643..89fc70c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -801,7 +801,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
if (!addr)
return -ENXIO;

- of_setup_earlycon(addr, match->setup);
+ of_setup_earlycon(addr, match);
return 0;
}
return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 1bd822c..1cb2864 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -210,7 +210,7 @@ static int __init param_setup_earlycon(char *buf)
early_param("earlycon", param_setup_earlycon);

int __init of_setup_earlycon(unsigned long addr,
- int (*setup)(struct earlycon_device *, const char *))
+ const struct earlycon_id *match)
{
int err;
struct uart_port *port = &early_console_dev.port;
@@ -220,8 +220,8 @@ int __init of_setup_earlycon(unsigned long addr,
port->uartclk = BASE_BAUD * 16;
port->membase = earlycon_map(addr, SZ_4K);

- early_console_dev.con->data = &early_console_dev;
- err = setup(&early_console_dev, NULL);
+ earlycon_init(&early_console_dev, match->name);
+ err = match->setup(&early_console_dev, NULL);
if (err < 0)
return err;
if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index b8367c0..63662e8 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -358,8 +358,7 @@ extern const struct earlycon_id __earlycon_table_end[];
#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)

extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr,
- int (*setup)(struct earlycon_device *, const char *));
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);

struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c);
--
2.3.5

2015-04-08 17:45:56

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 05/13] of: earlycon: Add options string handling

Pass-through any options string in the 'stdout-path' property to the
earlycon "driver" setup.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 6 ++++--
drivers/tty/serial/earlycon.c | 9 +++++++--
include/linux/serial_core.h | 3 ++-
3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 89fc70c..e0b8013 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -764,7 +764,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
static int __init early_init_dt_scan_chosen_serial(void)
{
int offset;
- const char *p, *q;
+ const char *p, *q, *options = NULL;
int l;
const struct earlycon_id *match;
const void *fdt = initial_boot_params;
@@ -782,6 +782,8 @@ static int __init early_init_dt_scan_chosen_serial(void)
return -ENOENT;

q = strchrnul(p, ':');
+ if (*q != '\0')
+ options = q + 1;

/* Get the node specified by stdout-path */
offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
@@ -801,7 +803,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
if (!addr)
return -ENXIO;

- of_setup_earlycon(addr, match);
+ of_setup_earlycon(addr, match, options);
return 0;
}
return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 1cb2864..46f39c9 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -210,7 +210,8 @@ static int __init param_setup_earlycon(char *buf)
early_param("earlycon", param_setup_earlycon);

int __init of_setup_earlycon(unsigned long addr,
- const struct earlycon_id *match)
+ const struct earlycon_id *match,
+ const char *options)
{
int err;
struct uart_port *port = &early_console_dev.port;
@@ -220,8 +221,12 @@ int __init of_setup_earlycon(unsigned long addr,
port->uartclk = BASE_BAUD * 16;
port->membase = earlycon_map(addr, SZ_4K);

+ if (options) {
+ strlcpy(early_console_dev.options, options,
+ sizeof(early_console_dev.options));
+ }
earlycon_init(&early_console_dev, match->name);
- err = match->setup(&early_console_dev, NULL);
+ err = match->setup(&early_console_dev, options);
if (err < 0)
return err;
if (!early_console_dev.con->write)
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 63662e8..3cc5e42 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -358,7 +358,8 @@ extern const struct earlycon_id __earlycon_table_end[];
#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)

extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match);
+extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+ const char *options);

struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c);
--
2.3.5

2015-04-08 17:48:00

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 06/13] of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE

DT earlycon is only supported for CONFIG_OF_EARLY_FLATTREE=y; exclude
of_setup_earlycon() if not defined.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/tty/serial/earlycon.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 46f39c9..96e3ad1 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -209,6 +209,8 @@ static int __init param_setup_earlycon(char *buf)
}
early_param("earlycon", param_setup_earlycon);

+#ifdef CONFIG_OF_EARLY_FLATTREE
+
int __init of_setup_earlycon(unsigned long addr,
const struct earlycon_id *match,
const char *options)
@@ -236,3 +238,5 @@ int __init of_setup_earlycon(unsigned long addr,
register_console(early_console_dev.con);
return 0;
}
+
+#endif /* CONFIG_OF_EARLY_FLATTREE */
--
2.3.5

2015-04-08 17:47:56

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 07/13] of: earlycon: Initialize port fields from DT properties

Read the optional "reg-offset", "reg-shift" and "reg-io-width" properties
and initialize the respective struct uart_port field if found.

NB: These bindings are common to several drivers and the values merely
indicate the default value; the registering earlycon setup() method can
simply override the values if required.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 2 +-
drivers/tty/serial/earlycon.c | 27 +++++++++++++++++++++++++++
include/linux/serial_core.h | 1 +
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index e0b8013..47d5054 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -803,7 +803,7 @@ static int __init early_init_dt_scan_chosen_serial(void)
if (!addr)
return -ENXIO;

- of_setup_earlycon(addr, match, options);
+ of_setup_earlycon(addr, match, offset, options);
return 0;
}
return -ENODEV;
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 96e3ad1..b618015 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -20,6 +20,10 @@
#include <linux/serial_core.h>
#include <linux/sizes.h>

+#ifdef CONFIG_OF_EARLY_FLATTREE
+#include <linux/of_fdt.h>
+#endif
+
#ifdef CONFIG_FIX_EARLYCON_MEM
#include <asm/fixmap.h>
#endif
@@ -213,16 +217,39 @@ early_param("earlycon", param_setup_earlycon);

int __init of_setup_earlycon(unsigned long addr,
const struct earlycon_id *match,
+ unsigned long node,
const char *options)
{
int err;
struct uart_port *port = &early_console_dev.port;
+ const __be32 *val;

port->iotype = UPIO_MEM;
port->mapbase = addr;
port->uartclk = BASE_BAUD * 16;
port->membase = earlycon_map(addr, SZ_4K);

+ val = of_get_flat_dt_prop(node, "reg-offset", NULL);
+ if (val)
+ port->mapbase += be32_to_cpu(*val);
+ val = of_get_flat_dt_prop(node, "reg-shift", NULL);
+ if (val)
+ port->regshift = be32_to_cpu(*val);
+ val = of_get_flat_dt_prop(node, "reg-io-width", NULL);
+ if (val) {
+ switch (be32_to_cpu(*val)) {
+ case 1:
+ port->iotype = UPIO_MEM;
+ break;
+ case 4:
+ port->iotype = UPIO_MEM32;
+ break;
+ default:
+ pr_warn("[%s] unsupported reg-io-width\n", match->name);
+ return -EINVAL;
+ }
+ }
+
if (options) {
strlcpy(early_console_dev.options, options,
sizeof(early_console_dev.options));
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 3cc5e42..fe48f4e 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -359,6 +359,7 @@ extern const struct earlycon_id __earlycon_table_end[];

extern int setup_earlycon(char *buf);
extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+ unsigned long node,
const char *options);

struct uart_port *uart_get_console(struct uart_port *ports, int nr,
--
2.3.5

2015-04-08 17:47:33

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 08/13] of: earlycon: Move address translation to of_setup_earlycon()

Cleanup the early DT/earlycon separation; remove the 'addr' parameter
from of_setup_earlycon() and get the uart phys addr directly with a
new wrapper function, of_flat_dt_translate_addr(). Limit
fdt_translate_address() to file scope.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 8 +-------
drivers/of/fdt_address.c | 11 ++++++++++-
drivers/tty/serial/earlycon.c | 11 +++++++----
include/linux/of_fdt.h | 2 +-
include/linux/serial_core.h | 2 +-
5 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 47d5054..007c330 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -791,19 +791,13 @@ static int __init early_init_dt_scan_chosen_serial(void)
return -ENODEV;

for (match = __earlycon_table; match < __earlycon_table_end; match++) {
- unsigned long addr;
-
if (!match->compatible[0])
continue;

if (fdt_node_check_compatible(fdt, offset, match->compatible))
continue;

- addr = fdt_translate_address(fdt, offset);
- if (!addr)
- return -ENXIO;
-
- of_setup_earlycon(addr, match, offset, options);
+ of_setup_earlycon(match, offset, options);
return 0;
}
return -ENODEV;
diff --git a/drivers/of/fdt_address.c b/drivers/of/fdt_address.c
index 8d3dc6f..dca8f9b 100644
--- a/drivers/of/fdt_address.c
+++ b/drivers/of/fdt_address.c
@@ -161,7 +161,7 @@ static int __init fdt_translate_one(const void *blob, int parent,
* that can be mapped to a cpu physical address). This is not really specified
* that way, but this is traditionally the way IBM at least do things
*/
-u64 __init fdt_translate_address(const void *blob, int node_offset)
+static u64 __init fdt_translate_address(const void *blob, int node_offset)
{
int parent, len;
const struct of_bus *bus, *pbus;
@@ -239,3 +239,12 @@ u64 __init fdt_translate_address(const void *blob, int node_offset)
bail:
return result;
}
+
+/**
+ * of_flat_dt_translate_address - translate DT addr into CPU phys addr
+ * @node: node in the flat blob
+ */
+u64 __init of_flat_dt_translate_address(unsigned long node)
+{
+ return fdt_translate_address(initial_boot_params, node);
+}
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index b618015..0d8f187 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -215,8 +215,7 @@ early_param("earlycon", param_setup_earlycon);

#ifdef CONFIG_OF_EARLY_FLATTREE

-int __init of_setup_earlycon(unsigned long addr,
- const struct earlycon_id *match,
+int __init of_setup_earlycon(const struct earlycon_id *match,
unsigned long node,
const char *options)
{
@@ -225,9 +224,13 @@ int __init of_setup_earlycon(unsigned long addr,
const __be32 *val;

port->iotype = UPIO_MEM;
- port->mapbase = addr;
+ port->mapbase = of_flat_dt_translate_address(node);
+ if (!port->mapbase) {
+ pr_warn("[%s] bad address\n", match->name);
+ return -ENXIO;
+ }
port->uartclk = BASE_BAUD * 16;
- port->membase = earlycon_map(addr, SZ_4K);
+ port->membase = earlycon_map(port->mapbase, SZ_4K);

val = of_get_flat_dt_prop(node, "reg-offset", NULL);
if (val)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 0ff360d..d31e6cb 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -85,7 +85,7 @@ extern void unflatten_device_tree(void);
extern void unflatten_and_copy_device_tree(void);
extern void early_init_devtree(void *);
extern void early_get_first_memblock_info(void *, phys_addr_t *);
-extern u64 fdt_translate_address(const void *blob, int node_offset);
+extern u64 of_flat_dt_translate_address(unsigned long node);
extern void of_fdt_limit_memory(int limit);
#else /* CONFIG_OF_FLATTREE */
static inline void early_init_fdt_scan_reserved_mem(void) {}
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index fe48f4e..16ee372 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -358,7 +358,7 @@ extern const struct earlycon_id __earlycon_table_end[];
#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)

extern int setup_earlycon(char *buf);
-extern int of_setup_earlycon(unsigned long addr, const struct earlycon_id *match,
+extern int of_setup_earlycon(const struct earlycon_id *match,
unsigned long node,
const char *options);

--
2.3.5

2015-04-08 17:47:29

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 09/13] serial: earlycon: Common log banner for command line and DT

Refactor the command line earlycon banner into earlycon_init() so
both earlycon startup methods output an info banner.

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/tty/serial/earlycon.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 0d8f187..7c61581 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -61,6 +61,7 @@ static void __init earlycon_init(struct earlycon_device *device,
const char *name)
{
struct console *earlycon = device->con;
+ struct uart_port *port = &device->port;
const char *s;
size_t len;

@@ -74,6 +75,16 @@ static void __init earlycon_init(struct earlycon_device *device,
len = s - name;
strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
earlycon->data = &early_console_dev;
+
+ if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32)
+ pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+ (port->iotype == UPIO_MEM32) ? "32" : "",
+ (unsigned long long)port->mapbase,
+ device->options);
+ else
+ pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+ port->iobase,
+ device->options);
}

static int __init parse_options(struct earlycon_device *device, char *options)
@@ -105,16 +116,6 @@ static int __init parse_options(struct earlycon_device *device, char *options)
strlcpy(device->options, options, length);
}

- if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32)
- pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
- (port->iotype == UPIO_MEM32) ? "32" : "",
- (unsigned long long)port->mapbase,
- device->options);
- else
- pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
- port->iobase,
- device->options);
-
return 0;
}

--
2.3.5

2015-04-08 17:47:08

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 10/13] serial: earlycon: Show the earlycon "driver" in banner

Output the earlycon "driver" from the just-parsed console 'name'
and 'index' fields.

NB: ->mapbase is a resource_size_t so use %pa format specifier
Signed-off-by: Peter Hurley <[email protected]>
---
drivers/tty/serial/earlycon.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index 7c61581..9834afc 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -77,12 +77,14 @@ static void __init earlycon_init(struct earlycon_device *device,
earlycon->data = &early_console_dev;

if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM32)
- pr_info("Early serial console at MMIO%s 0x%llx (options '%s')\n",
+ pr_info("%s%d at MMIO%s %pa (options '%s')\n",
+ earlycon->name, earlycon->index,
(port->iotype == UPIO_MEM32) ? "32" : "",
- (unsigned long long)port->mapbase,
+ &port->mapbase,
device->options);
else
- pr_info("Early serial console at I/O port 0x%lx (options '%s')\n",
+ pr_info("%s%d at I/O port 0x%lx (options '%s')\n",
+ earlycon->name, earlycon->index,
port->iobase,
device->options);
}
--
2.3.5

2015-04-08 17:46:50

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 11/13] of: earlycon: Log more helpful message if earlycon not found

Earlycon may fail to initialize for a variety of reasons, most of
which log the default early param message. If the earlycon is
not found, log the OF path which was not found (and suppress the
default early param message).

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/of/fdt.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 007c330..f55c77c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -800,7 +800,8 @@ static int __init early_init_dt_scan_chosen_serial(void)
of_setup_earlycon(match, offset, options);
return 0;
}
- return -ENODEV;
+ pr_warn("earlycon: %.*s no match\n", (int)(q - p), p);
+ return 0;
}

static int __init setup_of_earlycon(char *buf)
--
2.3.5

2015-04-08 17:46:14

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 12/13] serial: 8250_early: Use port->regshift

earlycon initializes struct uart_port::regshift to the correct
value for UPIO_MEM32 already. Use the port field rather than
hard-coded value.

This enables broader support for various i/o access methods in
8250 earlycon (eg., omap8250 earlycon).

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/tty/serial/8250/8250_early.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 8e11968..1b5aca3 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -37,11 +37,13 @@

unsigned int __weak __init serial8250_early_in(struct uart_port *port, int offset)
{
+ offset <<= port->regshift;
+
switch (port->iotype) {
case UPIO_MEM:
return readb(port->membase + offset);
case UPIO_MEM32:
- return readl(port->membase + (offset << 2));
+ return readl(port->membase + offset);
case UPIO_PORT:
return inb(port->iobase + offset);
default:
@@ -51,12 +53,14 @@ unsigned int __weak __init serial8250_early_in(struct uart_port *port, int offse

void __weak __init serial8250_early_out(struct uart_port *port, int offset, int value)
{
+ offset <<= port->regshift;
+
switch (port->iotype) {
case UPIO_MEM:
writeb(value, port->membase + offset);
break;
case UPIO_MEM32:
- writel(value, port->membase + (offset << 2));
+ writel(value, port->membase + offset);
break;
case UPIO_PORT:
outb(value, port->iobase + offset);
--
2.3.5

2015-04-08 17:46:11

by Peter Hurley

[permalink] [raw]
Subject: [PATCH v3 13/13] serial: 8250_omap: Add omap8250 earlycon

Add DT earlycon for 8250_omap driver. This boot console is included
for kernels built with CONFIG_SERIAL_EARLYCON=y, CONFIG_OF=y,
CONFIG_SERIAL_8250_OMAP=y, and CONFIG_OF_EARLY_FLATTREE=y.

This boot console is enabled with the command line option "earlycon"
(without "=<name>...") when the DT 'stdout-path' property matches a
compatible uart. For example,

/ {
chosen {
stdout-path = "serial0:115200";
};

....

aliases {
serial0 = &uart0;
};

....

ocp : ocp {
uart0 : serial@44e09000 {
compatible = "ti,omap3-uart";
}
};
};

Signed-off-by: Peter Hurley <[email protected]>
---
drivers/tty/serial/8250/8250_early.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 1b5aca3..e5ce06e 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -149,5 +149,26 @@ static int __init early_serial8250_setup(struct earlycon_device *device,
device->con->write = early_serial8250_write;
return 0;
}
+
EARLYCON_DECLARE(uart8250, early_serial8250_setup);
EARLYCON_DECLARE(uart, early_serial8250_setup);
+
+#ifdef CONFIG_SERIAL_8250_OMAP
+
+static int __init early_omap8250_setup(struct earlycon_device *device,
+ const char *options)
+{
+ struct uart_port *port = &device->port;
+
+ if (!(device->port.membase || device->port.iobase))
+ return -ENODEV;
+
+ port->regshift = 2;
+ device->con->write = early_serial8250_write;
+ return 0;
+}
+
+OF_EARLYCON_DECLARE(omap8250, "ti,omap2-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap3-uart", early_omap8250_setup);
+OF_EARLYCON_DECLARE(omap8250, "ti,omap4-uart", early_omap8250_setup);
+#endif
--
2.3.5

2015-04-08 18:07:10

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v3 00/13] Earlycon cleanup

On 04/08/2015 01:45 PM, Peter Hurley wrote:
> Hi Greg, Grant & Rob,
>
> This patch series builds on my earlier "Extensible console matching &
> direct earlycon" to add several useful features to earlycon:
> * Proper port i/o configuration from DT node with of_serial properties
> (such as reg-io-width, reg-shift and reg-offset)
> * Proper console name & index initialization from earlycon name
> (for both command line and DT-defined earlycons)
> * Support for DT 'stdout-path' options pass-through to earlycon setup
> * Improved log messages for troubleshooting
> * Support for multiple OF earlycon declarations so different
> compatible strings can specify the same OF earlycon
>
> * Changes from v1 *
>
> - Rebase on top of device-tree compiler patch submission,
> "libfdt: Add fdt_path_offset_namelen()"
> - Fixed x86 build breakage, conditionally compile of_setup_earlycon();
> Note: this should have already been the case since of_setup_earlycon()
> is dead code without CONFIG_OF_EARLY_FLATTREE
> - Fixed Geert's suggestion to change the printf specifier for ->mapbase
> - Fixed initial console index value for earlycon name without trailing
> numerals
>
> * Changes from v2 *
>
> - All earlycon declarations are now in a single table, with a common
> framework for devicetree and command line earlycons
>
>
> Requires: 1) "libfdt: Add fdt_path_offset_namelen()" -- now in
> upstream dtc

also requires "earlycon: Fix __earlycon_table stride"


> 2) the last patch which adds omap8250 earlycon requires some
> kind of fixmap support, such as "ARM: early fixmap support
> for earlycon", which has not yet been accepted upstream.
>
> Regards,
>
> Peter Hurley (13):
> of: earlycon: Fix 'stdout-path' with ':' path terminator
> earlycon: Use common framework for earlycon declarations
> serial: earlycon: Fixup earlycon console name and index
> of: earlycon: Fixup earlycon console name and index
> of: earlycon: Add options string handling
> of: earlycon: of_setup_earlycon() requires CONFIG_OF_EARLY_FLATTREE
> of: earlycon: Initialize port fields from DT properties
> of: earlycon: Move address translation to of_setup_earlycon()
> serial: earlycon: Common log banner for command line and DT
> serial: earlycon: Show the earlycon "driver" in banner
> of: earlycon: Log more helpful message if earlycon not found
> serial: 8250_early: Use port->regshift
> serial: 8250_omap: Add omap8250 earlycon
>
> drivers/of/fdt.c | 28 ++++-----
> drivers/of/fdt_address.c | 11 +++-
> drivers/tty/serial/8250/8250_early.c | 29 +++++++++-
> drivers/tty/serial/amba-pl011.c | 1 -
> drivers/tty/serial/arc_uart.c | 1 -
> drivers/tty/serial/earlycon.c | 109 ++++++++++++++++++++++++++---------
> drivers/tty/serial/msm_serial.c | 2 -
> drivers/tty/serial/samsung.c | 6 --
> drivers/tty/serial/sprd_serial.c | 2 -
> include/asm-generic/vmlinux.lds.h | 8 +--
> include/linux/of_fdt.h | 2 +-
> include/linux/serial_core.h | 25 ++++----
> 12 files changed, 151 insertions(+), 73 deletions(-)
>

2015-04-08 21:24:29

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <[email protected]> wrote:
> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
> ("of: add optional options parameter to of_find_node_by_path()") added
> the necessary support to parse paths terminated with ':'.
> commit 7914a7c5651a5 ("of: support passing console options with
> stdout-path") added options string support to the stdout-path property,
> which broke earlycon.
>
> Add the same support to earlycon to process 'stdout-path' properties
> which contain an options string.
>
> Requires: "libfdt: Add fdt_path_offset_namelen()"

Since David has applied this, we can cherrypick that commit for the
kernel copy. Ideally, we would do a dtc sync, but it's not going to
happen for 4.1.

Rob

> Cc: Leif Lindholm <[email protected]>
> Signed-off-by: Peter Hurley <[email protected]>
> ---
> drivers/of/fdt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9..7cef9f9 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -765,7 +765,7 @@ extern struct of_device_id __earlycon_of_table[];
> static int __init early_init_dt_scan_chosen_serial(void)
> {
> int offset;
> - const char *p;
> + const char *p, *q;
> int l;
> const struct of_device_id *match = __earlycon_of_table;
> const void *fdt = initial_boot_params;
> @@ -782,8 +782,10 @@ static int __init early_init_dt_scan_chosen_serial(void)
> if (!p || !l)
> return -ENOENT;
>
> + q = strchrnul(p, ':');
> +
> /* Get the node specified by stdout-path */
> - offset = fdt_path_offset(fdt, p);
> + offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
> if (offset < 0)
> return -ENODEV;
>
> --
> 2.3.5
>

2015-04-28 11:38:42

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v3 12/13] serial: 8250_early: Use port->regshift

On Wed, Apr 08, 2015 at 01:45:18PM -0400, Peter Hurley wrote:
> earlycon initializes struct uart_port::regshift to the correct
> value for UPIO_MEM32 already. Use the port field rather than
> hard-coded value.
>
> This enables broader support for various i/o access methods in
> 8250 earlycon (eg., omap8250 earlycon).
>
> Signed-off-by: Peter Hurley <[email protected]>
> ---
> drivers/tty/serial/8250/8250_early.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)

This patch fails to apply to my tty-testing branch. Can you refresh it
and resend this one, and patch 13/13 so that I can apply them?

thanks,

greg k-h

2015-04-28 13:08:12

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

On 04/08/2015 05:24 PM, Rob Herring wrote:
> On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <[email protected]> wrote:
>> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
>> ("of: add optional options parameter to of_find_node_by_path()") added
>> the necessary support to parse paths terminated with ':'.
>> commit 7914a7c5651a5 ("of: support passing console options with
>> stdout-path") added options string support to the stdout-path property,
>> which broke earlycon.
>>
>> Add the same support to earlycon to process 'stdout-path' properties
>> which contain an options string.
>>
>> Requires: "libfdt: Add fdt_path_offset_namelen()"
>
> Since David has applied this, we can cherrypick that commit for the
> kernel copy. Ideally, we would do a dtc sync, but it's not going to
> happen for 4.1.

Rob,

Greg pulled this series for -next and kbuild robot promptly blew up
because of this missing commit. Are you planning on cherry-picking
"libfdt: Add fdt_path_offset_namelen()"?

Regards,
Peter Hurley

2015-04-28 13:28:47

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

On Tue, Apr 28, 2015 at 09:07:54AM -0400, Peter Hurley wrote:
> On 04/08/2015 05:24 PM, Rob Herring wrote:
> > On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <[email protected]> wrote:
> >> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
> >> ("of: add optional options parameter to of_find_node_by_path()") added
> >> the necessary support to parse paths terminated with ':'.
> >> commit 7914a7c5651a5 ("of: support passing console options with
> >> stdout-path") added options string support to the stdout-path property,
> >> which broke earlycon.
> >>
> >> Add the same support to earlycon to process 'stdout-path' properties
> >> which contain an options string.
> >>
> >> Requires: "libfdt: Add fdt_path_offset_namelen()"
> >
> > Since David has applied this, we can cherrypick that commit for the
> > kernel copy. Ideally, we would do a dtc sync, but it's not going to
> > happen for 4.1.
>
> Rob,
>
> Greg pulled this series for -next and kbuild robot promptly blew up
> because of this missing commit. Are you planning on cherry-picking
> "libfdt: Add fdt_path_offset_namelen()"?

Can I just take that patch so I don't see the build issues in my branch?

thanks,

greg k-h

2015-04-28 13:58:34

by Peter Hurley

[permalink] [raw]
Subject: Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

On 04/28/2015 09:28 AM, Greg Kroah-Hartman wrote:
> On Tue, Apr 28, 2015 at 09:07:54AM -0400, Peter Hurley wrote:
>> On 04/08/2015 05:24 PM, Rob Herring wrote:
>>> On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <[email protected]> wrote:
>>>> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
>>>> ("of: add optional options parameter to of_find_node_by_path()") added
>>>> the necessary support to parse paths terminated with ':'.
>>>> commit 7914a7c5651a5 ("of: support passing console options with
>>>> stdout-path") added options string support to the stdout-path property,
>>>> which broke earlycon.
>>>>
>>>> Add the same support to earlycon to process 'stdout-path' properties
>>>> which contain an options string.
>>>>
>>>> Requires: "libfdt: Add fdt_path_offset_namelen()"
>>>
>>> Since David has applied this, we can cherrypick that commit for the
>>> kernel copy. Ideally, we would do a dtc sync, but it's not going to
>>> happen for 4.1.
>>
>> Rob,
>>
>> Greg pulled this series for -next and kbuild robot promptly blew up
>> because of this missing commit. Are you planning on cherry-picking
>> "libfdt: Add fdt_path_offset_namelen()"?
>
> Can I just take that patch so I don't see the build issues in my branch?

It's ok with me, fwiw.

However, you should be aware that the patch is for the out-of-tree
devicetree compiler at git://git.kernel.org/pub/scm/utils/dtc/dtc.git,
which is not the same as in-tree compiler.

I could send you an edited patch that applies cleanly to the
in-tree compiler but I don't know how Rob and Grant feel about that.

Regards,
Peter Hurley

2015-04-28 14:02:46

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

On Tue, Apr 28, 2015 at 8:58 AM, Peter Hurley <[email protected]> wrote:
> On 04/28/2015 09:28 AM, Greg Kroah-Hartman wrote:
>> On Tue, Apr 28, 2015 at 09:07:54AM -0400, Peter Hurley wrote:
>>> On 04/08/2015 05:24 PM, Rob Herring wrote:
>>>> On Wed, Apr 8, 2015 at 12:45 PM, Peter Hurley <[email protected]> wrote:
>>>>> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
>>>>> ("of: add optional options parameter to of_find_node_by_path()") added
>>>>> the necessary support to parse paths terminated with ':'.
>>>>> commit 7914a7c5651a5 ("of: support passing console options with
>>>>> stdout-path") added options string support to the stdout-path property,
>>>>> which broke earlycon.
>>>>>
>>>>> Add the same support to earlycon to process 'stdout-path' properties
>>>>> which contain an options string.
>>>>>
>>>>> Requires: "libfdt: Add fdt_path_offset_namelen()"
>>>>
>>>> Since David has applied this, we can cherrypick that commit for the
>>>> kernel copy. Ideally, we would do a dtc sync, but it's not going to
>>>> happen for 4.1.
>>>
>>> Rob,
>>>
>>> Greg pulled this series for -next and kbuild robot promptly blew up
>>> because of this missing commit. Are you planning on cherry-picking
>>> "libfdt: Add fdt_path_offset_namelen()"?
>>
>> Can I just take that patch so I don't see the build issues in my branch?
>
> It's ok with me, fwiw.
>
> However, you should be aware that the patch is for the out-of-tree
> devicetree compiler at git://git.kernel.org/pub/scm/utils/dtc/dtc.git,
> which is not the same as in-tree compiler.
>
> I could send you an edited patch that applies cleanly to the
> in-tree compiler but I don't know how Rob and Grant feel about that.

That is what I suggested above if it was for 4.1. I would like to get
a full sync of dtc done for 4.2 though. Give me a few days and I'll
try to get that done.

Rob

2015-07-22 10:16:14

by Sudeep Holla

[permalink] [raw]
Subject: Re: [PATCH v3 01/13] of: earlycon: Fix 'stdout-path' with ':' path terminator

On Wed, Apr 8, 2015 at 6:45 PM, Peter Hurley <[email protected]> wrote:
> stdout-path defines ':' as a path terminator and commit 75c28c09af99a
> ("of: add optional options parameter to of_find_node_by_path()") added
> the necessary support to parse paths terminated with ':'.
> commit 7914a7c5651a5 ("of: support passing console options with
> stdout-path") added options string support to the stdout-path property,
> which broke earlycon.
>
> Add the same support to earlycon to process 'stdout-path' properties
> which contain an options string.
>

Any update on this patch ? Without this earlycon fails to parse stdout-path
with baud separated by ':'

Regards,
sudeep

> Requires: "libfdt: Add fdt_path_offset_namelen()"
> Cc: Leif Lindholm <[email protected]>
> Signed-off-by: Peter Hurley <[email protected]>
> ---
> drivers/of/fdt.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 3a896c9..7cef9f9 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -765,7 +765,7 @@ extern struct of_device_id __earlycon_of_table[];
> static int __init early_init_dt_scan_chosen_serial(void)
> {
> int offset;
> - const char *p;
> + const char *p, *q;
> int l;
> const struct of_device_id *match = __earlycon_of_table;
> const void *fdt = initial_boot_params;
> @@ -782,8 +782,10 @@ static int __init early_init_dt_scan_chosen_serial(void)
> if (!p || !l)
> return -ENOENT;
>
> + q = strchrnul(p, ':');
> +
> /* Get the node specified by stdout-path */
> - offset = fdt_path_offset(fdt, p);
> + offset = fdt_path_offset_namelen(fdt, p, (int)(q - p));
> if (offset < 0)
> return -ENODEV;
>
> --
> 2.3.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/