Message ID | 20230926061319.15140-1-tony@atomide.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;ruipengqi7@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <tony@atomide.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org> Cc: Andy Shevchenko <andriy.shevchenko@intel.com>, Dhruva Gole <d-gole@ti.com>, =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>, John Ogness <john.ogness@linutronix.de>, Johan Hovold <johan@kernel.org>, Sebastian Andrzej Siewior <bigeasy@linutronix.de>, Vignesh Raghavendra <vigneshr@ti.com>, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Udit Kumar <u-kumar1@ti.com>, Thomas Richard <thomas.richard@bootlin.com> 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 pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> 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 |
Series |
serial: 8250_omap: Fix errors with no_console_suspend
|
|
Commit Message
Tony Lindgren
Sept. 26, 2023, 6:13 a.m. UTC
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 <u-kumar1@ti.com>
Reported-by: Thomas Richard <thomas.richard@bootlin.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/tty/serial/8250/8250_omap.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
Comments
Hi Tony, Thanks for the fix. On 9/26/23 08:13, Tony Lindgren wrote: > 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 <u-kumar1@ti.com> > Reported-by: Thomas Richard <thomas.richard@bootlin.com> > Signed-off-by: Tony Lindgren <tony@atomide.com> Tested-by: Thomas Richard <thomas.richard@bootlin.com> > --- > 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;
On Sep 26, 2023 at 09:51:30 +0200, Thomas Richard wrote: > Hi Tony, > > Thanks for the fix. > > On 9/26/23 08:13, Tony Lindgren wrote: > > 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 <u-kumar1@ti.com> > > Reported-by: Thomas Richard <thomas.richard@bootlin.com> Don't we want a closes: tag? > > Signed-off-by: Tony Lindgren <tony@atomide.com> > > Tested-by: Thomas Richard <thomas.richard@bootlin.com> Thanks for testing Thomas > > > --- > > 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; > > + } LGTM, thanks for the fix Tony. Reviewed-by: Dhruva Gole <d-gole@ti.com> > > + > > 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; > -- > Thomas Richard >
On Tue, Sep 26, 2023 at 09:13:17AM +0300, Tony Lindgren wrote: > 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"). ... Btw, how close are we to getting rid the pm_runtime_irq_safe() call?
* Andy Shevchenko <andriy.shevchenko@intel.com> [230926 11:59]:
> Btw, how close are we to getting rid the pm_runtime_irq_safe() call?
Very close, I think still doable for v6.7 merge window.. Below is what I'm
testing with, there's one error that I've seen that may or may not be
related.
Regards,
Tony
8< ---------------------------
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
@@ -8,6 +8,7 @@
*
*/
+#include <linux/atomic.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/io.h>
@@ -130,6 +131,7 @@ struct omap8250_priv {
u8 tx_trigger;
u8 rx_trigger;
+ atomic_t active;
bool is_suspending;
int wakeirq;
int wakeups_enabled;
@@ -632,14 +634,21 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
unsigned int iir, lsr;
int ret;
+ pm_runtime_get_noresume(port->dev);
+
+ /* Shallow idle state wake-up to an IO interrupt? */
+ if (atomic_add_unless(&priv->active, 1, 1)) {
+ priv->latency = priv->calc_latency;
+ schedule_work(&priv->qos_work);
+ }
+
#ifdef CONFIG_SERIAL_8250_DMA
if (up->dma) {
ret = omap_8250_dma_handle_irq(port);
- return IRQ_RETVAL(ret);
+ goto out_runtime_put;
}
#endif
- serial8250_rpm_get(up);
lsr = serial_port_in(port, UART_LSR);
iir = serial_port_in(port, UART_IIR);
ret = serial8250_handle_irq(port, iir);
@@ -676,7 +685,9 @@ static irqreturn_t omap8250_irq(int irq, void *dev_id)
schedule_delayed_work(&up->overrun_backoff, delay);
}
- serial8250_rpm_put(up);
+out_runtime_put:
+ pm_runtime_mark_last_busy(port->dev);
+ pm_runtime_put(port->dev);
return IRQ_RETVAL(ret);
}
@@ -1270,11 +1281,8 @@ static int omap_8250_dma_handle_irq(struct uart_port *port)
u16 status;
u8 iir;
- serial8250_rpm_get(up);
-
iir = serial_port_in(port, UART_IIR);
if (iir & UART_IIR_NO_INT) {
- serial8250_rpm_put(up);
return IRQ_HANDLED;
}
@@ -1305,7 +1313,6 @@ static int omap_8250_dma_handle_irq(struct uart_port *port)
uart_unlock_and_check_sysrq(port);
- serial8250_rpm_put(up);
return 1;
}
@@ -1500,8 +1507,6 @@ static int omap8250_probe(struct platform_device *pdev)
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_get_sync(&pdev->dev);
omap_serial_fill_features_erratas(&up, priv);
@@ -1740,6 +1745,7 @@ static int omap8250_runtime_suspend(struct device *dev)
priv->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE;
schedule_work(&priv->qos_work);
+ atomic_set(&priv->active, 0);
return 0;
}
@@ -1749,6 +1755,10 @@ static int omap8250_runtime_resume(struct device *dev)
struct omap8250_priv *priv = dev_get_drvdata(dev);
struct uart_8250_port *up = NULL;
+ /* Did the hardware wake to a device IO interrupt before a wakeirq? */
+ if (atomic_read(&priv->active))
+ return 0;
+
if (priv->line >= 0)
up = serial8250_get_port(priv->line);
@@ -1764,8 +1774,10 @@ static int omap8250_runtime_resume(struct device *dev)
spin_unlock_irq(&up->port.lock);
}
+ atomic_set(&priv->active, 1);
priv->latency = priv->calc_latency;
schedule_work(&priv->qos_work);
+
return 0;
}
* Dhruva Gole <d-gole@ti.com> [230926 11:32]:
> Don't we want a closes: tag?
Seems it should only be used if there's some bugzilla type report and
not for email threads.
Regards,
Tony
* Tony Lindgren <tony@atomide.com> [230927 07:29]: > * Andy Shevchenko <andriy.shevchenko@intel.com> [230926 11:59]: > > Btw, how close are we to getting rid the pm_runtime_irq_safe() call? > > Very close, I think still doable for v6.7 merge window.. Below is what I'm > testing with, there's one error that I've seen that may or may not be > related. I'm unable to reproduce the issue I was seeing with v6.6-rc3 with and without the pm_runtime_irq_safe() dropping patch. So AFAIK no issues dropping pm_runtime_irq_safe(). I was seeing some warning earlier after detaching kernel console and doing any sysrq trigger on the serial port, seems like it was unrelated. Regards, Tony
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;