Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp271982imm; Wed, 12 Sep 2018 23:01:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ/2UBQNPhgtQ2tNGmvJHSDk4OM874fD4EHncGZLNcOr2R9bVeVN0Y/fxbGXranazTg10Vj X-Received: by 2002:a62:cec6:: with SMTP id y189-v6mr5695044pfg.140.1536818487483; Wed, 12 Sep 2018 23:01:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536818487; cv=none; d=google.com; s=arc-20160816; b=eHkjDJCpGlPLnVJulW0dFhzU0SAXBKezdrJyTeNZgbOGOxlqu5gyEYvwNXL0+nPyUc v04+HoiLht8yci/Usubc8oAAGduoJ2f87oqwqPBwEsNzDPJPpN0MFbc93fIuTwCgtvfB 5+vZBirF61E965Uyq1Pji9BKnKoIjwdiNeFauvfq22/UKvz2K3soXQmbM+4abzEArs05 Qz5pLmzT6H6vd1Uhp1iRY68O3/zcOcCGRrruJ1D/zlidUxGG6Dr3R5Gwd9LaYmPzWhS1 rwXQgXounRVjKqWu4DFtsdP8gtR/gbCJweGKXHHeqAeLEBB14qGP2DxQs/zZquhDkIXQ xm0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=Zzz6TfVv4KOjT4SlS07cnGQiDxiJTQwq6CquERnGz1Y=; b=QOUtfucBjBv4Ux/bSqQe7SXus1wpFa8ATBK2C76mzMz+cTzTeqzXEv0YbgY9uFfT0c mpV51fET4eB/HDfGBACM27bopSY0+aC/ZUCJZN7BNS058VkIckc5qU5OFcmLh1OHKBWq 9PlRc6iQ6IujNpKYTpElDxtGziJVPOgff1pBeBwJig++1ShyIXYfH+FklhUbiuNWHj7f O8F0R/5ezfh98vz+pXgrBju4PFZJ6dODqxNMWabXOSeurfudHS+MQlZHAhaeL08cLXEz e+GMqux9Tl5RD+okY1Cyz4DK+agXvu4U3F/ipi7Qvo9/aJYNCqYuy5jiZHADl8CWQnao sIvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=edS5DDnB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x37-v6si3522612pgl.544.2018.09.12.23.01.10; Wed, 12 Sep 2018 23:01:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=edS5DDnB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726797AbeIMLJE (ORCPT + 99 others); Thu, 13 Sep 2018 07:09:04 -0400 Received: from conuserg-11.nifty.com ([210.131.2.78]:32912 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbeIMLJE (ORCPT ); Thu, 13 Sep 2018 07:09:04 -0400 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id w8D5wsjd002858; Thu, 13 Sep 2018 14:58:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com w8D5wsjd002858 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1536818335; bh=Zzz6TfVv4KOjT4SlS07cnGQiDxiJTQwq6CquERnGz1Y=; h=From:To:Cc:Subject:Date:From; b=edS5DDnBL8jPnK/UBkiK82hNjaZ8uEmzPtUArvhnKXF/6aPLzehcTql3eGBXpIFwM FiL4a+1MBNs4M0uVx0RrxmPjkYHdCY0VCQrhaqWSTDw+Txj7HdcpV5YgHy+vzG+Rdf WjNVrpjlkfjjonpxarD3YOto6FxiVMne7npQoj6TS/phh6vBY9kINpurK5YZusxaxl AvyLfPr46jZQBvth97R1bwjGnYO2nq6Y2JoUpITBj93GquWLkv+twtEUBA1Cttl1AA ZGTdErOqbRrbz3SMoI8Eu4ocfyHsBnXbSGoj1fCv3iAUVObULDeOPsFiHpmr5UET3O 7vUd1a5cucXYw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Boris Brezillon , Miquel Raynal Cc: Steffen Trumtrar , Masahiro Yamada , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , Richard Weinberger , David Woodhouse Subject: [PATCH] mtd: rawnand: denali: fix a race condition when DMA is kicked Date: Thu, 13 Sep 2018 14:58:49 +0900 Message-Id: <1536818329-11068-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I thought the read-back of the DMA_ENABLE register was unnecessary (at least it is working on my boards), then deleted it in commit 586a2c52909d ("mtd: nand: denali: squash denali_enable_dma() helper into caller"). Sorry, I was wrong - it caused a timing issue on Cyclone5 SoCFPGAs. Revive the register read-back, commenting why this is necessary. Fixes: 586a2c52909d ("mtd: nand: denali: squash denali_enable_dma() helper into caller") Reported-by: Steffen Trumtrar Signed-off-by: Masahiro Yamada --- drivers/mtd/nand/raw/denali.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 67b2065..b864b93 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -596,6 +596,12 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf, } iowrite32(DMA_ENABLE__FLAG, denali->reg + DMA_ENABLE); + /* + * The ->setup_dma() hook kicks DMA by using the data/command + * interface, which belongs to a different AXI port from the + * register interface. Read back the register to avoid a race. + */ + ioread32(denali->reg + DMA_ENABLE); denali_reset_irq(denali); denali->setup_dma(denali, dma_addr, page, write); -- 2.7.4