diff mbox

[PATCHv3] driver: serial: prevent UART console idle on suspend while using "no_console_suspend"

Message ID 1365167733-28083-1-git-send-email-sourav.poddar@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Poddar, Sourav April 5, 2013, 1:15 p.m. UTC
With dt boot, uart wakeup after suspend is non functional while using
"no_console_suspend" in the bootargs. With "no_console_suspend" used, we
should prevent the runtime suspend of the uart port which is getting used
as an console.

Cc: Santosh Shilimkar<santosh.shilimkar@ti.com>
Cc: Felipe Balbi<balbi@ti.com>
Cc: Rajendra nayak<rnayak@ti.com>
Tested on omap5430evm, omap4430sdp.

Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
---
v2->v3
Based on Kevin Hilman and Santosh Shilimkar comments, modified
serial core/driver layer to bypass runtime suspend 
for console uart while using "no_console_suspend".

This patch is based on Santosh Shilimkar serial patch[1]

[1]: http://permalink.gmane.org/gmane.linux.ports.arm.omap/95828
	
 drivers/tty/serial/omap-serial.c |    5 ++++-
 drivers/tty/serial/serial_core.c |    3 +++
 include/linux/serial_core.h      |    1 +
 3 files changed, 8 insertions(+), 1 deletions(-)

Comments

Kevin Hilman April 5, 2013, 5:40 p.m. UTC | #1
Sourav Poddar <sourav.poddar@ti.com> writes:

> With dt boot, uart wakeup after suspend is non functional while using
> "no_console_suspend" in the bootargs. With "no_console_suspend" used, we
> should prevent the runtime suspend of the uart port which is getting used
> as an console.
>
> Cc: Santosh Shilimkar<santosh.shilimkar@ti.com>
> Cc: Felipe Balbi<balbi@ti.com>
> Cc: Rajendra nayak<rnayak@ti.com>
> Tested on omap5430evm, omap4430sdp.
>
> Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>

Rather than make these special checks inside the driver's runtime PM
callbacks, you should just disable runtime PM (pm_runtime_disable())

Then, this should be broken into 2 patches.

1) serial core: add the '->is_console' flag.  (nit on naming: don't call
   it port_is_console, since the struct is already a uart_port)

2) In the OMAP UART driver's ->prepare callback, check the is_console flag
   and pm_runtime_disable() accordingly  (then pm_runtime_enable() in
   the drivers's ->complete callback.

Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Russell King - ARM Linux April 8, 2013, 5:14 p.m. UTC | #2
On Fri, Apr 05, 2013 at 06:45:33PM +0530, Sourav Poddar wrote:
> With dt boot, uart wakeup after suspend is non functional while using
> "no_console_suspend" in the bootargs. With "no_console_suspend" used, we
> should prevent the runtime suspend of the uart port which is getting used
> as an console.
> 
> Cc: Santosh Shilimkar<santosh.shilimkar@ti.com>
> Cc: Felipe Balbi<balbi@ti.com>
> Cc: Rajendra nayak<rnayak@ti.com>
> Tested on omap5430evm, omap4430sdp.
> 
> Signed-off-by: Sourav Poddar <sourav.poddar@ti.com>
> ---
> v2->v3
> Based on Kevin Hilman and Santosh Shilimkar comments, modified
> serial core/driver layer to bypass runtime suspend 
> for console uart while using "no_console_suspend".
> 
> This patch is based on Santosh Shilimkar serial patch[1]

Rather than introducing this "port_is_console" thing, please move
uart_console() into the serial_core.h header file, making it an inline
function, and use that in omap-serial.c.

Remember to fix drivers/tty/serial/mpc52xx_uart.c as well for that change.
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Poddar, Sourav April 10, 2013, 5:27 a.m. UTC | #3
Hi Russell,
On Monday 08 April 2013 10:44 PM, Russell King - ARM Linux wrote:
> On Fri, Apr 05, 2013 at 06:45:33PM +0530, Sourav Poddar wrote:
>> With dt boot, uart wakeup after suspend is non functional while using
>> "no_console_suspend" in the bootargs. With "no_console_suspend" used, we
>> should prevent the runtime suspend of the uart port which is getting used
>> as an console.
>>
>> Cc: Santosh Shilimkar<santosh.shilimkar@ti.com>
>> Cc: Felipe Balbi<balbi@ti.com>
>> Cc: Rajendra nayak<rnayak@ti.com>
>> Tested on omap5430evm, omap4430sdp.
>>
>> Signed-off-by: Sourav Poddar<sourav.poddar@ti.com>
>> ---
>> v2->v3
>> Based on Kevin Hilman and Santosh Shilimkar comments, modified
>> serial core/driver layer to bypass runtime suspend
>> for console uart while using "no_console_suspend".
>>
>> This patch is based on Santosh Shilimkar serial patch[1]
> Rather than introducing this "port_is_console" thing, please move
> uart_console() into the serial_core.h header file, making it an inline
> function, and use that in omap-serial.c.
>
> Remember to fix drivers/tty/serial/mpc52xx_uart.c as well for that change.
Thanks for the pointer. Will take care of your suggestions
in the next version.

~Sourav
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 08332f3..81a1760 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1582,7 +1582,7 @@  static int serial_omap_runtime_suspend(struct device *dev)
 	struct uart_omap_port *up = dev_get_drvdata(dev);
 	struct omap_uart_port_info *pdata = dev->platform_data;
 
-	if (!up)
+	if (!up || (!console_suspend_enabled && up->port.port_is_console))
 		return -EINVAL;
 
 	if (!pdata)
@@ -1614,6 +1614,9 @@  static int serial_omap_runtime_resume(struct device *dev)
 
 	int loss_cnt = serial_omap_get_context_loss_count(up);
 
+	if (!console_suspend_enabled && up->port.port_is_console)
+		return -EINVAL;
+
 	if (loss_cnt < 0) {
 		dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
 			loss_cnt);
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index a400002..6c8b041 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2594,6 +2594,9 @@  int uart_add_one_port(struct uart_driver *drv, struct uart_port *uport)
 	uport->cons = drv->cons;
 	uport->state = state;
 
+	if (uart_console(uport))
+		uport->port_is_console = true;
+
 	/*
 	 * If this port is a console, then the spinlock is already
 	 * initialised.
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 87d4bbc..c944414 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -194,6 +194,7 @@  struct uart_port {
 	unsigned char		irq_wake;
 	unsigned char		unused[2];
 	void			*private_data;		/* generic platform data pointer */
+	bool			port_is_console;
 };
 
 static inline int serial_port_in(struct uart_port *up, int offset)