diff mbox series

[v3] serial: 8250: 8250_omap: Do not start RX DMA on THRI interrupt

Message ID 20231031110950.11714-1-rwahl@gmx.de
State Superseded
Headers show
Series [v3] serial: 8250: 8250_omap: Do not start RX DMA on THRI interrupt | expand

Commit Message

Ronald Wahl Oct. 31, 2023, 11:09 a.m. UTC
From: Ronald Wahl <ronald.wahl@raritan.com>

Starting RX DMA on THRI interrupt is too early because TX may not have
finished yet.

This change is inspired by commit 90b8596ac460 ("serial: 8250: Prevent
starting up DMA Rx on THRI interrupt") and fixes DMA issues I had with
an AM62 SoC that is using the 8250 OMAP variant.

Cc: stable@vger.kernel.org
Fixes: c26389f998a8 ("serial: 8250: 8250_omap: Add DMA support for UARTs on K3 SoCs")
Signed-off-by: Ronald Wahl <ronald.wahl@raritan.com>
---
V3: - add Cc: stable@vger.kernel.org

V2: - add Fixes: tag
    - fix author

 drivers/tty/serial/8250/8250_omap.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--
2.41.0

Comments

kernel test robot Nov. 1, 2023, 1:03 a.m. UTC | #1
Hi Ronald,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on tty/tty-next tty/tty-linus usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.6 next-20231031]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ronald-Wahl/serial-8250-8250_omap-Do-not-start-RX-DMA-on-THRI-interrupt/20231031-191258
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
patch link:    https://lore.kernel.org/r/20231031110950.11714-1-rwahl%40gmx.de
patch subject: [PATCH v3] serial: 8250: 8250_omap: Do not start RX DMA on THRI interrupt
config: mips-allmodconfig (https://download.01.org/0day-ci/archive/20231101/202311010816.kXNniDbT-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231101/202311010816.kXNniDbT-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311010816.kXNniDbT-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/tty/serial/8250/8250_omap.c: In function 'omap_8250_dma_handle_irq':
>> drivers/tty/serial/8250/8250_omap.c:1301:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
    1301 |         if ((iir & 0x3f) != UART_IIR_THRI)
         |            ^


vim +/else +1301 drivers/tty/serial/8250/8250_omap.c

  1279	
  1280	/*
  1281	 * This is mostly serial8250_handle_irq(). We have a slightly different DMA
  1282	 * hoook for RX/TX and need different logic for them in the ISR. Therefore we
  1283	 * use the default routine in the non-DMA case and this one for with DMA.
  1284	 */
  1285	static int omap_8250_dma_handle_irq(struct uart_port *port)
  1286	{
  1287		struct uart_8250_port *up = up_to_u8250p(port);
  1288		struct omap8250_priv *priv = up->port.private_data;
  1289		u16 status;
  1290		u8 iir;
  1291	
  1292		iir = serial_port_in(port, UART_IIR);
  1293		if (iir & UART_IIR_NO_INT) {
  1294			return IRQ_HANDLED;
  1295		}
  1296	
  1297		uart_port_lock(port);
  1298	
  1299		status = serial_port_in(port, UART_LSR);
  1300	
> 1301		if ((iir & 0x3f) != UART_IIR_THRI)
  1302			if (priv->habit & UART_HAS_EFR2)
  1303				am654_8250_handle_rx_dma(up, iir, status);
  1304			else
  1305				status = omap_8250_handle_rx_dma(up, iir, status);
  1306	
  1307		serial8250_modem_status(up);
  1308		if (status & UART_LSR_THRE && up->dma->tx_err) {
  1309			if (uart_tx_stopped(&up->port) ||
  1310			    uart_circ_empty(&up->port.state->xmit)) {
  1311				up->dma->tx_err = 0;
  1312				serial8250_tx_chars(up);
  1313			} else  {
  1314				/*
  1315				 * try again due to an earlier failer which
  1316				 * might have been resolved by now.
  1317				 */
  1318				if (omap_8250_tx_dma(up))
  1319					serial8250_tx_chars(up);
  1320			}
  1321		}
  1322	
  1323		uart_unlock_and_check_sysrq(port);
  1324	
  1325		return 1;
  1326	}
  1327
diff mbox series

Patch

diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index c7ab2963040b..f2f59ec6b50b 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -1282,10 +1282,11 @@  static int omap_8250_dma_handle_irq(struct uart_port *port)

 	status = serial_port_in(port, UART_LSR);

-	if (priv->habit & UART_HAS_EFR2)
-		am654_8250_handle_rx_dma(up, iir, status);
-	else
-		status = omap_8250_handle_rx_dma(up, iir, status);
+	if ((iir & 0x3f) != UART_IIR_THRI)
+		if (priv->habit & UART_HAS_EFR2)
+			am654_8250_handle_rx_dma(up, iir, status);
+		else
+			status = omap_8250_handle_rx_dma(up, iir, status);

 	serial8250_modem_status(up);
 	if (status & UART_LSR_THRE && up->dma->tx_err) {