From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Daniel Walker <dwalker@mvista.com>
Subject: Re: [PATCH v2] serial: 8250: fix shared interrupts issues with SMP and RT kernels
Date: Wed, 9 Jul 2008 23:29:43 +0400 [thread overview]
Message-ID: <20080709192943.GA12278@polina.dev.rtsoft.ru> (raw)
In-Reply-To: <20080701150254.GA13390@polina.dev.rtsoft.ru>
On Tue, Jul 01, 2008 at 07:02:54PM +0400, Anton Vorontsov wrote:
[...]
> Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
> ---
>
> On Tue, Jul 01, 2008 at 02:43:53PM +0100, Alan Cox wrote:
[...]
> > It looks correct to me except that you cannot use spin_lock/disable_irq
> > in that way safely. You must always disable_irq before taking the lock,
> > or prove it is safe and use disable_irq_nosync
> >
> > The reason:
> > CPU#0 spin_lock_... [taken]
> > CPU#1 IRQ
> > CPU#1 spin_lock [waits]
> > CPU#0 disable_irq (deadlock)
>
> This deadlock possibility is interesting by itself, thanks for
> mentioning it.
>
> But this can't happen here. IRQ will not grab the up->port.lock,
> because port isn't registered in the 8250 IRQ handling chain (yet).
Alan, are there any issues with the proof or the patch itself?
Thanks,
> As for _nosync, probably this is good idea indeed, and should be safe
> AFAICS.
>
> drivers/serial/8250.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
> index 76ccef7..cad0c2d 100644
> --- a/drivers/serial/8250.c
> +++ b/drivers/serial/8250.c
> @@ -1831,7 +1831,9 @@ static int serial8250_startup(struct uart_port *port)
> * the interrupt is enabled. Delays are necessary to
> * allow register changes to become visible.
> */
> - spin_lock_irqsave(&up->port.lock, flags);
> + spin_lock(&up->port.lock);
> + if (up->port.flags & UPF_SHARE_IRQ)
> + disable_irq_nosync(up->port.irq);
>
> wait_for_xmitr(up, UART_LSR_THRE);
> serial_out_sync(up, UART_IER, UART_IER_THRI);
> @@ -1843,7 +1845,9 @@ static int serial8250_startup(struct uart_port *port)
> iir = serial_in(up, UART_IIR);
> serial_out(up, UART_IER, 0);
>
> - spin_unlock_irqrestore(&up->port.lock, flags);
> + if (up->port.flags & UPF_SHARE_IRQ)
> + enable_irq(up->port.irq);
> + spin_unlock(&up->port.lock);
>
> /*
> * If the interrupt is not reasserted, setup a timer to
> --
> 1.5.5.4
>
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
next prev parent reply other threads:[~2008-07-09 19:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-23 23:29 [PATCH -rt] serial: 8250: fix shared interrupts issues under RT kernels Anton Vorontsov
2008-06-24 0:12 ` Ingo Molnar
2008-07-01 13:43 ` [PATCH] serial: 8250: fix shared interrupts issues with SMP and " Anton Vorontsov
2008-07-01 13:43 ` Alan Cox
2008-07-01 15:02 ` [PATCH v2] " Anton Vorontsov
2008-07-09 19:29 ` Anton Vorontsov [this message]
2008-07-09 19:21 ` Alan Cox
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=20080709192943.GA12278@polina.dev.rtsoft.ru \
--to=avorontsov@ru.mvista.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dwalker@mvista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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