All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: 8250: Fix ...console_fifo_write on BCM283x
@ 2022-01-26 14:11 Phil Elwell
  2022-01-26 14:21 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Elwell @ 2022-01-26 14:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Wander Lairson Costa, Johan Hovold,
	Maciej W. Rozycki, Lukas Wunner, Florian Fainelli, linux-serial,
	linux-rpi-kernel
  Cc: Phil Elwell

The mini-UART on BCM283x is doubly crippled - it has 8-byte FIFOs and
the THRE bit indicates that the TX FIFO is not-full rather than empty.

The optimisation to enable the use of the FIFO assumes that it is safe
to write fifosize bytes whenever THRE is set, but the BCM283x quirk
(indicated by the presence of UART_CAP_MINI) makes it necessary to
check the FIFO state after each byte.

See: https://github.com/raspberrypi/linux/issues/4849

Fixes: 5021d709b31b ("tty: serial: Use fifo in 8250 console driver")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/tty/serial/8250/8250_port.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 2abb3de11a48..8a2b462d363c 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3357,6 +3357,13 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up,
 				serial_out(up, UART_TX, *s++);
 				cr_sent = false;
 			}
+			/*
+			 * The BCM2835 MINI UART THRE bit is really a not-full
+			 * bit, so be prepared to bail out early.
+			 */
+			if ((up->capabilities & UART_CAP_MINI) &&
+			    !(serial_in(up, UART_LSR) & UART_LSR_THRE))
+				break;
 		}
 	}
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: 8250: Fix ...console_fifo_write on BCM283x
  2022-01-26 14:11 [PATCH] serial: 8250: Fix ...console_fifo_write on BCM283x Phil Elwell
@ 2022-01-26 14:21 ` Greg Kroah-Hartman
  2022-01-26 14:27   ` Phil Elwell
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-01-26 14:21 UTC (permalink / raw)
  To: Phil Elwell
  Cc: Wander Lairson Costa, Johan Hovold, Maciej W. Rozycki,
	Lukas Wunner, Florian Fainelli, linux-serial, linux-rpi-kernel

On Wed, Jan 26, 2022 at 02:11:24PM +0000, Phil Elwell wrote:
> The mini-UART on BCM283x is doubly crippled - it has 8-byte FIFOs and
> the THRE bit indicates that the TX FIFO is not-full rather than empty.
> 
> The optimisation to enable the use of the FIFO assumes that it is safe
> to write fifosize bytes whenever THRE is set, but the BCM283x quirk
> (indicated by the presence of UART_CAP_MINI) makes it necessary to
> check the FIFO state after each byte.
> 
> See: https://github.com/raspberrypi/linux/issues/4849
> 
> Fixes: 5021d709b31b ("tty: serial: Use fifo in 8250 console driver")

I have just reverted this commit, it's broken for many platforms now,
not just yours.

So there shouldn't be a need for this change now, right?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: 8250: Fix ...console_fifo_write on BCM283x
  2022-01-26 14:21 ` Greg Kroah-Hartman
@ 2022-01-26 14:27   ` Phil Elwell
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Elwell @ 2022-01-26 14:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Wander Lairson Costa, Johan Hovold, Maciej W. Rozycki,
	Lukas Wunner, Florian Fainelli, linux-serial, linux-rpi-kernel

Hi Greg,

On 26/01/2022 14:21, Greg Kroah-Hartman wrote:
> On Wed, Jan 26, 2022 at 02:11:24PM +0000, Phil Elwell wrote:
>> The mini-UART on BCM283x is doubly crippled - it has 8-byte FIFOs and
>> the THRE bit indicates that the TX FIFO is not-full rather than empty.
>>
>> The optimisation to enable the use of the FIFO assumes that it is safe
>> to write fifosize bytes whenever THRE is set, but the BCM283x quirk
>> (indicated by the presence of UART_CAP_MINI) makes it necessary to
>> check the FIFO state after each byte.
>>
>> See: https://github.com/raspberrypi/linux/issues/4849
>>
>> Fixes: 5021d709b31b ("tty: serial: Use fifo in 8250 console driver")
> 
> I have just reverted this commit, it's broken for many platforms now,
> not just yours.
> 
> So there shouldn't be a need for this change now, right?

This patch is sufficient on the BCM283x family of devices, but a Fix
for a non-existent patch is clearly superfluous. The author of the
original patch can consider this as a hint about the kind of issues that
need to be considered before resubmitting.

Thanks,

Phil

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-26 14:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 14:11 [PATCH] serial: 8250: Fix ...console_fifo_write on BCM283x Phil Elwell
2022-01-26 14:21 ` Greg Kroah-Hartman
2022-01-26 14:27   ` Phil Elwell

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.