From: Xuewen Yan <xuewen.yan@unisoc.com>
To: <gregkh@linuxfoundation.org>, <jirislaby@kernel.org>,
<ilpo.jarvinen@linux.intel.com>, <tony@atomide.com>,
<john.ogness@linutronix.de>
Cc: <tglx@linutronix.de>, <andriy.shevchenko@linux.intel.com>,
<linux-kernel@vger.kernel.org>, <linux-serial@vger.kernel.org>,
<ke.wang@unisoc.com>, <xuewen.yan94@gmail.com>
Subject: [RFC PATCH] serial: core: Use pm_runtime_get_sync() in uart_start()
Date: Fri, 24 Nov 2023 20:22:58 +0800 [thread overview]
Message-ID: <20231124122258.1050-1-xuewen.yan@unisoc.com> (raw)
The commit 84a9582fd203("serial: core: Start managing serial controllers to enable runtime PM")
use the pm_runtime_get() after uart_port_lock() which would close the irq and disable preement.
At this time, pm_runtime_get may cause the following two problems:
(1) deadlock in try_to_wake_up:
uart_write()
uart_port_lock() <<< get lock
__uart_start
__pm_runtime_resume
rpm_resume
queue_work_on
try_to_wake_up
_printk
uart_console_write
...
uart_port_lock() <<< wait forever
(2) scheduling while atomic:
uart_write()
uart_port_lock() <<< get lock
__uart_start
__pm_runtime_resume
rpm_resume
chedule() << sleep
So let us use pm_runtime_get_sync() to prevent these.
Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
drivers/tty/serial/serial_core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index f1348a509552..902f7ed35f4d 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -145,7 +145,7 @@ static void __uart_start(struct uart_state *state)
port_dev = port->port_dev;
/* Increment the runtime PM usage count for the active check below */
- err = pm_runtime_get(&port_dev->dev);
+ err = pm_runtime_get_sync(&port_dev->dev);
if (err < 0 && err != -EINPROGRESS) {
pm_runtime_put_noidle(&port_dev->dev);
return;
@@ -159,7 +159,7 @@ static void __uart_start(struct uart_state *state)
if (!pm_runtime_enabled(port->dev) || pm_runtime_active(port->dev))
port->ops->start_tx(port);
pm_runtime_mark_last_busy(&port_dev->dev);
- pm_runtime_put_autosuspend(&port_dev->dev);
+ pm_runtime_put_sync_autosuspend(&port_dev->dev);
}
static void uart_start(struct tty_struct *tty)
--
2.25.1
next reply other threads:[~2023-11-24 12:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-24 12:22 Xuewen Yan [this message]
2023-11-25 7:47 ` Tony Lindgren
2023-11-27 1:54 ` Xuewen Yan
2023-11-26 16:17 ` John Ogness
2023-11-27 2:06 ` Xuewen Yan
2023-11-28 15:11 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231124122258.1050-1-xuewen.yan@unisoc.com \
--to=xuewen.yan@unisoc.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tony@atomide.com \
--cc=xuewen.yan94@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®