linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: omap: Fix device tree based PM runtime
@ 2013-06-07 21:58 Tony Lindgren
  2013-06-07 22:47 ` Kevin Hilman
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2013-06-07 21:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-omap, linux-arm-kernel

In the runtime_suspend function pdata is not being used, and
also blocks the function in device tree based booting. Fix it
by removing the unused pdata from the runtime_suspend function.

Further, context loss count is not being passed in pdata, so
let's just reinitialize the port every time for those case.
This can be further optimized later on for the device tree
case by adding detection for the hardware state and possibly
by adding a driver specific autosuspend timeout.

And doing this, we can then make the related dev_err into a
dev_dbg message instead of an error.

In order for the wake-up events to work, we also need to set
autosuspend_timeout to -1 if 0, and also device_init_wakeup()
as that's not being done by the platform init code for the
device tree case.

Note that this does not affect legacy booting, and in fact
might make it work for the cases where the context loss info
is not being passed in pdata.

Thanks to Kevin Hilman <khilman@linaro.org> for debugging
and suggesting fixes for the autosuspend_timeout and
device_init_wakeup() related initializiation.

Cc: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>

---

This can wait for v3.11 merge window as the related PM patches
have not yet been merged.

--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -197,7 +197,7 @@ static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
 	struct omap_uart_port_info *pdata = up->dev->platform_data;
 
 	if (!pdata || !pdata->get_context_loss_count)
-		return 0;
+		return -EINVAL;
 
 	return pdata->get_context_loss_count(up->dev);
 }
@@ -1482,6 +1482,9 @@ static int serial_omap_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, up);
 	pm_runtime_enable(&pdev->dev);
+	if (omap_up_info->autosuspend_timeout == 0)
+		omap_up_info->autosuspend_timeout = -1;
+	device_init_wakeup(up->dev, true);
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_set_autosuspend_delay(&pdev->dev,
 			omap_up_info->autosuspend_timeout);
@@ -1500,6 +1503,7 @@ static int serial_omap_probe(struct platform_device *pdev)
 
 	pm_runtime_mark_last_busy(up->dev);
 	pm_runtime_put_autosuspend(up->dev);
+
 	return 0;
 
 err_add_port:
@@ -1591,14 +1595,10 @@ static void serial_omap_restore_context(struct uart_omap_port *up)
 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)
 		return -EINVAL;
 
-	if (!pdata)
-		return 0;
-
 	up->context_loss_cnt = serial_omap_get_context_loss_count(up);
 
 	if (device_may_wakeup(dev)) {
@@ -1626,7 +1626,7 @@ static int serial_omap_runtime_resume(struct device *dev)
 	int loss_cnt = serial_omap_get_context_loss_count(up);
 
 	if (loss_cnt < 0) {
-		dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
+		dev_dbg(dev, "serial_omap_get_context_loss_count failed : %d\n",
 			loss_cnt);
 		serial_omap_restore_context(up);
 	} else if (up->context_loss_cnt != loss_cnt) {

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

* Re: [PATCH] serial: omap: Fix device tree based PM runtime
  2013-06-07 21:58 [PATCH] serial: omap: Fix device tree based PM runtime Tony Lindgren
@ 2013-06-07 22:47 ` Kevin Hilman
  2013-06-07 23:00   ` Tony Lindgren
  0 siblings, 1 reply; 5+ messages in thread
From: Kevin Hilman @ 2013-06-07 22:47 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Greg Kroah-Hartman, linux-omap, linux-arm-kernel

Tony Lindgren <tony@atomide.com> writes:

> In the runtime_suspend function pdata is not being used, and
> also blocks the function in device tree based booting. Fix it
> by removing the unused pdata from the runtime_suspend function.
>
> Further, context loss count is not being passed in pdata, so
> let's just reinitialize the port every time for those case.
> This can be further optimized later on for the device tree
> case by adding detection for the hardware state and possibly
> by adding a driver specific autosuspend timeout.
>
> And doing this, we can then make the related dev_err into a
> dev_dbg message instead of an error.
>
> In order for the wake-up events to work, we also need to set
> autosuspend_timeout to -1 if 0, and also device_init_wakeup()
> as that's not being done by the platform init code for the
> device tree case.
>
> Note that this does not affect legacy booting, and in fact
> might make it work for the cases where the context loss info
> is not being passed in pdata.
>
> Thanks to Kevin Hilman <khilman@linaro.org> for debugging
> and suggesting fixes for the autosuspend_timeout and
> device_init_wakeup() related initializiation.
>
> Cc: Kevin Hilman <khilman@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

There's a stray whitespace change in the patch, and also, maybe it
should be broken up into a few different patches:

1) stray pdata
2) context_loss: -EINVAL + dev_dbg change
3) device_init_wakeup
4) autosuspend timeout defaults

but otherwise the content is right.

Reviewed-by: Kevin Hilman <khilman@linaro.org>

Also, tested on OMAP3/4

Tested-by: Kevin Hilman <khilman@linaro.org>

Kevin

> ---
>
> This can wait for v3.11 merge window as the related PM patches
> have not yet been merged.
>
> --- a/drivers/tty/serial/omap-serial.c
> +++ b/drivers/tty/serial/omap-serial.c
> @@ -197,7 +197,7 @@ static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
>  	struct omap_uart_port_info *pdata = up->dev->platform_data;
>  
>  	if (!pdata || !pdata->get_context_loss_count)
> -		return 0;
> +		return -EINVAL;
>  
>  	return pdata->get_context_loss_count(up->dev);
>  }
> @@ -1482,6 +1482,9 @@ static int serial_omap_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, up);
>  	pm_runtime_enable(&pdev->dev);
> +	if (omap_up_info->autosuspend_timeout == 0)
> +		omap_up_info->autosuspend_timeout = -1;
> +	device_init_wakeup(up->dev, true);
>  	pm_runtime_use_autosuspend(&pdev->dev);
>  	pm_runtime_set_autosuspend_delay(&pdev->dev,
>  			omap_up_info->autosuspend_timeout);
> @@ -1500,6 +1503,7 @@ static int serial_omap_probe(struct platform_device *pdev)
>  
>  	pm_runtime_mark_last_busy(up->dev);
>  	pm_runtime_put_autosuspend(up->dev);
> +
>  	return 0;
>  
>  err_add_port:
> @@ -1591,14 +1595,10 @@ static void serial_omap_restore_context(struct uart_omap_port *up)
>  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)
>  		return -EINVAL;
>  
> -	if (!pdata)
> -		return 0;
> -
>  	up->context_loss_cnt = serial_omap_get_context_loss_count(up);
>  
>  	if (device_may_wakeup(dev)) {
> @@ -1626,7 +1626,7 @@ static int serial_omap_runtime_resume(struct device *dev)
>  	int loss_cnt = serial_omap_get_context_loss_count(up);
>  
>  	if (loss_cnt < 0) {
> -		dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
> +		dev_dbg(dev, "serial_omap_get_context_loss_count failed : %d\n",
>  			loss_cnt);
>  		serial_omap_restore_context(up);
>  	} else if (up->context_loss_cnt != loss_cnt) {
> --
> 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

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

* Re: [PATCH] serial: omap: Fix device tree based PM runtime
  2013-06-07 22:47 ` Kevin Hilman
@ 2013-06-07 23:00   ` Tony Lindgren
  2013-06-09  5:32     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Tony Lindgren @ 2013-06-07 23:00 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Greg Kroah-Hartman, linux-omap, linux-arm-kernel

In the runtime_suspend function pdata is not being used, and
also blocks the function in device tree based booting. Fix it
by removing the unused pdata from the runtime_suspend function.

Further, context loss count is not being passed in pdata, so
let's just reinitialize the port every time for those case.
This can be further optimized later on for the device tree
case by adding detection for the hardware state and possibly
by adding a driver specific autosuspend timeout.

And doing this, we can then make the related dev_err into a
dev_dbg message instead of an error.

In order for the wake-up events to work, we also need to set
autosuspend_timeout to -1 if 0, and also device_init_wakeup()
as that's not being done by the platform init code for the
device tree case.

Note that this does not affect legacy booting, and in fact
might make it work for the cases where the context loss info
is not being passed in pdata.

Thanks to Kevin Hilman <khilman@linaro.org> for debugging
and suggesting fixes for the autosuspend_timeout and
device_init_wakeup() related initializiation.

Reviewed-by: Kevin Hilman <khilman@linaro.org>
Tested-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>

---

Here's an updated version with the white space fixed. Since
you already acked it, I won't waste the opportunity to keep it
in a single patch :)

--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -197,7 +197,7 @@ static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
 	struct omap_uart_port_info *pdata = up->dev->platform_data;
 
 	if (!pdata || !pdata->get_context_loss_count)
-		return 0;
+		return -EINVAL;
 
 	return pdata->get_context_loss_count(up->dev);
 }
@@ -1482,6 +1482,9 @@ static int serial_omap_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, up);
 	pm_runtime_enable(&pdev->dev);
+	if (omap_up_info->autosuspend_timeout == 0)
+		omap_up_info->autosuspend_timeout = -1;
+	device_init_wakeup(up->dev, true);
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_set_autosuspend_delay(&pdev->dev,
 			omap_up_info->autosuspend_timeout);
@@ -1591,14 +1594,10 @@ static void serial_omap_restore_context(struct uart_omap_port *up)
 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)
 		return -EINVAL;
 
-	if (!pdata)
-		return 0;
-
 	up->context_loss_cnt = serial_omap_get_context_loss_count(up);
 
 	if (device_may_wakeup(dev)) {
@@ -1626,7 +1625,7 @@ static int serial_omap_runtime_resume(struct device *dev)
 	int loss_cnt = serial_omap_get_context_loss_count(up);
 
 	if (loss_cnt < 0) {
-		dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
+		dev_dbg(dev, "serial_omap_get_context_loss_count failed : %d\n",
 			loss_cnt);
 		serial_omap_restore_context(up);
 	} else if (up->context_loss_cnt != loss_cnt) {

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

* Re: [PATCH] serial: omap: Fix device tree based PM runtime
  2013-06-07 23:00   ` Tony Lindgren
@ 2013-06-09  5:32     ` Greg Kroah-Hartman
  2013-06-10 14:39       ` Tony Lindgren
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2013-06-09  5:32 UTC (permalink / raw)
  To: Tony Lindgren; +Cc: Kevin Hilman, linux-omap, linux-arm-kernel

On Fri, Jun 07, 2013 at 04:00:22PM -0700, Tony Lindgren wrote:
> In the runtime_suspend function pdata is not being used, and
> also blocks the function in device tree based booting. Fix it
> by removing the unused pdata from the runtime_suspend function.
> 
> Further, context loss count is not being passed in pdata, so
> let's just reinitialize the port every time for those case.
> This can be further optimized later on for the device tree
> case by adding detection for the hardware state and possibly
> by adding a driver specific autosuspend timeout.
> 
> And doing this, we can then make the related dev_err into a
> dev_dbg message instead of an error.
> 
> In order for the wake-up events to work, we also need to set
> autosuspend_timeout to -1 if 0, and also device_init_wakeup()
> as that's not being done by the platform init code for the
> device tree case.
> 
> Note that this does not affect legacy booting, and in fact
> might make it work for the cases where the context loss info
> is not being passed in pdata.
> 
> Thanks to Kevin Hilman <khilman@linaro.org> for debugging
> and suggesting fixes for the autosuspend_timeout and
> device_init_wakeup() related initializiation.
> 
> Reviewed-by: Kevin Hilman <khilman@linaro.org>
> Tested-by: Kevin Hilman <khilman@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> 
> ---
> 
> Here's an updated version with the white space fixed. Since
> you already acked it, I won't waste the opportunity to keep it
> in a single patch :)

It doesn't apply to my tree, so you'll have to refresh it against my
tty-next tree and resend it.

thanks,

greg k-h

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

* Re: [PATCH] serial: omap: Fix device tree based PM runtime
  2013-06-09  5:32     ` Greg Kroah-Hartman
@ 2013-06-10 14:39       ` Tony Lindgren
  0 siblings, 0 replies; 5+ messages in thread
From: Tony Lindgren @ 2013-06-10 14:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Kevin Hilman, linux-omap, linux-arm-kernel

In the runtime_suspend function pdata is not being used, and
also blocks the function in device tree based booting. Fix it
by removing the unused pdata from the runtime_suspend function.

Further, context loss count is not being passed in pdata, so
let's just reinitialize the port every time for those case.
This can be further optimized later on for the device tree
case by adding detection for the hardware state and possibly
by adding a driver specific autosuspend timeout.

And doing this, we can then make the related dev_err into a
dev_dbg message instead of an error.

In order for the wake-up events to work, we also need to set
autosuspend_timeout to -1 if 0, and also device_init_wakeup()
as that's not being done by the platform init code for the
device tree case.

Note that this does not affect legacy booting, and in fact
might make it work for the cases where the context loss info
is not being passed in pdata.

Thanks to Kevin Hilman <khilman@linaro.org> for debugging
and suggesting fixes for the autosuspend_timeout and
device_init_wakeup() related initializiation.

Reviewed-by: Kevin Hilman <khilman@linaro.org>
Tested-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>

---

Here's this one updated against Linux next.

--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -198,7 +198,7 @@ static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
 	struct omap_uart_port_info *pdata = up->dev->platform_data;
 
 	if (!pdata || !pdata->get_context_loss_count)
-		return 0;
+		return -EINVAL;
 
 	return pdata->get_context_loss_count(up->dev);
 }
@@ -1502,6 +1502,9 @@ static int serial_omap_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, up);
 	pm_runtime_enable(&pdev->dev);
+	if (omap_up_info->autosuspend_timeout == 0)
+		omap_up_info->autosuspend_timeout = -1;
+	device_init_wakeup(up->dev, true);
 	pm_runtime_use_autosuspend(&pdev->dev);
 	pm_runtime_set_autosuspend_delay(&pdev->dev,
 			omap_up_info->autosuspend_timeout);
@@ -1611,7 +1614,6 @@ static void serial_omap_restore_context(struct uart_omap_port *up)
 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)
 		return -EINVAL;
@@ -1626,9 +1628,6 @@ static int serial_omap_runtime_suspend(struct device *dev)
 	    uart_console(&up->port))
 		return -EBUSY;
 
-	if (!pdata)
-		return 0;
-
 	up->context_loss_cnt = serial_omap_get_context_loss_count(up);
 
 	if (device_may_wakeup(dev)) {
@@ -1656,7 +1655,7 @@ static int serial_omap_runtime_resume(struct device *dev)
 	int loss_cnt = serial_omap_get_context_loss_count(up);
 
 	if (loss_cnt < 0) {
-		dev_err(dev, "serial_omap_get_context_loss_count failed : %d\n",
+		dev_dbg(dev, "serial_omap_get_context_loss_count failed : %d\n",
 			loss_cnt);
 		serial_omap_restore_context(up);
 	} else if (up->context_loss_cnt != loss_cnt) {

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

end of thread, other threads:[~2013-06-10 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-07 21:58 [PATCH] serial: omap: Fix device tree based PM runtime Tony Lindgren
2013-06-07 22:47 ` Kevin Hilman
2013-06-07 23:00   ` Tony Lindgren
2013-06-09  5:32     ` Greg Kroah-Hartman
2013-06-10 14:39       ` Tony Lindgren

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