From patchwork Tue Jul 23 11:54:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 11054387 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 985301399 for ; Tue, 23 Jul 2019 11:54:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E02726E47 for ; Tue, 23 Jul 2019 11:54:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 719DB2863C; Tue, 23 Jul 2019 11:54:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09A8726E47 for ; Tue, 23 Jul 2019 11:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732093AbfGWLyI (ORCPT ); Tue, 23 Jul 2019 07:54:08 -0400 Received: from muru.com ([72.249.23.125]:55696 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728765AbfGWLyI (ORCPT ); Tue, 23 Jul 2019 07:54:08 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 2C1F0808C; Tue, 23 Jul 2019 11:54:32 +0000 (UTC) From: Tony Lindgren To: Peter Hurley , Greg Kroah-Hartman Cc: Peter Ujfalusi , Sebastian Andrzej Siewior , Vignesh R , linux-serial@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH] serial: 8250_omap: Fix idling for unloaded serdev drivers Date: Tue, 23 Jul 2019 04:54:00 -0700 Message-Id: <20190723115400.46432-1-tony@atomide.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For many years omap variants have been setting the runtime PM autosuspend delay to -1 to prevent unsafe policy with lossy first character on wake-up. The user must specifically enable the timeout for UARTs if desired. We must not enable the workaround for serdev devices though. It leads into UARTs not idling if no serdev devices are loaded and there is no sysfs entry to configure the UART in that case. And this means that my PM may not work unless the serdev modules are loaded. We can detect a serdev device being configured based on a dts child node, and we can simply skip the workround in that case. And the serdev driver can idle the port during runtime when suitable if an out-of-band wake-up GPIO line exists for example. Let's also add some comments to the workaround while at it. Cc: Johan Hovold Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 @@ -1234,7 +1234,16 @@ static int omap8250_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, true); pm_runtime_use_autosuspend(&pdev->dev); - pm_runtime_set_autosuspend_delay(&pdev->dev, -1); + + /* + * Disable runtime PM until autosuspend delay unless specifically + * enabled by the user via sysfs. This is the historic way to + * prevent an unsafe default policy with lossy characters on wake-up. + * For serdev devices this is not needed, the policy can be managed by + * the serdev driver. + */ + if (!of_get_available_child_count(pdev->dev.of_node)) + pm_runtime_set_autosuspend_delay(&pdev->dev, -1); pm_runtime_irq_safe(&pdev->dev); pm_runtime_enable(&pdev->dev);