From patchwork Thu Mar 23 00:18:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 95873 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp497719qgd; Wed, 22 Mar 2017 17:35:58 -0700 (PDT) X-Received: by 10.99.5.133 with SMTP id 127mr39376305pgf.8.1490229358248; Wed, 22 Mar 2017 17:35:58 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id g6si2519634pfk.140.2017.03.22.17.35.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 17:35:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@infradead.org; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org 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:References: In-Reply-To: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:List-Owner; bh=w13tnkK1/anKGp9rXCsg+tpY1k46p45nWtKr+Q+rtVE=; b=cb0fnv1t5u16sisiw0G8Dc17Ms 6S9WzMOMw2+91XrBbcPCrAWqmipW2J2nggrP8N7KVi3aU+qIqw35L7ejeeRppq/nN3UKfvVkGLR1z C6xHmSgXkL6oMWGbLSnCuEglR6p5Av486XoOZJePXeILpxoH0GlpAwg5/aARlRNmUO4IpmyCMtpBw 1ba2AAweRNtw2+oq+QbEqIQEBe7UKr2vHznaU3+zT+FADKgpddrQAJnaJETn5xwctX/VFimzMpfMa ZrUz6sgZ9LX/BRfunfr0JdCeHnBdzNc91Xct/ol5y1q8D0EuVj1nYXp/tzUEBKjcxWdDEBvnfR8TB DL7/qokw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqqjJ-00072e-2V; Thu, 23 Mar 2017 00:35:53 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqqj0-0006Ye-27 for linux-mtd@bombadil.infradead.org; Thu, 23 Mar 2017 00:35:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/cZ23fp1nl9rmQavNeqPGpBRXLOWOn6qvvsGhaEQnz4=; b=V0wWTIdBMFUL1r5KYeSGOeDWc fxrakOxD5TfY7QTzYTtay7HcshiurDEq8G8FqV/hM9SqITxBhBS7AVv6qyVTU+E7oIwg2doRrbsh3 caJ08wdUBlIL5+o76ta41mT/wKqKuwt9ps8RoJVFGRQABHLdSS9QFtRjKX9zgeEZKdt+30YsQdsEb zqd8oOSuaMX8mROucLwBKHKnxclkmqAdkj2S8owFmp/1crhAPtcItVwwAhazZzlRIF0uYhf/j5m9v O+2ZzxbbBQEQk1OiGOOl250fwZ8uYk28XnZ8iUKjCTVtlFl9ijQ9jSKO8MIXYEVuYit6ZJ6chySWj 5svcsdm/Q==; Received: from conuserg-09.nifty.com ([210.131.2.76]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqqTT-0001GT-AI for linux-mtd@lists.infradead.org; Thu, 23 Mar 2017 00:19:35 +0000 Received: from grover.sesame (FL1-111-169-71-157.osk.mesh.ad.jp [111.169.71.157]) (authenticated) by conuserg-09.nifty.com with ESMTP id v2N0I4c3008011; Thu, 23 Mar 2017 09:18:34 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v2N0I4c3008011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1490228315; bh=/cZ23fp1nl9rmQavNeqPGpBRXLOWOn6qvvsGhaEQnz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnUp8N9DSSzn+j7GCukxjuLJdRSJ4+NRs1Jbz0OFaoho1IzmlEc+PI7455I5hBWuU wQ3jqjQT+TAUHK/9a/z+1F7WezHUYziuxl5iSOLUCZIbgv0n8TGq+EHfziV9YoO+hX O/LxGSZhxxn/Y68ZTG/8PJzXGVL4MZBZ9BKmzu+8SpVbbOjqyPL3VHyy72eH4qG3XD PFsUcNhbiXWaYjby2lDZoeEQQYOHS0hLD/z/CzPDUTDzcfvIIWXGe0oE9RQ2djXzbk qXJ/njgKKYP/j3zk3TUP9JnwiEoUP+LnHJ7jt9VB3EWBSAp5YbOMwuySdNcm/3HbE0 atg5fURRX9Q/w== X-Nifty-SrcIP: [111.169.71.157] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [RESEND PATCH v2 51/53] mtd: nand: denali: skip driver internal bounce buffer when possible Date: Thu, 23 Mar 2017 09:18:00 +0900 Message-Id: <1490228282-10805-25-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490228282-10805-1-git-send-email-yamada.masahiro@socionext.com> References: <1490228282-10805-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170323_001931_934151_5D0171D3 X-CRM114-Status: GOOD ( 16.24 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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: laurent.monat@idquantique.com, Boris Brezillon , thorsten.christiansson@idquantique.com, Dinh Nguyen , Enrico Jorns , Artem Bityutskiy , Marek Vasut , Masahiro Yamada , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , David Woodhouse , Rob Herring , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org For ecc->read_page() and ecc->write_page(), it is possible to call dma_map_single() against the given buffer. This bypasses the driver internal bounce buffer and save the memcpy(). Signed-off-by: Masahiro Yamada --- Changes in v2: - Newly added drivers/mtd/nand/denali.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index c3a7f7b..4900745 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -601,12 +601,16 @@ static int denali_pio_xfer(struct denali_nand_info *denali, void *buf, static int denali_dma_xfer(struct denali_nand_info *denali, void *buf, size_t size, int page, int raw, int write) { - dma_addr_t dma_addr = denali->dma_addr; + dma_addr_t dma_addr; uint32_t irq_mask, irq_status, ecc_err_mask; enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE; int ret = 0; - dma_sync_single_for_device(denali->dev, dma_addr, size, dir); + dma_addr = dma_map_single(denali->dev, buf, size, dir); + if (dma_mapping_error(denali->dev, dma_addr)) { + dev_dbg(denali->dev, "Failed to DMA-map buffer. Trying PIO.\n"); + return denali_pio_xfer(denali, buf, size, page, raw, write); + } if (write) { irq_mask = INTR__DMA_CMD_COMP | INTR__PROGRAM_FAIL; @@ -632,7 +636,7 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf, ret = -EBADMSG; denali_enable_dma(denali, false); - dma_sync_single_for_cpu(denali->dev, dma_addr, size, dir); + dma_unmap_single(denali->dev, dma_addr, size, dir); if (irq_status & INTR__ERASED_PAGE) memset(buf, 0xff, size); @@ -807,12 +811,10 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip, int stat = 0; int ret; - ret = denali_data_xfer(denali, denali->buf, mtd->writesize, page, 0, 0); + ret = denali_data_xfer(denali, buf, mtd->writesize, page, 0, 0); if (ret && ret != -EBADMSG) return ret; - memcpy(buf, denali->buf, mtd->writesize); - if (denali->caps & DENALI_CAP_HW_ECC_FIXUP) stat = denali_hw_ecc_fixup(mtd, denali); else if (ret == -EBADMSG) @@ -924,10 +926,8 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip, { struct denali_nand_info *denali = mtd_to_denali(mtd); - memcpy(denali->buf, buf, mtd->writesize); - - return denali_data_xfer(denali, denali->buf, mtd->writesize, page, - 0, 1); + return denali_data_xfer(denali, (void *)buf, mtd->writesize, + page, 0, 1); } static void denali_select_chip(struct mtd_info *mtd, int chip) @@ -1363,15 +1363,8 @@ int denali_init(struct denali_nand_info *denali) } } - if (denali->dma_avail) { - denali->dma_addr = dma_map_single(denali->dev, denali->buf, - mtd->writesize + mtd->oobsize, - DMA_BIDIRECTIONAL); - if (dma_mapping_error(denali->dev, denali->dma_addr)) { - dev_info(denali->dev, "Failed to map DMA buffer. Disabling DMA.\n"); - denali->dma_avail = 0; - }; - } + if (denali->dma_avail) + chip->options |= NAND_USE_BOUNCE_BUFFER; /* * second stage of the NAND scan