Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2184584rwd; Tue, 13 Jun 2023 22:11:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wA/mkKmSLKJa99LHbOpoPzinAr7FL2/SDssRXw/PqWlKcvyENaZlumKWAqlYlNepumjji X-Received: by 2002:a17:906:fe46:b0:974:1838:88d8 with SMTP id wz6-20020a170906fe4600b00974183888d8mr12868098ejb.57.1686719467801; Tue, 13 Jun 2023 22:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686719467; cv=none; d=google.com; s=arc-20160816; b=K3YanGGaug/YB2AfZtPmwotlIxMlSK9YREds9S5XbPQwtRVPSTWRJ7ahd3GXm/8c3y qGxHwPbjeKRV+BSvyfuXLps6mKKhX0YJSPC8na0qb5XxbjCTK6H5/IVlaDf9yTAGSYn2 WlkWH0p94YtN+IdceRYoqkFcFpz96njPyGHEVIk0T7SPTkyspMXFU3OQNSuV/N/Wu4Mz ksw1JqHdoxsEMb06RKcedZOqms3NHZFYpg57TStT9d7hRcLliEGlw6iW0HFEuoESHIMN MuNRrDkSB212pl7kUWRTnsw+rkQCga3HrSwRQXL/awUopHc5LrDJXc2UNugu4pflEzHv ObHg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gv11-20020a170906f10b00b0097d75ad0dedsi4774735ejb.282.2023.06.13.22.10.38; Tue, 13 Jun 2023 22:11:07 -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 S242702AbjFNE7b (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=20J=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 Content-Transfer-Encoding: 8bit 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 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; } -- 2.41.0