u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] console: Add option to keep it silent until env is loaded
@ 2022-07-06 11:19 Harald Seiler
  2022-07-12 10:58 ` Simon Glass
  2023-01-13  0:16 ` Tom Rini
  0 siblings, 2 replies; 7+ messages in thread
From: Harald Seiler @ 2022-07-06 11:19 UTC (permalink / raw)
  To: Tom Rini, u-boot; +Cc: Simon Glass, Patrick Delaunay, Harald Seiler

Add a config-option which forces the console to stay silent until the
proper environment is loaded from flash.

This is important when the default environment does not silence the
console but no output must be printed when 'silent' is set in the flash
environment.

After the environment from flash is loaded, the console will be
silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
used, the buffer will now be flushed if the console should not be
silenced.

Signed-off-by: Harald Seiler <hws@denx.de>
---
 common/Kconfig   | 10 ++++++++++
 common/console.c |  5 +++++
 2 files changed, 15 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index fdcf4536d0..506a4d6245 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -120,6 +120,16 @@ config SILENT_CONSOLE_UPDATE_ON_RELOC
 	  (e.g. NAND). This option makes the value of the 'silent'
 	  environment variable take effect at relocation.
 
+config SILENT_CONSOLE_UNTIL_ENV
+	bool "Keep console silent until environment is loaded"
+	depends on SILENT_CONSOLE
+	help
+	  This option makes sure U-Boot will never use the console unless the
+	  environment from flash does not contain the 'silent' variable.  If
+	  set, the console is kept silent until after the environment was
+	  loaded.  Use this in combination with PRE_CONSOLE_BUFFER to print out
+	  earlier messages after loading the environment when allowed.
+
 config PRE_CONSOLE_BUFFER
 	bool "Buffer characters before the console is available"
 	help
diff --git a/common/console.c b/common/console.c
index 0013d183ae..f0f5a9cf80 100644
--- a/common/console.c
+++ b/common/console.c
@@ -893,6 +893,11 @@ static bool console_update_silent(void)
 	if (!IS_ENABLED(CONFIG_SILENT_CONSOLE))
 		return false;
 
+	if (IS_ENABLED(CONFIG_SILENT_CONSOLE_UNTIL_ENV) && !(gd->flags & GD_FLG_ENV_READY)) {
+		gd->flags |= GD_FLG_SILENT;
+		return false;
+	}
+
 	if (env_get("silent")) {
 		gd->flags |= GD_FLG_SILENT;
 		return false;
-- 
2.36.1


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

* Re: [PATCH] console: Add option to keep it silent until env is loaded
  2022-07-06 11:19 [PATCH] console: Add option to keep it silent until env is loaded Harald Seiler
@ 2022-07-12 10:58 ` Simon Glass
  2022-07-12 11:58   ` Harald Seiler
  2023-01-13  0:16 ` Tom Rini
  1 sibling, 1 reply; 7+ messages in thread
From: Simon Glass @ 2022-07-12 10:58 UTC (permalink / raw)
  To: Harald Seiler; +Cc: Tom Rini, U-Boot Mailing List, Patrick Delaunay

Hi Harald,

On Wed, 6 Jul 2022 at 05:19, Harald Seiler <hws@denx.de> wrote:
>
> Add a config-option which forces the console to stay silent until the
> proper environment is loaded from flash.
>
> This is important when the default environment does not silence the
> console but no output must be printed when 'silent' is set in the flash
> environment.
>
> After the environment from flash is loaded, the console will be
> silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
> used, the buffer will now be flushed if the console should not be
> silenced.
>
> Signed-off-by: Harald Seiler <hws@denx.de>
> ---
>  common/Kconfig   | 10 ++++++++++
>  common/console.c |  5 +++++
>  2 files changed, 15 insertions(+)

This seems OK to me. You might want to implement the silent-console
device tree property in console_update_silent() too, which was dropped
in the conversion to driver model.

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* Re: [PATCH] console: Add option to keep it silent until env is loaded
  2022-07-12 10:58 ` Simon Glass
@ 2022-07-12 11:58   ` Harald Seiler
  2022-07-13 15:28     ` Simon Glass
  0 siblings, 1 reply; 7+ messages in thread
From: Harald Seiler @ 2022-07-12 11:58 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List, Patrick Delaunay

Hi Simon,

On Tue, 2022-07-12 at 04:58 -0600, Simon Glass wrote:
> Hi Harald,
> 
> On Wed, 6 Jul 2022 at 05:19, Harald Seiler <hws@denx.de> wrote:
> > 
> > Add a config-option which forces the console to stay silent until the
> > proper environment is loaded from flash.
> > 
> > This is important when the default environment does not silence the
> > console but no output must be printed when 'silent' is set in the flash
> > environment.
> > 
> > After the environment from flash is loaded, the console will be
> > silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
> > used, the buffer will now be flushed if the console should not be
> > silenced.
> > 
> > Signed-off-by: Harald Seiler <hws@denx.de>
> > ---
> >  common/Kconfig   | 10 ++++++++++
> >  common/console.c |  5 +++++
> >  2 files changed, 15 insertions(+)
> 
> This seems OK to me. You might want to implement the silent-console
> device tree property in console_update_silent() too, which was dropped
> in the conversion to driver model.

This looks interesting, I'll have to look into it.

Do you know if there's any effort towards supporting such a flag in the
kernel as well?  I had to remove the serial console property from my DT
and instead pass console info via cmdline to make the silent console
work.  A "pure DT" solution of any sort would have been nicer of
course...

-- 
Harald

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

* Re: [PATCH] console: Add option to keep it silent until env is loaded
  2022-07-12 11:58   ` Harald Seiler
@ 2022-07-13 15:28     ` Simon Glass
  2022-07-18 15:07       ` Harald Seiler
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Glass @ 2022-07-13 15:28 UTC (permalink / raw)
  To: Harald Seiler; +Cc: Tom Rini, U-Boot Mailing List, Patrick Delaunay

Hi Harald,

On Tue, 12 Jul 2022 at 05:58, Harald Seiler <hws@denx.de> wrote:
>
> Hi Simon,
>
> On Tue, 2022-07-12 at 04:58 -0600, Simon Glass wrote:
> > Hi Harald,
> >
> > On Wed, 6 Jul 2022 at 05:19, Harald Seiler <hws@denx.de> wrote:
> > >
> > > Add a config-option which forces the console to stay silent until the
> > > proper environment is loaded from flash.
> > >
> > > This is important when the default environment does not silence the
> > > console but no output must be printed when 'silent' is set in the flash
> > > environment.
> > >
> > > After the environment from flash is loaded, the console will be
> > > silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
> > > used, the buffer will now be flushed if the console should not be
> > > silenced.
> > >
> > > Signed-off-by: Harald Seiler <hws@denx.de>
> > > ---
> > >  common/Kconfig   | 10 ++++++++++
> > >  common/console.c |  5 +++++
> > >  2 files changed, 15 insertions(+)
> >
> > This seems OK to me. You might want to implement the silent-console
> > device tree property in console_update_silent() too, which was dropped
> > in the conversion to driver model.
>
> This looks interesting, I'll have to look into it.
>
> Do you know if there's any effort towards supporting such a flag in the
> kernel as well?  I had to remove the serial console property from my DT
> and instead pass console info via cmdline to make the silent console
> work.  A "pure DT" solution of any sort would have been nicer of
> course...

The console's 'silent' flag is propagated to Linux by dropping the
'console=' text from the bootargs. See fixup_silent_linux().

Regards,
Simon


>
> --
> Harald

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

* Re: [PATCH] console: Add option to keep it silent until env is loaded
  2022-07-13 15:28     ` Simon Glass
@ 2022-07-18 15:07       ` Harald Seiler
  2022-07-20 15:01         ` Simon Glass
  0 siblings, 1 reply; 7+ messages in thread
From: Harald Seiler @ 2022-07-18 15:07 UTC (permalink / raw)
  To: Simon Glass; +Cc: Tom Rini, U-Boot Mailing List, Patrick Delaunay

Hi Simon,

On Wed, 2022-07-13 at 09:28 -0600, Simon Glass wrote:
> Hi Harald,
> 
> On Tue, 12 Jul 2022 at 05:58, Harald Seiler <hws@denx.de> wrote:
> > 
> > Hi Simon,
> > 
> > On Tue, 2022-07-12 at 04:58 -0600, Simon Glass wrote:
> > > Hi Harald,
> > > 
> > > On Wed, 6 Jul 2022 at 05:19, Harald Seiler <hws@denx.de> wrote:
> > > > 
> > > > Add a config-option which forces the console to stay silent until the
> > > > proper environment is loaded from flash.
> > > > 
> > > > This is important when the default environment does not silence the
> > > > console but no output must be printed when 'silent' is set in the flash
> > > > environment.
> > > > 
> > > > After the environment from flash is loaded, the console will be
> > > > silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
> > > > used, the buffer will now be flushed if the console should not be
> > > > silenced.
> > > > 
> > > > Signed-off-by: Harald Seiler <hws@denx.de>
> > > > ---
> > > >  common/Kconfig   | 10 ++++++++++
> > > >  common/console.c |  5 +++++
> > > >  2 files changed, 15 insertions(+)
> > > 
> > > This seems OK to me. You might want to implement the silent-console
> > > device tree property in console_update_silent() too, which was dropped
> > > in the conversion to driver model.
> > 
> > This looks interesting, I'll have to look into it.
> > 
> > Do you know if there's any effort towards supporting such a flag in the
> > kernel as well?  I had to remove the serial console property from my DT
> > and instead pass console info via cmdline to make the silent console
> > work.  A "pure DT" solution of any sort would have been nicer of
> > course...
> 
> The console's 'silent' flag is propagated to Linux by dropping the
> 'console=' text from the bootargs. See fixup_silent_linux().

Right, this is what I am relying on right now.  The problem is that this
does not have any effect when `console=` is not used and the console is
instead passed using the `/chosen/stdout-path` DT property.

I was wondering whether U-Boot should maybe delete this property from
the DT passed to Linux when going silent...

(But of course this is unrelated to the original patch here)

-- 
Harald

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

* Re: [PATCH] console: Add option to keep it silent until env is loaded
  2022-07-18 15:07       ` Harald Seiler
@ 2022-07-20 15:01         ` Simon Glass
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2022-07-20 15:01 UTC (permalink / raw)
  To: Harald Seiler; +Cc: Tom Rini, U-Boot Mailing List, Patrick Delaunay

Hi Harald,

On Mon, 18 Jul 2022 at 09:08, Harald Seiler <hws@denx.de> wrote:
>
> Hi Simon,
>
> On Wed, 2022-07-13 at 09:28 -0600, Simon Glass wrote:
> > Hi Harald,
> >
> > On Tue, 12 Jul 2022 at 05:58, Harald Seiler <hws@denx.de> wrote:
> > >
> > > Hi Simon,
> > >
> > > On Tue, 2022-07-12 at 04:58 -0600, Simon Glass wrote:
> > > > Hi Harald,
> > > >
> > > > On Wed, 6 Jul 2022 at 05:19, Harald Seiler <hws@denx.de> wrote:
> > > > >
> > > > > Add a config-option which forces the console to stay silent until the
> > > > > proper environment is loaded from flash.
> > > > >
> > > > > This is important when the default environment does not silence the
> > > > > console but no output must be printed when 'silent' is set in the flash
> > > > > environment.
> > > > >
> > > > > After the environment from flash is loaded, the console will be
> > > > > silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
> > > > > used, the buffer will now be flushed if the console should not be
> > > > > silenced.
> > > > >
> > > > > Signed-off-by: Harald Seiler <hws@denx.de>
> > > > > ---
> > > > >  common/Kconfig   | 10 ++++++++++
> > > > >  common/console.c |  5 +++++
> > > > >  2 files changed, 15 insertions(+)
> > > >
> > > > This seems OK to me. You might want to implement the silent-console
> > > > device tree property in console_update_silent() too, which was dropped
> > > > in the conversion to driver model.
> > >
> > > This looks interesting, I'll have to look into it.
> > >
> > > Do you know if there's any effort towards supporting such a flag in the
> > > kernel as well?  I had to remove the serial console property from my DT
> > > and instead pass console info via cmdline to make the silent console
> > > work.  A "pure DT" solution of any sort would have been nicer of
> > > course...
> >
> > The console's 'silent' flag is propagated to Linux by dropping the
> > 'console=' text from the bootargs. See fixup_silent_linux().
>
> Right, this is what I am relying on right now.  The problem is that this
> does not have any effect when `console=` is not used and the console is
> instead passed using the `/chosen/stdout-path` DT property.

OK.

>
> I was wondering whether U-Boot should maybe delete this property from
> the DT passed to Linux when going silent...

Yes it probably should!

>
> (But of course this is unrelated to the original patch here)

Regards,
Simon

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

* Re: [PATCH] console: Add option to keep it silent until env is loaded
  2022-07-06 11:19 [PATCH] console: Add option to keep it silent until env is loaded Harald Seiler
  2022-07-12 10:58 ` Simon Glass
@ 2023-01-13  0:16 ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2023-01-13  0:16 UTC (permalink / raw)
  To: Harald Seiler; +Cc: u-boot, Simon Glass, Patrick Delaunay

[-- Attachment #1: Type: text/plain, Size: 719 bytes --]

On Wed, Jul 06, 2022 at 01:19:10PM +0200, Harald Seiler wrote:

> Add a config-option which forces the console to stay silent until the
> proper environment is loaded from flash.
> 
> This is important when the default environment does not silence the
> console but no output must be printed when 'silent' is set in the flash
> environment.
> 
> After the environment from flash is loaded, the console will be
> silenced/unsilenced depending on it.  If PRE_CONSOLE_BUFFER is also
> used, the buffer will now be flushed if the console should not be
> silenced.
> 
> Signed-off-by: Harald Seiler <hws@denx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2023-01-13  0:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06 11:19 [PATCH] console: Add option to keep it silent until env is loaded Harald Seiler
2022-07-12 10:58 ` Simon Glass
2022-07-12 11:58   ` Harald Seiler
2022-07-13 15:28     ` Simon Glass
2022-07-18 15:07       ` Harald Seiler
2022-07-20 15:01         ` Simon Glass
2023-01-13  0:16 ` Tom Rini

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