All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: 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>,
	 Tim Kryger <tim.kryger@linaro.org>,
	Matt Porter <matt.porter@linaro.org>,
	 Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	 Markus Mayer <markus.mayer@linaro.org>,
	Jamie Iles <jamie@jamieiles.com>,
	 LKML <linux-kernel@vger.kernel.org>,
	 "Bandal, Shankar" <shankar.bandal@intel.com>,
	 "Murthy, Shanth" <shanth.murthy@intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 7/7] serial: 8250_dw: Ensure BUSY is deasserted
Date: Fri, 30 Jan 2026 14:44:38 +0200 (EET)	[thread overview]
Message-ID: <407db45d-c4d9-e6b1-8e35-e398da89d40e@linux.intel.com> (raw)
In-Reply-To: <aXouStgDF635dYya@smile.fi.intel.com>

[-- Attachment #1: Type: text/plain, Size: 4083 bytes --]

On Wed, 28 Jan 2026, Andy Shevchenko wrote:

> On Wed, Jan 28, 2026 at 12:53:01PM +0200, Ilpo Järvinen wrote:
> > DW UART cannot write to LCR, DLL, and DLH while BUSY is asserted.
> > Existance of BUSY depends on uart_16550_compatible, if UART HW is
> > configured with it those registers can always be written.
> > 
> > There currently is dw8250_force_idle() which attempts to achieve
> > non-BUSY state by disabling FIFO, however, the solution is unreliable
> > when Rx keeps getting more and more characters.
> > 
> > Create a sequence of operations that ensures UART cannot keep BUSY
> > asserted indefinitely. The new sequence relies on enabling loopback mode
> > temporarily to prevent incoming Rx characters keeping UART BUSY.
> > 
> > Ensure no Tx in ongoing while the UART is switches into the loopback
> > mode (requires exporting serial8250_fifo_wait_for_lsr_thre() and adding
> > DMA Tx pause/resume functions).
> > 
> > According to tests performed by Adriana Nicolae <adriana@arista.com>,
> > simply disabling FIFO or clearing FIFOs only once does not always
> > ensure BUSY is deasserted but up to two tries may be needed. This could
> > be related to ongoing Rx of a character (a guess, not known for sure).
> > Therefore, retry FIFO clearing a few times (retry limit 4 is arbitrary
> > number but using, e.g., p->fifosize seems overly large). Tests
> > performed by others did not exhibit similar challenge but it does not
> > seem harmful to leave the FIFO clearing loop in place for all DW UARTs
> > with BUSY functionality.
> > 
> > Use the new dw8250_idle_enter/exit() to do divisor writes and LCR
> > writes. In case of plain LCR writes, opportunistically try to update
> > LCR first and only invoke dw8250_idle_enter() if the write did not
> > succeed (it has been observed that in practice most LCR writes do
> > succeed without complications).
> > 
> > This issue was first reported by qianfan Zhao who put lots of debugging
> > effort into understanding the solution space.
> 
> Some nit-picks below, otherwise seems good to go
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> ...
> 
> > Reported-by: qianfan Zhao <qianfanguijin@163.com>
> > Link: https://lore.kernel.org/linux-serial/289bb78a-7509-1c5c-2923-a04ed3b6487d@163.com/
> > Reported-by: Adriana Nicolae <adriana@arista.com>
> > Link: https://lore.kernel.org/linux-serial/20250819182322.3451959-1-adriana@arista.com/
> 
> Shouldn't these Link:s be Closes: tags?

To not possibly give wrong signals, until they confirm their cases are 
indeed solved by this patch, I'd like to keep these as Link tag only.

> > +	struct dw8250_data *d = to_dw8250_data(p->private_data);
> >  	struct uart_8250_port *up = up_to_u8250p(p);
> > +	unsigned int usr_reg = DW_UART_USR;
> > +	int retries;
> > +	u32 lsr;
> 
> 
> > +	if (d->pdata)
> > +		usr_reg = d->pdata->usr_reg;
> 
> I would unite this with definition above:
> 
> 	unsigned int usr_reg = d->pdata ? d->pdata->usr_reg : DW_UART_USR;
>
> > +	lsr = serial_lsr_in(up);
> 
> > +	if (lsr & UART_LSR_DR) {
> > +		serial_port_in(p, UART_RX);
> > +		up->lsr_saved_flags = 0;
> >  	}
> 
> This seems repeating a top of serial8250_read_char(). Perhaps we can do it
> in a helper at some point?

I don't see enough similarity as I'd need to deal with lsr_saved_flags 
somehow still here.

> > +	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);
> > +		 */
> 
> Does it make sense to print an error here (assuming it will work with nbcon)?
> If so, maybe leave it at the end of the function, after dw8250_idle_exit()
> and goto there?

I think the print would be useful. I'll leave the FIXME+commented out 
print into the end of the function in v3.

I also realized that on error, dw8250_idle_enter() should undo what it 
changed, that is, call dw8250_idle_exit() within which will simplify 
caller-side error handling slightly.

-- 
 i.

      reply	other threads:[~2026-01-30 12:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 10:52 [PATCH v2 0/7] 8250 DW UART fixes when under constant Rx pressure Ilpo Järvinen
2026-01-28 10:52 ` [PATCH v2 1/7] serial: 8250: Protect LCR write in shutdown Ilpo Järvinen
2026-01-28 13:12   ` Andy Shevchenko
2026-01-28 10:52 ` [PATCH v2 2/7] serial: 8250_dw: Avoid unnecessary LCR writes Ilpo Järvinen
2026-01-28 13:36   ` Andy Shevchenko
2026-01-28 10:52 ` [PATCH v2 3/7] serial: 8250: Add serial8250_handle_irq_locked() Ilpo Järvinen
2026-01-28 13:20   ` Andy Shevchenko
2026-01-28 13:26     ` Ilpo Järvinen
2026-01-28 10:52 ` [PATCH v2 4/7] serial: 8250_dw: Rework dw8250_handle_irq() locking and IIR handling Ilpo Järvinen
2026-01-28 13:48   ` Andy Shevchenko
2026-01-28 14:00     ` Ilpo Järvinen
2026-01-28 10:52 ` [PATCH v2 5/7] serial: 8250_dw: Rework IIR_NO_INT handling to stop interrupt storm Ilpo Järvinen
2026-01-28 14:03   ` Andy Shevchenko
2026-01-28 10:53 ` [PATCH v2 6/7] serial: 8250: Add late synchronize_irq() to shutdown to handle DW UART BUSY Ilpo Järvinen
2026-01-28 14:37   ` Andy Shevchenko
2026-01-28 15:07     ` Ilpo Järvinen
2026-01-28 10:53 ` [PATCH v2 7/7] serial: 8250_dw: Ensure BUSY is deasserted Ilpo Järvinen
2026-01-28 15:42   ` Andy Shevchenko
2026-01-30 12:44     ` Ilpo Järvinen [this message]

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=407db45d-c4d9-e6b1-8e35-e398da89d40e@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=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=markus.mayer@linaro.org \
    --cc=matt.porter@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.