From: Jiri Slaby <jirislaby@kernel.org>
To: Andy Chiu <andy.chiu@sifive.com>,
linux-serial@vger.kernel.org, linux-riscv@lists.infradead.org,
palmer@dabbelt.com, gregkh@linuxfoundation.org
Cc: paul.walmsley@sifive.com
Subject: Re: [PATCH] tty: serial: manage irq with spin_lock_irqsave in SiFive console
Date: Thu, 1 Feb 2024 08:21:44 +0100 [thread overview]
Message-ID: <2f1b1262-8c32-4dd5-8052-d47682c0b1f6@kernel.org> (raw)
In-Reply-To: <20240201065932.19899-1-andy.chiu@sifive.com>
On 01. 02. 24, 7:59, Andy Chiu wrote:
> It is not safe to call spin_lock() with irq disabled on RT-linux.
> Instead, transfer the code segment to spin_lock_irqsave to make it work
> on both RT and non-RT linux.
Hi,
have you investigated what is protected by the local_irq_save() in
there? The lock is not always taken, OTOH the interrupts are always
disabled.
I believe the fix is not as easy as is presented below.
> Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
> ---
> drivers/tty/serial/sifive.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/tty/serial/sifive.c b/drivers/tty/serial/sifive.c
> index fa4c9336924f..3f0ddf8bfa7b 100644
> --- a/drivers/tty/serial/sifive.c
> +++ b/drivers/tty/serial/sifive.c
> @@ -788,13 +788,12 @@ static void sifive_serial_console_write(struct console *co, const char *s,
> if (!ssp)
> return;
>
> - local_irq_save(flags);
> if (ssp->port.sysrq)
> locked = 0;
> else if (oops_in_progress)
> - locked = spin_trylock(&ssp->port.lock);
> + locked = spin_trylock_irqsave(&ssp->port.lock, flags);
> else
> - spin_lock(&ssp->port.lock);
> + spin_lock_irqsave(&ssp->port.lock, flags);
>
> ier = __ssp_readl(ssp, SIFIVE_SERIAL_IE_OFFS);
> __ssp_writel(0, SIFIVE_SERIAL_IE_OFFS, ssp);
> @@ -804,8 +803,7 @@ static void sifive_serial_console_write(struct console *co, const char *s,
> __ssp_writel(ier, SIFIVE_SERIAL_IE_OFFS, ssp);
>
> if (locked)
> - spin_unlock(&ssp->port.lock);
> - local_irq_restore(flags);
> + spin_unlock_irqrestore(&ssp->port.lock, flags);
> }
>
> static int __init sifive_serial_console_setup(struct console *co, char *options)
--
js
suse labs
next prev parent reply other threads:[~2024-02-01 7:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 6:59 [PATCH] tty: serial: manage irq with spin_lock_irqsave in SiFive console Andy Chiu
2024-02-01 7:21 ` Jiri Slaby [this message]
2024-02-26 6:22 ` Andy Chiu
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=2f1b1262-8c32-4dd5-8052-d47682c0b1f6@kernel.org \
--to=jirislaby@kernel.org \
--cc=andy.chiu@sifive.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.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