]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.18.11/mtd-rawnand-denali-fix-a-race-condition-when-dma-is-kicked.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.18.11 / mtd-rawnand-denali-fix-a-race-condition-when-dma-is-kicked.patch
1 From cf51e4b9c34407bf0c3d9b582b7837e047e1df47 Mon Sep 17 00:00:00 2001
2 From: Masahiro Yamada <yamada.masahiro@socionext.com>
3 Date: Thu, 13 Sep 2018 14:58:49 +0900
4 Subject: mtd: rawnand: denali: fix a race condition when DMA is kicked
5
6 From: Masahiro Yamada <yamada.masahiro@socionext.com>
7
8 commit cf51e4b9c34407bf0c3d9b582b7837e047e1df47 upstream.
9
10 I thought the read-back of the DMA_ENABLE register was unnecessary
11 (at least it is working on my boards), then deleted it in commit
12 586a2c52909d ("mtd: nand: denali: squash denali_enable_dma() helper
13 into caller"). Sorry, I was wrong - it caused a timing issue on
14 Cyclone5 SoCFPGAs.
15
16 Revive the register read-back, commenting why this is necessary.
17
18 Fixes: 586a2c52909d ("mtd: nand: denali: squash denali_enable_dma() helper into caller")
19 Cc: <stable@vger.kernel.org>
20 Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
21 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
22 Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
23 Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26 ---
27 drivers/mtd/nand/raw/denali.c | 6 ++++++
28 1 file changed, 6 insertions(+)
29
30 --- a/drivers/mtd/nand/raw/denali.c
31 +++ b/drivers/mtd/nand/raw/denali.c
32 @@ -604,6 +604,12 @@ static int denali_dma_xfer(struct denali
33 }
34
35 iowrite32(DMA_ENABLE__FLAG, denali->reg + DMA_ENABLE);
36 + /*
37 + * The ->setup_dma() hook kicks DMA by using the data/command
38 + * interface, which belongs to a different AXI port from the
39 + * register interface. Read back the register to avoid a race.
40 + */
41 + ioread32(denali->reg + DMA_ENABLE);
42
43 denali_reset_irq(denali);
44 denali->setup_dma(denali, dma_addr, page, write);