Skip to contentSkip to conversation

serial: 8250: Fix THRE flag usage for CAP_MINI

PATCH In review Phil Elwell 3 participants 6 messages Jun 28, 2017 3 messages not in the archive TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 serial: 8250: Fix THRE flag usage for CAP_MINI

The BCM2835 MINI UART has non-standard THRE semantics. Conventionally the bit means that the FIFO is empty (although there may still be a byte in the transmit register), but on 2835 it indicates that the FIFO is not full. This causes interrupts after every byte is transmitted, with the FIFO providing some interrupt latency tolerance.

A consequence of this difference is that the usual strategy of writing multiple bytes into the TX FIFO after checking THRE once is unsafe. In the worst case of 7 bytes in the FIFO, writing 8 bytes loses all but the first since by then the FIFO is full.

There is an HFIFO ("Hidden FIFO") capability that causes the transmit loop to terminate when both THRE and TEMT are set, i.e. when the TX block is completely idle. This is unnecessarily cautious, potentially causing gaps in transmission.

Add a new conditional to the transmit loop, predicated on CAP_MINI, that exits when THRE is no longer set (the FIFO is full). This allows the FIFO to fill quickly but subsequent writes are paced by the transmission rate.

---
Changes in v2:
Add review tags.

 drivers/tty/serial/8250/8250_port.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_port.c +4 -0
index 4c620be..a5fe0e6 100644
@@ -1764,6 +1764,10 @@ void serial8250_tx_chars(struct uart_8250_port *up)
 		if ((up->capabilities & UART_CAP_HFIFO) &&
 		    (serial_in(up, UART_LSR) & BOTH_EMPTY) != BOTH_EMPTY)
 			break;
+		/* The BCM2835 MINI UART THRE bit is really a not-full bit. */
+		if ((up->capabilities & UART_CAP_MINI) &&
+		    !(serial_in(up, UART_LSR) & UART_LSR_THRE))
+			break;
 	} while (--count > 0);
 
 	if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
Signature · 1 line
1.9.1
Acked-by Eric Anholt Acked-by Andy Shevchenko
#2 lore raw
In reply to a message not in the archive

Hello,

Quoted 6 lines · Phil Elwell

---
Changes in v2:
Add review tags.

nitpick: The order of lines in the Sob area matter and you should add your Sob at the end. So as it was you adding the ack by Eric and Andy, it should look as follows:

. Note that this comment is very picky, quite some people don't get it right and I never saw a maintainer refuse a patch because of this. So this probably doesn't warrant a v3 :-)

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
author Acked-by Mika Penttilä Tested-by Mika Penttilä Acked-by Steve Twiss Tested-by Steve Twiss
#4 lore raw
In reply to a message not in the archive
Quoted 10 lines · Uwe Kleine-König

Hello,

Quoted 6 lines · Phil Elwell

---
Changes in v2:
Add review tags.

Quoted 7 lines

nitpick: The order of lines in the Sob area matter and you should add your Sob at the end. So as it was you adding the ack by Eric and Andy, it should look as follows:

Really? I thought the submitter went first and the final merger went last, with other reviewers in-between, like this:

commit 6df765dca378bddf994cfd2044acafa501bd800f
Author: Uwe Kleine-König <[email protected]>
Date: Wed May 24 21:38:46 2017 +0200

serial: imx: ensure UCR3 and UFCR are setup correctly

[...]

Fixes e61c38d85b73 ("serial: imx: setup DCEDTE early and ensure DCD and RI irqs to be off")
Quoted 7 lines

. Note that this comment is very picky, quite some people don't get it right and I never saw a maintainer refuse a patch because of this. So this probably doesn't warrant a v3 :-)

Best regards
Uwe

_______________________________________________
linux-rpi-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

#6 lore raw
In reply to a message not in the archive
Quoted 17 lines · Phil Elwell
Quoted 16 lines · Uwe Kleine-König

Hello,

Quoted 6 lines · Phil Elwell

---
Changes in v2:
 Add review tags.

nitpick: The order of lines in the Sob area matter and you should add
your Sob at the end. So as it was you adding the ack by Eric and Andy,
it should look as follows:

Quoted 6 lines
Quoted 3 lines

Really? I thought the submitter went first and the final merger went last, with other reviewers in-between, like this:

There is a difference between two, i.e. who has added tags in your case and below one? I guess whoever adds them, adds before their own SoB tag.

Quoted 28 lines

    commit 6df765dca378bddf994cfd2044acafa501bd800f
    Author: Uwe Kleine-König <[email protected]> Date:   Wed May 24 21:38:46 2017 +0200

        serial: imx: ensure UCR3 and UFCR are setup correctly

        [...]

Fixes e61c38d85b73 ("serial: imx: setup DCEDTE early and

ensure DCD and RI irqs to be off")

e>

Quoted 9 lines

. Note that this comment is very picky, quite some people don't get it
right and I never saw a maintainer refuse a patch because of this. So
this probably doesn't warrant a v3 :-)

Best regards
Uwe

Signature · 7 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy

_______________________________________________
linux-rpi-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel
#8 lore raw
In reply to a message not in the archive
Quoted 14 lines · Uwe Kleine-König

Hello,

Quoted 6 lines · Phil Elwell

---
Changes in v2:
 Add review tags.

nitpick: The order of lines in the Sob area matter and you should add your Sob at the end. So as it was you adding the ack by Eric and Andy, it should look as follows:

Quoted 7 lines

. Note that this comment is very picky, quite some people don't get it right and I never saw a maintainer refuse a patch because of this. So this probably doesn't warrant a v3 :-)

Yeah, it's easily learned when one is using

% git commit -s [--amend]

Signature · 7 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy

_______________________________________________
linux-rpi-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel
#7 lore raw
In reply to a message not in the archive

Hello,

Quoted 20 lines · Phil Elwell
Quoted 7 lines · Uwe Kleine-König

nitpick: The order of lines in the Sob area matter and you should add your Sob at the end. So as it was you adding the ack by Eric and Andy, it should look as follows:

Really? I thought the submitter went first and the final merger went last, with other reviewers in-between, like this:

commit 6df765dca378bddf994cfd2044acafa501bd800f
Author: Uwe Kleine-König <[email protected]>
Date: Wed May 24 21:38:46 2017 +0200

serial: imx: ensure UCR3 and UFCR are setup correctly

[...]

Quoted 7 lines

Right, I would expect that it was Greg who added the Acked and Tested-by tags when reading this.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |