From patchwork Tue Sep 21 10:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 12507565 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F674C4332F for ; Tue, 21 Sep 2021 10:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BE7E61038 for ; Tue, 21 Sep 2021 10:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232029AbhIUKfh (ORCPT ); Tue, 21 Sep 2021 06:35:37 -0400 Received: from muru.com ([72.249.23.125]:35554 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbhIUKfc (ORCPT ); Tue, 21 Sep 2021 06:35:32 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 052B68132; Tue, 21 Sep 2021 10:34:29 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman Cc: Andy Shevchenko , Jiri Slaby , Johan Hovold , Vignesh Raghavendra , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] serial: 8250_omap: Require a valid wakeirq for deeper idle states Date: Tue, 21 Sep 2021 13:33:45 +0300 Message-Id: <20210921103346.64824-6-tony@atomide.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210921103346.64824-1-tony@atomide.com> References: <20210921103346.64824-1-tony@atomide.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 --- 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); @@ -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(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(port->dev); + pm_runtime_mark_last_busy(port->dev); pm_runtime_put_autosuspend(port->dev); free_irq(port->irq, port);