From patchwork Tue Sep 26 06:13:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 144739 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp1702926vqu; Mon, 25 Sep 2023 23:15:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHWlqQvXFQ2i41OfpBBpGia7OJxgIs2RIrT+OiCQY6os+RHYCqp5iFKkKdSoeQIK0nm/dT X-Received: by 2002:a05:6871:7a5:b0:1bb:5bc3:7f23 with SMTP id o37-20020a05687107a500b001bb5bc37f23mr10871591oap.46.1695708917389; Mon, 25 Sep 2023 23:15:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695708917; cv=none; d=google.com; s=arc-20160816; b=yXDcCBH0GnS8F2VeQCPulvi42mWvWBOb4znSgAbLNsJ+6hXad8LUbaKb4P3bA4+Nlt L/IcmFSqsUbDrD3eR9vYN265XIlxdpWHXZNE+zcqXfK/0oXOZuGDilUOISKmXQde9npj U4Y+p0uVZupye9J4qIkUbpJry1YPFuUBcKM5RqehRwl/QuDQdKqrcAM0g/F21CfgZP4e EmskbZjKkq8W6OMbLwewAxOucCnUrys14MkiB5Tlfnw1NRIMDSDYgh/8DzTnfXY6/VNx kncJp1G6FjSSrZcyyBGwGD1hDyqk8InSUxaNdoH120zeuUcTiXlnBqOrKK3qCgURuZ1F AqLg== 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.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id n13-20020a65488d000000b005777bea0b6asi11674020pgs.859.2023.09.25.23.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:15:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id B0D3280AC474; Mon, 25 Sep 2023 23:14:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233730AbjIZGNw (ORCPT + 27 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_J=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 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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 23:14:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778079673912250510 X-GMAIL-MSGID: 1778079673912250510 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 Tested-by: Thomas Richard Reviewed-by: Dhruva Gole --- 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;