Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1619749 > unrolled thread

[PATCH 1/2] serial: omap: fix runtime-pm handling on unbind

Started byJohan Hovold <johan@kernel.org>
First post2017-04-10 11:30 +0200
Last post2017-04-10 18:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] serial: omap: fix runtime-pm handling on unbind Johan Hovold <johan@kernel.org> - 2017-04-10 11:30 +0200
    [PATCH 2/2] serial: omap: suspend device on probe errors Johan Hovold <johan@kernel.org> - 2017-04-10 11:30 +0200
      Re: [PATCH 2/2] serial: omap: suspend device on probe errors Tony Lindgren <tony@atomide.com> - 2017-04-10 18:20 +0200
    Re: [PATCH 1/2] serial: omap: fix runtime-pm handling on unbind Tony Lindgren <tony@atomide.com> - 2017-04-10 18:20 +0200

#1619749 — [PATCH 1/2] serial: omap: fix runtime-pm handling on unbind

FromJohan Hovold <johan@kernel.org>
Date2017-04-10 11:30 +0200
Subject[PATCH 1/2] serial: omap: fix runtime-pm handling on unbind
Message-ID<tuDO2-7gt-7@gated-at.bofh.it>
An unbalanced and misplaced synchronous put was used to suspend the
device on driver unbind, something which with a likewise misplaced
pm_runtime_disable leads to external aborts when an open port is being
removed.

Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa024010
...
[<c046e760>] (serial_omap_set_mctrl) from [<c046a064>] (uart_update_mctrl+0x50/0x60)
[<c046a064>] (uart_update_mctrl) from [<c046a400>] (uart_shutdown+0xbc/0x138)
[<c046a400>] (uart_shutdown) from [<c046bd2c>] (uart_hangup+0x94/0x190)
[<c046bd2c>] (uart_hangup) from [<c045b760>] (__tty_hangup+0x404/0x41c)
[<c045b760>] (__tty_hangup) from [<c045b794>] (tty_vhangup+0x1c/0x20)
[<c045b794>] (tty_vhangup) from [<c046ccc8>] (uart_remove_one_port+0xec/0x260)
[<c046ccc8>] (uart_remove_one_port) from [<c046ef4c>] (serial_omap_remove+0x40/0x60)
[<c046ef4c>] (serial_omap_remove) from [<c04845e8>] (platform_drv_remove+0x34/0x4c)

Fix this up by resuming the device before deregistering the port and by
suspending and disabling runtime pm only after the port has been
removed.

Also make sure to disable autosuspend before disabling runtime pm so
that the usage count is balanced and device actually suspended before
returning.

Note that due to a negative autosuspend delay being set in probe, the
unbalanced put would actually suspend the device on first driver unbind,
while rebinding and again unbinding would result in a negative
power.usage_count.

Fixes: 7e9c8e7dbf3b ("serial: omap: make sure to suspend device before remove")
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/omap-serial.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6c6f82ad8d5c..8c2086e14b51 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1780,9 +1780,13 @@ static int serial_omap_remove(struct platform_device *dev)
 {
 	struct uart_omap_port *up = platform_get_drvdata(dev);
 
+	pm_runtime_get_sync(up->dev);
+
+	uart_remove_one_port(&serial_omap_reg, &up->port);
+
+	pm_runtime_dont_use_autosuspend(up->dev);
 	pm_runtime_put_sync(up->dev);
 	pm_runtime_disable(up->dev);
-	uart_remove_one_port(&serial_omap_reg, &up->port);
 	pm_qos_remove_request(&up->pm_qos_request);
 	device_init_wakeup(&dev->dev, false);
 
-- 
2.12.2

[toc] | [next] | [standalone]


#1619751 — [PATCH 2/2] serial: omap: suspend device on probe errors

FromJohan Hovold <johan@kernel.org>
Date2017-04-10 11:30 +0200
Subject[PATCH 2/2] serial: omap: suspend device on probe errors
Message-ID<tuDO2-7gt-9@gated-at.bofh.it>
In reply to#1619749
Make sure to actually suspend the device before returning after a failed
(or deferred) probe.

Note that autosuspend must be disabled before runtime pm is disabled in
order to balance the usage count due to a negative autosuspend delay as
well as to make the final put suspend the device synchronously.

Fixes: 388bc2622680 ("omap-serial: Fix the error handling in the omap_serial probe")
Cc: Shubhrajyoti D <shubhrajyoti@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/tty/serial/omap-serial.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 8c2086e14b51..e4210b9ad0d3 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -1767,7 +1767,8 @@ static int serial_omap_probe(struct platform_device *pdev)
 	return 0;
 
 err_add_port:
-	pm_runtime_put(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
+	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 	pm_qos_remove_request(&up->pm_qos_request);
 	device_init_wakeup(up->dev, false);
-- 
2.12.2

[toc] | [prev] | [next] | [standalone]


#1620188 — Re: [PATCH 2/2] serial: omap: suspend device on probe errors

FromTony Lindgren <tony@atomide.com>
Date2017-04-10 18:20 +0200
SubjectRe: [PATCH 2/2] serial: omap: suspend device on probe errors
Message-ID<tuKcO-2ZH-23@gated-at.bofh.it>
In reply to#1619751
* Johan Hovold <johan@kernel.org> [170410 02:27]:
> Make sure to actually suspend the device before returning after a failed
> (or deferred) probe.
> 
> Note that autosuspend must be disabled before runtime pm is disabled in
> order to balance the usage count due to a negative autosuspend delay as
> well as to make the final put suspend the device synchronously.
> 
> Fixes: 388bc2622680 ("omap-serial: Fix the error handling in the omap_serial probe")
> Cc: Shubhrajyoti D <shubhrajyoti@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: Tony Lindgren <tony@atomide.com>

[toc] | [prev] | [next] | [standalone]


#1620208

FromTony Lindgren <tony@atomide.com>
Date2017-04-10 18:20 +0200
Message-ID<tuKcP-2ZH-55@gated-at.bofh.it>
In reply to#1619749
* Johan Hovold <johan@kernel.org> [170410 02:27]:
> An unbalanced and misplaced synchronous put was used to suspend the
> device on driver unbind, something which with a likewise misplaced
> pm_runtime_disable leads to external aborts when an open port is being
> removed.
> 
> Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa024010
> ...
> [<c046e760>] (serial_omap_set_mctrl) from [<c046a064>] (uart_update_mctrl+0x50/0x60)
> [<c046a064>] (uart_update_mctrl) from [<c046a400>] (uart_shutdown+0xbc/0x138)
> [<c046a400>] (uart_shutdown) from [<c046bd2c>] (uart_hangup+0x94/0x190)
> [<c046bd2c>] (uart_hangup) from [<c045b760>] (__tty_hangup+0x404/0x41c)
> [<c045b760>] (__tty_hangup) from [<c045b794>] (tty_vhangup+0x1c/0x20)
> [<c045b794>] (tty_vhangup) from [<c046ccc8>] (uart_remove_one_port+0xec/0x260)
> [<c046ccc8>] (uart_remove_one_port) from [<c046ef4c>] (serial_omap_remove+0x40/0x60)
> [<c046ef4c>] (serial_omap_remove) from [<c04845e8>] (platform_drv_remove+0x34/0x4c)
> 
> Fix this up by resuming the device before deregistering the port and by
> suspending and disabling runtime pm only after the port has been
> removed.
> 
> Also make sure to disable autosuspend before disabling runtime pm so
> that the usage count is balanced and device actually suspended before
> returning.
> 
> Note that due to a negative autosuspend delay being set in probe, the
> unbalanced put would actually suspend the device on first driver unbind,
> while rebinding and again unbinding would result in a negative
> power.usage_count.
> 
> Fixes: 7e9c8e7dbf3b ("serial: omap: make sure to suspend device before remove")
> Cc: Felipe Balbi <balbi@kernel.org>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Acked-by: Tony Lindgren <tony@atomide.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web