tty: serial: 8250_omap: do not use RX DMA if pause is not supported
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 14 Aug 2015 15:52:07 +0000 (17:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 15 Aug 2015 00:19:49 +0000 (17:19 -0700)
The 8250-omap driver requires the DMA-engine driver to support the pause
command in order to properly turn off programmed RX transfer before the
driver stars manually reading from the FIFO.
The lacking support of the requirement has been discovered recently. In
order to stay safe here we disable RX-DMA completly on probe.
The rx_dma_broken assignment on probe could be removed once we working
pause function in omap-dma.

Cc: <stable@vger.kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_omap.c

index 0340ee6ba970b40df2cd2f9d220b8bd9812f7be9..826c5c4a2103be3ac9c5065eeb8274fd8ce8c75f 100644 (file)
@@ -112,6 +112,7 @@ struct omap8250_priv {
        struct work_struct qos_work;
        struct uart_8250_dma omap8250_dma;
        spinlock_t rx_dma_lock;
+       bool rx_dma_broken;
 };
 
 static u32 uart_read(struct uart_8250_port *up, u32 reg)
@@ -761,6 +762,7 @@ static void omap_8250_rx_dma_flush(struct uart_8250_port *p)
        struct omap8250_priv    *priv = p->port.private_data;
        struct uart_8250_dma    *dma = p->dma;
        unsigned long           flags;
+       int ret;
 
        spin_lock_irqsave(&priv->rx_dma_lock, flags);
 
@@ -769,7 +771,9 @@ static void omap_8250_rx_dma_flush(struct uart_8250_port *p)
                return;
        }
 
-       dmaengine_pause(dma->rxchan);
+       ret = dmaengine_pause(dma->rxchan);
+       if (WARN_ON_ONCE(ret))
+               priv->rx_dma_broken = true;
 
        spin_unlock_irqrestore(&priv->rx_dma_lock, flags);
 
@@ -813,6 +817,9 @@ static int omap_8250_rx_dma(struct uart_8250_port *p, unsigned int iir)
                break;
        }
 
+       if (priv->rx_dma_broken)
+               return -EINVAL;
+
        spin_lock_irqsave(&priv->rx_dma_lock, flags);
 
        if (dma->rx_running)
@@ -1207,6 +1214,11 @@ static int omap8250_probe(struct platform_device *pdev)
 
                        if (of_machine_is_compatible("ti,am33xx"))
                                priv->habit |= OMAP_DMA_TX_KICK;
+                       /*
+                        * pause is currently not supported atleast on omap-sdma
+                        * and edma on most earlier kernels.
+                        */
+                       priv->rx_dma_broken = true;
                }
        }
 #endif