linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Tony Lindgren <tony@atomide.com>, Petr Mladek <pmladek@suse.com>,
	Raul Rangel <rrangel@google.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kurt@linutronix.de, "S, Shirish" <Shirish.S@amd.com>,
	Peter Zijlstra <peterz@infradead.org>,
	John Ogness <john.ogness@linutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: UART/TTY console deadlock
Date: Thu, 2 Jul 2020 11:20:08 +0300	[thread overview]
Message-ID: <20200702082008.GE3703480@smile.fi.intel.com> (raw)
In-Reply-To: <20200702054033.GC3450@jagdpanzerIV.localdomain>

On Thu, Jul 02, 2020 at 02:40:33PM +0900, Sergey Senozhatsky wrote:
> On (20/07/02 14:12), Sergey Senozhatsky wrote:
> > From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> > On (20/06/30 11:02), Tony Lindgren wrote:

...

> > I think we can do it. serial8250_do_startup() and irq handler take
> > port->lock, so they should be synchronized.
> 
> Hmm, hold on. Why does it disable IRQ in the first place? IRQ handlers
> should grab the port->lock. So if there is already running IRQ, then
> serial8250_do_startup() will wait until IRQ handler unlocks the port->lock.
> If serial8250_do_startup() grabs the port->lock first, then IRQ will wait
> for serial8250_do_startup() to unlock it. serial8250_do_startup() does
> not release the port->unlock until its done:
> 
> 		spin_lock_irqsave(&port->lock, flags);
> 
> 		wait_for_xmitr(up, UART_LSR_THRE);
> 		serial_port_out_sync(port, UART_IER, UART_IER_THRI);
> 		udelay(1); /* allow THRE to set */
> 		iir1 = serial_port_in(port, UART_IIR);
> 		serial_port_out(port, UART_IER, 0);
> 		serial_port_out_sync(port, UART_IER, UART_IER_THRI);
> 		udelay(1); /* allow a working UART time to re-assert THRE */
> 		iir = serial_port_in(port, UART_IIR);
> 		serial_port_out(port, UART_IER, 0);
> 
> 		spin_unlock_irqrestore(&port->lock, flags);
> 
> so IRQ will not see the inconsistent device state.
> 
> What exactly is the purpose of disable_irq_nosync()? Can we just remove
> disable_irq_nosync()/enable_irq() instead? Are there any IRQ handlers
> that don't acquire the port->lock?

I didn't look into this deeply, but my understanding that this is something for
special case when you have several UART ports sharing the IRQ (multi-port card)
and IRQ even maybe undesirable b/c it will confuse real IRQ handler. I don't
remember details, but AFAIR IRQ handler does a busyloop to service as much as
possible and in between it may release the lock (again, multi-port UART cards),
that's why we better avoid IRQ event in the first place.
But it's my pure speculation.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2020-07-02  8:20 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 17:30 UART/TTY console deadlock Raul Rangel
2020-06-22 17:37 ` Andy Shevchenko
2020-06-30  3:58   ` Sergey Senozhatsky
2020-06-30 10:21     ` Petr Mladek
2020-06-30 10:55       ` Sergey Senozhatsky
2020-06-30 11:40         ` Andy Shevchenko
2020-06-30 12:22         ` Petr Mladek
2020-06-30 13:05           ` Sergey Senozhatsky
2020-06-30 18:02             ` Tony Lindgren
2020-07-01  6:44               ` S, Shirish
2020-07-02  3:48                 ` S, Shirish
2020-07-02  6:11                   ` Greg Kroah-Hartman
2020-07-02  6:14                     ` S, Shirish
2020-07-02  6:34                       ` Sergey Senozhatsky
2020-07-02  7:11                       ` Greg Kroah-Hartman
2020-07-02  5:12               ` Sergey Senozhatsky
2020-07-02  5:40                 ` Sergey Senozhatsky
2020-07-02  8:20                   ` Andy Shevchenko [this message]
2020-07-03 10:53                     ` Sergey Senozhatsky
2020-07-04 11:37                       ` Andy Shevchenko
2020-07-02 16:05                 ` Tony Lindgren
2020-07-03 10:32                   ` Sergey Senozhatsky
2020-07-04 11:35                     ` Andy Shevchenko
2020-07-04 11:59                       ` Andy Shevchenko
2020-07-06 11:31                       ` Kurt Kanzenbach
2020-07-06 14:43                         ` Sergey Senozhatsky
2020-07-08  7:40                           ` Kurt Kanzenbach
2020-07-08  8:07                             ` Sergey Senozhatsky
2020-07-08  9:52                               ` Petr Mladek
2020-07-09 13:22                                 ` Sergey Senozhatsky
2020-07-14 16:16                                   ` Raul Rangel

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=20200702082008.GE3703480@smile.fi.intel.com \
    --to=andy.shevchenko@gmail.com \
    --cc=Shirish.S@amd.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=rrangel@google.com \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=tony@atomide.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;
as well as URLs for NNTP newsgroup(s).