* [PATCH 0/2] two serial_core suspend/resume fixes--to
@ 2010-08-21 7:08 Jason Wang
2010-08-21 7:08 ` [PATCH 1/2] serial-core: skip call set_termios/console_start when no_console_suspend Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2010-08-21 7:08 UTC (permalink / raw)
To: alan, arnd, sbrabec; +Cc: linux-serial
The [1/2] fix this situation:
we set no_console_supend and console=ttyS0 to bootargs, then bootup
the kernel, the boot logs will print out from ttyS0. When we execute
echo mem > /sys/power/state, the system will suspend, we press a
key(or other wakeup trigger) to resume the system, but the ttyS0 can't
work anymore.
The [2/2] fix this situation:
we set console=ttyS0 to bootargs, then bootup the kernel, the boot
logs will print out from ttyS0, this time we set ttyS1 as tty and
login for shell. When we execute echo mem > /sys/power/state, the
system will suspend, we press a key(or other wakeup trigger) to
resume the system, but the ttyS0 can't work anymore.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] serial-core: skip call set_termios/console_start when no_console_suspend
2010-08-21 7:08 [PATCH 0/2] two serial_core suspend/resume fixes--to Jason Wang
@ 2010-08-21 7:08 ` Jason Wang
2010-08-21 7:08 ` [PATCH 2/2] serial-core: restore termios settings when resume console ports Jason Wang
0 siblings, 1 reply; 3+ messages in thread
From: Jason Wang @ 2010-08-21 7:08 UTC (permalink / raw)
To: alan, arnd, sbrabec; +Cc: linux-serial
The commit 4547be7 rewrites suspend and resume functions, this
introduces a problem on the OMAP3EVM platoform. when the kernel boots
with no_console_suspend and we suspend the kernel, then resume it,
the serial console will be not usable. This problem should be common
for all platforms.
The cause for this problem is that when enter suspend, if we choose
no_console_suspend, the console_stop will be skiped. But in resume
function, the console port will be set to uninitialized state by
calling set_termios function and the console_start is called without
checking whether the no_console_suspend is set, Now fix it.
Signed-off-by: Jason Wang <jason77.wang@gmail.com>
---
drivers/serial/serial_core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index cd85112..ff21200 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2065,7 +2065,7 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
/*
* Re-enable the console device after suspending.
*/
- if (uart_console(uport)) {
+ if (console_suspend_enabled && uart_console(uport)) {
uart_change_pm(state, 0);
uport->ops->set_termios(uport, &termios, NULL);
console_start(uport->cons);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] serial-core: restore termios settings when resume console ports
2010-08-21 7:08 ` [PATCH 1/2] serial-core: skip call set_termios/console_start when no_console_suspend Jason Wang
@ 2010-08-21 7:08 ` Jason Wang
0 siblings, 0 replies; 3+ messages in thread
From: Jason Wang @ 2010-08-21 7:08 UTC (permalink / raw)
To: alan, arnd, sbrabec; +Cc: linux-serial
The commit 4547be7 rewrites suspend and resume functions. According
to this rewrite, when a serial port is a printk console device and
can suspend(without set no_console_suspend flag), it will definitely
call set_termios function during its resume, but parameter termios
isn't initialized, this will pass an unpredictable config to the
serial port. If this serial port is not a userspace opened tty device
, a suspend and resume action will make this serial port unusable.
I.E. ttyS0 is a printk console device, ttyS1 or keyboard+display is
userspace tty device, a suspend/resume action will make ttyS0
unusable.
If a serial port is both a printk console device and an opened tty
device, this issue can be overcome because it will call set_termios
again with the correct parameter in the uart_change_speed function.
Refer to the deleted content of commit 4547be7, revert parts relate
to restore settings into parameter termios. It is safe because if
a serial port is a printk console only device, the only meaningful
field in termios is c_cflag and its old config is saved in
uport->cons->cflag, if this port is also an opened tty device,
it will clear uport->cons->cflag in the uart_open and the old config
is saved in tty->termios.
Signed-off-by: Jason Wang <jason77.wang@gmail.com>
---
drivers/serial/serial_core.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index ff21200..bc6cddd 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2066,6 +2066,18 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
* Re-enable the console device after suspending.
*/
if (console_suspend_enabled && uart_console(uport)) {
+ /*
+ * First try to use the console cflag setting.
+ */
+ memset(&termios, 0, sizeof(struct ktermios));
+ termios.c_cflag = uport->cons->cflag;
+
+ /*
+ * If that's unset, use the tty termios setting.
+ */
+ if (port->tty && port->tty->termios && termios.c_cflag == 0)
+ termios = *(port->tty->termios);
+
uart_change_pm(state, 0);
uport->ops->set_termios(uport, &termios, NULL);
console_start(uport->cons);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-21 7:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-21 7:08 [PATCH 0/2] two serial_core suspend/resume fixes--to Jason Wang
2010-08-21 7:08 ` [PATCH 1/2] serial-core: skip call set_termios/console_start when no_console_suspend Jason Wang
2010-08-21 7:08 ` [PATCH 2/2] serial-core: restore termios settings when resume console ports Jason Wang
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).