From patchwork Fri Apr 15 20:28:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 8858241 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 42D8EBF29F for ; Fri, 15 Apr 2016 20:29:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71F1B202A1 for ; Fri, 15 Apr 2016 20:29:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8BA7D20279 for ; Fri, 15 Apr 2016 20:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752359AbcDOU3Y (ORCPT ); Fri, 15 Apr 2016 16:29:24 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34238 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbcDOU3X (ORCPT ); Fri, 15 Apr 2016 16:29:23 -0400 Received: by mail-oi0-f65.google.com with SMTP id q133so15051053oib.1; Fri, 15 Apr 2016 13:29:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KKrYfw4jLsNfHD1ks/VKzpvsbqCE3CIbtex8Lbuuw+c=; b=hGzY7VbfI7lwvharjK58MUvVVqM/Is6Se78FMrEXCyR8E8Fdmbd3fPmP8w3mBNKP1T 38ryTHzrjz3yd3jmnI8pl/t5Ql0Ry7+yopwWhiGtwTUOy6K+S0YZlwARyiIXCUjq7pN2 bi1tEhdZbxophuGjOZQqOBj7fC/KMuzEJb814iwbBjhpqhpv+TtN0zCMNxsazQhz1u1P H1O5FwurtrW3l4r6YvoiquemnBKBBbwrqiQh+k2ppTm8z8PDYFfjGYwdrQG0a3DNds7j rVQYUUnlNfq/o/+pKP8Tp6DXuwGuZFWrnznJp39FtLQpJwV3NZkYqfPzODHwLNhKgf4R fGMw== X-Gm-Message-State: AOPr4FUIzLeABhSq5NU+QtKq6ocxzZ+1HfpGrMOZ0LqEqbrDKyg6Mvk8uDdkgHtZDdUn7w== X-Received: by 10.157.41.200 with SMTP id g8mr11644765otd.37.1460752161710; Fri, 15 Apr 2016 13:29:21 -0700 (PDT) Received: from beast-server.fios-router.home ([173.64.219.161]) by smtp.gmail.com with ESMTPSA id 71sm15279202otj.24.2016.04.15.13.29.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Apr 2016 13:29:15 -0700 (PDT) From: Franklin S Cooper Jr To: boris.brezillon@free-electrons.com, dwmw2@infradead.org, computersforpeace@gmail.com, tony@atomide.com, rogerq@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Cc: "Cooper Jr., Franklin" Subject: [PATCH 1/2] mtd: nand: omap2: Start dma request before enabling prefetch Date: Fri, 15 Apr 2016 15:28:58 -0500 Message-Id: <1460752139-12742-2-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1460752139-12742-1-git-send-email-fcooper@ti.com> References: <1460752139-12742-1-git-send-email-fcooper@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Cooper Jr., Franklin" The prefetch engine sends a dma request once a FIFO threshold has been met. No other requests are received until the previous request is handled. Starting a dma transfer (dma_async_issue_pending) results in any previous event for the dma channel to be cleared. Therefore, starting the prefetch engine before initiating the dma transfer may result in the prefetch triggering a dma request but instead of it being handled it can end up being cleared. This will result in a hang since the code will continue to wait for the dma request to complete. By initiating the dma request before enabling the prefetch engine this race condition is avoided and no dma request are missed/cleared. Signed-off-by: Franklin S Cooper Jr --- drivers/mtd/nand/omap2.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 0749ca1..762e0ed 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -497,6 +497,11 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, tx->callback_param = &info->comp; dmaengine_submit(tx); + init_completion(&info->comp); + + /* setup and start DMA using dma_addr */ + dma_async_issue_pending(info->dma); + /* configure and start prefetch transfer */ ret = omap_prefetch_enable(info->gpmc_cs, PREFETCH_FIFOTHRESHOLD_MAX, 0x1, len, is_write, info); @@ -504,10 +509,6 @@ static inline int omap_nand_dma_transfer(struct mtd_info *mtd, void *addr, /* PFPW engine is busy, use cpu copy method */ goto out_copy_unmap; - init_completion(&info->comp); - dma_async_issue_pending(info->dma); - - /* setup and start DMA using dma_addr */ wait_for_completion(&info->comp); tim = 0; limit = (loops_per_jiffy * msecs_to_jiffies(OMAP_NAND_TIMEOUT_MS));