From: Paul Burton <paul.burton@mips.com>
To: Marek Vasut <marex@denx.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>
Subject: Re: [PATCH] serial: 8250: Fix clearing FIFOs in RS485 mode again
Date: Thu, 13 Dec 2018 03:33:02 +0000 [thread overview]
Message-ID: <20181213033301.febmn5qt3chn3vqb@pburton-laptop> (raw)
In-Reply-To: <117fda17-40e6-664b-2b8a-f1032610bf0b@denx.de>
Hi Marek,
On Thu, Dec 13, 2018 at 03:27:51AM +0100, Marek Vasut wrote:
> > I wonder whether the issue may be the JZ4780 UART not automatically
> > resetting the FIFOs when FCR[0] changes. This is a guess, but the manual
> > doesn't explicitly say it'll happen & the programming example it gives
> > says to explicitly clear the FIFOs using FCR[2:1]. Since this is what
> > the kernel has been doing for at least the whole git era I wouldn't be
> > surprised if other devices are bitten by the change as people start
> > trying 4.20 on them.
>
> The patch you're complaining about is doing exactly that -- it sets
> UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT in FCR , and then clears it.
> Those two bits are exactly FCR[2:1]. It also explicitly does not touch
> any other bits in FCR.
No - your patch does that *only* if the FIFO enable bit is set, and
presumes that clearing FIFOs is a no-op when they're disabled. I don't
believe that's true on my system. I also believe that not touching the
FIFO enable bit is problematic, since some callers clearly expect that
to be cleared.
> > @@ -558,25 +558,26 @@ static void serial8250_clear_fifos(struct uart_8250_port *p)
> > if (p->capabilities & UART_CAP_FIFO) {
> > /*
> > * Make sure to avoid changing FCR[7:3] and ENABLE_FIFO bits.
> > - * In case ENABLE_FIFO is not set, there is nothing to flush
> > - * so just return. Furthermore, on certain implementations of
> > - * the 8250 core, the FCR[7:3] bits may only be changed under
> > - * specific conditions and changing them if those conditions
> > - * are not met can have nasty side effects. One such core is
> > - * the 8250-omap present in TI AM335x.
> > + * On certain implementations of the 8250 core, the FCR[7:3]
> > + * bits may only be changed under specific conditions and
> > + * changing them if those conditions are not met can have nasty
> > + * side effects. One such core is the 8250-omap present in TI
> > + * AM335x.
> > */
> > fcr = serial_in(p, UART_FCR);
> > + serial_out(p, UART_FCR, fcr | clr_mask);
> > + serial_out(p, UART_FCR, fcr & ~clr);
>
> Note that, if I understand the patch correctly, this will _not_ restore
> the original (broken) behavior. The original behavior cleared the entire
> FCR at the end, which cleared even bits that were not supposed to be
> cleared .
It will restore the original behaviour with regards to disabling the
FIFOs, so long as callers that expect that use
serial8250_clear_and_disable_fifos().
> This patch will make things worse by retaining the clr_mask set in the
> FCR, thus the FCR[2:1] will be set when you return from this function.
> That cannot be right ?
You're mistaken - clr_mask (ie. the FIFO reset bits) get cleared again
by the second call to serial_out(), I just did it without modifying the
fcr variable - ie. we write the original fcr value again at the end, but
with UART_FCR_ENABLE_FIFO cleared in the
serial8250_clear_and_disable_fifos() case. It would probably be clearer
with the clr argument renamed disable or something like that.
Thanks,
Paul
next prev parent reply other threads:[~2018-12-13 3:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-13 0:41 Paul Burton
2018-12-13 0:55 ` Marek Vasut
2018-12-13 1:48 ` Paul Burton
2018-12-13 2:27 ` Marek Vasut
2018-12-13 3:33 ` Paul Burton [this message]
2018-12-13 4:18 ` Marek Vasut
2018-12-13 5:11 ` Paul Burton
2018-12-13 14:51 ` Marek Vasut
2018-12-13 17:48 ` Paul Burton
2018-12-16 20:10 ` [PATCH] Revert "serial: 8250: Fix clearing FIFOs in RS485 mode again" Paul Burton
2018-12-16 20:32 ` Marek Vasut
2018-12-16 21:31 ` Paul Burton
2018-12-16 21:45 ` Marek Vasut
2018-12-16 21:52 ` Ezequiel Garcia
2018-12-16 22:11 ` Marek Vasut
2018-12-16 22:24 ` Paul Burton
2018-12-16 22:28 ` Ezequiel Garcia
2018-12-16 22:35 ` Paul Burton
2018-12-17 15:18 ` Greg Kroah-Hartman
2018-12-17 15:43 ` Marek Vasut
2018-12-17 16:30 ` Ezequiel Garcia
2018-12-17 17:20 ` Marek Vasut
2018-12-19 0:12 ` Marek Vasut
2018-12-16 22:16 ` Paul Burton
2018-12-16 21:08 ` Marek Vasut
2018-12-16 21:39 ` Paul Burton
2018-12-16 22:01 ` Marek Vasut
2018-12-16 22:28 ` Paul Burton
2018-12-21 20:08 ` Marek Vasut
2018-12-21 21:08 ` Paul Burton
2018-12-21 22:02 ` Marek Vasut
2018-12-24 15:43 ` Paul Burton
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=20181213033301.febmn5qt3chn3vqb@pburton-laptop \
--to=paul.burton@mips.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=marex@denx.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
all inboxes | Powered by JetHome®