45400204c4478192d1025421cb667140759aa18b
[openwrt/staging/pepe2k.git] /
1 From 3af7822df36e36b5a74d877df7654695c0e0d34a Mon Sep 17 00:00:00 2001
2 From: Jonathan Bell <jonathan@raspberrypi.com>
3 Date: Mon, 22 Jul 2024 15:27:51 +0100
4 Subject: [PATCH 1191/1215] spi: dw: don't immediately kill DMA transfers if an
5 error occurs
6
7 Disabling the peripheral resets controller state which has a dangerous
8 side-effect of disabling the DMA handshake interface while it is active.
9 This can cause DMA channels to hang.
10
11 The error recovery pathway will wait for DMA to stop and reset the chip
12 anyway, so mask further FIFO interrupts and let the transfer finish
13 gracefully.
14
15 Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
16 ---
17 drivers/spi/spi-dw-core.c | 13 ++++++++++++-
18 1 file changed, 12 insertions(+), 1 deletion(-)
19
20 --- a/drivers/spi/spi-dw-core.c
21 +++ b/drivers/spi/spi-dw-core.c
22 @@ -200,7 +200,18 @@ int dw_spi_check_status(struct dw_spi *d
23
24 /* Generically handle the erroneous situation */
25 if (ret) {
26 - dw_spi_reset_chip(dws);
27 + /*
28 + * Forcibly halting the controller can cause DMA to hang.
29 + * Defer to dw_spi_handle_err outside of interrupt context
30 + * and mask further interrupts for the current transfer.
31 + */
32 + if (dws->dma_mapped) {
33 + dw_spi_mask_intr(dws, 0xff);
34 + dw_readl(dws, DW_SPI_ICR);
35 + } else {
36 + dw_spi_reset_chip(dws);
37 + }
38 +
39 if (dws->host->cur_msg)
40 dws->host->cur_msg->status = ret;
41 }