From patchwork Wed Jun 14 04:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 107720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1034365vqr; Tue, 13 Jun 2023 23:27:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6p7dyipYD6tPHc9KoK8o9C8q7+Zr/ucSgg33F0NKPIW+b2QmpO1ab6zCUsU8n1nBJI4L2t X-Received: by 2002:a2e:740c:0:b0:2a2:47a8:728b with SMTP id p12-20020a2e740c000000b002a247a8728bmr5423546ljc.13.1686724047614; Tue, 13 Jun 2023 23:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686724047; cv=none; d=google.com; s=arc-20160816; b=t5KAHp+ZKLoY40GUnxAO2T1RLFiVXfeyRNq7b+mIFNhwV24vSLFF9cRv/fcG+rTvB+ 8e0TceCzazrA9tfNb53XAZx4iQZTl3MVD/LuD/q8hcY2rPJB+1CcTTxKL549JxfucH+h 5bNtd9pLdFd9xvUhJZuLDLTgvtFfvAgWtKUDzCAcJVBSlPK+51uJG5fVAWxOQBZCaDHj Rw/ey6xJLIibLHll8ODdbu0776HC7RbCG55iT7CDy762Y22opPTV5TFWFxtKdrfKi9dk Fx+OLNBnF+BHEAwQdkTB/cDPWQs1+rc/XGiMTErvXLLz4rIEGHvp4WhTCZWcaueHvApg e0tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=UIDo//XrCwNm8q3O4wBxS66HPVZck4myLUa1sS5Th+M=; b=kFpVi1PDo+q5jSRyXV1eYqaKC+S3RQJw8fcB9NVGQMot1rxXxfmQD0M/sOiUD9Cr/A KQiyJspc2mJh8coSXQ6hBxuarIYknQM/2IKtiFQB2HlkEEcTfghtquRR84fDOXjrvCnC MnKvnf7im8UeM8ALwGTDcXVQmnhAi2DjV3khbvvl8JGCNB51sJHKx1pyDb2tPN14ExdN Ea4EJMb+VHfO3rO8DRr3cxQj2JLxW+upSR95w/sGJ9AodHpCvGtXsdiFodDd/6zK8GGi /Mu05gW8PfV0a/s8xnUTBH8vKxLFmsdGNvZ6V6hwAAw+1BEZ5t29OW9bp1yq40JK5zZW KZnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020aa7c714000000b00514934f0ddcsi8529364edq.113.2023.06.13.23.27.02; Tue, 13 Jun 2023 23:27:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242705AbjFNE7b (ORCPT + 99 others); Wed, 14 Jun 2023 00:59:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242693AbjFNE72 (ORCPT ); Wed, 14 Jun 2023 00:59:28 -0400 Received: from muru.com (muru.com [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CE62010E3; Tue, 13 Jun 2023 21:59:26 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 6814B80F9; Wed, 14 Jun 2023 04:59:24 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby , Vignesh R Cc: Andy Shevchenko , Dhruva Gole , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , linux-omap@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] serial: 8250_omap: Use force_suspend and resume for system suspend Date: Wed, 14 Jun 2023 07:59:19 +0300 Message-ID: <20230614045922.4798-1-tony@atomide.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768656484530529671?= X-GMAIL-MSGID: =?utf-8?q?1768658354831956856?= We should not rely on autosuspend timeout for system suspend. Instead, let's use force_suspend and force_resume functions. Otherwise the serial port controller device may not be idled on suspend. As we are doing a register write on suspend to configure the serial port, we still need to runtime PM resume the port on suspend. While at it, let's switch to pm_runtime_resume_and_get() and check for errors returned. And let's add the missing line break before return to the suspend function while at it. Fixes: 09d8b2bdbc5c ("serial: 8250: omap: Provide ability to enable/disable UART as wakeup source") Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 @@ -1618,25 +1618,35 @@ 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; serial8250_suspend_port(priv->line); - pm_runtime_get_sync(dev); + err = pm_runtime_resume_and_get(dev); + if (err) + return err; if (!device_may_wakeup(dev)) priv->wer = 0; serial_out(up, UART_OMAP_WER, priv->wer); - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); - + err = pm_runtime_force_suspend(dev); flush_work(&priv->qos_work); - return 0; + + return err; } static int omap8250_resume(struct device *dev) { struct omap8250_priv *priv = dev_get_drvdata(dev); + int err; + 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); + pm_runtime_put_autosuspend(dev); + return 0; }