8250: DMA Fixes
Ilpo Järvinen
maintainerv2 cover 8250: DMA Fixes
Here are a number of 8250 DMA related fixes. The last one seems the most serious problem able to corrupt the payload ordering.
v2:
- Tweak configure logic to match Andy's suggestion
- Cleaned up the tags from the oneliner patch
Ilpo Järvinen (4):
serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs
serial: 8250_lpss: Configure DMA also w/o DMA filter
serial: 8250_lpss: Use 16B DMA burst with Elkhart Lake
serial: 8250: Flush DMA Rx on RLSI
drivers/tty/serial/8250/8250_lpss.c | 17 +++++++++++++---- drivers/tty/serial/8250/8250_port.c | 7 +++++-- 2 files changed, 18 insertions(+), 6 deletions(-)
Signature · 1 line
2.30.2
Ilpo Järvinen
maintainerPATCH v2 1/4 serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs
DW UART sometimes triggers IIR_RDI during DMA Rx when IIR_RX_TIMEOUT should have been triggered instead. Since IIR_RDI has higher priority than IIR_RX_TIMEOUT, this causes the Rx to hang into interrupt loop. The problem seems to occur at least with some combinations of small-sized transfers (I've reproduced the problem on Elkhart Lake PSE UARTs).
If there's already an on-going Rx DMA and IIR_RDI triggers, fall graciously back to non-DMA Rx. That is, behave as if IIR_RX_TIMEOUT had occurred.
8250_omap already considers IIR_RDI similar to this change so its nothing unheard of.
--- drivers/tty/serial/8250/8250_port.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_port.c +4 -0
@@ -1897,6 +1897,10 @@ EXPORT_SYMBOL_GPL(serial8250_modem_status);static bool handle_rx_dma (struct uart_8250_port *up,unsigned int iir) {switch (iir &0x3f ) { +case UART_IIR_RDI : +if (!up->dma->rx_running) +break ; + fallthrough;case UART_IIR_RX_TIMEOUT :serial8250_rx_dma_flush (up); fallthrough;
Signature · 1 line
2.30.2
Ilpo Järvinen
maintainerPATCH v2 2/4 serial: 8250_lpss: Configure DMA also w/o DMA filter
In reply to Ilpo JärvinenIf the platform doesn't use DMA device filter (as is the case with Elkhart Lake), whole lpss8250_dma_setup() setup is skipped. This results in skipping also *_maxburst setup which is undesirable. Refactor lpss8250_dma_setup() to configure DMA even if filter is not setup.
--- drivers/tty/serial/8250/8250_lpss.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_lpss.c +11 -4
@@ -277,8 +277,13 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *portstruct dw_dma_slave *rx_param, *tx_param;struct device *dev = port->port.dev; -if (!lpss->dma_param.dma_dev) +if (!lpss->dma_param.dma_dev) { + dma = port->dma; +if (dma) + goto out_configuration_only; +return 0 ; + } rx_param =devm_kzalloc (dev,sizeof (*rx_param),GFP_KERNEL );if (!rx_param)
@@ -289,16 +294,18 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *portreturn -ENOMEM ; *rx_param = lpss->dma_param; - dma->rxconf.src_maxburst = lpss->dma_maxburst; - *tx_param = lpss->dma_param; - dma->txconf.dst_maxburst = lpss->dma_maxburst; dma->fn = lpss8250_dma_filter; dma->rx_param = rx_param; dma->tx_param = tx_param; port->dma = dma; + +out_configuration_only: + dma->rxconf.src_maxburst = lpss->dma_maxburst; + dma->txconf.dst_maxburst = lpss->dma_maxburst; +return 0 ; }
Signature · 1 line
2.30.2
Ilpo Järvinen
maintainerPATCH v2 3/4 serial: 8250_lpss: Use 16B DMA burst with Elkhart Lake
In reply to Ilpo JärvinenConfigure DMA to use 16B burst size with Elkhart Lake. This makes the bus use more efficient and works around an issue which occurs with the previously used 1B.
The fix was initially developed by Srikanth Thokala and Aman Kumar. This together with the previous config change is the cleaned up version of the original fix.
--- drivers/tty/serial/8250/8250_lpss.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_lpss.c +2 -0
@@ -174,6 +174,8 @@ static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)*/ up->dma = dma; + lpss->dma_maxburst =16 ; + port->set_termios = dw8250_do_set_termios;return 0 ;
Signature · 1 line
2.30.2
Ilpo Järvinen
maintainerPATCH v2 4/4 serial: 8250: Flush DMA Rx on RLSI
In reply to Ilpo JärvinenReturning true from handle_rx_dma() without flushing DMA first creates a data ordering hazard. If DMA Rx has handled any character at the point when RLSI occurs, the non-DMA path handles any pending characters jumping them ahead of those characters that are pending under DMA.
--- drivers/tty/serial/8250/8250_port.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/8250/8250_port.c +1 -2
@@ -1901,10 +1901,9 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir)if (!up->dma->rx_running)break ; fallthrough; +case UART_IIR_RLSI :case UART_IIR_RX_TIMEOUT :serial8250_rx_dma_flush (up); - fallthrough; -case UART_IIR_RLSI :return true; }return up->dma->rx_dma (up);
Signature · 1 line
2.30.2
Quoted 2 lines · Ilpo Järvinen
Here are a number of 8250 DMA related fixes. The last one seems the most serious problem able to corrupt the payload ordering.
Thank you for the update!
LGTM,
Quoted 9 lines
v2:
- Tweak configure logic to match Andy's suggestion
- Cleaned up the tags from the oneliner patchIlpo Järvinen (4):
serial: 8250: Fall back to non-DMA Rx ifIIR_RDIoccurs
serial: 8250_lpss: Configure DMA also w/o DMA filter
serial: 8250_lpss: Use 16B DMA burst with Elkhart Lake
serial: 8250: Flush DMA Rx on RLSI
Signature · 2 lines
With Best Regards, Andy Shevchenko