Skip to contentSkip to conversation

Revert "serial: ns16550: Add RX interrupt buffer support"

PATCH New Stefan Roese 3 participants 16 messages Aug 16, 2017 – Aug 26, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Revert "serial: ns16550: Add RX interrupt buffer support"

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt for the RX buffer support at all. Just reading all available characters into a buffer is sufficient to solve the problem with the dropped characters upon long lines pasted into the U-Boot prompt. Since this RX buffer support can be implemented in a generic way, without any device specifica (e.g. for the ns16550), I'll post a new patch with a new serial RX buffer support for DM, which all DM based serial drivers can use.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
---
 drivers/serial/Kconfig   |  10 ----
 drivers/serial/ns16550.c | 123 ++---------------------------------------------
 include/ns16550.h        |  10 ----
 3 files changed, 5 insertions(+), 138 deletions(-)
drivers/serial/Kconfig +0 -10
index a8e997834a..1c2c5d66e1 100644
@@ -64,16 +64,6 @@ config DM_SERIAL
 	  implements serial_putc() etc. The uclass interface is
 	  defined in include/serial.h.
 
-config SERIAL_IRQ_BUFFER
-	bool "Enable RX interrupt buffer for serial input"
-	depends on DM_SERIAL
-	default n
-	help
-	  Enable RX interrupt buffer support for the serial driver.
-	  This enables pasting longer strings, even when the RX FIFO
-	  of the UART is not big enough (e.g. 16 bytes on the normal
-	  NS16550).
-
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL
drivers/serial/ns16550.c +5 -118

163 lines not on this page · raw message

include/ns16550.h +0 -10
index 7e9944d0d9..5fcbcd2e74 100644
@@ -51,10 +51,6 @@
  * @base:		Base register address
  * @reg_shift:		Shift size of registers (0=byte, 1=16bit, 2=32bit...)
  * @clock:		UART base clock speed in Hz
- *
- * @buf:		Pointer to the RX interrupt buffer
- * @rd_ptr:		Read pointer in the RX interrupt buffer
- * @wr_ptr:		Write pointer in the RX interrupt buffer
  */
 struct ns16550_platdata {
 	unsigned long base;
@@ -62,12 +58,6 @@ struct ns16550_platdata {
 	int clock;
 	int reg_offset;
 	u32 fcr;
-
-	int irq;
-
-	char *buf;
-	int rd_ptr;
-	int wr_ptr;
 };
 
 struct udevice;
Signature · 1 line
2.14.1
#1 lore raw

PATCH 2/4 serial: serial-uclass: Add generic serial RX buffer support

Pasting longer lines into the U-Boot console prompt sometimes leads to characters missing. One problem here is the small 16-byte FIFO of the legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX buffer support for all DM based serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
---
 drivers/serial/Kconfig         | 15 +++++++++++++
 drivers/serial/serial-uclass.c | 48 ++++++++++++++++++++++++++++++++++++++++--
 include/serial.h               | 10 ++++++++-
 3 files changed, 70 insertions(+), 3 deletions(-)
drivers/serial/Kconfig +15 -0
index 1c2c5d66e1..aeed538fa4 100644
@@ -64,6 +64,21 @@ config DM_SERIAL
 	  implements serial_putc() etc. The uclass interface is
 	  defined in include/serial.h.
 
+config SERIAL_RX_BUFFER
+	bool "Enable RX buffer for serial input"
+	depends on DM_SERIAL
+	help
+	  Enable RX buffer support for the serial driver. This enables
+	  pasting longer strings, even when the RX FIFO of the UART is
+	  not big enough (e.g. 16 bytes on the normal NS16550).
+
+config SERIAL_RX_BUFFER_SIZE
+	int "RX buffer size"
+	depends on SERIAL_RX_BUFFER
+	default 256
+	help
+	  The size of the RX buffer (needs to be power of 2)
+
 config SPL_DM_SERIAL
 	bool "Enable Driver Model for serial drivers in SPL"
 	depends on DM_SERIAL
drivers/serial/serial-uclass.c +46 -2

72 lines not on this page · raw message

include/serial.h +9 -1
index f4171964ae..d87f01082a 100644
@@ -148,10 +148,18 @@ struct dm_serial_ops {
 /**
  * struct serial_dev_priv - information about a device used by the uclass
  *
- * @sdev: stdio device attached to this uart
+ * @sdev:	stdio device attached to this uart
+ *
+ * @buf:	Pointer to the RX buffer
+ * @rd_ptr:	Read pointer in the RX buffer
+ * @wr_ptr:	Write pointer in the RX buffer
  */
 struct serial_dev_priv {
 	struct stdio_dev *sdev;
+
+	char *buf;
+	int rd_ptr;
+	int wr_ptr;
 };
 
 /* Access the serial operations for a device */
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/4 serial: serial-uclass: Add generic serial RX buffer support

Quoted 13 lines · Stefan Roese

Pasting longer lines into the U-Boot console prompt sometimes leads to characters missing. One problem here is the small 16-byte FIFO of the legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX buffer support for all DM based serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 6 lines
---
 drivers/serial/Kconfig         | 15 +++++++++++++
 drivers/serial/serial-uclass.c | 48 ++++++++++++++++++++++++++++++++++++++++--
 include/serial.h               | 10 ++++++++-
 3 files changed, 70 insertions(+), 3 deletions(-)

Great!

Tested on MinnowMax

#3 lore raw

PATCH 2/4 serial: serial-uclass: Add generic serial RX buffer support

Quoted 21 lines · Bin Meng
Quoted 13 lines · Stefan Roese

Pasting longer lines into the U-Boot console prompt sometimes leads to characters missing. One problem here is the small 16-byte FIFO of the legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX buffer support for all DM based serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 6 lines
---
 drivers/serial/Kconfig         | 15 +++++++++++++
 drivers/serial/serial-uclass.c | 48 ++++++++++++++++++++++++++++++++++++++++--
 include/serial.h               | 10 ++++++++-
 3 files changed, 70 insertions(+), 3 deletions(-)
Quoted 6 lines

Great!

Tested on MinnowMax

applied to u-boot-x86, thanks!

#4 lore raw

PATCH 2/4 serial: serial-uclass: Add generic serial RX buffer support

In reply to Stefan Roese

Hi Stefan,

Quoted 13 lines · Stefan Roese

Pasting longer lines into the U-Boot console prompt sometimes leads to characters missing. One problem here is the small 16-byte FIFO of the legacy NS16550 UART, e.g. on x86 platforms.

This patch now introduces a Kconfig option to enable RX buffer support for all DM based serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 6 lines
---
 drivers/serial/Kconfig         | 15 +++++++++++++
 drivers/serial/serial-uclass.c | 48 ++++++++++++++++++++++++++++++++++++++++--
 include/serial.h               | 10 ++++++++-
 3 files changed, 70 insertions(+), 3 deletions(-)

I have wanted this for a long time - this is a really great feature!

- Simon

#5 lore raw

PATCH 3/4 x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

In reply to Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
 board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
 1 file changed, 1 insertion(+)
board/congatec/conga-qeval20-qa3-e3845/Kconfig +1 -0
index e1fae737ac..9e44413c2c 100644
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	select SPI_FLASH_STMICRO
 	imply SPI_FLASH_SPANSION
 	imply SPI_FLASH_WINBOND
+	select SERIAL_RX_BUFFER
 
 config PCIE_ECAM_BASE
 	default 0xe0000000
Signature · 1 line
2.14.1
#6 lore raw

PATCH 3/4 x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

Hi Bin,

Quoted 16 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
  board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
  1 file changed, 1 insertion(+)
board/congatec/conga-qeval20-qa3-e3845/Kconfig +0 -0
index e1fae737ac..9e44413c2c 100644

board/congatec/conga-qeval20-qa3-e3845/Kconfig config BOARD_SPECIFIC_OPTIONS # dummy · line 28

Quoted 4 lines
board/congatec/conga-qeval20-qa3-e3845/Kconfig +1 -0
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
  	select SPI_FLASH_STMICRO
  	imply SPI_FLASH_SPANSION
  	imply SPI_FLASH_WINBOND
+	select SERIAL_RX_BUFFER

It might be better to select (or imply) this Kconfig option for x86 in general, once this support is available in mainline.

What do you think?

Thanks,
Stefan

#7 lore raw

PATCH 3/4 x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

Hi Stefan,

Quoted 30 lines · Stefan Roese

Hi Bin,

Quoted 18 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
  board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
  1 file changed, 1 insertion(+)
board/congatec/conga-qeval20-qa3-e3845/Kconfig +0 -0
index e1fae737ac..9e44413c2c 100644

board/congatec/conga-qeval20-qa3-e3845/Kconfig config BOARD_SPECIFIC_OPTIONS # dummy · line 28

Quoted 4 lines
board/congatec/conga-qeval20-qa3-e3845/Kconfig +1 -0
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
        select SPI_FLASH_STMICRO
        imply SPI_FLASH_SPANSION
        imply SPI_FLASH_WINBOND
+       select SERIAL_RX_BUFFER

It might be better to select (or imply) this Kconfig option for x86 in general, once this support is available in mainline.

Quoted 1 line

What do you think?

When I tested the patch on the QEMU, I got interesting results:

Without the patch, QEMU's ns16550 does not lose any character or out of order when I paste a really long strings to the U-Boot console (it seems that U-Boot's maximum length for a command line is 256, so the 256 bytes are all there).

After applying the patch, I got something interesting:

The long strings I was using for testing was: "As Bin Meng has tested and pointed out, we don't need the RX interrupt for the RX buffer support at all. Just reading all available characters into a buffer is sufficient to solve the problem with the dropped characters upon long lines pasted into the U-Boot prompt. Since this RX buffer support can be implemented in a generic way, without any device specifica (e.g. for the ns16550), I'll post a new patch with a new serial RX buffer support for DM, which all DM based serial drivers can use. Pasting longer lines into the U-Boot console prompt sometimes leads to characters missing. One problem here is the small 16-byte FIFO of the legacy NS16550 UART, e.g. on x86 platforms. This patch now introduces a Kconfig option to enable RX buffer support for all DM based serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing."

I just got the following strings on the console:

=> serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing. Unknown command 'serial' - try 'help'
=> serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing. Unknown command 'serial' - try 'help'

All previous characters before this string are completely lost.

If we want to turn this option for all x86, I think this should be fixed.

Regards,
Bin

#8 lore raw

PATCH 3/4 x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

Hi Bin,

Quoted 66 lines · Bin Meng
Quoted 30 lines · Stefan Roese

Hi Bin,

Quoted 18 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
   board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
   1 file changed, 1 insertion(+)
board/congatec/conga-qeval20-qa3-e3845/Kconfig +0 -0
index e1fae737ac..9e44413c2c 100644

board/congatec/conga-qeval20-qa3-e3845/Kconfig config BOARD_SPECIFIC_OPTIONS # dummy · line 28

Quoted 4 lines
board/congatec/conga-qeval20-qa3-e3845/Kconfig +1 -0
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
         select SPI_FLASH_STMICRO
         imply SPI_FLASH_SPANSION
         imply SPI_FLASH_WINBOND
+       select SERIAL_RX_BUFFER

It might be better to select (or imply) this Kconfig option for x86 in general, once this support is available in mainline.

Quoted 1 line

What do you think?

When I tested the patch on the QEMU, I got interesting results:

Without the patch, QEMU's ns16550 does not lose any character or out of order when I paste a really long strings to the U-Boot console (it seems that U-Boot's maximum length for a command line is 256, so the 256 bytes are all there).

After applying the patch, I got something interesting:

The long strings I was using for testing was: "As Bin Meng has tested and pointed out, we don't need the RX interrupt for the RX buffer support at all. Just reading all available characters into a buffer is sufficient to solve the problem with the dropped characters upon long lines pasted into the U-Boot prompt. Since this RX buffer support can be implemented in a generic way, without any device specifica (e.g. for the ns16550), I'll post a new patch with a new serial RX buffer support for DM, which all DM based serial drivers can use. Pasting longer lines into the U-Boot console prompt sometimes leads to characters missing. One problem here is the small 16-byte FIFO of the legacy NS16550 UART, e.g. on x86 platforms. This patch now introduces a Kconfig option to enable RX buffer support for all DM based serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing."

I just got the following strings on the console:

=> serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing. Unknown command 'serial' - try 'help'
=> serial drivers. With this option enabled, I was able paste really long lines into the U-Boot console, without any characters missing. Unknown command 'serial' - try 'help'

Quoted 3 lines

All previous characters before this string are completely lost.

If we want to turn this option for all x86, I think this should be fixed.

Okay, I fully agree. I'll hopefully be able to revisit this RX buffer support in a few weeks again and fix this issue on QEMU. Until then, it would be great if those 4 patches could be applied to enable this RX buffer support for these specific x86 boards.

Thanks,
Stefan

#9 lore raw

PATCH 3/4 x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

In reply to Stefan Roese
Quoted 11 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
 board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
 1 file changed, 1 insertion(+)
#10 lore raw

PATCH 3/4 x86: conga-qeval20-qa3-e3845: Select SERIAL_RX_BUFFER via Kconfig

Quoted 13 lines · Bin Meng
Quoted 11 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
 board/congatec/conga-qeval20-qa3-e3845/Kconfig | 1 +
 1 file changed, 1 insertion(+)
Quoted 1 line

applied to u-boot-x86, thanks!

#11 lore raw

PATCH 4/4 x86: dfi-bt700: Select SERIAL_RX_BUFFER via Kconfig

In reply to Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
 board/dfi/dfi-bt700/Kconfig | 1 +
 1 file changed, 1 insertion(+)
board/dfi/dfi-bt700/Kconfig +1 -0
index 4b6c3fc56c..f92f50a448 100644
@@ -25,6 +25,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
 	select SPI_FLASH_STMICRO
 	imply SPI_FLASH_SPANSION
 	imply SPI_FLASH_WINBOND
+	select SERIAL_RX_BUFFER
 
 config PCIE_ECAM_BASE
 	default 0xe0000000
Signature · 1 line
2.14.1
#12 lore raw

PATCH 4/4 x86: dfi-bt700: Select SERIAL_RX_BUFFER via Kconfig

Quoted 11 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
 board/dfi/dfi-bt700/Kconfig | 1 +
 1 file changed, 1 insertion(+)
#13 lore raw

PATCH 4/4 x86: dfi-bt700: Select SERIAL_RX_BUFFER via Kconfig

Quoted 13 lines · Bin Meng
Quoted 11 lines · Stefan Roese

To support more input characters (longer stings pasted into the U-Boot prompt) without dropping, lets selects the recently added UART RX buffer for these boards.

---
 board/dfi/dfi-bt700/Kconfig | 1 +
 1 file changed, 1 insertion(+)
Quoted 1 line

applied to u-boot-x86, thanks!

#14 lore raw

PATCH 1/4 Revert "serial: ns16550: Add RX interrupt buffer support"

In reply to Stefan Roese
Quoted 15 lines · Stefan Roese

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt for the RX buffer support at all. Just reading all available characters into a buffer is sufficient to solve the problem with the dropped characters upon long lines pasted into the U-Boot prompt. Since this RX buffer support can be implemented in a generic way, without any device specifica (e.g. for the ns16550), I'll post a new patch with a new serial RX buffer support for DM, which all DM based serial drivers can use.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 6 lines
---
 drivers/serial/Kconfig   |  10 ----
 drivers/serial/ns16550.c | 123 ++---------------------------------------------
 include/ns16550.h        |  10 ----
 3 files changed, 5 insertions(+), 138 deletions(-)
#15 lore raw

PATCH 1/4 Revert "serial: ns16550: Add RX interrupt buffer support"

Quoted 23 lines · Bin Meng
Quoted 15 lines · Stefan Roese

This reverts commit 6822cf3ec7c8768b8727573b8f4b2cb3d870b881.

As Bin Meng has tested and pointed out, we don't need the RX interrupt for the RX buffer support at all. Just reading all available characters into a buffer is sufficient to solve the problem with the dropped characters upon long lines pasted into the U-Boot prompt. Since this RX buffer support can be implemented in a generic way, without any device specifica (e.g. for the ns16550), I'll post a new patch with a new serial RX buffer support for DM, which all DM based serial drivers can use.

Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 6 lines
---
 drivers/serial/Kconfig   |  10 ----
 drivers/serial/ns16550.c | 123 ++---------------------------------------------
 include/ns16550.h        |  10 ----
 3 files changed, 5 insertions(+), 138 deletions(-)
Quoted 1 line

applied to u-boot-x86, thanks!