Skip to content

Commit

Permalink
serial: 8250_omap: Fix errors with no_console_suspend
Browse files Browse the repository at this point in the history
We now get errors on system suspend if no_console_suspend is set as
reported by Thomas. The errors started with commit 20a41a6 ("serial:
8250_omap: Use force_suspend and resume for system suspend").

Let's fix the issue by checking for console_suspend_enabled in the system
suspend and resume path.

Note that with this fix the checks for console_suspend_enabled in
omap8250_runtime_suspend() become useless. We now keep runtime PM usage
count for an attached kernel console starting with commit bedb404
("serial: 8250_port: Don't use power management for kernel console").

Fixes: 20a41a6 ("serial: 8250_omap: Use force_suspend and resume for system suspend")
Cc: stable <[email protected]>
Cc: Udit Kumar <[email protected]>
Reported-by: Thomas Richard <[email protected]>
Signed-off-by: Tony Lindgren <[email protected]>
Tested-by: Thomas Richard <[email protected]>
Reviewed-by: Dhruva Gole <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
tmlind authored and gregkh committed Oct 3, 2023
1 parent 8679328 commit 560706e
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions drivers/tty/serial/8250/8250_omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@ static int omap8250_suspend(struct device *dev)
{
struct omap8250_priv *priv = dev_get_drvdata(dev);
struct uart_8250_port *up = serial8250_get_port(priv->line);
int err;
int err = 0;

serial8250_suspend_port(priv->line);

Expand All @@ -1627,7 +1627,8 @@ static int omap8250_suspend(struct device *dev)
if (!device_may_wakeup(dev))
priv->wer = 0;
serial_out(up, UART_OMAP_WER, priv->wer);
err = pm_runtime_force_suspend(dev);
if (uart_console(&up->port) && console_suspend_enabled)
err = pm_runtime_force_suspend(dev);
flush_work(&priv->qos_work);

return err;
Expand All @@ -1636,11 +1637,15 @@ static int omap8250_suspend(struct device *dev)
static int omap8250_resume(struct device *dev)
{
struct omap8250_priv *priv = dev_get_drvdata(dev);
struct uart_8250_port *up = serial8250_get_port(priv->line);
int err;

err = pm_runtime_force_resume(dev);
if (err)
return err;
if (uart_console(&up->port) && console_suspend_enabled) {
err = pm_runtime_force_resume(dev);
if (err)
return err;
}

serial8250_resume_port(priv->line);
/* Paired with pm_runtime_resume_and_get() in omap8250_suspend() */
pm_runtime_mark_last_busy(dev);
Expand Down Expand Up @@ -1717,16 +1722,6 @@ static int omap8250_runtime_suspend(struct device *dev)

if (priv->line >= 0)
up = serial8250_get_port(priv->line);
/*
* When using 'no_console_suspend', the console UART must not be
* suspended. Since driver suspend is managed by runtime suspend,
* preventing runtime suspend (by returning error) will keep device
* active during suspend.
*/
if (priv->is_suspending && !console_suspend_enabled) {
if (up && uart_console(&up->port))
return -EBUSY;
}

if (priv->habit & UART_ERRATA_CLOCK_DISABLE) {
int ret;
Expand Down

0 comments on commit 560706e

Please sign in to comment.