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
6 From: Masahiro Yamada <yamada.masahiro@socionext.com>
8 commit cf51e4b9c34407bf0c3d9b582b7837e047e1df47 upstream.
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
16 Revive the register read-back, commenting why this is necessary.
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>
27 drivers/mtd/nand/raw/denali.c | 6 ++++++
28 1 file changed, 6 insertions(+)
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
35 iowrite32(DMA_ENABLE__FLAG, denali->reg + DMA_ENABLE);
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.
41 + ioread32(denali->reg + DMA_ENABLE);
43 denali_reset_irq(denali);
44 denali->setup_dma(denali, dma_addr, page, write);