From patchwork Thu Oct 15 17:37:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 7408681 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BDE0B9F443 for ; Thu, 15 Oct 2015 17:39:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CB231206BA for ; Thu, 15 Oct 2015 17:39:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2292206B5 for ; Thu, 15 Oct 2015 17:39:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753158AbbJORi7 (ORCPT ); Thu, 15 Oct 2015 13:38:59 -0400 Received: from mail-oi0-f45.google.com ([209.85.218.45]:35230 "EHLO mail-oi0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752229AbbJORhk (ORCPT ); Thu, 15 Oct 2015 13:37:40 -0400 Received: by oiev17 with SMTP id v17so2798924oie.2; Thu, 15 Oct 2015 10:37:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=61RRYc0ctYinRHON5RNDkECaPYS4m4W8zcRoh02mG0M=; b=fn9ckDzXe+sMdmSgvXf7GcDJSp4w9xRG3yQIqnzVIPGfn6ajVXj4NEbIzkHCA8raPA zEam6tV5sjs8cVYddCrI9AAxXWaZqE+QUzkLKCChSmHBViEbl9MKI5phX/+0fv1s6phc jdAfwPn4r/nnpcstdyC1U0AaG+D/wvDwxC10ayBWbJp5p9Q8Sme+eerUs7nw5qMZGjG0 u4GZc5mlCnVZ7rKyQfeXDfwhvNDZEFWAjIqjoy1vxZ2CeyCH5TX2Y96cPgGWco3fVHCs QfzuRyLOIt8tRc/wT24EEqMeOkubdCBq5qAT9maD22SzA2UL30G8WEB6Fyxgch9hHKYN Kebw== X-Received: by 10.202.216.8 with SMTP id p8mr6271064oig.65.1444930658973; Thu, 15 Oct 2015 10:37:38 -0700 (PDT) Received: from localhost.localdomain (pool-71-97-41-79.dllstx.fios.verizon.net. [71.97.41.79]) by smtp.gmail.com with ESMTPSA id l133sm6771574oia.19.2015.10.15.10.37.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Oct 2015 10:37:38 -0700 (PDT) From: Franklin S Cooper Jr To: linux-kernel@vger.kernel.org, rogerq@ti.com, devicetree@vger.kernel.org, linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org, nsekhar@ti.com, computersforpeace@gmail.com, dwmw2@infradead.org, tony@atomide.com Cc: Franklin S Cooper Jr Subject: [PATCH v2 2/5] mtd: nand: omap2: Start dma request before enabling prefetch Date: Thu, 15 Oct 2015 12:37:25 -0500 Message-Id: <1444930648-19313-3-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1444930648-19313-1-git-send-email-fcooper@ti.com> References: <1444930648-19313-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 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 an edma 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 --- V2 Changes: Moved comment 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 957c32f..1f58420 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -509,6 +509,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); @@ -516,10 +521,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));