From patchwork Tue Oct 13 01:38:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 7380661 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 463ABBEEA4 for ; Tue, 13 Oct 2015 01:41:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6B637205DA for ; Tue, 13 Oct 2015 01:41:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 811C1205C6 for ; Tue, 13 Oct 2015 01:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932146AbbJMBkf (ORCPT ); Mon, 12 Oct 2015 21:40:35 -0400 Received: from mail-ob0-f174.google.com ([209.85.214.174]:33941 "EHLO mail-ob0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932225AbbJMBjY (ORCPT ); Mon, 12 Oct 2015 21:39:24 -0400 Received: by obbda8 with SMTP id da8so2594650obb.1; Mon, 12 Oct 2015 18:39:24 -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=frp2pxlEU155XcLlqDmaLttbqQn8po//sg62PudQl10=; b=iCBiAI0F5xXxHtgPl3pbUOOBGdPrk3d2Y1Y1t6Zr81uzLV/NA6pSRjNN4rniQOGoI9 L0EG2cve796HdaIBCKcL9Hd856sck/NcuyYRVtALFkBZEBw8JnkFh4TwuZZtx3nPW3Kv Nib127MrCIpypAtYYgz4+D95uV02Fqo6M1UTqMfaS5A+/jfRRYz2XTjZx9WnvmOZjDBe IVnWo3m8Va0m+WQHfRPaVuc+Qh/x7+aJ2iqcEQIf7KMUEf/ehhu2J4gh/hRef0yxYV/I lJkBVI3GzJFOvf0JWAM9c1JP9tg7LnEoYradH1lRNNa8umqm31QKsEvVc6auIjKwY8uK WSbA== X-Received: by 10.60.70.40 with SMTP id j8mr17402361oeu.78.1444700364124; Mon, 12 Oct 2015 18:39:24 -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 ta5sm320312obc.13.2015.10.12.18.39.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 18:39:23 -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 2/5] mtd: nand: omap2: Start dma request before enabling prefetch Date: Mon, 12 Oct 2015 20:38:55 -0500 Message-Id: <1444700338-27582-3-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1444700338-27582-1-git-send-email-fcooper@ti.com> References: <1444700338-27582-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 --- drivers/mtd/nand/omap2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c index 957c32f..94d11de 100644 --- a/drivers/mtd/nand/omap2.c +++ b/drivers/mtd/nand/omap2.c @@ -509,6 +509,9 @@ 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); + 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,9 +519,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;