Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1676908rdh; Mon, 25 Sep 2023 23:14:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqlIn1bBOJzyCR9E9chtG7CWwzSz8p8ptGVxYY2RDDZk1ypbk/v5Vkpc42hx4Im3OQP4IA X-Received: by 2002:a05:6808:35a:b0:3ae:16aa:8ba9 with SMTP id j26-20020a056808035a00b003ae16aa8ba9mr9921722oie.30.1695708887318; Mon, 25 Sep 2023 23:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695708887; cv=none; d=google.com; s=arc-20160816; b=kyEbyhToHli5tu8CAue6hdWY1JT2J8anaDZjE4AgBsVJyeNmQohfpPn1RaIE20avUX xpq8wmoMD6A4j0eeLsC9D5i9cVmlgmLa7uQvzk2L9Q5e+MCfapSXxijeE4v0BJg0BFrS vFqEgPfNsGYmWFVwt9vTz0++ldmttsipC1xYJ6yT72WAjUJo1DBuXYcVLKYXyBC9ZbXB rDMc+qf1c54nJFT0EnfawohlUKtAkyVVDut39Uu+qXr/dApMokehVm3UtTZkf853zt4h 5nxmfs5dyALaIsp545X2BT/ERKa2W4vN7vFR6nb8amgsHSPO9xyzXiIniNzuzEQQdJOF wdzA== 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=0uZQ7gZ5UEavIm0sLXTZbit8doHfe4tFiGMib6Duhag=; fh=XK0LkrabiTeoN6ZN/UOGCGqrvV4x9tNA6FqA53d3AiQ=; b=CGkhvGpa++MAA8HHqwlZ3vnAah4ibJQGceEeVJBmVlDMAjq+4CI+8ocaz86iEtg1aO g2oFdLaOg9L35U1t2h26zoVGUuMxHLxCfchjPKApzxn4jcjbtZCbmumZ7fBQkyIa7Usf ZNmp6PBQYnOEHmHbkbJ0kzh+H5pM3YYABbN3CanI5CJRqpelpwIp01NMhlmaUd80ult1 z8hPdnsyhm0r5qhMx40ZxF81FbptHAUWDdBK7TT2vtJ5bDtt/Y37HlLoVQXd3eXe7px7 +XTE8zsyYdmxLQmrepHBlU0b+XwOcMgwjRejFxmEkpL6yjcxCl5U1/btRUtT8zIJ0jUo uadw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id y14-20020a056a00180e00b00690d33fed3asi12816212pfa.53.2023.09.25.23.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:14:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6AA6081B17A7; Mon, 25 Sep 2023 23:13:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233727AbjIZGNw (ORCPT + 99 others); Tue, 26 Sep 2023 02:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233717AbjIZGNu (ORCPT ); Tue, 26 Sep 2023 02:13:50 -0400 Received: from muru.com (unknown [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A5B82E9; Mon, 25 Sep 2023 23:13:40 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 155DA80E2; Tue, 26 Sep 2023 06:13:22 +0000 (UTC) From: Tony Lindgren To: Greg Kroah-Hartman , Jiri Slaby Cc: Andy Shevchenko , Dhruva Gole , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , John Ogness , Johan Hovold , Sebastian Andrzej Siewior , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Udit Kumar , Thomas Richard Subject: [PATCH] serial: 8250_omap: Fix errors with no_console_suspend Date: Tue, 26 Sep 2023 09:13:17 +0300 Message-ID: <20230926061319.15140-1-tony@atomide.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 25 Sep 2023 23:13:54 -0700 (PDT) We now get errors on system suspend if no_console_suspend is set as reported by Thomas. The errors started with commit 20a41a62618d ("serial: 8250_omap: Use force_suspend and resume for system suspend"). Let's fix the issue by checking for console_suspend_enabled in the system suspend and resume path. Note that with this fix the checks for console_suspend_enabled in omap8250_runtime_suspend() become useless. We now keep runtime PM usage count for an attached kernel console starting with commit bedb404e91bb ("serial: 8250_port: Don't use power management for kernel console"). Fixes: 20a41a62618d ("serial: 8250_omap: Use force_suspend and resume for system suspend") Cc: Udit Kumar Reported-by: Thomas Richard Signed-off-by: Tony Lindgren --- drivers/tty/serial/8250/8250_omap.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 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 @@ -1617,7 +1617,7 @@ 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; + int err = 0; serial8250_suspend_port(priv->line); @@ -1627,7 +1627,8 @@ static int omap8250_suspend(struct device *dev) if (!device_may_wakeup(dev)) priv->wer = 0; serial_out(up, UART_OMAP_WER, priv->wer); - err = pm_runtime_force_suspend(dev); + if (uart_console(&up->port) && console_suspend_enabled) + err = pm_runtime_force_suspend(dev); flush_work(&priv->qos_work); return err; @@ -1636,11 +1637,15 @@ static int omap8250_suspend(struct device *dev) static int omap8250_resume(struct device *dev) { struct omap8250_priv *priv = dev_get_drvdata(dev); + struct uart_8250_port *up = serial8250_get_port(priv->line); int err; - err = pm_runtime_force_resume(dev); - if (err) - return err; + if (uart_console(&up->port) && console_suspend_enabled) { + 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); @@ -1717,16 +1722,6 @@ static int omap8250_runtime_suspend(struct device *dev) if (priv->line >= 0) up = serial8250_get_port(priv->line); - /* - * When using 'no_console_suspend', the console UART must not be - * suspended. Since driver suspend is managed by runtime suspend, - * preventing runtime suspend (by returning error) will keep device - * active during suspend. - */ - if (priv->is_suspending && !console_suspend_enabled) { - if (up && uart_console(&up->port)) - return -EBUSY; - } if (priv->habit & UART_ERRATA_CLOCK_DISABLE) { int ret; -- 2.42.0