diff options
| author | Tony Lindgren <tony@atomide.com> | 2014-03-25 14:48:47 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-04-16 17:19:13 -0400 |
| commit | d758c9c1b36b4d9a141c2146c70398d756167ed1 (patch) | |
| tree | 5b300e37228195c31af4e3056185908efab52aa7 | |
| parent | bf903c0c6ddfedec19ba92626ca30e98bfafbe08 (diff) | |
serial: omap: Fix missing pm_runtime_resume handling by simplifying code
The lack of pm_runtime_resume handling for the device state leads into
device wake-up interrupts not working after a while for runtime PM.
Also, serial-omap is confused about the use of device_may_wakeup.
The checks for device_may_wakeup should only be done for suspend and
resume, not for pm_runtime_suspend and pm_runtime_resume. The wake-up
events for PM runtime should always be enabled.
The lack of pm_runtime_resume handling leads into device wake-up
interrupts not working after a while for runtime PM.
Rather than try to patch over the issue of adding complex tests to
the pm_runtime_resume, let's fix the issues properly:
1. Make serial_omap_enable_wakeup deal with all internal PM state
handling so we don't need to test for up->wakeups_enabled elsewhere.
Later on once omap3 boots in device tree only mode we can also
remove the up->wakeups_enabled flag and rely on the wake-up
interrupt enable/disable state alone.
2. Do the device_may_wakeup checks in suspend and resume only,
for runtime PM the wake-up events need to be always enabled.
3. Finally just call serial_omap_enable_wakeup and make sure we
call it also in pm_runtime_resume.
4. Note that we also have to use disable_irq_nosync as serial_omap_irq
calls pm_runtime_get_sync.
Fixes: 2a0b965cfb6e (serial: omap: Add support for optional wake-up)
Cc: stable@vger.kernel.org # v3.13+
Signed-off-by: Tony Lindgren <tony@atomide.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/tty/serial/omap-serial.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index ecfafbb30356..08b6b9419f0d 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
| @@ -225,14 +225,19 @@ static inline void serial_omap_enable_wakeirq(struct uart_omap_port *up, | |||
| 225 | if (enable) | 225 | if (enable) |
| 226 | enable_irq(up->wakeirq); | 226 | enable_irq(up->wakeirq); |
| 227 | else | 227 | else |
| 228 | disable_irq(up->wakeirq); | 228 | disable_irq_nosync(up->wakeirq); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) | 231 | static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable) |
| 232 | { | 232 | { |
| 233 | struct omap_uart_port_info *pdata = dev_get_platdata(up->dev); | 233 | struct omap_uart_port_info *pdata = dev_get_platdata(up->dev); |
| 234 | 234 | ||
| 235 | if (enable == up->wakeups_enabled) | ||
| 236 | return; | ||
| 237 | |||
| 235 | serial_omap_enable_wakeirq(up, enable); | 238 | serial_omap_enable_wakeirq(up, enable); |
| 239 | up->wakeups_enabled = enable; | ||
| 240 | |||
| 236 | if (!pdata || !pdata->enable_wakeup) | 241 | if (!pdata || !pdata->enable_wakeup) |
| 237 | return; | 242 | return; |
| 238 | 243 | ||
| @@ -1495,6 +1500,11 @@ static int serial_omap_suspend(struct device *dev) | |||
| 1495 | uart_suspend_port(&serial_omap_reg, &up->port); | 1500 | uart_suspend_port(&serial_omap_reg, &up->port); |
| 1496 | flush_work(&up->qos_work); | 1501 | flush_work(&up->qos_work); |
| 1497 | 1502 | ||
| 1503 | if (device_may_wakeup(dev)) | ||
| 1504 | serial_omap_enable_wakeup(up, true); | ||
| 1505 | else | ||
| 1506 | serial_omap_enable_wakeup(up, false); | ||
| 1507 | |||
| 1498 | return 0; | 1508 | return 0; |
| 1499 | } | 1509 | } |
| 1500 | 1510 | ||
| @@ -1502,6 +1512,9 @@ static int serial_omap_resume(struct device *dev) | |||
| 1502 | { | 1512 | { |
| 1503 | struct uart_omap_port *up = dev_get_drvdata(dev); | 1513 | struct uart_omap_port *up = dev_get_drvdata(dev); |
| 1504 | 1514 | ||
| 1515 | if (device_may_wakeup(dev)) | ||
| 1516 | serial_omap_enable_wakeup(up, false); | ||
| 1517 | |||
| 1505 | uart_resume_port(&serial_omap_reg, &up->port); | 1518 | uart_resume_port(&serial_omap_reg, &up->port); |
| 1506 | 1519 | ||
| 1507 | return 0; | 1520 | return 0; |
| @@ -1878,17 +1891,7 @@ static int serial_omap_runtime_suspend(struct device *dev) | |||
| 1878 | 1891 | ||
| 1879 | up->context_loss_cnt = serial_omap_get_context_loss_count(up); | 1892 | up->context_loss_cnt = serial_omap_get_context_loss_count(up); |
| 1880 | 1893 | ||
| 1881 | if (device_may_wakeup(dev)) { | 1894 | serial_omap_enable_wakeup(up, true); |
| 1882 | if (!up->wakeups_enabled) { | ||
| 1883 | serial_omap_enable_wakeup(up, true); | ||
| 1884 | up->wakeups_enabled = true; | ||
| 1885 | } | ||
| 1886 | } else { | ||
| 1887 | if (up->wakeups_enabled) { | ||
| 1888 | serial_omap_enable_wakeup(up, false); | ||
| 1889 | up->wakeups_enabled = false; | ||
| 1890 | } | ||
| 1891 | } | ||
| 1892 | 1895 | ||
| 1893 | up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; | 1896 | up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; |
| 1894 | schedule_work(&up->qos_work); | 1897 | schedule_work(&up->qos_work); |
| @@ -1902,6 +1905,8 @@ static int serial_omap_runtime_resume(struct device *dev) | |||
| 1902 | 1905 | ||
| 1903 | int loss_cnt = serial_omap_get_context_loss_count(up); | 1906 | int loss_cnt = serial_omap_get_context_loss_count(up); |
| 1904 | 1907 | ||
| 1908 | serial_omap_enable_wakeup(up, false); | ||
| 1909 | |||
| 1905 | if (loss_cnt < 0) { | 1910 | if (loss_cnt < 0) { |
| 1906 | dev_dbg(dev, "serial_omap_get_context_loss_count failed : %d\n", | 1911 | dev_dbg(dev, "serial_omap_get_context_loss_count failed : %d\n", |
| 1907 | loss_cnt); | 1912 | loss_cnt); |
