From patchwork Thu Apr 26 15:41:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 905172 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=essensium.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="c4F9m1Q3"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=essensium-com.20150623.gappssmtp.com header.i=@essensium-com.20150623.gappssmtp.com header.b="PSGXmS8S"; 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 40X1m50mKFz9s08 for ; Fri, 27 Apr 2018 01:52:21 +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: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=LpYhMizurdYSM3OGjqFeyVfn5+iJY5lI4YiiqNrVFco=; b=c4F9m1Q356EId+JUlBLrNlfKdx ohX8dS887C8v+WSRGF4eEqHiZUsziDNJbQUnf6CYP2T5kmaMK273RyYcd4RuiA5MwC92xsHaU97ST MNo+zyCoe5ZPUGMuG6kemhiniQr3iAvCOXeARomzN+ZFd1oy51H4r9UsLGPZkmMnD0g5BeN8UhoHO whU9ui2rRiGgPL9AkgbJRmEHLGW+lJEBFmlkaIBnleWb8/3Dbtc4IbltTtuiEcEjlxjLfyvZmp7rz P2lln3mwNI67Yz0Qh7+06ui9mtMlBRXP+kwMT0eUwJZfW6kUC+lSU9WEzbwqrXSyP/j0iSx52VAua FhUrGymw==; 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 1fBjBr-0003yo-0h; Thu, 26 Apr 2018 15:52:11 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fBj2P-0005lM-0S for linux-mtd@lists.infradead.org; Thu, 26 Apr 2018 15:42:26 +0000 Received: by mail-wr0-x243.google.com with SMTP id v5-v6so6503064wrf.9 for ; Thu, 26 Apr 2018 08:42:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dlC1ntnZqo3xDZSc5/354Zpp8Tdp1PMgL4d8+TGsqow=; b=PSGXmS8Sj5dwfUUoEfWL9EK2j9EW4FWCPtG4X1Ne8RQMK/T8IReIdAlpmcAnZNyvuO laO8ZAvb+fwj7l3TFTBlo/e+8g0V4676/6pzF0azDiv9UoDBL/8s5Ji229Awux/YUgSb yVc1wdKXQ2KiKv5kXRYPOZVYUeCXUxxm0iyVkPGyCG/c+1Sn4k9fEe+M4EtTRu8mSOCX 5Q7tGieTJyuwj/Q30TLOUYrElWVc5aAMSiAouhizbCBHeY1U6Vnxd5RlWFSiHZnBU4Ql z+swp3F7m8M+SA+peUYbJLvnI18aFVjo7ZOeLdfdtubMese36IqFHN53B9k1i6BZ0NFg dz5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dlC1ntnZqo3xDZSc5/354Zpp8Tdp1PMgL4d8+TGsqow=; b=rXgdDdXNExcmRb6qJgiSTEBK6++WlJSQzdfF/aPO/QlckHnh8xLiVeBMIT56oZ/AO5 vctVKzJhwMbaISDVclAC3f3rUBVLWsock/xr/QXvS3XJTgTgVEICy5dWxlE61RRZMVP9 9LlIzYNEqTpJDzOwWxD4E9ZzJrMLqd2R0wEeoZJrQAMOCoAdI9UVRvxkmAr+ajTZ28Vt 7F/c4CYo9i2hDjMDtUbP56vrm4plIBigeX6rHpD/Fu2lPWz/gEiBPmze7qNee3Ig5IMt EvyqqigdgkaG5hrA3z9xzJ4gF/VhL98bRa3dAYA8EUr47d6tkTYL7z8/mg5lf/VE4R4p Erpg== X-Gm-Message-State: ALQs6tAmLLQN2SQi1+R0zVSw8fpkvxbeuNiYgPfHAQyYYutkGyVHHqAr BurM5BZXWua41pHkc2iwYMV9vQo0 X-Google-Smtp-Source: AIpwx48jASg2O2BFi7WWuGIzq0SenUsSm43M7g2PHI4NmyO7Di8sflp/4OsnDxwl4z+ZnvzweFU+lg== X-Received: by 2002:adf:992d:: with SMTP id x42-v6mr29314513wrb.145.1524757333020; Thu, 26 Apr 2018 08:42:13 -0700 (PDT) Received: from Darth.local.ess-mail.com (178-118-196-9.access.telenet.be. [178.118.196.9]) by smtp.gmail.com with ESMTPSA id n23-v6sm19916031wra.39.2018.04.26.08.42.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Apr 2018 08:42:12 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 12/13] mtd: rawnand: gpmi: issue two commands in a single DMA chain Date: Thu, 26 Apr 2018 17:41:33 +0200 Message-Id: <20180426154134.8270-13-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180426154134.8270-1-sam.lefebvre@essensium.com> References: <20180426154134.8270-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180426_084225_089828_4C8C2160 X-CRM114-Status: GOOD ( 16.06 ) 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 [2a00:1450:400c:c0c:0:0:0:243 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 -0.0 T_DKIMWL_WL_MED DKIMwl.org - Whitelisted Medium sender 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: Arnout Vandecapelle , Sam Lefebvre , Dries Staelens MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org gpmi_nand_command() may issue two commands. Instead of issuing them as separate DMAs, chain them together and issue only a single DMA. This removes one DMA interrupt and associated overhead. For full-page reads with ECC, it reduces the number of interrupts from 4 per page to 3 per page (2 DMA interrupts + 1 BCH interrupt). Signed-off-by: Sam Lefebvre Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 12 +++++++----- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 8 +++++--- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index 46b2208df30e..8f5a2a242228 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -549,12 +549,12 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip) } int gpmi_send_command(struct gpmi_nand_data *this, struct scatterlist *sgl, - unsigned int command_length) + unsigned int command_length, bool chain, bool start_dma) { struct dma_chan *channel = get_dma_chan(this); struct dma_async_tx_descriptor *desc; int chip = this->current_chip; - int ret; + int ret = 0; u32 pio[3]; /* [1] send out the PIO words */ @@ -568,7 +568,8 @@ int gpmi_send_command(struct gpmi_nand_data *this, struct scatterlist *sgl, pio[1] = pio[2] = 0; desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)pio, - ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); + ARRAY_SIZE(pio), DMA_TRANS_NONE, + chain ? DMA_PREP_INTERRUPT : 0); if (!desc) return -EINVAL; @@ -579,8 +580,9 @@ int gpmi_send_command(struct gpmi_nand_data *this, struct scatterlist *sgl, if (!desc) return -EINVAL; - /* [3] submit the DMA */ - ret = start_dma_without_bch_irq(this, desc); + if (start_dma) + /* [3] submit the DMA */ + ret = start_dma_without_bch_irq(this, desc); return ret; } diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 81accbf175bf..49599d6dd841 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -1163,11 +1163,12 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, break; } - /* This starts the DMA for the command and waits for it to finish. */ + /* Chain the two commands, start the DMA and wait for it to finish. */ if (this->command_length > 0) { sg_init_one(&this->cmd_sgl, this->cmd_buffer, this->command_length); dma_map_sg(this->dev, &this->cmd_sgl, 1, DMA_TO_DEVICE); - ret = gpmi_send_command(this, &this->cmd_sgl, this->command_length); + ret = gpmi_send_command(this, &this->cmd_sgl, this->command_length, + false, this->command_length2 == 0); if (ret) dev_err(this->dev, "Chip: %u, Error %d\n", this->current_chip, ret); @@ -1176,7 +1177,8 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, if (this->command_length2 > 0) { sg_init_one(&this->cmd_sgl2, this->cmd_buffer + 64, this->command_length2); dma_map_sg(this->dev, &this->cmd_sgl2, 1, DMA_TO_DEVICE); - ret = gpmi_send_command(this, &this->cmd_sgl2, this->command_length2); + ret = gpmi_send_command(this, &this->cmd_sgl2, this->command_length2, + this->command_length > 0, true); if (ret) dev_err(this->dev, "Chip: %u, Error %d\n", this->current_chip, ret); diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h index 9dc3dd16fa0b..a09ec300754f 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h @@ -189,7 +189,7 @@ void gpmi_dump_info(struct gpmi_nand_data *); int bch_set_geometry(struct gpmi_nand_data *); int gpmi_is_ready(struct gpmi_nand_data *, unsigned chip); int gpmi_send_command(struct gpmi_nand_data *, struct scatterlist *sgl, - unsigned int command_length); + unsigned int command_length, bool chain, bool start_dma); int gpmi_enable_clk(struct gpmi_nand_data *this); int gpmi_disable_clk(struct gpmi_nand_data *this); int gpmi_setup_data_interface(struct mtd_info *mtd, int chipnr,