Patch "serial: tegra: avoid reg access when clk disabled" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    serial: tegra: avoid reg access when clk disabled

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     serial-tegra-avoid-reg-access-when-clk-disabled.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 00965a987eac2e9506fc8c3d98a0fd7a3f96d792
Author: Ahung Cheng <ahcheng@xxxxxxxxxx>
Date:   Wed Sep 4 10:12:57 2019 +0530

    serial: tegra: avoid reg access when clk disabled
    
    [ Upstream commit 494f79bd2365703e4093efa0ecf4b139d83aba97 ]
    
    This avoids two race conditions from the UART shutdown sequence both
    leading to 'Machine check error in AXI2APB' and kernel oops.
    
    One was that the clock was disabled before the DMA was terminated making
    it possible for the DMA callbacks to be called after the clock was
    disabled. These callbacks could write to the UART registers causing
    timeout.
    
    The second was that the clock was disabled before the UART was
    completely flagged as closed. This is done after the shutdown is called
    and a new write could be started after the clock was disabled.
    tegra_uart_start_pio_tx could be called causing timeout.
    
    Given that the baud rate is reset at the end of shutdown sequence, this
    fix is to examine the baud rate to avoid register access from both race
    conditions.
    
    Besides, terminate the DMA before disabling the clock.
    
    Signed-off-by: Ahung Cheng <ahcheng@xxxxxxxxxx>
    Signed-off-by: Shardar Mohammed <smohammed@xxxxxxxxxx>
    Signed-off-by: Krishna Yarlagadda <kyarlagadda@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/1567572187-29820-3-git-send-email-kyarlagadda@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Stable-dep-of: 109a951a9f1f ("serial: tegra: Read DMA status before terminating")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index ee480a1480e8..c113a0b1ece1 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -126,6 +126,8 @@ struct tegra_uart_port {
 
 static void tegra_uart_start_next_tx(struct tegra_uart_port *tup);
 static int tegra_uart_start_rx_dma(struct tegra_uart_port *tup);
+static void tegra_uart_dma_channel_free(struct tegra_uart_port *tup,
+					bool dma_to_memory);
 
 static inline unsigned long tegra_uart_read(struct tegra_uart_port *tup,
 		unsigned long reg)
@@ -440,6 +442,9 @@ static void tegra_uart_start_next_tx(struct tegra_uart_port *tup)
 	unsigned long count;
 	struct circ_buf *xmit = &tup->uport.state->xmit;
 
+	if (!tup->current_baud)
+		return;
+
 	tail = (unsigned long)&xmit->buf[xmit->tail];
 	count = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE);
 	if (!count)
@@ -803,6 +808,12 @@ static void tegra_uart_hw_deinit(struct tegra_uart_port *tup)
 	tup->current_baud = 0;
 	spin_unlock_irqrestore(&tup->uport.lock, flags);
 
+	tup->rx_in_progress = 0;
+	tup->tx_in_progress = 0;
+
+	tegra_uart_dma_channel_free(tup, true);
+	tegra_uart_dma_channel_free(tup, false);
+
 	clk_disable_unprepare(tup->uart_clk);
 }
 
@@ -1040,12 +1051,6 @@ static void tegra_uart_shutdown(struct uart_port *u)
 	struct tegra_uart_port *tup = to_tegra_uport(u);
 
 	tegra_uart_hw_deinit(tup);
-
-	tup->rx_in_progress = 0;
-	tup->tx_in_progress = 0;
-
-	tegra_uart_dma_channel_free(tup, true);
-	tegra_uart_dma_channel_free(tup, false);
 	free_irq(u->irq, tup);
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux