]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
serial: sh-sci: Fix fallback to PIO in sci_dma_rx_complete()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 7 Jan 2019 16:23:19 +0000 (17:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Jan 2019 15:56:52 +0000 (16:56 +0100)
When submitting a DMA request fails in sci_dma_rx_complete(), the driver
tries to fall back to PIO, but that does not work: no more data will be
received, or the kernel will even crash.

Fix this similar as in (but not identical to) sci_submit_rx():
  - On SCIF, PIO cannot take over if any DMA transactions are pending,
    hence they must be terminated first.
  - All active cookies must be invalidated, else rx_timer_fn() may
    trigger a NULL pointer dereference.
  - Restarting the port is not needed, as it is already running, but
    serial port interrupts must be directed back from the DMA engine to
    the CPU.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sh-sci.c

index 4d814c30c4189b56041a1894dd25cfb2118d2331..891833315698b953113ff30b9541a06e6b52e9e2 100644 (file)
@@ -1337,8 +1337,9 @@ static void sci_dma_rx_complete(void *arg)
        dev_warn(port->dev, "Failed submitting Rx DMA descriptor\n");
        /* Switch to PIO */
        spin_lock_irqsave(&port->lock, flags);
-       s->chan_rx = NULL;
-       sci_start_rx(port);
+       dmaengine_terminate_async(chan);
+       sci_dma_rx_chan_invalidate(s);
+       sci_dma_rx_reenable_irq(s);
        spin_unlock_irqrestore(&port->lock, flags);
 }