mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Vamshi Gajjela <vamshigajjela@google.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Phil Edworthy <phil.edworthy@renesas.com>,
	Emil Renner Berthing <kernel@esmil.dk>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Johan Hovold <johan@kernel.org>,
	linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	manugautam@google.com
Subject: Re: [PATCH v3] serial: 8250_dw: Avoid pslverr on reading empty receiver fifo
Date: Wed, 13 Jul 2022 19:11:29 +0300	[thread overview]
Message-ID: <Ys7usW3W3kemtVc+@smile.fi.intel.com> (raw)
In-Reply-To: <20220713131722.2316829-1-vamshigajjela@google.com>

On Wed, Jul 13, 2022 at 06:47:22PM +0530, Vamshi Gajjela wrote:
> From: VAMSHI GAJJELA <vamshigajjela@google.com>
> 
> With PSLVERR_RESP_EN parameter set to 1, the device generates an error
> response when an attempt to read an empty RBR with FIFO enabled.
> 
> This happens when LCR writes are ignored when UART is busy.
> dw8250_check_lcr() in retries to update LCR, invokes dw8250_force_idle()
> to clear and reset FIFO and eventually reads UART_RX causing the error.
> 
> Avoid this by not reading RBR/UART_RX when no data is available.

From code perspective looks good,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

but maybe Ilpo or others have something to add based on the practical use.

> Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
> ---
> v3:
> - check lsr based on FIFO enablement
> v2:
> - update as per review comments (re-format comments, xmas tree ordering)
>  drivers/tty/serial/8250/8250_dw.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index f57bbd32ef11..7573904579f6 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -82,8 +82,21 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
>  static void dw8250_force_idle(struct uart_port *p)
>  {
>  	struct uart_8250_port *up = up_to_u8250p(p);
> +	unsigned int lsr;
>  
>  	serial8250_clear_and_reinit_fifos(up);
> +
> +	/*
> +	 * With PSLVERR_RESP_EN parameter set to 1, the device generates an
> +	 * error response when an attempt to read an empty RBR with FIFO
> +	 * enabled.
> +	 */
> +	if (up->fcr & UART_FCR_ENABLE_FIFO) {
> +		lsr = p->serial_in(p, UART_LSR);
> +		if (!(lsr & UART_LSR_DR))
> +			return;
> +	}
> +
>  	(void)p->serial_in(p, UART_RX);
>  }
>  
> -- 
> 2.37.0.144.g8ac04bfd2-goog
> 

-- 
With Best Regards,
Andy Shevchenko



      reply	other threads:[~2022-07-13 16:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 13:17 Vamshi Gajjela
2022-07-13 16:11 ` Andy Shevchenko [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=Ys7usW3W3kemtVc+@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jirislaby@kernel.org \
    --cc=johan@kernel.org \
    --cc=kernel@esmil.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=manugautam@google.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=phil.edworthy@renesas.com \
    --cc=vamshigajjela@google.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

all inboxes | Powered by JetHome®