diff mbox series

[5/7] serial: 8250_omap: Require a valid wakeirq for deeper idle states

Message ID 20211115084203.56478-6-tony@atomide.com
State New
Headers show
Series Serial port generic PM to fix 8250 PM | expand

Commit Message

Tony Lindgren Nov. 15, 2021, 8:42 a.m. UTC
For deeper idle states the 8250 device gets powered off. The wakeup is
handled with a separate wakeirq controller monitoring the RX pin.

Let's check for a valid wakeirq before enabling deeper idle states.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/tty/serial/8250/8250_omap.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Johan Hovold Nov. 30, 2021, 10:40 a.m. UTC | #1
On Mon, Nov 15, 2021 at 10:42:01AM +0200, Tony Lindgren wrote:
> For deeper idle states the 8250 device gets powered off. The wakeup is
> handled with a separate wakeirq controller monitoring the RX pin.
> 
> Let's check for a valid wakeirq before enabling deeper idle states.
> 
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  drivers/tty/serial/8250/8250_omap.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
> --- a/drivers/tty/serial/8250/8250_omap.c
> +++ b/drivers/tty/serial/8250/8250_omap.c
> @@ -133,6 +133,7 @@ struct omap8250_priv {
>  	spinlock_t rx_dma_lock;
>  	bool rx_dma_broken;
>  	bool throttled;
> +	unsigned int allow_rpm:1;
>  };
>  
>  struct omap8250_dma_params {
> @@ -676,6 +677,7 @@ static int omap_8250_startup(struct uart_port *port)
>  		ret = dev_pm_set_dedicated_wake_irq(port->dev, priv->wakeirq);
>  		if (ret)
>  			return ret;
> +		priv->allow_rpm = 1;
>  	}
>  
>  	pm_runtime_get_sync(port->dev);

Note that you still have synchronous resumes here despite this function
being called in atomic context. It didn't look like these were removed
by the next patch that drops irq_safe.

> @@ -722,6 +724,10 @@ static int omap_8250_startup(struct uart_port *port)
>  	if (up->dma && !(priv->habit & UART_HAS_EFR2))
>  		up->dma->rx_dma(up);
>  
> +	/* Block runtime PM if no wakeirq, paired with shutdown */
> +	if (!priv->allow_rpm)
> +		pm_runtime_get_noresume(port->dev);
> +
>  	pm_runtime_mark_last_busy(port->dev);
>  	pm_runtime_put_autosuspend(port->dev);
>  	return 0;
> @@ -760,6 +766,10 @@ static void omap_8250_shutdown(struct uart_port *port)
>  		serial_out(up, UART_LCR, up->lcr & ~UART_LCR_SBC);
>  	serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
>  
> +	/* Clear possible PM runtime block to pair with startup */
> +	if (!priv->allow_rpm)
> +		pm_runtime_put_noidle(port->dev);
> +
>  	pm_runtime_mark_last_busy(port->dev);
>  	pm_runtime_put_autosuspend(port->dev);
>  	free_irq(port->irq, port);

Johan
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -133,6 +133,7 @@  struct omap8250_priv {
 	spinlock_t rx_dma_lock;
 	bool rx_dma_broken;
 	bool throttled;
+	unsigned int allow_rpm:1;
 };
 
 struct omap8250_dma_params {
@@ -676,6 +677,7 @@  static int omap_8250_startup(struct uart_port *port)
 		ret = dev_pm_set_dedicated_wake_irq(port->dev, priv->wakeirq);
 		if (ret)
 			return ret;
+		priv->allow_rpm = 1;
 	}
 
 	pm_runtime_get_sync(port->dev);
@@ -722,6 +724,10 @@  static int omap_8250_startup(struct uart_port *port)
 	if (up->dma && !(priv->habit & UART_HAS_EFR2))
 		up->dma->rx_dma(up);
 
+	/* Block runtime PM if no wakeirq, paired with shutdown */
+	if (!priv->allow_rpm)
+		pm_runtime_get_noresume(port->dev);
+
 	pm_runtime_mark_last_busy(port->dev);
 	pm_runtime_put_autosuspend(port->dev);
 	return 0;
@@ -760,6 +766,10 @@  static void omap_8250_shutdown(struct uart_port *port)
 		serial_out(up, UART_LCR, up->lcr & ~UART_LCR_SBC);
 	serial_out(up, UART_FCR, UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
 
+	/* Clear possible PM runtime block to pair with startup */
+	if (!priv->allow_rpm)
+		pm_runtime_put_noidle(port->dev);
+
 	pm_runtime_mark_last_busy(port->dev);
 	pm_runtime_put_autosuspend(port->dev);
 	free_irq(port->irq, port);