From patchwork Thu Sep 13 05:58:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 969263 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=socionext.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NVMk8Nt6"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nifty.com header.i=@nifty.com header.b="edS5DDnB"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 429p011Cxzz9s4V for ; Thu, 13 Sep 2018 15:59:56 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=6OzWmj3IwaCR8/PHE2mNStTXK/XwaZeoqucu5/zmxCs=; b=NVM k8Nt6gZxXokdg3QFOz9zvBjCrosU/CTG2o7gOYrW7gJnffGSbZ+NDQGwoEZUYUOP+NYRBRc5gKsAO MhGgKe5HF5svgf4pegTByhCXQD/pMgy8l6OG6YVi/x+PnPcHuv8X3sNL6qLUvqGcm0UwUeyfHDfqq XISnFOC5rug7QqXkrbJGB2IpfUkDCI/2N72Dd5uYGb7G9AAt9DIyqQNDX6d5tuAhuEw5pAy9ZoxtL AXkp92DSIZ08ctvjDYLxPiC6N9H7aWwsfrIg8QiNtCme5CufGO5EKFx0jemxKgHNinhCBNuL3AqDA buQUDMKeoWs5mWxs+GPmN//3VhA2j6w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0KfN-0007bK-9P; Thu, 13 Sep 2018 05:59:49 +0000 Received: from conuserg-11.nifty.com ([210.131.2.78]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g0KfJ-0007aM-6N for linux-mtd@lists.infradead.org; Thu, 13 Sep 2018 05:59:47 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180912_225945_572948_8E668981 X-CRM114-Status: UNSURE ( 9.60 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [210.131.2.78 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Steffen Trumtrar , Marek Vasut , Richard Weinberger , linux-kernel@vger.kernel.org, Masahiro Yamada , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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 Reviewed-by: Miquel Raynal --- 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);