Skip to content

Commit f70c9d4

Browse files
Fan Wugregkh
authored andcommitted
serial: amba-pl011: synchronize DMA teardown
[ Upstream commit 4409154 ] dmaengine_terminate_all() does not wait for a running callback, so the TX callback can still touch the TX buffer after it is freed. The RX poll timer reads the RX buffers without the port lock. Switch to dmaengine_terminate_sync() and delete the RX timer before freeing the buffers. Fixes: ead76f3 ("ARM: 6763/1: pl011: add optional RX DMA to PL011 v2") Cc: stable <stable@kernel.org> Assisted-by: Codex:gpt-5.6 Signed-off-by: Fan Wu <fanwu01@zju.edu.cn> Link: https://patch.msgid.link/20260731085915.326775-4-fanwu01@zju.edu.cn Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [ changed upstream's `timer_delete_sync()` deletion to match this tree's `del_timer_sync()` spelling at the old call site ] Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 272df0f commit f70c9d4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/tty/serial/amba-pl011.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap)
11931193

11941194
if (uap->using_tx_dma) {
11951195
/* In theory, this should already be done by pl011_dma_flush_buffer */
1196-
dmaengine_terminate_all(uap->dmatx.chan);
1196+
dmaengine_terminate_sync(uap->dmatx.chan);
11971197
if (uap->dmatx.queued) {
11981198
dma_unmap_single(uap->dmatx.chan->device->dev,
11991199
uap->dmatx.dma, uap->dmatx.len,
@@ -1206,12 +1206,12 @@ static void pl011_dma_shutdown(struct uart_amba_port *uap)
12061206
}
12071207

12081208
if (uap->using_rx_dma) {
1209-
dmaengine_terminate_all(uap->dmarx.chan);
1209+
if (uap->dmarx.poll_rate)
1210+
timer_delete_sync(&uap->dmarx.timer);
1211+
dmaengine_terminate_sync(uap->dmarx.chan);
12101212
/* Clean up the RX DMA */
12111213
pl011_dmabuf_free(uap->dmarx.chan, &uap->dmarx.dbuf_a, DMA_FROM_DEVICE);
12121214
pl011_dmabuf_free(uap->dmarx.chan, &uap->dmarx.dbuf_b, DMA_FROM_DEVICE);
1213-
if (uap->dmarx.poll_rate)
1214-
del_timer_sync(&uap->dmarx.timer);
12151215
uap->using_rx_dma = false;
12161216
}
12171217
}

0 commit comments

Comments
 (0)