Skip to content

Commit 7c4a509

Browse files
Zhiyong Taogregkh
authored andcommitted
serial: 8250_mtk: fix uart corruption issue when rx power off
Fix uart corruption issue when rx power off. Add spin lock in mtk8250_dma_rx_complete function in APDMA mode. when uart is used as a communication port with external device(GPS). when external device(GPS) power off, the power of rx pin is also from 1.8v to 0v. Even if there is not any data in rx. But uart rx pin can capture the data "0". If uart don't receive any data in specified cycle, uart will generates BI(Break interrupt) interrupt. If external device(GPS) power off, we found that BI interrupt appeared continuously and very frequently. When uart interrupt type is BI, uart IRQ handler(8250 framwork API:serial8250_handle_irq) will push data to tty buffer. mtk8250_dma_rx_complete is a task of mtk_uart_apdma_rx_handler. mtk8250_dma_rx_complete priority is lower than uart irq handler(serial8250_handle_irq). if we are in process of mtk8250_dma_rx_complete, uart appear BI interrupt:1)serial8250_handle_irq will priority execution.2)it may cause write tty buffer conflict in mtk8250_dma_rx_complete. So the spin lock protect the rx receive data process is not break. Signed-off-by: Zhiyong Tao <[email protected]> Cc: stable <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 06e91df commit 7c4a509

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/tty/serial/8250/8250_mtk.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,13 @@ static void mtk8250_dma_rx_complete(void *param)
9393
struct dma_tx_state state;
9494
int copied, total, cnt;
9595
unsigned char *ptr;
96+
unsigned long flags;
9697

9798
if (data->rx_status == DMA_RX_SHUTDOWN)
9899
return;
99100

101+
spin_lock_irqsave(&up->port.lock, flags);
102+
100103
dmaengine_tx_status(dma->rxchan, dma->rx_cookie, &state);
101104
total = dma->rx_size - state.residue;
102105
cnt = total;
@@ -120,6 +123,8 @@ static void mtk8250_dma_rx_complete(void *param)
120123
tty_flip_buffer_push(tty_port);
121124

122125
mtk8250_rx_dma(up);
126+
127+
spin_unlock_irqrestore(&up->port.lock, flags);
123128
}
124129

125130
static void mtk8250_rx_dma(struct uart_8250_port *up)

0 commit comments

Comments
 (0)