From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Petr Mladek <pmladek@suse.com>,
John Ogness <john.ogness@linutronix.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
linux-serial <linux-serial@vger.kernel.org>,
qianfan Zhao <qianfanguijin@163.com>,
Adriana Nicolae <adriana@arista.com>,
Markus Mayer <markus.mayer@linaro.org>,
Tim Kryger <tim.kryger@linaro.org>,
Matt Porter <matt.porter@linaro.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Jamie Iles <jamie@jamieiles.com>,
LKML <linux-kernel@vger.kernel.org>,
stable@vger.kernel.org, "Bandal,
Shankar" <shankar.bandal@intel.com>,
"Murthy, Shanth" <shanth.murthy@intel.com>
Subject: Re: [PATCH 6/6] serial: 8250_dw: Ensure BUSY is deasserted
Date: Tue, 27 Jan 2026 16:40:28 +0200 (EET) [thread overview]
Message-ID: <379cc557-7d09-d6e9-3b16-9621e344bd36@linux.intel.com> (raw)
In-Reply-To: <aXjHZQnIFjfPabdU@smile.fi.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4266 bytes --]
On Tue, 27 Jan 2026, Andy Shevchenko wrote:
> On Tue, Jan 27, 2026 at 03:35:27PM +0200, Ilpo Järvinen wrote:
> > On Sat, 24 Jan 2026, Andy Shevchenko wrote:
> > > On Fri, Jan 23, 2026 at 07:27:39PM +0200, Ilpo Järvinen wrote:
>
> +Cc: printk people to check on printing from a serial driver routines.
>
> ...
>
> > > > + /* Prevent triggering interrupt from RBR filling */
> > > > + p->serial_out(p, UART_IER, 0);
> > >
> > > Do we specifically use callbacks directly and not wrappers all over the change?
> >
> > I guess it's just a habit, I suppose you meant using serial_port_in/out
> > instead. I can try to change those.
>
> Not (only) me. Jiri updated this driver (and many others) to use callbacks.
> That's why I added comments here and there about possible recursions.
Fair, this patch originated from a time way older than Jiri's conversion
(not an excuse, just stating how it came to be and I've not realized
using an old way until you mentioned).
> > > > + serial8250_fifo_wait_for_lsr_thre(up, p->fifosize);
> > > > + ndelay(p->frame_time);
> > >
> > > Wouldn't be a problem on lowest baud rates (exempli gratia 110)?
> >
> > Perhaps, but until somebody comes with an issue report related to 110, I'm
> > wondering if this really is worth trying to address. Any suggestion how is
> > welcome as well?
>
> Polling work? Timer?
And how do I prevent others messing with the UART during that time? While
IER is zeroed here (and I could make up->ier zero as well, I think), I
can't hold port's lock if I do either of those.
And I can't take the tty_port's mutex here either because the caller
is already holding port's lock (and it wouldn't prevent console writes
anyway as that, I think, only takes port's lock).
Sadly THRE/TEMT are not trustworthy as they are set before all those
non-data bits have been fully blasted on to the wire (we learned this with
rs485 half-duplex scenarios).
Normal behavioral exceptation what I have here is that userspace is sane
and won't do LCR write and tx at the same time but I don't know how to
ensure that. Perhaps using now > last xmit timestamp + frame_time could
avoid this unconditional delay.
> > > > + retries = 4; /* Arbitrary limit, 2 was always enough in tests */
> > > > + do {
> > > > + serial8250_clear_fifos(up);
> > > > + if (!(p->serial_in(p, usr_reg) & DW_UART_USR_BUSY))
> > > > + break;
> > > > + ndelay(p->frame_time);
> > > > + } while (--retries);
> > >
> > > read_poll_timeout_atomic() ? I assume it can't be used due to small frame time?
> >
> > Frame time is in nanoseconds yes. I did consider
> > read_poll_timeout_atomic() but it would have required nsec -> usec
> > conversion so I left this as it is.
>
> Yeah with the same issue on low baud rates. So far I think we need to consider
> 9600 as commonly used by the old HW (which may be connected to a modern PC with
> this new kernel running), so the frame time sounds like close to a millisecond.
> And this can be met in real life.
>
> Maybe put TODO/FIXME around these ndelay() calls?
Seems reasonable, I'll add that.
I'm under impression that all LCR writes occur from contexts that are
non-atomic by nature (except they are holding the port's lock, of course)
so this should never delay an interrupt handler.
> > > > + if (d->in_idle) {
> > >
> > > > + /*
> > > > + * FIXME: this deadlocks if port->lock is already held
> > > > + * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
> > > > + */
> > >
> > > Hmm... That FIXME should gone since we have non-blocking consoles, no?
> >
> > No, lockdep still gets angry if printing is used while holding port's
> > lock.
>
> Hmm... Let's ask PRINTK people about this. John, do we still have a gap
> with nbcon? Or did I misunderstand the scope of its use?
>
> > What would be possible though, is to mark the port's lock critical section
> > for print deferral (but it's outside the scope of this series). In case of
> > serial, it would be justified to use deferred printing (which is only
> > meant for special cases) because serial console and printing are related.
> >
> > > > + return;
> > > > + }
>
>
--
i.
next prev parent reply other threads:[~2026-01-27 14:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 17:27 [PATCH 0/6] 8250 DW UART fixes when under constant Rx pressure Ilpo Järvinen
2026-01-23 17:27 ` [PATCH 1/6] serial: 8250: Protect LCR write in shutdown Ilpo Järvinen
2026-01-23 17:27 ` [PATCH 2/6] serial: 8250_dw: Avoid unnecessary LCR writes Ilpo Järvinen
2026-01-23 21:41 ` Andy Shevchenko
2026-01-23 17:27 ` [PATCH 3/6] serial: 8250_dw: Rework dw8250_handle_irq() locking and IIR handling Ilpo Järvinen
2026-01-23 22:05 ` Andy Shevchenko
2026-01-27 12:48 ` Ilpo Järvinen
2026-01-27 13:48 ` Andy Shevchenko
2026-01-23 17:27 ` [PATCH 4/6] serial: 8250_dw: Rework IIR_NO_INT handling to stop interrupt storm Ilpo Järvinen
2026-01-23 22:13 ` Andy Shevchenko
2026-01-27 13:01 ` Ilpo Järvinen
2026-01-27 13:57 ` Andy Shevchenko
2026-01-23 17:27 ` [PATCH 5/6] serial: 8250: Add late synchronize_irq() to shutdown to handle DW UART BUSY Ilpo Järvinen
2026-01-23 17:27 ` [PATCH 6/6] serial: 8250_dw: Ensure BUSY is deasserted Ilpo Järvinen
2026-01-23 22:42 ` Andy Shevchenko
2026-01-27 13:35 ` Ilpo Järvinen
2026-01-27 14:10 ` Andy Shevchenko
2026-01-27 14:40 ` Ilpo Järvinen [this message]
2026-01-27 16:19 ` John Ogness
2026-01-26 15:22 ` Greg Kroah-Hartman
2026-01-27 14:45 ` Ilpo Järvinen
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=379cc557-7d09-d6e9-3b16-9621e344bd36@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=adriana@arista.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jamie@jamieiles.com \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=markus.mayer@linaro.org \
--cc=matt.porter@linaro.org \
--cc=pmladek@suse.com \
--cc=qianfanguijin@163.com \
--cc=shankar.bandal@intel.com \
--cc=shanth.murthy@intel.com \
--cc=stable@vger.kernel.org \
--cc=tim.kryger@linaro.org \
/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
Powered by JetHome