linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] console: don't select first registered console if stdout-path used
@ 2017-08-25 13:14 Eugeniy Paltsev
  2017-08-25 13:20 ` Steven Rostedt
  2017-08-25 17:44 ` Sergey Senozhatsky
  0 siblings, 2 replies; 4+ messages in thread
From: Eugeniy Paltsev @ 2017-08-25 13:14 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky
  Cc: Steven Rostedt, linux-snps-arc, linux-kernel, Eugeniy Paltsev

In the current implementation we take the first console that
registers if we didn't select one.

But if we specify console via "stdout-path" property in device tree
we don't want first console that registers here to be selected.
Otherwise we may choose wrong console - for example if some console
is registered earlier than console is pointed in "stdout-path"
property because console pointed in "stdout-path" property can be add as
preferred quite late - when it's driver is probed.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
 kernel/printk/printk.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 512f7c2..23262c1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -26,6 +26,7 @@
 #include <linux/nmi.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/of.h>
 #include <linux/delay.h>
 #include <linux/smp.h>
 #include <linux/security.h>
@@ -2431,6 +2432,16 @@ void register_console(struct console *newcon)
 	if (!has_preferred || bcon || !console_drivers)
 		has_preferred = preferred_console >= 0;
 
+
+	/*
+	 * If we specify console via "stdout-path" property in device tree
+	 * we don't want first console that registers here to be selected.
+	 */
+#ifdef CONFIG_OF
+	if (of_stdout)
+		has_preferred = true;
+#endif
+
 	/*
 	 *	See if we want to use this console driver. If we
 	 *	didn't select a console we take the first one
-- 
2.9.3

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

* Re: [PATCH] console: don't select first registered console if stdout-path used
  2017-08-25 13:14 [PATCH] console: don't select first registered console if stdout-path used Eugeniy Paltsev
@ 2017-08-25 13:20 ` Steven Rostedt
  2017-08-25 17:44 ` Sergey Senozhatsky
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2017-08-25 13:20 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Petr Mladek, Sergey Senozhatsky, linux-snps-arc, linux-kernel

On Fri, 25 Aug 2017 16:14:51 +0300
Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com> wrote:

> In the current implementation we take the first console that
> registers if we didn't select one.
> 
> But if we specify console via "stdout-path" property in device tree
> we don't want first console that registers here to be selected.
> Otherwise we may choose wrong console - for example if some console
> is registered earlier than console is pointed in "stdout-path"
> property because console pointed in "stdout-path" property can be add as
> preferred quite late - when it's driver is probed.
> 
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> ---
>  kernel/printk/printk.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 512f7c2..23262c1 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -26,6 +26,7 @@
>  #include <linux/nmi.h>
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
> +#include <linux/of.h>
>  #include <linux/delay.h>
>  #include <linux/smp.h>
>  #include <linux/security.h>
> @@ -2431,6 +2432,16 @@ void register_console(struct console *newcon)
>  	if (!has_preferred || bcon || !console_drivers)
>  		has_preferred = preferred_console >= 0;
>  
> +
> +	/*
> +	 * If we specify console via "stdout-path" property in device tree
> +	 * we don't want first console that registers here to be selected.
> +	 */
> +#ifdef CONFIG_OF
> +	if (of_stdout)
> +		has_preferred = true;
> +#endif

To remove the #ifdef from the code, could the of.h move

#ifdef CONFIG_OF

Above the extern declarations of of_stdout and friends, and then have:

#else /* !CONFIG_OF */

#define of_stdout	NULL

#endif

Then we could just have:

	if (of_stdout)
		has_preferred = true;

without the ifdefs.

-- Steve

> +
>  	/*
>  	 *	See if we want to use this console driver. If we
>  	 *	didn't select a console we take the first one

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

* Re: [PATCH] console: don't select first registered console if stdout-path used
  2017-08-25 13:14 [PATCH] console: don't select first registered console if stdout-path used Eugeniy Paltsev
  2017-08-25 13:20 ` Steven Rostedt
@ 2017-08-25 17:44 ` Sergey Senozhatsky
  2017-08-28 12:41   ` Eugeniy Paltsev
  1 sibling, 1 reply; 4+ messages in thread
From: Sergey Senozhatsky @ 2017-08-25 17:44 UTC (permalink / raw)
  To: Eugeniy Paltsev
  Cc: Petr Mladek, Sergey Senozhatsky, Steven Rostedt, linux-snps-arc,
	linux-kernel

On (08/25/17 16:14), Eugeniy Paltsev wrote:
> In the current implementation we take the first console that
> registers if we didn't select one.
> 
> But if we specify console via "stdout-path" property in device tree
> we don't want first console that registers here to be selected.
> Otherwise we may choose wrong console - for example if some console
> is registered earlier than console is pointed in "stdout-path"
> property because console pointed in "stdout-path" property can be add as
> preferred quite late - when it's driver is probed.
> 
> Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>

hm... this is not the first time we see DT and stdout-path.
and so far it was pretty painful :) e.g. commits c6c7d83b9c9e, 05fd007e4629.

	-ss

> ---
>  kernel/printk/printk.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 512f7c2..23262c1 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -26,6 +26,7 @@
>  #include <linux/nmi.h>
>  #include <linux/module.h>
>  #include <linux/moduleparam.h>
> +#include <linux/of.h>
>  #include <linux/delay.h>
>  #include <linux/smp.h>
>  #include <linux/security.h>
> @@ -2431,6 +2432,16 @@ void register_console(struct console *newcon)
>  	if (!has_preferred || bcon || !console_drivers)
>  		has_preferred = preferred_console >= 0;
>  
> +
> +	/*
> +	 * If we specify console via "stdout-path" property in device tree
> +	 * we don't want first console that registers here to be selected.
> +	 */
> +#ifdef CONFIG_OF
> +	if (of_stdout)
> +		has_preferred = true;
> +#endif
> +
>  	/*
>  	 *	See if we want to use this console driver. If we
>  	 *	didn't select a console we take the first one
> -- 
> 2.9.3
> 

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

* Re: [PATCH] console: don't select first registered console if stdout-path used
  2017-08-25 17:44 ` Sergey Senozhatsky
@ 2017-08-28 12:41   ` Eugeniy Paltsev
  0 siblings, 0 replies; 4+ messages in thread
From: Eugeniy Paltsev @ 2017-08-28 12:41 UTC (permalink / raw)
  To: sergey.senozhatsky; +Cc: linux-kernel, rostedt, pmladek, linux-snps-arc

On Sat, 2017-08-26 at 02:44 +0900, Sergey Senozhatsky wrote:
> On (08/25/17 16:14), Eugeniy Paltsev wrote:
> > In the current implementation we take the first console that
> > registers if we didn't select one.
> > 
> > But if we specify console via "stdout-path" property in device tree
> > we don't want first console that registers here to be selected.
> > Otherwise we may choose wrong console - for example if some console
> > is registered earlier than console is pointed in "stdout-path"
> > property because console pointed in "stdout-path" property can be
> > add as
> > preferred quite late - when it's driver is probed.
> > 
> > Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> 
> hm... this is not the first time we see DT and stdout-path.
> and so far it was pretty painful :) e.g. commits c6c7d83b9c9e,
> 05fd007e4629.
> 
> 	-ss

Hm... looks like I had to update my patch to keep existing tty0
behavior.

Before this patch tty0 was registered even if it was specified neither
in "bootargs" nor in "stdout-path". 
So I should retain this behavior as a lot of ARM boards (and some
powerpc) rely on it.

> 
> > ---
> >  kernel/printk/printk.c | 11 +++++++++++
> >  1 file changed, 11 insertions(+)
> > 
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index 512f7c2..23262c1 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -26,6 +26,7 @@
> >  #include <linux/nmi.h>
> >  #include <linux/module.h>
> >  #include <linux/moduleparam.h>
> > +#include <linux/of.h>
> >  #include <linux/delay.h>
> >  #include <linux/smp.h>
> >  #include <linux/security.h>
> > @@ -2431,6 +2432,16 @@ void register_console(struct console
> > *newcon)
> >  	if (!has_preferred || bcon || !console_drivers)
> >  		has_preferred = preferred_console >= 0;
> >  
> > +
> > +	/*
> > +	 * If we specify console via "stdout-path" property in
> > device tree
> > +	 * we don't want first console that registers here to be
> > selected.
> > +	 */
> > +#ifdef CONFIG_OF
> > +	if (of_stdout)
> > +		has_preferred = true;
> > +#endif
> > +
> >  	/*
> >  	 *	See if we want to use this console driver. If we
> >  	 *	didn't select a console we take the first one
> > -- 
> > 2.9.3
> > 
-- 
 Eugeniy Paltsev

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

end of thread, other threads:[~2017-08-28 12:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 13:14 [PATCH] console: don't select first registered console if stdout-path used Eugeniy Paltsev
2017-08-25 13:20 ` Steven Rostedt
2017-08-25 17:44 ` Sergey Senozhatsky
2017-08-28 12:41   ` Eugeniy Paltsev

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