2018-03-15 01:49:37

by Daniel Kurtz

[permalink] [raw]
Subject: [PATCH v2] earlycon: Fix __earlycon_table stride... again

Commit 470ca0de69fe ("serial: earlycon: Enable earlycon without command
line param") added EARLYCON_TABLE().

Commit 99492c39f39f ("earlycon: Fix __earlycon_table stride") referenced
commit 07fca0e57fca92 ("tracing: Properly align linker defined symbols")
and tried to fix EARLYCON_TABLE() using __aligned(32).

However, the fix copied just works around compiler behavior. In fact, it
was subsequently re-implemented for tracing using a table of pointers in
commit 3d56e331b653 ("tracing: Replace syscall_meta_data struct array with
pointer array"), commit 654986462939 ("tracepoints: Fix section alignment
using pointer array") and commit e4a9ea5ee7c8 ("tracing: Replace
trace_event struct array with pointer array").

Let's do the same "array of pointers to structs" approach for
EARLYCON_TABLE.

Signed-off-by: Daniel Kurtz <[email protected]>
---
Changes since v1:
* Change __earlycon_table to an array of pointers.

Note: I do not have a convenient system to test the of/fdt.c part of this
patch, so would apreciate help verifying it. Thanks!

drivers/of/fdt.c | 7 +++++--
drivers/tty/serial/earlycon.c | 6 ++++--
include/asm-generic/vmlinux.lds.h | 2 +-
include/linux/serial_core.h | 21 ++++++++++++++-------
4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 84aa9d676375..6da20b9688f7 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -942,7 +942,7 @@ int __init early_init_dt_scan_chosen_stdout(void)
int offset;
const char *p, *q, *options = NULL;
int l;
- const struct earlycon_id *match;
+ const struct earlycon_id **p_match;
const void *fdt = initial_boot_params;

offset = fdt_path_offset(fdt, "/chosen");
@@ -969,7 +969,10 @@ int __init early_init_dt_scan_chosen_stdout(void)
return 0;
}

- for (match = __earlycon_table; match < __earlycon_table_end; match++) {
+ for (p_match = __earlycon_table; p_match < __earlycon_table_end;
+ p_match++) {
+ const struct earlycon_id *match = *p_match;
+
if (!match->compatible[0])
continue;

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index a24278380fec..22683393a0f2 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -169,7 +169,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
*/
int __init setup_earlycon(char *buf)
{
- const struct earlycon_id *match;
+ const struct earlycon_id **p_match;

if (!buf || !buf[0])
return -EINVAL;
@@ -177,7 +177,9 @@ int __init setup_earlycon(char *buf)
if (early_con.flags & CON_ENABLED)
return -EALREADY;

- for (match = __earlycon_table; match < __earlycon_table_end; match++) {
+ for (p_match = __earlycon_table; p_match < __earlycon_table_end;
+ p_match++) {
+ const struct earlycon_id *match = *p_match;
size_t len = strlen(match->name);

if (strncmp(buf, match->name, len))
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 1ab0e520d6fc..e17de55c2542 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -179,7 +179,7 @@
#endif

#ifdef CONFIG_SERIAL_EARLYCON
-#define EARLYCON_TABLE() STRUCT_ALIGN(); \
+#define EARLYCON_TABLE() . = ALIGN(8); \
VMLINUX_SYMBOL(__earlycon_table) = .; \
KEEP(*(__earlycon_table)) \
VMLINUX_SYMBOL(__earlycon_table_end) = .;
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index b32df49a3bd5..93b7add47087 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -351,10 +351,10 @@ 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[];
+extern const struct earlycon_id *__earlycon_table[];
+extern const struct earlycon_id *__earlycon_table_end[];

#if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
#define EARLYCON_USED_OR_UNUSED __used
@@ -362,12 +362,19 @@ extern const struct earlycon_id __earlycon_table_end[];
#define EARLYCON_USED_OR_UNUSED __maybe_unused
#endif

-#define OF_EARLYCON_DECLARE(_name, compat, fn) \
- static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
- EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \
+#define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \
+ static const struct earlycon_id unique_id \
+ EARLYCON_USED_OR_UNUSED __initdata \
= { .name = __stringify(_name), \
.compatible = compat, \
- .setup = fn }
+ .setup = fn }; \
+ static const struct earlycon_id EARLYCON_USED_OR_UNUSED \
+ __section(__earlycon_table) \
+ * const __PASTE(__p, unique_id) = &unique_id
+
+#define OF_EARLYCON_DECLARE(_name, compat, fn) \
+ _OF_EARLYCON_DECLARE(_name, compat, fn, \
+ __UNIQUE_ID(__earlycon_##_name))

#define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)

--
2.16.2.804.g6dcf76e118-goog



2018-03-15 01:59:05

by Daniel Kurtz

[permalink] [raw]
Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again

On Wed, Mar 14, 2018 at 7:48 PM Daniel Kurtz <[email protected]> wrote:

> Commit 470ca0de69fe ("serial: earlycon: Enable earlycon without command
> line param") added EARLYCON_TABLE().

> Commit 99492c39f39f ("earlycon: Fix __earlycon_table stride") referenced
> commit 07fca0e57fca92 ("tracing: Properly align linker defined symbols")
> and tried to fix EARLYCON_TABLE() using __aligned(32).

> However, the fix copied just works around compiler behavior. In fact, it
> was subsequently re-implemented for tracing using a table of pointers in
> commit 3d56e331b653 ("tracing: Replace syscall_meta_data struct array with
> pointer array"), commit 654986462939 ("tracepoints: Fix section alignment
> using pointer array") and commit e4a9ea5ee7c8 ("tracing: Replace
> trace_event struct array with pointer array").

> Let's do the same "array of pointers to structs" approach for
> EARLYCON_TABLE.

> Signed-off-by: Daniel Kurtz <[email protected]>

Oops, I forgot to add:

Suggested-by: Aaron Durbin <[email protected]>

> ---
> Changes since v1:
> * Change __earlycon_table to an array of pointers.

> Note: I do not have a convenient system to test the of/fdt.c part of this
> patch, so would apreciate help verifying it. Thanks!

> drivers/of/fdt.c | 7 +++++--
> drivers/tty/serial/earlycon.c | 6 ++++--
> include/asm-generic/vmlinux.lds.h | 2 +-
> include/linux/serial_core.h | 21 ++++++++++++++-------
> 4 files changed, 24 insertions(+), 12 deletions(-)

> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 84aa9d676375..6da20b9688f7 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -942,7 +942,7 @@ int __init early_init_dt_scan_chosen_stdout(void)
> int offset;
> const char *p, *q, *options = NULL;
> int l;
> - const struct earlycon_id *match;
> + const struct earlycon_id **p_match;
> const void *fdt = initial_boot_params;

> offset = fdt_path_offset(fdt, "/chosen");
> @@ -969,7 +969,10 @@ int __init early_init_dt_scan_chosen_stdout(void)
> return 0;
> }

> - for (match = __earlycon_table; match < __earlycon_table_end;
match++) {
> + for (p_match = __earlycon_table; p_match < __earlycon_table_end;
> + p_match++) {
> + const struct earlycon_id *match = *p_match;
> +
> if (!match->compatible[0])
> continue;

> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index a24278380fec..22683393a0f2 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -169,7 +169,7 @@ static int __init register_earlycon(char *buf, const
struct earlycon_id *match)
> */
> int __init setup_earlycon(char *buf)
> {
> - const struct earlycon_id *match;
> + const struct earlycon_id **p_match;

> if (!buf || !buf[0])
> return -EINVAL;
> @@ -177,7 +177,9 @@ int __init setup_earlycon(char *buf)
> if (early_con.flags & CON_ENABLED)
> return -EALREADY;

> - for (match = __earlycon_table; match < __earlycon_table_end;
match++) {
> + for (p_match = __earlycon_table; p_match < __earlycon_table_end;
> + p_match++) {
> + const struct earlycon_id *match = *p_match;
> size_t len = strlen(match->name);

> if (strncmp(buf, match->name, len))
> diff --git a/include/asm-generic/vmlinux.lds.h
b/include/asm-generic/vmlinux.lds.h
> index 1ab0e520d6fc..e17de55c2542 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -179,7 +179,7 @@
> #endif

> #ifdef CONFIG_SERIAL_EARLYCON
> -#define EARLYCON_TABLE() STRUCT_ALIGN(); \
> +#define EARLYCON_TABLE() . = ALIGN(8); \
> VMLINUX_SYMBOL(__earlycon_table) = .; \
> KEEP(*(__earlycon_table)) \
> VMLINUX_SYMBOL(__earlycon_table_end) = .;
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index b32df49a3bd5..93b7add47087 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -351,10 +351,10 @@ 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[];
> +extern const struct earlycon_id *__earlycon_table[];
> +extern const struct earlycon_id *__earlycon_table_end[];

> #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
> #define EARLYCON_USED_OR_UNUSED __used
> @@ -362,12 +362,19 @@ extern const struct earlycon_id
__earlycon_table_end[];
> #define EARLYCON_USED_OR_UNUSED __maybe_unused
> #endif

> -#define OF_EARLYCON_DECLARE(_name, compat, fn) \
> - static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
> - EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \
> +#define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \
> + static const struct earlycon_id unique_id \
> + EARLYCON_USED_OR_UNUSED __initdata \
> = { .name = __stringify(_name), \
> .compatible = compat, \
> - .setup = fn }
> + .setup = fn }; \
> + static const struct earlycon_id EARLYCON_USED_OR_UNUSED \
> + __section(__earlycon_table) \
> + * const __PASTE(__p, unique_id) = &unique_id
> +
> +#define OF_EARLYCON_DECLARE(_name, compat, fn) \
> + _OF_EARLYCON_DECLARE(_name, compat, fn, \
> + __UNIQUE_ID(__earlycon_##_name))

> #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)

> --
> 2.16.2.804.g6dcf76e118-goog

2018-03-15 02:34:46

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again

On 03/14/2018 06:48 PM, Daniel Kurtz wrote:
> Commit 470ca0de69fe ("serial: earlycon: Enable earlycon without command
> line param") added EARLYCON_TABLE().
>
> Commit 99492c39f39f ("earlycon: Fix __earlycon_table stride") referenced
> commit 07fca0e57fca92 ("tracing: Properly align linker defined symbols")
> and tried to fix EARLYCON_TABLE() using __aligned(32).
>
> However, the fix copied just works around compiler behavior. In fact, it
> was subsequently re-implemented for tracing using a table of pointers in
> commit 3d56e331b653 ("tracing: Replace syscall_meta_data struct array with
> pointer array"), commit 654986462939 ("tracepoints: Fix section alignment
> using pointer array") and commit e4a9ea5ee7c8 ("tracing: Replace
> trace_event struct array with pointer array").
>
> Let's do the same "array of pointers to structs" approach for
> EARLYCON_TABLE.

Please describe what the problem is instead of just what the fix is.
Thanks.

> Signed-off-by: Daniel Kurtz <[email protected]>
> ---
> Changes since v1:
> * Change __earlycon_table to an array of pointers.
>
> Note: I do not have a convenient system to test the of/fdt.c part of this
> patch, so would apreciate help verifying it. Thanks!
>
> drivers/of/fdt.c | 7 +++++--
> drivers/tty/serial/earlycon.c | 6 ++++--
> include/asm-generic/vmlinux.lds.h | 2 +-
> include/linux/serial_core.h | 21 ++++++++++++++-------
> 4 files changed, 24 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 84aa9d676375..6da20b9688f7 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -942,7 +942,7 @@ int __init early_init_dt_scan_chosen_stdout(void)
> int offset;
> const char *p, *q, *options = NULL;
> int l;
> - const struct earlycon_id *match;
> + const struct earlycon_id **p_match;
> const void *fdt = initial_boot_params;
>
> offset = fdt_path_offset(fdt, "/chosen");
> @@ -969,7 +969,10 @@ int __init early_init_dt_scan_chosen_stdout(void)
> return 0;
> }
>
> - for (match = __earlycon_table; match < __earlycon_table_end; match++) {
> + for (p_match = __earlycon_table; p_match < __earlycon_table_end;
> + p_match++) {
> + const struct earlycon_id *match = *p_match;
> +
> if (!match->compatible[0])
> continue;
>
> diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
> index a24278380fec..22683393a0f2 100644
> --- a/drivers/tty/serial/earlycon.c
> +++ b/drivers/tty/serial/earlycon.c
> @@ -169,7 +169,7 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
> */
> int __init setup_earlycon(char *buf)
> {
> - const struct earlycon_id *match;
> + const struct earlycon_id **p_match;
>
> if (!buf || !buf[0])
> return -EINVAL;
> @@ -177,7 +177,9 @@ int __init setup_earlycon(char *buf)
> if (early_con.flags & CON_ENABLED)
> return -EALREADY;
>
> - for (match = __earlycon_table; match < __earlycon_table_end; match++) {
> + for (p_match = __earlycon_table; p_match < __earlycon_table_end;
> + p_match++) {
> + const struct earlycon_id *match = *p_match;
> size_t len = strlen(match->name);
>
> if (strncmp(buf, match->name, len))
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index 1ab0e520d6fc..e17de55c2542 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -179,7 +179,7 @@
> #endif
>
> #ifdef CONFIG_SERIAL_EARLYCON
> -#define EARLYCON_TABLE() STRUCT_ALIGN(); \
> +#define EARLYCON_TABLE() . = ALIGN(8); \
> VMLINUX_SYMBOL(__earlycon_table) = .; \
> KEEP(*(__earlycon_table)) \
> VMLINUX_SYMBOL(__earlycon_table_end) = .;
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index b32df49a3bd5..93b7add47087 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -351,10 +351,10 @@ 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[];
> +extern const struct earlycon_id *__earlycon_table[];
> +extern const struct earlycon_id *__earlycon_table_end[];
>
> #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
> #define EARLYCON_USED_OR_UNUSED __used
> @@ -362,12 +362,19 @@ extern const struct earlycon_id __earlycon_table_end[];
> #define EARLYCON_USED_OR_UNUSED __maybe_unused
> #endif
>
> -#define OF_EARLYCON_DECLARE(_name, compat, fn) \
> - static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
> - EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \
> +#define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \
> + static const struct earlycon_id unique_id \
> + EARLYCON_USED_OR_UNUSED __initdata \
> = { .name = __stringify(_name), \
> .compatible = compat, \
> - .setup = fn }
> + .setup = fn }; \
> + static const struct earlycon_id EARLYCON_USED_OR_UNUSED \
> + __section(__earlycon_table) \
> + * const __PASTE(__p, unique_id) = &unique_id
> +
> +#define OF_EARLYCON_DECLARE(_name, compat, fn) \
> + _OF_EARLYCON_DECLARE(_name, compat, fn, \
> + __UNIQUE_ID(__earlycon_##_name))
>
> #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
>
>


--
~Randy

2018-03-15 16:16:58

by Daniel Kurtz

[permalink] [raw]
Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again

On Wed, Mar 14, 2018 at 8:33 PM Randy Dunlap <[email protected]> wrote:

> On 03/14/2018 06:48 PM, Daniel Kurtz wrote:
> > Commit 470ca0de69fe ("serial: earlycon: Enable earlycon without command
> > line param") added EARLYCON_TABLE().
> >
> > Commit 99492c39f39f ("earlycon: Fix __earlycon_table stride") referenced
> > commit 07fca0e57fca92 ("tracing: Properly align linker defined symbols")
> > and tried to fix EARLYCON_TABLE() using __aligned(32).
> >
> > However, the fix copied just works around compiler behavior. In fact,
it
> > was subsequently re-implemented for tracing using a table of pointers in
> > commit 3d56e331b653 ("tracing: Replace syscall_meta_data struct array
with
> > pointer array"), commit 654986462939 ("tracepoints: Fix section
alignment
> > using pointer array") and commit e4a9ea5ee7c8 ("tracing: Replace
> > trace_event struct array with pointer array").
> >
> > Let's do the same "array of pointers to structs" approach for
> > EARLYCON_TABLE.

> Please describe what the problem is instead of just what the fix is.
> Thanks.

The problem is the same as in 99492c39f39f; the __earlycon_table stride may
be wrong depending on how the compiler decides to align the contents of
__earlycon_table.
See the other referenced patches for a detailed description of the problem
and its solution.

-Dan


> > Signed-off-by: Daniel Kurtz <[email protected]>
> > ---
> > Changes since v1:
> > * Change __earlycon_table to an array of pointers.
> >
> > Note: I do not have a convenient system to test the of/fdt.c part of
this
> > patch, so would apreciate help verifying it. Thanks!
> >
> > drivers/of/fdt.c | 7 +++++--
> > drivers/tty/serial/earlycon.c | 6 ++++--
> > include/asm-generic/vmlinux.lds.h | 2 +-
> > include/linux/serial_core.h | 21 ++++++++++++++-------
> > 4 files changed, 24 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index 84aa9d676375..6da20b9688f7 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -942,7 +942,7 @@ int __init early_init_dt_scan_chosen_stdout(void)
> > int offset;
> > const char *p, *q, *options = NULL;
> > int l;
> > - const struct earlycon_id *match;
> > + const struct earlycon_id **p_match;
> > const void *fdt = initial_boot_params;
> >
> > offset = fdt_path_offset(fdt, "/chosen");
> > @@ -969,7 +969,10 @@ int __init early_init_dt_scan_chosen_stdout(void)
> > return 0;
> > }
> >
> > - for (match = __earlycon_table; match < __earlycon_table_end;
match++) {
> > + for (p_match = __earlycon_table; p_match < __earlycon_table_end;
> > + p_match++) {
> > + const struct earlycon_id *match = *p_match;
> > +
> > if (!match->compatible[0])
> > continue;
> >
> > diff --git a/drivers/tty/serial/earlycon.c
b/drivers/tty/serial/earlycon.c
> > index a24278380fec..22683393a0f2 100644
> > --- a/drivers/tty/serial/earlycon.c
> > +++ b/drivers/tty/serial/earlycon.c
> > @@ -169,7 +169,7 @@ static int __init register_earlycon(char *buf,
const struct earlycon_id *match)
> > */
> > int __init setup_earlycon(char *buf)
> > {
> > - const struct earlycon_id *match;
> > + const struct earlycon_id **p_match;
> >
> > if (!buf || !buf[0])
> > return -EINVAL;
> > @@ -177,7 +177,9 @@ int __init setup_earlycon(char *buf)
> > if (early_con.flags & CON_ENABLED)
> > return -EALREADY;
> >
> > - for (match = __earlycon_table; match < __earlycon_table_end;
match++) {
> > + for (p_match = __earlycon_table; p_match < __earlycon_table_end;
> > + p_match++) {
> > + const struct earlycon_id *match = *p_match;
> > size_t len = strlen(match->name);
> >
> > if (strncmp(buf, match->name, len))
> > diff --git a/include/asm-generic/vmlinux.lds.h
b/include/asm-generic/vmlinux.lds.h
> > index 1ab0e520d6fc..e17de55c2542 100644
> > --- a/include/asm-generic/vmlinux.lds.h
> > +++ b/include/asm-generic/vmlinux.lds.h
> > @@ -179,7 +179,7 @@
> > #endif
> >
> > #ifdef CONFIG_SERIAL_EARLYCON
> > -#define EARLYCON_TABLE() STRUCT_ALIGN(); \
> > +#define EARLYCON_TABLE() . = ALIGN(8); \
> > VMLINUX_SYMBOL(__earlycon_table) = .; \
> > KEEP(*(__earlycon_table)) \
> > VMLINUX_SYMBOL(__earlycon_table_end) = .;
> > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> > index b32df49a3bd5..93b7add47087 100644
> > --- a/include/linux/serial_core.h
> > +++ b/include/linux/serial_core.h
> > @@ -351,10 +351,10 @@ 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[];
> > +extern const struct earlycon_id *__earlycon_table[];
> > +extern const struct earlycon_id *__earlycon_table_end[];
> >
> > #if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
> > #define EARLYCON_USED_OR_UNUSED __used
> > @@ -362,12 +362,19 @@ extern const struct earlycon_id
__earlycon_table_end[];
> > #define EARLYCON_USED_OR_UNUSED __maybe_unused
> > #endif
> >
> > -#define OF_EARLYCON_DECLARE(_name, compat, fn)
\
> > - static const struct earlycon_id __UNIQUE_ID(__earlycon_##_name) \
> > - EARLYCON_USED_OR_UNUSED __section(__earlycon_table) \
> > +#define _OF_EARLYCON_DECLARE(_name, compat, fn, unique_id) \
> > + static const struct earlycon_id unique_id \
> > + EARLYCON_USED_OR_UNUSED __initdata \
> > = { .name = __stringify(_name), \
> > .compatible = compat, \
> > - .setup = fn }
> > + .setup = fn }; \
> > + static const struct earlycon_id EARLYCON_USED_OR_UNUSED \
> > + __section(__earlycon_table) \
> > + * const __PASTE(__p, unique_id) = &unique_id
> > +
> > +#define OF_EARLYCON_DECLARE(_name, compat, fn)
\
> > + _OF_EARLYCON_DECLARE(_name, compat, fn, \
> > + __UNIQUE_ID(__earlycon_##_name))
> >
> > #define EARLYCON_DECLARE(_name, fn) OF_EARLYCON_DECLARE(_name, "", fn)
> >
> >


> --
> ~Randy

2018-03-17 11:34:00

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again

Hi Daniel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v4.16-rc4]
[also build test ERROR on next-20180316]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Daniel-Kurtz/earlycon-Fix-__earlycon_table-stride-again/20180317-180525
config: h8300-h8300h-sim_defconfig (attached as .config)
compiler: h8300-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=h8300

All errors (new ones prefixed by >>):

In file included from include/asm-generic/bitops/le.h:6:0,
from arch/h8300/include/asm/bitops.h:177,
from include/linux/bitops.h:38,
from include/linux/kernel.h:11,
from include/linux/clk.h:16,
from drivers/tty/serial/sh-sci.c:24:
arch/h8300/include/asm/byteorder.h:5:0: warning: "__BIG_ENDIAN" redefined
#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__

In file included from <command-line>:0:0:
include/linux/kconfig.h:8:0: note: this is the location of the previous definition
#define __BIG_ENDIAN 4321

>> drivers/tty/serial/sh-sci.c:3278:29: error: port_cfg causes a section type conflict with __UNIQUE_ID___earlycon_hscif28
static struct plat_sci_port port_cfg __initdata;
^~~~~~~~
In file included from include/linux/serial_sci.h:6:0,
from drivers/tty/serial/sh-sci.c:45:
include/linux/compiler-gcc.h:193:45: note: '__UNIQUE_ID___earlycon_hscif28' was declared here
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^
include/linux/serial_core.h:366:34: note: in definition of macro '_OF_EARLYCON_DECLARE'
static const struct earlycon_id unique_id \
^~~~~~~~~
include/linux/compiler_types.h:53:22: note: in expansion of macro '___PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
^~~~~~~~
include/linux/compiler-gcc.h:193:29: note: in expansion of macro '__PASTE'
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^~~~~~~
include/linux/compiler_types.h:53:22: note: in expansion of macro '___PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
^~~~~~~~
include/linux/compiler-gcc.h:193:37: note: in expansion of macro '__PASTE'
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^~~~~~~
include/linux/serial_core.h:377:9: note: in expansion of macro '__UNIQUE_ID'
__UNIQUE_ID(__earlycon_##_name))
^~~~~~~~~~~
drivers/tty/serial/sh-sci.c:3330:1: note: in expansion of macro 'OF_EARLYCON_DECLARE'
OF_EARLYCON_DECLARE(hscif, "renesas,hscif", hscif_early_console_setup);
^~~~~~~~~~~~~~~~~~~

vim +3278 drivers/tty/serial/sh-sci.c

^1da177e drivers/serial/sh-sci.c Linus Torvalds 2005-04-16 3272
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3273 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3274 early_platform_init_buffer("earlyprintk", &sci_driver,
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3275 early_serial_buf, ARRAY_SIZE(early_serial_buf));
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3276 #endif
0b0cced1 drivers/tty/serial/sh-sci.c Yoshinori Sato 2015-12-24 3277 #ifdef CONFIG_SERIAL_SH_SCI_EARLYCON
dd076cff drivers/tty/serial/sh-sci.c Matthias Kaehlcke 2017-10-09 @3278 static struct plat_sci_port port_cfg __initdata;
0b0cced1 drivers/tty/serial/sh-sci.c Yoshinori Sato 2015-12-24 3279

:::::: The code at line 3278 was first introduced by commit
:::::: dd076cffb8cd675a8973fc9b6cea0c04be6f0111 serial: sh-sci: Fix init data attribute for struct 'port_cfg'

:::::: TO: Matthias Kaehlcke <[email protected]>
:::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (4.45 kB)
.config.gz (4.62 kB)
Download all attachments

2018-03-17 11:54:27

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2] earlycon: Fix __earlycon_table stride... again

Hi Daniel,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v4.16-rc4]
[also build test ERROR on next-20180316]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Daniel-Kurtz/earlycon-Fix-__earlycon_table-stride-again/20180317-180525
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=alpha

All errors (new ones prefixed by >>):

>> drivers/tty/serial/sh-sci.c:3278:29: error: port_cfg causes a section type conflict with __UNIQUE_ID___earlycon_hscif32
static struct plat_sci_port port_cfg __initdata;
^~~~~~~~
In file included from include/linux/serial_sci.h:6:0,
from drivers/tty/serial/sh-sci.c:45:
include/linux/compiler-gcc.h:193:45: note: '__UNIQUE_ID___earlycon_hscif32' was declared here
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^
include/linux/serial_core.h:366:34: note: in definition of macro '_OF_EARLYCON_DECLARE'
static const struct earlycon_id unique_id \
^~~~~~~~~
include/linux/compiler_types.h:53:22: note: in expansion of macro '___PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
^~~~~~~~
include/linux/compiler-gcc.h:193:29: note: in expansion of macro '__PASTE'
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^~~~~~~
include/linux/compiler_types.h:53:22: note: in expansion of macro '___PASTE'
#define __PASTE(a,b) ___PASTE(a,b)
^~~~~~~~
include/linux/compiler-gcc.h:193:37: note: in expansion of macro '__PASTE'
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
^~~~~~~
include/linux/serial_core.h:377:9: note: in expansion of macro '__UNIQUE_ID'
__UNIQUE_ID(__earlycon_##_name))
^~~~~~~~~~~
drivers/tty/serial/sh-sci.c:3330:1: note: in expansion of macro 'OF_EARLYCON_DECLARE'
OF_EARLYCON_DECLARE(hscif, "renesas,hscif", hscif_early_console_setup);
^~~~~~~~~~~~~~~~~~~

vim +3278 drivers/tty/serial/sh-sci.c

^1da177e drivers/serial/sh-sci.c Linus Torvalds 2005-04-16 3272
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3273 #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3274 early_platform_init_buffer("earlyprintk", &sci_driver,
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3275 early_serial_buf, ARRAY_SIZE(early_serial_buf));
7b6fd3bf drivers/serial/sh-sci.c Magnus Damm 2009-12-14 3276 #endif
0b0cced1 drivers/tty/serial/sh-sci.c Yoshinori Sato 2015-12-24 3277 #ifdef CONFIG_SERIAL_SH_SCI_EARLYCON
dd076cff drivers/tty/serial/sh-sci.c Matthias Kaehlcke 2017-10-09 @3278 static struct plat_sci_port port_cfg __initdata;
0b0cced1 drivers/tty/serial/sh-sci.c Yoshinori Sato 2015-12-24 3279

:::::: The code at line 3278 was first introduced by commit
:::::: dd076cffb8cd675a8973fc9b6cea0c04be6f0111 serial: sh-sci: Fix init data attribute for struct 'port_cfg'

:::::: TO: Matthias Kaehlcke <[email protected]>
:::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (3.83 kB)
.config.gz (51.56 kB)
Download all attachments