All of lore.kernel.org
 help / color / mirror / Atom feed
* + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree
@ 2007-08-09 20:26 akpm
       [not found] ` <200708092340.46523.rjw@sisk.pl>
  0 siblings, 1 reply; 6+ messages in thread
From: akpm @ 2007-08-09 20:26 UTC (permalink / raw)
  To: mm-commits; +Cc: dilinger, dilinger, pavel, rjw


The patch titled
     serial: turn serial console suspend a boot rather than compile time option
has been added to the -mm tree.  Its filename is
     serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: serial: turn serial console suspend a boot rather than compile time option
From: Andres Salomon <dilinger@queued.net>

Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
the serial console from being suspended when the rest of the machine goes
to sleep.  This is incredibly useful for debugging power management-related
things; however, having it as a compile-time option has proved to be
incredibly inconvenient for us (OLPC).  There are plenty of times that we
want serial console to not suspend, but for the most part we'd like serial
console to be suspended.

This drops CONFIG_DISABLE_CONSOLE_SUSPEND, and replaces it with a kernel
boot parameter (no_console_suspend).  By default, the serial console will
be suspended along with the rest of the system; by passing
'no_console_suspend' to the kernel during boot, serial console will remain
alive during suspend.

I have another version of this patch which keeps #ifdefs around; however,
it's uglier.  I prefer this version of the patch, and don't feel that it
increases bloat.  If people strongly disagree, let me know and I'll submit
the other patch.

Signed-off-by: Andres Salomon <dilinger@debian.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 Documentation/kernel-parameters.txt        |    8 ++++++++
 Documentation/power/basic-pm-debugging.txt |    4 ++--
 arch/powerpc/configs/pmac32_defconfig      |    1 -
 drivers/serial/serial_core.c               |   10 ++++------
 include/linux/console.h                    |    7 ++-----
 kernel/power/Kconfig                       |   11 -----------
 kernel/printk.c                            |   15 +++++++++++++--
 7 files changed, 29 insertions(+), 27 deletions(-)

diff -puN Documentation/kernel-parameters.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/Documentation/kernel-parameters.txt
@@ -477,6 +477,14 @@ and is between 256 and 4096 characters. 
 			UART at the specified I/O port or MMIO address.
 			The options are the same as for ttyS, above.
 
+	no_console_suspend
+			[HW] Never suspend the serial console
+			Disable suspending the serial console during
+			suspend/resume operations.  If disabled, debugging
+			messages can reach the console while the rest of
+			the system is being put to sleep (ie, while
+			debugging driver suspend/resume hooks).
+
 	cpcihp_generic=	[HW,PCI] Generic port I/O CompactPCI driver
 			Format:
 			<first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
diff -puN Documentation/power/basic-pm-debugging.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option Documentation/power/basic-pm-debugging.txt
--- a/Documentation/power/basic-pm-debugging.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/Documentation/power/basic-pm-debugging.txt
@@ -78,8 +78,8 @@ c) Advanced debugging
 In case the STD does not work on your system even in the minimal configuration
 and compiling more drivers as modules is not practical or some modules cannot
 be unloaded, you can use one of the more advanced debugging techniques to find
-the problem.  First, if there is a serial port in your box, you can set the
-CONFIG_DISABLE_CONSOLE_SUSPEND kernel configuration option and try to log kernel
+the problem.  First, if there is a serial port in your box, you boot the
+kernel with the 'no_console_suspend' parameter and try to log kernel
 messages using the serial console.  This may provide you with some information
 about the reasons of the suspend (resume) failure.  Alternatively, it may be
 possible to use a FireWire port for debugging with firescope
diff -puN arch/powerpc/configs/pmac32_defconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option arch/powerpc/configs/pmac32_defconfig
--- a/arch/powerpc/configs/pmac32_defconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/arch/powerpc/configs/pmac32_defconfig
@@ -216,7 +216,6 @@ CONFIG_PROC_DEVICETREE=y
 CONFIG_PM=y
 # CONFIG_PM_LEGACY is not set
 CONFIG_PM_DEBUG=y
-# CONFIG_DISABLE_CONSOLE_SUSPEND is not set
 CONFIG_PM_SYSFS_DEPRECATED=y
 CONFIG_HIBERNATION=y
 CONFIG_PM_STD_PARTITION=""
diff -puN drivers/serial/serial_core.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option drivers/serial/serial_core.c
--- a/drivers/serial/serial_core.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/drivers/serial/serial_core.c
@@ -1954,12 +1954,11 @@ int uart_suspend_port(struct uart_driver
 
 	mutex_lock(&state->mutex);
 
-#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
-	if (uart_console(port)) {
+	if (!serial_console_suspend_enabled && uart_console(port)) {
+		/* we're going to avoid suspending serial console */
 		mutex_unlock(&state->mutex);
 		return 0;
 	}
-#endif
 
 	if (state->info && state->info->flags & UIF_INITIALIZED) {
 		const struct uart_ops *ops = port->ops;
@@ -2002,12 +2001,11 @@ int uart_resume_port(struct uart_driver 
 
 	mutex_lock(&state->mutex);
 
-#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
-	if (uart_console(port)) {
+	if (!serial_console_suspend_enabled && uart_console(port)) {
+		/* no need to resume serial console, it wasn't suspended */
 		mutex_unlock(&state->mutex);
 		return 0;
 	}
-#endif
 
 	uart_change_pm(state, 0);
 
diff -puN include/linux/console.h~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option include/linux/console.h
--- a/include/linux/console.h~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/include/linux/console.h
@@ -121,14 +121,11 @@ extern void console_stop(struct console 
 extern void console_start(struct console *);
 extern int is_console_locked(void);
 
-#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
+extern int serial_console_suspend_enabled;
+
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
 extern void resume_console(void);
-#else
-static inline void suspend_console(void) {}
-static inline void resume_console(void) {}
-#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
 
 int mda_console_init(void);
 void prom_con_init(void);
diff -puN kernel/power/Kconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option kernel/power/Kconfig
--- a/kernel/power/Kconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/kernel/power/Kconfig
@@ -44,17 +44,6 @@ config PM_VERBOSE
 	---help---
 	This option enables verbose messages from the Power Management code.
 
-config DISABLE_CONSOLE_SUSPEND
-	bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
-	depends on PM_DEBUG && PM_SLEEP
-	default n
-	---help---
-	This option turns off the console suspend mechanism that prevents
-	debug messages from reaching the console during the suspend/resume
-	operations.  This may be helpful when debugging device drivers'
-	suspend/resume routines, but may itself lead to problems, for example
-	if netconsole is used.
-
 config PM_TRACE
 	bool "Suspend/resume event tracing"
 	depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
diff -puN kernel/printk.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option kernel/printk.c
--- a/kernel/printk.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/kernel/printk.c
@@ -810,7 +810,15 @@ int update_console_cmdline(char *name, i
 	return -1;
 }
 
-#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
+int serial_console_suspend_enabled = 1;
+
+static int __init console_suspend_disable(char *str)
+{
+	serial_console_suspend_enabled = 0;
+	return 1;
+}
+__setup("no_console_suspend", console_suspend_disable);
+
 /**
  * suspend_console - suspend the console subsystem
  *
@@ -818,6 +826,8 @@ int update_console_cmdline(char *name, i
  */
 void suspend_console(void)
 {
+	if (!serial_console_suspend_enabled)
+		return;
 	printk("Suspending console(s)\n");
 	acquire_console_sem();
 	console_suspended = 1;
@@ -825,10 +835,11 @@ void suspend_console(void)
 
 void resume_console(void)
 {
+	if (!serial_console_suspend_enabled)
+		return;
 	console_suspended = 0;
 	release_console_sem();
 }
-#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
 
 /**
  * acquire_console_sem - lock the console system for exclusive use.
_

Patches currently in -mm which might be from dilinger@queued.net are

geode-mfgpt-support-for-geode-class-machines.patch
geode-mfgpt-clock-event-device-support.patch
serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch

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

* Re: + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree
       [not found]       ` <20070813142331.9b0774ae.dilinger@queued.net>
@ 2007-08-14 10:39         ` Pavel Machek
  2007-08-14 18:23           ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2007-08-14 10:39 UTC (permalink / raw)
  To: Andres Salomon; +Cc: Rafael J. Wysocki, akpm, kernel list

Hi!

> Thanks, updated below!
> 
> 
> 
> serial: turn serial console suspend a boot rather than compile time option
> 
> From: Andres Salomon <dilinger@debian.org>
> 
> Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
> the serial console from being suspended when the rest of the machine goes
> to sleep.  This is incredibly useful for debugging power
> management-related

Actually, this should not be configurable. We should simply enable
console during suspend for consoles that can handle this,
automatically.... this patch does just that. I hope I separated it
correctly.

It may be that something else than netconsole is broken during
suspend... but it should not be, we were running without suspending
consoles for quite long; we can always fix it when we hit the bug.

Signed-off-by: Pavel Machek <pavel@suse.cz>

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 69233f6..7f7c2ce 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -115,6 +115,7 @@ static int init_netconsole(void)
 	if (err)
 		return err;
 
+	disable_console_on_suspend++;
 	register_console(&netconsole);
 	printk(KERN_INFO "netconsole: network logging started\n");
 	return 0;
@@ -123,6 +124,7 @@ static int init_netconsole(void)
 static void cleanup_netconsole(void)
 {
 	unregister_console(&netconsole);
+	disable_console_on_suspend--;
 	netpoll_cleanup(&np);
 }
 
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 030a606..426c3d6 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1941,12 +1941,10 @@ int uart_suspend_port(struct uart_driver
 
 	mutex_lock(&state->mutex);
 
-#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
 	if (uart_console(port)) {
 		mutex_unlock(&state->mutex);
 		return 0;
 	}
-#endif
 
 	if (state->info && state->info->flags & UIF_INITIALIZED) {
 		const struct uart_ops *ops = port->ops;
@@ -1989,12 +1987,10 @@ int uart_resume_port(struct uart_driver 
 
 	mutex_lock(&state->mutex);
 
-#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
 	if (uart_console(port)) {
 		mutex_unlock(&state->mutex);
 		return 0;
 	}
-#endif
 
 	uart_change_pm(state, 0);
 
diff --git a/include/linux/console.h b/include/linux/console.h
index 56a7bcd..2e2b9bc 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -121,14 +121,11 @@ extern void console_stop(struct console 
 extern void console_start(struct console *);
 extern int is_console_locked(void);
 
-#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
+extern int disable_console_on_suspend;
+
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
 extern void resume_console(void);
-#else
-static inline void suspend_console(void) {}
-static inline void resume_console(void) {}
-#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
 
 int mda_console_init(void);
 void prom_con_init(void);
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 412859f..a68e841 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -44,17 +44,6 @@ config PM_VERBOSE
 	---help---
 	This option enables verbose messages from the Power Management code.
 
-config DISABLE_CONSOLE_SUSPEND
-	bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
-	depends on PM_DEBUG && PM_SLEEP
-	default n
-	---help---
-	This option turns off the console suspend mechanism that prevents
-	debug messages from reaching the console during the suspend/resume
-	operations.  This may be helpful when debugging device drivers'
-	suspend/resume routines, but may itself lead to problems, for example
-	if netconsole is used.
-
 config PM_TRACE
 	bool "Suspend/resume event tracing"
 	depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
diff --git a/kernel/printk.c b/kernel/printk.c
index bd2cd06..5a2d6c0 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -751,7 +751,9 @@ int update_console_cmdline(char *name, i
 	return -1;
 }
 
-#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
+
+int disable_console_on_suspend;
+
 /**
  * suspend_console - suspend the console subsystem
  *
@@ -759,17 +761,22 @@ #ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
  */
 void suspend_console(void)
 {
-	printk("Suspending console(s)\n");
-	acquire_console_sem();
-	console_suspended = 1;
+	if (disable_console_on_suspend) {
+		printk("Suspending console(s)\n");
+		acquire_console_sem();
+		console_suspended = 1;
+	}
 }
 
 void resume_console(void)
 {
-	console_suspended = 0;
-	release_console_sem();
+	if (console_suspended) {
+		BUG_ON(!disable_console_on_suspend);
+		console_suspended = 0;
+		release_console_sem();
+	}
 }
-#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
+
 
 /**
  * acquire_console_sem - lock the console system for exclusive use.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree
  2007-08-14 10:39         ` Pavel Machek
@ 2007-08-14 18:23           ` Rafael J. Wysocki
  2007-08-14 18:44             ` Andres Salomon
  0 siblings, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2007-08-14 18:23 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Andres Salomon, akpm, kernel list

On Tuesday, 14 August 2007 12:39, Pavel Machek wrote:
> Hi!
> 
> > Thanks, updated below!
> > 
> > 
> > 
> > serial: turn serial console suspend a boot rather than compile time option
> > 
> > From: Andres Salomon <dilinger@debian.org>
> > 
> > Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
> > the serial console from being suspended when the rest of the machine goes
> > to sleep.  This is incredibly useful for debugging power
> > management-related
> 
> Actually, this should not be configurable. We should simply enable
> console during suspend for consoles that can handle this,
> automatically.... this patch does just that. I hope I separated it
> correctly.
> 
> It may be that something else than netconsole is broken during
> suspend... but it should not be, we were running without suspending
> consoles for quite long; we can always fix it when we hit the bug.
> 
> Signed-off-by: Pavel Machek <pavel@suse.cz>
> 

Well, my box used to hang on suspend when the framebuffer console was enabled.

It doesn't do that any more, though, so it may be safe.

I think we can do this, but I expect some bug reports to show up as a result.

Greetings,
Rafael


> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 69233f6..7f7c2ce 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -115,6 +115,7 @@ static int init_netconsole(void)
>  	if (err)
>  		return err;
>  
> +	disable_console_on_suspend++;
>  	register_console(&netconsole);
>  	printk(KERN_INFO "netconsole: network logging started\n");
>  	return 0;
> @@ -123,6 +124,7 @@ static int init_netconsole(void)
>  static void cleanup_netconsole(void)
>  {
>  	unregister_console(&netconsole);
> +	disable_console_on_suspend--;
>  	netpoll_cleanup(&np);
>  }
>  
> diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
> index 030a606..426c3d6 100644
> --- a/drivers/serial/serial_core.c
> +++ b/drivers/serial/serial_core.c
> @@ -1941,12 +1941,10 @@ int uart_suspend_port(struct uart_driver
>  
>  	mutex_lock(&state->mutex);
>  
> -#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
>  	if (uart_console(port)) {
>  		mutex_unlock(&state->mutex);
>  		return 0;
>  	}
> -#endif
>  
>  	if (state->info && state->info->flags & UIF_INITIALIZED) {
>  		const struct uart_ops *ops = port->ops;
> @@ -1989,12 +1987,10 @@ int uart_resume_port(struct uart_driver 
>  
>  	mutex_lock(&state->mutex);
>  
> -#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
>  	if (uart_console(port)) {
>  		mutex_unlock(&state->mutex);
>  		return 0;
>  	}
> -#endif
>  
>  	uart_change_pm(state, 0);
>  
> diff --git a/include/linux/console.h b/include/linux/console.h
> index 56a7bcd..2e2b9bc 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -121,14 +121,11 @@ extern void console_stop(struct console 
>  extern void console_start(struct console *);
>  extern int is_console_locked(void);
>  
> -#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
> +extern int disable_console_on_suspend;
> +
>  /* Suspend and resume console messages over PM events */
>  extern void suspend_console(void);
>  extern void resume_console(void);
> -#else
> -static inline void suspend_console(void) {}
> -static inline void resume_console(void) {}
> -#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
>  
>  int mda_console_init(void);
>  void prom_con_init(void);
> diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
> index 412859f..a68e841 100644
> --- a/kernel/power/Kconfig
> +++ b/kernel/power/Kconfig
> @@ -44,17 +44,6 @@ config PM_VERBOSE
>  	---help---
>  	This option enables verbose messages from the Power Management code.
>  
> -config DISABLE_CONSOLE_SUSPEND
> -	bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
> -	depends on PM_DEBUG && PM_SLEEP
> -	default n
> -	---help---
> -	This option turns off the console suspend mechanism that prevents
> -	debug messages from reaching the console during the suspend/resume
> -	operations.  This may be helpful when debugging device drivers'
> -	suspend/resume routines, but may itself lead to problems, for example
> -	if netconsole is used.
> -
>  config PM_TRACE
>  	bool "Suspend/resume event tracing"
>  	depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
> diff --git a/kernel/printk.c b/kernel/printk.c
> index bd2cd06..5a2d6c0 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -751,7 +751,9 @@ int update_console_cmdline(char *name, i
>  	return -1;
>  }
>  
> -#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
> +
> +int disable_console_on_suspend;
> +
>  /**
>   * suspend_console - suspend the console subsystem
>   *
> @@ -759,17 +761,22 @@ #ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
>   */
>  void suspend_console(void)
>  {
> -	printk("Suspending console(s)\n");
> -	acquire_console_sem();
> -	console_suspended = 1;
> +	if (disable_console_on_suspend) {
> +		printk("Suspending console(s)\n");
> +		acquire_console_sem();
> +		console_suspended = 1;
> +	}
>  }
>  
>  void resume_console(void)
>  {
> -	console_suspended = 0;
> -	release_console_sem();
> +	if (console_suspended) {
> +		BUG_ON(!disable_console_on_suspend);
> +		console_suspended = 0;
> +		release_console_sem();
> +	}
>  }
> -#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
> +
>  
>  /**
>   * acquire_console_sem - lock the console system for exclusive use.
> 

-- 
"Premature optimization is the root of all evil." - Donald Knuth

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

* Re: + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree
  2007-08-14 18:23           ` Rafael J. Wysocki
@ 2007-08-14 18:44             ` Andres Salomon
  2007-08-14 18:58               ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Andres Salomon @ 2007-08-14 18:44 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Pavel Machek, akpm, kernel list

On Tue, 14 Aug 2007 20:23:23 +0200
"Rafael J. Wysocki" <rjw@sisk.pl> wrote:

> On Tuesday, 14 August 2007 12:39, Pavel Machek wrote:
> > Hi!
> > 
> > > Thanks, updated below!
> > > 
> > > 
> > > 
> > > serial: turn serial console suspend a boot rather than compile time option
> > > 
> > > From: Andres Salomon <dilinger@debian.org>
> > > 
> > > Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
> > > the serial console from being suspended when the rest of the machine goes
> > > to sleep.  This is incredibly useful for debugging power
> > > management-related
> > 
> > Actually, this should not be configurable. We should simply enable
> > console during suspend for consoles that can handle this,
> > automatically.... this patch does just that. I hope I separated it
> > correctly.


I disagree.  I expect that this will break things; I would prefer to keep
it as a configuration option.  If you want to enable it by default, that's
one thing; but give users the option to turn it off.



-- 
Andres Salomon <dilinger@queued.net>

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

* Re: + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree
  2007-08-14 18:44             ` Andres Salomon
@ 2007-08-14 18:58               ` Rafael J. Wysocki
  0 siblings, 0 replies; 6+ messages in thread
From: Rafael J. Wysocki @ 2007-08-14 18:58 UTC (permalink / raw)
  To: Andres Salomon; +Cc: Pavel Machek, akpm, kernel list

On Tuesday, 14 August 2007 20:44, Andres Salomon wrote:
> On Tue, 14 Aug 2007 20:23:23 +0200
> "Rafael J. Wysocki" <rjw@sisk.pl> wrote:
> 
> > On Tuesday, 14 August 2007 12:39, Pavel Machek wrote:
> > > Hi!
> > > 
> > > > Thanks, updated below!
> > > > 
> > > > 
> > > > 
> > > > serial: turn serial console suspend a boot rather than compile time option
> > > > 
> > > > From: Andres Salomon <dilinger@debian.org>
> > > > 
> > > > Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
> > > > the serial console from being suspended when the rest of the machine goes
> > > > to sleep.  This is incredibly useful for debugging power
> > > > management-related
> > > 
> > > Actually, this should not be configurable. We should simply enable
> > > console during suspend for consoles that can handle this,
> > > automatically.... this patch does just that. I hope I separated it
> > > correctly.
> 
> 
> I disagree.  I expect that this will break things; I would prefer to keep
> it as a configuration option.  If you want to enable it by default, that's
> one thing; but give users the option to turn it off.

Hm, I think this can be combined with your patch:

(1) add a command line parameter that will turn the suspending of consoles on
(2) add a switch that will disable the thing regardless of (1) if netconsole is
    enabled (like in the Pavel's patch).

Greetings,
Rafael

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

* + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree
@ 2007-08-14 19:37 akpm
  0 siblings, 0 replies; 6+ messages in thread
From: akpm @ 2007-08-14 19:37 UTC (permalink / raw)
  To: mm-commits; +Cc: dilinger, nigel, pavel, rjw, rmk


The patch titled
     serial: turn serial console suspend a boot rather than compile time option
has been added to the -mm tree.  Its filename is
     serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: serial: turn serial console suspend a boot rather than compile time option
From: Andres Salomon <dilinger@debian.org>

Currently, there's a CONFIG_DISABLE_CONSOLE_SUSPEND that allows one to stop
the serial console from being suspended when the rest of the machine goes
to sleep.  This is incredibly useful for debugging power management-related
things; however, having it as a compile-time option has proved to be
incredibly inconvenient for us (OLPC).  There are plenty of times that we
want serial console to not suspend, but for the most part we'd like serial
console to be suspended.

This drops CONFIG_DISABLE_CONSOLE_SUSPEND, and replaces it with a kernel
boot parameter (no_console_suspend).  By default, the serial console will
be suspended along with the rest of the system; by passing
'no_console_suspend' to the kernel during boot, serial console will remain
alive during suspend.

For now, this is pretty serial console specific; further fixes could be
applied to make this work for things like netconsole.

Signed-off-by: Andres Salomon <dilinger@debian.org>
Acked-by: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Nigel Cunningham <nigel@suspend2.net>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 Documentation/kernel-parameters.txt        |   10 ++++++++++
 Documentation/power/basic-pm-debugging.txt |    4 ++--
 arch/powerpc/configs/pmac32_defconfig      |    1 -
 drivers/serial/serial_core.c               |   10 ++++------
 include/linux/console.h                    |    7 ++-----
 kernel/power/Kconfig                       |   11 -----------
 kernel/printk.c                            |   15 +++++++++++++--
 7 files changed, 31 insertions(+), 27 deletions(-)

diff -puN Documentation/kernel-parameters.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option Documentation/kernel-parameters.txt
--- a/Documentation/kernel-parameters.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/Documentation/kernel-parameters.txt
@@ -477,6 +477,16 @@ and is between 256 and 4096 characters. 
 			UART at the specified I/O port or MMIO address.
 			The options are the same as for ttyS, above.
 
+	no_console_suspend
+			[HW] Never suspend the console
+			Disable suspending of consoles during suspend and
+			hibernate operations.  Once disabled, debugging
+			messages can reach various consoles while the rest
+			of the system is being put to sleep (ie, while
+			debugging driver suspend/resume hooks).  This may
+			not work reliably with all consoles, but is known
+			to work with serial and VGA consoles.
+
 	cpcihp_generic=	[HW,PCI] Generic port I/O CompactPCI driver
 			Format:
 			<first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
diff -puN Documentation/power/basic-pm-debugging.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option Documentation/power/basic-pm-debugging.txt
--- a/Documentation/power/basic-pm-debugging.txt~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/Documentation/power/basic-pm-debugging.txt
@@ -78,8 +78,8 @@ c) Advanced debugging
 In case the STD does not work on your system even in the minimal configuration
 and compiling more drivers as modules is not practical or some modules cannot
 be unloaded, you can use one of the more advanced debugging techniques to find
-the problem.  First, if there is a serial port in your box, you can set the
-CONFIG_DISABLE_CONSOLE_SUSPEND kernel configuration option and try to log kernel
+the problem.  First, if there is a serial port in your box, you can boot the
+kernel with the 'no_console_suspend' parameter and try to log kernel
 messages using the serial console.  This may provide you with some information
 about the reasons of the suspend (resume) failure.  Alternatively, it may be
 possible to use a FireWire port for debugging with firescope
diff -puN arch/powerpc/configs/pmac32_defconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option arch/powerpc/configs/pmac32_defconfig
--- a/arch/powerpc/configs/pmac32_defconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/arch/powerpc/configs/pmac32_defconfig
@@ -216,7 +216,6 @@ CONFIG_PROC_DEVICETREE=y
 CONFIG_PM=y
 # CONFIG_PM_LEGACY is not set
 CONFIG_PM_DEBUG=y
-# CONFIG_DISABLE_CONSOLE_SUSPEND is not set
 CONFIG_PM_SYSFS_DEPRECATED=y
 CONFIG_HIBERNATION=y
 CONFIG_PM_STD_PARTITION=""
diff -puN drivers/serial/serial_core.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option drivers/serial/serial_core.c
--- a/drivers/serial/serial_core.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/drivers/serial/serial_core.c
@@ -1954,12 +1954,11 @@ int uart_suspend_port(struct uart_driver
 
 	mutex_lock(&state->mutex);
 
-#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
-	if (uart_console(port)) {
+	if (!console_suspend_enabled && uart_console(port)) {
+		/* we're going to avoid suspending serial console */
 		mutex_unlock(&state->mutex);
 		return 0;
 	}
-#endif
 
 	if (state->info && state->info->flags & UIF_INITIALIZED) {
 		const struct uart_ops *ops = port->ops;
@@ -2002,12 +2001,11 @@ int uart_resume_port(struct uart_driver 
 
 	mutex_lock(&state->mutex);
 
-#ifdef CONFIG_DISABLE_CONSOLE_SUSPEND
-	if (uart_console(port)) {
+	if (!console_suspend_enabled && uart_console(port)) {
+		/* no need to resume serial console, it wasn't suspended */
 		mutex_unlock(&state->mutex);
 		return 0;
 	}
-#endif
 
 	uart_change_pm(state, 0);
 
diff -puN include/linux/console.h~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option include/linux/console.h
--- a/include/linux/console.h~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/include/linux/console.h
@@ -121,14 +121,11 @@ extern void console_stop(struct console 
 extern void console_start(struct console *);
 extern int is_console_locked(void);
 
-#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
+extern int console_suspend_enabled;
+
 /* Suspend and resume console messages over PM events */
 extern void suspend_console(void);
 extern void resume_console(void);
-#else
-static inline void suspend_console(void) {}
-static inline void resume_console(void) {}
-#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
 
 int mda_console_init(void);
 void prom_con_init(void);
diff -puN kernel/power/Kconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option kernel/power/Kconfig
--- a/kernel/power/Kconfig~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/kernel/power/Kconfig
@@ -44,17 +44,6 @@ config PM_VERBOSE
 	---help---
 	This option enables verbose messages from the Power Management code.
 
-config DISABLE_CONSOLE_SUSPEND
-	bool "Keep console(s) enabled during suspend/resume (DANGEROUS)"
-	depends on PM_DEBUG && PM_SLEEP
-	default n
-	---help---
-	This option turns off the console suspend mechanism that prevents
-	debug messages from reaching the console during the suspend/resume
-	operations.  This may be helpful when debugging device drivers'
-	suspend/resume routines, but may itself lead to problems, for example
-	if netconsole is used.
-
 config PM_TRACE
 	bool "Suspend/resume event tracing"
 	depends on PM_DEBUG && X86 && PM_SLEEP && EXPERIMENTAL
diff -puN kernel/printk.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option kernel/printk.c
--- a/kernel/printk.c~serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option
+++ a/kernel/printk.c
@@ -810,7 +810,15 @@ int update_console_cmdline(char *name, i
 	return -1;
 }
 
-#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND
+int console_suspend_enabled = 1;
+
+static int __init console_suspend_disable(char *str)
+{
+	console_suspend_enabled = 0;
+	return 1;
+}
+__setup("no_console_suspend", console_suspend_disable);
+
 /**
  * suspend_console - suspend the console subsystem
  *
@@ -818,6 +826,8 @@ int update_console_cmdline(char *name, i
  */
 void suspend_console(void)
 {
+	if (!console_suspend_enabled)
+		return;
 	printk("Suspending console(s)\n");
 	acquire_console_sem();
 	console_suspended = 1;
@@ -825,10 +835,11 @@ void suspend_console(void)
 
 void resume_console(void)
 {
+	if (!console_suspend_enabled)
+		return;
 	console_suspended = 0;
 	release_console_sem();
 }
-#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */
 
 /**
  * acquire_console_sem - lock the console system for exclusive use.
_

Patches currently in -mm which might be from dilinger@debian.org are

geode-mfgpt-support-for-geode-class-machines.patch
geode-mfgpt-clock-event-device-support.patch
serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch

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

end of thread, other threads:[~2007-08-14 19:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-09 20:26 + serial-turn-serial-console-suspend-a-boot-rather-than-compile-time-option.patch added to -mm tree akpm
     [not found] ` <200708092340.46523.rjw@sisk.pl>
     [not found]   ` <20070809182145.bae42748.dilinger@queued.net>
     [not found]     ` <200708101456.46102.rjw@sisk.pl>
     [not found]       ` <20070813142331.9b0774ae.dilinger@queued.net>
2007-08-14 10:39         ` Pavel Machek
2007-08-14 18:23           ` Rafael J. Wysocki
2007-08-14 18:44             ` Andres Salomon
2007-08-14 18:58               ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2007-08-14 19:37 akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.