From patchwork Fri Apr 20 08:19:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901771 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="cerdaL0d"; 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="TKxh69ve"; 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 40S8MQ0ZDWz9s1w for ; Fri, 20 Apr 2018 18:36:02 +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=G9BnG1rv0vo2IIL6EczjefDfucjr2s3TReHEa6YRZD8=; b=cerdaL0dAJWn1sbEMPB1BnGGnd uJU59alMfa+kF1Xi02k9cTn1zwdc7qDDt5725CjDS1J+NKrKxIK/s+3gK/1Vl8jWk2pGuDmq+yY1W DAsT0Jtif4nCpEXe3X+mW7/v83cc3Qmb9QXupjeUyMv3u7gO+hEQv9CI4R9hW429joZooBi4YTaoR 4Deh6sOQhhUVZsFSFgLosz3am5Eggdf0f6TnOvZ1dkbe15mUza5cOjS8pGAOWom2GN0NJ/XWX5A3q 6Pamp2+bY8NuN8SN7AJvr8FoWZgfs9Jz6r6nLzocMFeohvFOsJcf0zproWkfaH4AsRqXhqd+lHaEa hMghkZ0g==; 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 1f9RWI-0005pu-Gx; Fri, 20 Apr 2018 08:35:50 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RMs-0007Vr-4l for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:08 +0000 Received: by mail-wr0-x242.google.com with SMTP id p18-v6so1480314wrm.1 for ; Fri, 20 Apr 2018 01:25:55 -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=Q3DkjsnwIgL+vb/BRhinZJHXjSCO0qjOVcdWv0riBsU=; b=TKxh69veeKZC4AstkRoNZESvAkYG7JrTt2gGbr4Mt6NTKbIVT5OlvkmorPXPcTvJby wgA+VTYx82YsM2xWsYUGQFaBU9v5uRQevpVbX4iUusMr1VzhYD1JmFUBIG8rZE55L++p vKSwbCOZXhSOPOaUEwNockZexv5k8hbA43DMVaDocTcW1S4VGrUjVudtIvyExfupsT4f aT5oWpMop80TxOVtJsNvCRRWiTwxpGzHqivTaQz88iUKj/N38d0VI0qJW+0Y1QexY99B 3eX0AiNcIECwMK424m2emSxG6VGwZvmkkMH4nTOODuPCPzqb9pP8F3yHqmb0UvyAUPGM LByw== 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=Q3DkjsnwIgL+vb/BRhinZJHXjSCO0qjOVcdWv0riBsU=; b=Qqj3OZ4OBar9Yt8DrQMAivJac85l8h1IZqabma5zbHyiQ4vfQz9mCuxXRDK8nVcDIw b6Bwz0a8qAqua6Gm09GFJUYoMsz8aBby2030unn7VoEiyj8mIicRd+xtkhjCckTc7z6d dmzirULEkSnBsBbMU2PMFNEyl0FFKAdBOEUoU/JWPJAJyv6FwPmb/+wFWY7gXJee6JSO IGuKXunW5Oa1iZAyZOiExE6L4FBRfGfAbYizajm5+h6hYSKz7ZXbXhjSGsh9P/3AN49D uTkhbr0W6RfF5B7fAuE47S8LcgKF1j+1CWnXlQ2p3Y072OqsshIwp5k7HBfxXRvrHLbA awDw== X-Gm-Message-State: ALQs6tBDQr0xZQ6XEsfLtwa0hEuuPiPrKE7s4DulBAtaiJG90Mev2CNM 633TbY8KMSMDULdVUpSW8knUgfuI X-Google-Smtp-Source: AIpwx4/aFTpkuZps0uQ/nq4HMoc5Ww3quVSQzmvqcTw1D5WP9ItfRuXnVYaQ6LLarTAz39exVgxQCQ== X-Received: by 10.28.48.14 with SMTP id w14mr1291399wmw.21.1524212753664; Fri, 20 Apr 2018 01:25:53 -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 e64sm1834235wmg.22.2018.04.20.01.25.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:25:52 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 01/18] mtd: nand: gpmi: drop dma_ops_type Date: Fri, 20 Apr 2018 10:19:29 +0200 Message-Id: <20180420081946.16088-2-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012606_232432_0CAE323C X-CRM114-Status: GOOD ( 15.78 ) 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:242 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sascha Hauer , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer The GPMI nand driver puts dma_ops_type in its private data struct. Based on the ops type the DMA callback handler unmaps previously mapped buffers. Instead of unmapping the buffers in the DMA callback handler, do this in the caller directly which waits for the DMA transfer to finish. This makes the whole dma_ops_type mechanism unnecessary. Signed-off-by: Sascha Hauer Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v2: also unmap the cmd_sgl, don't unmap in gpmi_read_page() (it's done in the bch interrupt handler). Sascha, in the future better test with CONFIG_DMA_API_DEBUG :-) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 36 +++++++++++++++++------------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 31 ++----------------------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 11 --------- 3 files changed, 23 insertions(+), 55 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index e94556705dc7..d479358758a0 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -544,19 +544,13 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip) return reg & mask; } -static inline void set_dma_type(struct gpmi_nand_data *this, - enum dma_ops_type type) -{ - this->last_dma_type = this->dma_type; - this->dma_type = type; -} - int gpmi_send_command(struct gpmi_nand_data *this) { struct dma_chan *channel = get_dma_chan(this); struct dma_async_tx_descriptor *desc; struct scatterlist *sgl; int chip = this->current_chip; + int ret; u32 pio[3]; /* [1] send out the PIO words */ @@ -586,8 +580,11 @@ int gpmi_send_command(struct gpmi_nand_data *this) return -EINVAL; /* [3] submit the DMA */ - set_dma_type(this, DMA_FOR_COMMAND); - return start_dma_without_bch_irq(this, desc); + ret = start_dma_without_bch_irq(this, desc); + + dma_unmap_sg(this->dev, sgl, 1, DMA_TO_DEVICE); + + return ret; } int gpmi_send_data(struct gpmi_nand_data *this) @@ -595,6 +592,7 @@ int gpmi_send_data(struct gpmi_nand_data *this) struct dma_async_tx_descriptor *desc; struct dma_chan *channel = get_dma_chan(this); int chip = this->current_chip; + int ret; uint32_t command_mode; uint32_t address; u32 pio[2]; @@ -624,8 +622,11 @@ int gpmi_send_data(struct gpmi_nand_data *this) return -EINVAL; /* [3] submit the DMA */ - set_dma_type(this, DMA_FOR_WRITE_DATA); - return start_dma_without_bch_irq(this, desc); + ret = start_dma_without_bch_irq(this, desc); + + dma_unmap_sg(this->dev, &this->data_sgl, 1, DMA_TO_DEVICE); + + return ret; } int gpmi_read_data(struct gpmi_nand_data *this) @@ -633,6 +634,7 @@ int gpmi_read_data(struct gpmi_nand_data *this) struct dma_async_tx_descriptor *desc; struct dma_chan *channel = get_dma_chan(this); int chip = this->current_chip; + int ret; u32 pio[2]; /* [1] : send PIO */ @@ -658,8 +660,14 @@ int gpmi_read_data(struct gpmi_nand_data *this) return -EINVAL; /* [3] : submit the DMA */ - set_dma_type(this, DMA_FOR_READ_DATA); - return start_dma_without_bch_irq(this, desc); + + ret = start_dma_without_bch_irq(this, desc); + + dma_unmap_sg(this->dev, &this->data_sgl, 1, DMA_FROM_DEVICE); + if (this->direct_dma_map_ok == false) + memcpy(this->upper_buf, this->data_buffer_dma, this->upper_len); + + return ret; } int gpmi_send_page(struct gpmi_nand_data *this, @@ -703,7 +711,6 @@ int gpmi_send_page(struct gpmi_nand_data *this, if (!desc) return -EINVAL; - set_dma_type(this, DMA_FOR_WRITE_ECC_PAGE); return start_dma_with_bch_irq(this, desc); } @@ -785,7 +792,6 @@ int gpmi_read_page(struct gpmi_nand_data *this, return -EINVAL; /* [4] submit the DMA */ - set_dma_type(this, DMA_FOR_READ_ECC_PAGE); return start_dma_with_bch_irq(this, desc); } diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index c2597c8107a0..864fda1901a6 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -472,31 +472,6 @@ static void dma_irq_callback(void *param) struct gpmi_nand_data *this = param; struct completion *dma_c = &this->dma_done; - switch (this->dma_type) { - case DMA_FOR_COMMAND: - dma_unmap_sg(this->dev, &this->cmd_sgl, 1, DMA_TO_DEVICE); - break; - - case DMA_FOR_READ_DATA: - dma_unmap_sg(this->dev, &this->data_sgl, 1, DMA_FROM_DEVICE); - if (this->direct_dma_map_ok == false) - memcpy(this->upper_buf, this->data_buffer_dma, - this->upper_len); - break; - - case DMA_FOR_WRITE_DATA: - dma_unmap_sg(this->dev, &this->data_sgl, 1, DMA_TO_DEVICE); - break; - - case DMA_FOR_READ_ECC_PAGE: - case DMA_FOR_WRITE_ECC_PAGE: - /* We have to wait the BCH interrupt to finish. */ - break; - - default: - dev_err(this->dev, "in wrong DMA operation.\n"); - } - complete(dma_c); } @@ -516,8 +491,7 @@ int start_dma_without_bch_irq(struct gpmi_nand_data *this, /* Wait for the interrupt from the DMA block. */ timeout = wait_for_completion_timeout(dma_c, msecs_to_jiffies(1000)); if (!timeout) { - dev_err(this->dev, "DMA timeout, last DMA :%d\n", - this->last_dma_type); + dev_err(this->dev, "DMA timeout, last DMA\n"); gpmi_dump_info(this); return -ETIMEDOUT; } @@ -546,8 +520,7 @@ int start_dma_with_bch_irq(struct gpmi_nand_data *this, /* Wait for the interrupt from the BCH block. */ timeout = wait_for_completion_timeout(bch_c, msecs_to_jiffies(1000)); if (!timeout) { - dev_err(this->dev, "BCH timeout, last DMA :%d\n", - this->last_dma_type); + dev_err(this->dev, "BCH timeout\n"); gpmi_dump_info(this); return -ETIMEDOUT; } diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h index 62fde59b995f..2397010a8963 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h @@ -77,15 +77,6 @@ struct boot_rom_geometry { unsigned int search_area_stride_exponent; }; -/* DMA operations types */ -enum dma_ops_type { - DMA_FOR_COMMAND = 1, - DMA_FOR_READ_DATA, - DMA_FOR_WRITE_DATA, - DMA_FOR_READ_ECC_PAGE, - DMA_FOR_WRITE_ECC_PAGE -}; - enum gpmi_type { IS_MX23, IS_MX28, @@ -178,8 +169,6 @@ struct gpmi_nand_data { /* DMA channels */ #define DMA_CHANS 8 struct dma_chan *dma_chans[DMA_CHANS]; - enum dma_ops_type last_dma_type; - enum dma_ops_type dma_type; struct completion dma_done; /* private */ From patchwork Fri Apr 20 08:19:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901774 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="sWh3Ghgf"; 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="ETFElpfE"; 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 40S8Pv70BCz9s7M for ; Fri, 20 Apr 2018 18:38:11 +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=GnsBZIXZCK88y3IssRASOtXPVmE/KzTiP/q0jxcYWkQ=; b=sWh3Ghgf2Otc2MX+iLZKe6WikE p6oVgLwPOhNlCDqOU51E/OVl6Z9s3WmDzOXe5sSp/CbRAHGqV03b8MC+E6Wkh0TSP0AvWbTV1Xn5S n9hWrj4QAP+T8LBdKNoBctVcon5OgtYGpSfMMLoUK9J3Rur0TrJmRYUCV/HeLUDfXa4Njolp3/E2f iS269KSQwUMZtOoINE20ZsedbpBSEqsIvaowzqI9PwGQ8KTgoKhjbrJe26YI/tOUmH2a7vSYMLflT zf8uhdWXHT6pXQGDOV6A+y96E+RsZAo7IA3mqUVBWZOJfTZBqQrkqXgmekzRRDzGdhvU+++WThqCK l1d8bB/g==; 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 1f9RYO-0007Bn-Vb; Fri, 20 Apr 2018 08:38:00 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RMt-0007Wh-Qp for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:11 +0000 Received: by mail-wr0-x241.google.com with SMTP id d1-v6so20637977wrj.13 for ; Fri, 20 Apr 2018 01:25:57 -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=g7sPWEjpQ3DevmWDCLJfCqFlRb9cdi6dNB4Ei3ZzIYU=; b=ETFElpfEfnxpVnfFiyGBsRHnSX/GtLuqbE/DDeA897ICAn1VG3YjL0928YxrvPop+K 0j2P7zmFeo2Za/OZZO2+r+qIg4CMhVu7p8INhIDHdwuMoVOQnqEnLZpUoddmEfLeKc1z S3D9V9s8KqCT8LGXIWUehUrlLj+H+gGlO41aV37g88ops4dUVRcg237bwUxDjYnx7UNS RewEtQ9PO3w8FqvZewpcpXMd624lQZC0oJHFcOst9z+dfpfg0DWpe7F2Pv/OjCGjEG32 8OKNPVDD8kxU49fWpyTl3LwAdzoCbO50wl+apo2AuFaUV2PvTiNN7IBo3RBRmBbUWx9Y OETg== 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=g7sPWEjpQ3DevmWDCLJfCqFlRb9cdi6dNB4Ei3ZzIYU=; b=c63Dief6tB36gpLrv8v20gQryy65NwTxxt2hVEwLbmTiHLvZFyGzhOvSWLYqrbybId 44wYFF5Nm3i+g5EwxQKait/pxxB9yjXQ/aTax2JMxkWrBa+dShTzp4VNSlsKYibVjBuM uRf8R+n+xmEUeapX68e3hXV2H3qxAIYDtmXvyXt3kADPir6vy2mytC3W1dR1Of2Tf9jE XousoTH6Teh0IiCDixkloObv5YVfHsaphpPbNKsjR8VqXsAzeo1Pm9jC2oPnDTZNiiFZ Or6Zi5RV8PaQ1qSo1/mraES5AHj0huoxzW7gxFUeZvR4lMoo+oTju6XstWDFHRxo3VQM H/8Q== X-Gm-Message-State: ALQs6tC1EE2cPg0HTb+c0RAvppUuCgtIu5q72Uik4E11WA7Qge55ZbvE RJU+Q0kTTSU9zWUTIxD+CQXnwWqh X-Google-Smtp-Source: AIpwx49PRjBHMCdPQ9DOIYsBZ4z7nVTsHlwbujE9APbavLqqulyfLMbHu5xJdS0t3i6fosQW0uXaNw== X-Received: by 10.28.7.76 with SMTP id 73mr1298559wmh.128.1524212755624; Fri, 20 Apr 2018 01:25:55 -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 e64sm1834235wmg.22.2018.04.20.01.25.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:25:54 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 02/18] mtd: nand: gpmi: pass buffer and len around Date: Fri, 20 Apr 2018 10:19:30 +0200 Message-Id: <20180420081946.16088-3-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012607_911348_796EADF8 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:241 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sascha Hauer , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer Instead of putting the buffer and len passed in from the mtd core into the private data struct, just pass it around in the GPMI drivers functions. This makes the lifetime of the variables more clear and the code easier to follow. Signed-off-by: Sascha Hauer Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v2: rebased --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 14 +++++++------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 20 ++++++++------------ drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 11 ++++------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index d479358758a0..447961b798b4 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -587,7 +587,7 @@ int gpmi_send_command(struct gpmi_nand_data *this) return ret; } -int gpmi_send_data(struct gpmi_nand_data *this) +int gpmi_send_data(struct gpmi_nand_data *this, const void *buf, int len) { struct dma_async_tx_descriptor *desc; struct dma_chan *channel = get_dma_chan(this); @@ -606,7 +606,7 @@ int gpmi_send_data(struct gpmi_nand_data *this) | BF_GPMI_CTRL0_CS(chip, this) | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) | BF_GPMI_CTRL0_ADDRESS(address) - | BF_GPMI_CTRL0_XFER_COUNT(this->upper_len); + | BF_GPMI_CTRL0_XFER_COUNT(len); pio[1] = 0; desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)pio, ARRAY_SIZE(pio), DMA_TRANS_NONE, 0); @@ -614,7 +614,7 @@ int gpmi_send_data(struct gpmi_nand_data *this) return -EINVAL; /* [2] send DMA request */ - prepare_data_dma(this, DMA_TO_DEVICE); + prepare_data_dma(this, buf, len, DMA_TO_DEVICE); desc = dmaengine_prep_slave_sg(channel, &this->data_sgl, 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -629,7 +629,7 @@ int gpmi_send_data(struct gpmi_nand_data *this) return ret; } -int gpmi_read_data(struct gpmi_nand_data *this) +int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len) { struct dma_async_tx_descriptor *desc; struct dma_chan *channel = get_dma_chan(this); @@ -643,7 +643,7 @@ int gpmi_read_data(struct gpmi_nand_data *this) | BF_GPMI_CTRL0_CS(chip, this) | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) | BF_GPMI_CTRL0_ADDRESS(BV_GPMI_CTRL0_ADDRESS__NAND_DATA) - | BF_GPMI_CTRL0_XFER_COUNT(this->upper_len); + | BF_GPMI_CTRL0_XFER_COUNT(len); pio[1] = 0; desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)pio, @@ -652,7 +652,7 @@ int gpmi_read_data(struct gpmi_nand_data *this) return -EINVAL; /* [2] : send DMA request */ - prepare_data_dma(this, DMA_FROM_DEVICE); + prepare_data_dma(this, buf, len, DMA_FROM_DEVICE); desc = dmaengine_prep_slave_sg(channel, &this->data_sgl, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -665,7 +665,7 @@ int gpmi_read_data(struct gpmi_nand_data *this) dma_unmap_sg(this->dev, &this->data_sgl, 1, DMA_FROM_DEVICE); if (this->direct_dma_map_ok == false) - memcpy(this->upper_buf, this->data_buffer_dma, this->upper_len); + memcpy(buf, this->data_buffer_dma, len); 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 864fda1901a6..5fa9cd4fac4a 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -437,15 +437,15 @@ struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) } /* Can we use the upper's buffer directly for DMA? */ -void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr) +void prepare_data_dma(struct gpmi_nand_data *this, const void *buf, int len, + enum dma_data_direction dr) { struct scatterlist *sgl = &this->data_sgl; int ret; /* first try to map the upper buffer directly */ - if (virt_addr_valid(this->upper_buf) && - !object_is_on_stack(this->upper_buf)) { - sg_init_one(sgl, this->upper_buf, this->upper_len); + if (virt_addr_valid(buf) && !object_is_on_stack(buf)) { + sg_init_one(sgl, buf, len); ret = dma_map_sg(this->dev, sgl, 1, dr); if (ret == 0) goto map_fail; @@ -456,10 +456,10 @@ void prepare_data_dma(struct gpmi_nand_data *this, enum dma_data_direction dr) map_fail: /* We have to use our own DMA buffer. */ - sg_init_one(sgl, this->data_buffer_dma, this->upper_len); + sg_init_one(sgl, this->data_buffer_dma, len); if (dr == DMA_TO_DEVICE) - memcpy(this->data_buffer_dma, this->upper_buf, this->upper_len); + memcpy(this->data_buffer_dma, buf, len); dma_map_sg(this->dev, sgl, 1, dr); @@ -919,10 +919,8 @@ static void gpmi_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) struct gpmi_nand_data *this = nand_get_controller_data(chip); dev_dbg(this->dev, "len is %d\n", len); - this->upper_buf = buf; - this->upper_len = len; - gpmi_read_data(this); + gpmi_read_data(this, buf, len); } static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) @@ -931,10 +929,8 @@ static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) struct gpmi_nand_data *this = nand_get_controller_data(chip); dev_dbg(this->dev, "len is %d\n", len); - this->upper_buf = (uint8_t *)buf; - this->upper_len = len; - gpmi_send_data(this); + gpmi_send_data(this, buf, len); } static uint8_t gpmi_read_byte(struct mtd_info *mtd) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h index 2397010a8963..fba72ad28263 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h @@ -141,10 +141,6 @@ struct gpmi_nand_data { int current_chip; unsigned int command_length; - /* passed from upper layer */ - uint8_t *upper_buf; - int upper_len; - /* for DMA operations */ bool direct_dma_map_ok; @@ -178,7 +174,7 @@ struct gpmi_nand_data { /* Common Services */ int common_nfc_set_geometry(struct gpmi_nand_data *); struct dma_chan *get_dma_chan(struct gpmi_nand_data *); -void prepare_data_dma(struct gpmi_nand_data *, +void prepare_data_dma(struct gpmi_nand_data *, const void *buf, int len, enum dma_data_direction dr); int start_dma_without_bch_irq(struct gpmi_nand_data *, struct dma_async_tx_descriptor *); @@ -197,8 +193,9 @@ int gpmi_disable_clk(struct gpmi_nand_data *this); int gpmi_setup_data_interface(struct mtd_info *mtd, int chipnr, const struct nand_data_interface *conf); void gpmi_nfc_apply_timings(struct gpmi_nand_data *this); -int gpmi_read_data(struct gpmi_nand_data *); -int gpmi_send_data(struct gpmi_nand_data *); +int gpmi_read_data(struct gpmi_nand_data *, void *buf, int len); +int gpmi_send_data(struct gpmi_nand_data *, const void *buf, int len); + int gpmi_send_page(struct gpmi_nand_data *, dma_addr_t payload, dma_addr_t auxiliary); int gpmi_read_page(struct gpmi_nand_data *, From patchwork Fri Apr 20 08:19:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901773 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="o5rsKoWj"; 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="zDyo48Da"; 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 40S8P44JKhz9s1w for ; Fri, 20 Apr 2018 18:37:28 +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=kt1gyrCe4BV8iJPAS0bKGmN4sJ9PWxljfwN/QhiqHrw=; b=o5rsKoWjO/90ytnWP65OItXVYS J4KuAVZh9aXxPvMah91AHgTYpEK1LuawbfDeXdoUQLuHUUBcaV2F69sQszszlf0aLoms8I4QXtnmy J88x8/lX0uvFhA0lwixi6KHlUzMlQXBbtIVDIIZuxkdfUrzKKCPXPrvwPQR3jS0McldHF/d4jXA/f lBr0peaPNma/YkHZJ1Tw4J/mwWIfBHflJniofT/nJMyN8Q2kWsC1e5c/I+xLpYLd33M0u8RzBAfTe lE9aD5imkUIX7XQPy7Twl13dJb+RbNjQ4Zlq2UVsp+8o+WrMiQD+mX6qkGwRyVlT60AdyQ7lc44NP 9K6u0YuQ==; 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 1f9RXi-0006dJ-7l; Fri, 20 Apr 2018 08:37:18 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RMv-0007Xn-Np for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:11 +0000 Received: by mail-wr0-x244.google.com with SMTP id o15-v6so20637079wro.11 for ; Fri, 20 Apr 2018 01:25:59 -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=Hl9SQU9QSrA1C9BYNXVvCGUF3Na6suF5hBr4PKMBXew=; b=zDyo48Da3W5sYMcS2tRHrfvWYX/mNm7wuQSE6OvdBlIFqYv5geLGAx4iYHNVkqNHkC pXr45f3f81NU+0H2FNXxAULfX2LJIzEAxCOja6q+y/Hhnlmj5S8gHMGQRj9ppZHX+r4t k6AZaztOsGorSj4JyGoYNeSEg/CK5I7EtBcAfjT2p+ruiGBGFv8Ik5VdTLTvWpYsSRdv rGe8UBX8d59+GYNB+DoEsmSk7/Vp11/a0zX7G82VreOzCMl6/4DTvqWtvo5DYqAjlUsm CssQDbAMu5+/NVPzYj76qA9Wqwziy/ihztfSolvGkoQLmtIcGB1fPBkRA6314nY8I5AU Uf5A== 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=Hl9SQU9QSrA1C9BYNXVvCGUF3Na6suF5hBr4PKMBXew=; b=l6ilIVPtFiSfbJYs2HJ15nL4e4o0eRZS8BG5IUuIJOzy/T+FQFFJjAcOCaFnmojmv9 x89nPxSlggTaJQp9i6H42PiVjXqGB+c8OojG/lElJWVth9w6SrNI7k4fGzwHqipk+3DF Cq6Vk2nhEkMPhXNTn17CJyJh49lyBP7+Il9fJRZui8jY2/EHUw1Qoi6GmC8N5zCEFTih IDLbzpMO2tnVoyMdjeYEqlV174ChngbB/YqZOr88Zbp1/sFKjzoaGgxCvSHwKkRFFQDb +6Tz6iBp4GBVOn//bHHYQOIRGyZtNSyogSR9dp2TRptCCWZ9JyzUa4tFNqfPhBfytCeH um2g== X-Gm-Message-State: ALQs6tDR7JxZQohMEZpB/CyqcvOowrpw84n0ot2/N7ZqfGSALtW+MMMv Wzi3SHJpHS6YRZMY5X9pkktL42h/ X-Google-Smtp-Source: AIpwx49PXwGhjS2mUUJVVawUpFqPBo0xD/wKJn1DNEXjnru+HUrSILLNfE2d0jLg11Tp25/v0nzr8g== X-Received: by 2002:adf:e14e:: with SMTP id f14-v6mr6564051wri.56.1524212757444; Fri, 20 Apr 2018 01:25:57 -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 e64sm1834235wmg.22.2018.04.20.01.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:25:56 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 03/18] mtd: nand: gpmi: put only once used functions inline Date: Fri, 20 Apr 2018 10:19:31 +0200 Message-Id: <20180420081946.16088-4-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012609_844990_9D141EB5 X-CRM114-Status: GOOD ( 15.03 ) 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:244 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sascha Hauer , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer read_page_prepare(), read_page_end() and read_page_swap_end() are trivial functions that are used only once and take 8 arguments each. De-obfuscate the code by open coding these functions in gpmi_ecc_read_page() Signed-off-by: Sascha Hauer Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v2: rebased --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 89 ++++++++---------------------- 1 file changed, 23 insertions(+), 66 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 5fa9cd4fac4a..774ac98fbdb2 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -668,56 +668,6 @@ static void release_resources(struct gpmi_nand_data *this) release_dma_channels(this); } -static int read_page_prepare(struct gpmi_nand_data *this, - void *destination, unsigned length, - void *alt_virt, dma_addr_t alt_phys, unsigned alt_size, - void **use_virt, dma_addr_t *use_phys) -{ - struct device *dev = this->dev; - - if (virt_addr_valid(destination)) { - dma_addr_t dest_phys; - - dest_phys = dma_map_single(dev, destination, - length, DMA_FROM_DEVICE); - if (dma_mapping_error(dev, dest_phys)) { - if (alt_size < length) { - dev_err(dev, "Alternate buffer is too small\n"); - return -ENOMEM; - } - goto map_failed; - } - *use_virt = destination; - *use_phys = dest_phys; - this->direct_dma_map_ok = true; - return 0; - } - -map_failed: - *use_virt = alt_virt; - *use_phys = alt_phys; - this->direct_dma_map_ok = false; - return 0; -} - -static inline void read_page_end(struct gpmi_nand_data *this, - void *destination, unsigned length, - void *alt_virt, dma_addr_t alt_phys, unsigned alt_size, - void *used_virt, dma_addr_t used_phys) -{ - if (this->direct_dma_map_ok) - dma_unmap_single(this->dev, used_phys, length, DMA_FROM_DEVICE); -} - -static inline void read_page_swap_end(struct gpmi_nand_data *this, - void *destination, unsigned length, - void *alt_virt, dma_addr_t alt_phys, unsigned alt_size, - void *used_virt, dma_addr_t used_phys) -{ - if (!this->direct_dma_map_ok) - memcpy(destination, alt_virt, length); -} - static int send_page_prepare(struct gpmi_nand_data *this, const void *source, unsigned length, void *alt_virt, dma_addr_t alt_phys, unsigned alt_size, @@ -1008,24 +958,33 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, int ret; dev_dbg(this->dev, "page number is : %d\n", page); - ret = read_page_prepare(this, buf, nfc_geo->payload_size, - this->payload_virt, this->payload_phys, - nfc_geo->payload_size, - &payload_virt, &payload_phys); - if (ret) { - dev_err(this->dev, "Inadequate DMA buffer\n"); - ret = -ENOMEM; - return ret; + + payload_virt = this->payload_virt; + payload_phys = this->payload_phys; + this->direct_dma_map_ok = false; + + if (virt_addr_valid(buf)) { + dma_addr_t dest_phys; + + dest_phys = dma_map_single(this->dev, buf, nfc_geo->payload_size, + DMA_FROM_DEVICE); + if (!dma_mapping_error(this->dev, dest_phys)) { + payload_virt = buf; + payload_phys = dest_phys; + this->direct_dma_map_ok = true; + } } + auxiliary_virt = this->auxiliary_virt; auxiliary_phys = this->auxiliary_phys; /* go! */ ret = gpmi_read_page(this, payload_phys, auxiliary_phys); - read_page_end(this, buf, nfc_geo->payload_size, - this->payload_virt, this->payload_phys, - nfc_geo->payload_size, - payload_virt, payload_phys); + + if (this->direct_dma_map_ok) + dma_unmap_single(this->dev, payload_phys, nfc_geo->payload_size, + DMA_FROM_DEVICE); + if (ret) { dev_err(this->dev, "Error in ECC-based read: %d\n", ret); return ret; @@ -1034,10 +993,8 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, /* Loop over status bytes, accumulating ECC status. */ status = auxiliary_virt + nfc_geo->auxiliary_status_offset; - read_page_swap_end(this, buf, nfc_geo->payload_size, - this->payload_virt, this->payload_phys, - nfc_geo->payload_size, - payload_virt, payload_phys); + if (!this->direct_dma_map_ok) + memcpy(buf, this->payload_virt, nfc_geo->payload_size); for (i = 0; i < nfc_geo->ecc_chunk_count; i++, status++) { if ((*status == STATUS_GOOD) || (*status == STATUS_ERASED)) From patchwork Fri Apr 20 08:19:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901777 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="qmvcQ+ay"; 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="iVmFVRJK"; 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 40S8Sv2w1nz9s1w for ; Fri, 20 Apr 2018 18:40:47 +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=L2Yhxtc2soAXM4l71smihTcTiCRmdMuPL8LFWp6bsTg=; b=qmvcQ+aycGYArIe65RBw53TY3K HMeP9RnzinRQreL08hYPRpeG2KhB0r0EyZ478lm2FtgEk3wJP9zuESKcTcoe6vjpSTLJskIJo3yzp EsDE4QFSWZk23+uAUzhZi6i/j+gcSVHCyS8ERSfErfqwPwPtGGM7lmkwrjnpfIjLvR8k/PEP4S0Dp GxQW45CjjzSsEe27OMVPa2wA0QmPvG7PsCim5MBvzphWf87gSQXeZ3PBpZF1EKh2Z42MJ8xLxVgAX Cibk8Yvdx+Whdi+w8k2RtmOd6eBNiemBIz3oikUiZfmqpNAsQqGFFW70infWQlZatFIt5Ti97TpGy HWaIXjYA==; 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 1f9Rax-000182-FA; Fri, 20 Apr 2018 08:40:39 +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 1f9RMx-0007Yq-1m for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:14 +0000 Received: by mail-wr0-x243.google.com with SMTP id d1-v6so20638434wrj.13 for ; Fri, 20 Apr 2018 01:26:00 -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=T/UpHikRE23uZCDhB1gwh6RJBE/g2blBrL5dXzNO0Ro=; b=iVmFVRJKqZlXLIOFStZOVuXXcZnO7QwwFowZB1pFEfQrn0PHvMnhhlXfMtXtfEX7BN MPb6wHVen6xikPxa9s9wf4JsRhbFrY2MWAgR7sD+okuKLBQUGciY0XTaQCFWmGkW/3hn 3WldDh3PvHndzawKJktLB4fD3BylvXmDIZDQzn18WqvguFflDf2qFuU9S3kfGozsYOzn znx80WEMTkhxZvZserZ/5hRseP3l8UANzkp2b0qGdDXEopia3Rh9El8a3U+6LXz6e3ks nm+EysXu3ryV70SgHovV9D5iqGnufOpiB0pYwQEFpozakRWURtW0rDLr2AguuYdVmq1l UJOQ== 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=T/UpHikRE23uZCDhB1gwh6RJBE/g2blBrL5dXzNO0Ro=; b=bdZ0l6ITvJ6ZuMnNPbuYl7QOTkqzZbl8GoSymYak0ZyBPSHkYQnkh1bQ5/WPprTKRM VNS7di5OgKbmHYvgFRuCPc0E55baGTJXaKKcItwT9flw1SBbwPJkImEH1XuS3jwLTJHG J+GUdWKKIpejQ0CNyZ4zSy4JjUL8i876RA2zZXfLhG4YrYvF4BC9QBfiCxXgzqFbrg+t hcsGttVRTPKqx+M/qJMPvGNPWEgen2iP3Sb5VcI70HBNXUhRE/3ZQ1oUVLOLI33bMiRl Hm8sBS8urgAhwdnSFe5ua4zyA+W/pvuPyusdTKvyoQvCZjFaH1WWBg0SYS68btMvsaln MvnQ== X-Gm-Message-State: ALQs6tCiF8yoGPyeCwwfFjCEd/qbpYk5YvJpMkf3fVjYZ02+iKL9lhJo 9vxgA5thorwZKLI14aBuA1zt0wqF X-Google-Smtp-Source: AIpwx4+GGMmmXrZ3UxqdbAKQq1pQcPNJqaiJChh3wqehGu2DfM+yPwpci0J4sQ+jH0d2ZGli8lM7MQ== X-Received: by 2002:adf:b88f:: with SMTP id i15-v6mr6710198wrf.163.1524212759101; Fri, 20 Apr 2018 01:25:59 -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 e64sm1834235wmg.22.2018.04.20.01.25.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:25:58 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 04/18] mtd: nand: gpmi: remove direct_dma_map_ok from driver data struct Date: Fri, 20 Apr 2018 10:19:32 +0200 Message-Id: <20180420081946.16088-5-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012611_158889_A60E47F2 X-CRM114-Status: GOOD ( 16.81 ) 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sascha Hauer , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer Instead of putting direct_dma_map_ok into driver struct pass it around between functions to make the code more readable. Signed-off-by: Sascha Hauer Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v2: rebased --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 5 +++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 15 +++++++-------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 5 +---- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index 447961b798b4..39834bedf460 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -636,6 +636,7 @@ int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len) int chip = this->current_chip; int ret; u32 pio[2]; + bool direct; /* [1] : send PIO */ pio[0] = BF_GPMI_CTRL0_COMMAND_MODE(BV_GPMI_CTRL0_COMMAND_MODE__READ) @@ -652,7 +653,7 @@ int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len) return -EINVAL; /* [2] : send DMA request */ - prepare_data_dma(this, buf, len, DMA_FROM_DEVICE); + direct = prepare_data_dma(this, buf, len, DMA_FROM_DEVICE); desc = dmaengine_prep_slave_sg(channel, &this->data_sgl, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -664,7 +665,7 @@ int gpmi_read_data(struct gpmi_nand_data *this, void *buf, int len) ret = start_dma_without_bch_irq(this, desc); dma_unmap_sg(this->dev, &this->data_sgl, 1, DMA_FROM_DEVICE); - if (this->direct_dma_map_ok == false) + if (!direct) memcpy(buf, this->data_buffer_dma, len); 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 774ac98fbdb2..9ecba7ea0cd5 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -437,7 +437,7 @@ struct dma_chan *get_dma_chan(struct gpmi_nand_data *this) } /* Can we use the upper's buffer directly for DMA? */ -void prepare_data_dma(struct gpmi_nand_data *this, const void *buf, int len, +bool prepare_data_dma(struct gpmi_nand_data *this, const void *buf, int len, enum dma_data_direction dr) { struct scatterlist *sgl = &this->data_sgl; @@ -450,8 +450,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, const void *buf, int len, if (ret == 0) goto map_fail; - this->direct_dma_map_ok = true; - return; + return true; } map_fail: @@ -463,7 +462,7 @@ void prepare_data_dma(struct gpmi_nand_data *this, const void *buf, int len, dma_map_sg(this->dev, sgl, 1, dr); - this->direct_dma_map_ok = false; + return false; } /* This will be called after the DMA operation is finished. */ @@ -956,12 +955,12 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, unsigned char *status; unsigned int max_bitflips = 0; int ret; + bool direct = false; dev_dbg(this->dev, "page number is : %d\n", page); payload_virt = this->payload_virt; payload_phys = this->payload_phys; - this->direct_dma_map_ok = false; if (virt_addr_valid(buf)) { dma_addr_t dest_phys; @@ -971,7 +970,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, if (!dma_mapping_error(this->dev, dest_phys)) { payload_virt = buf; payload_phys = dest_phys; - this->direct_dma_map_ok = true; + direct = true; } } @@ -981,7 +980,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, /* go! */ ret = gpmi_read_page(this, payload_phys, auxiliary_phys); - if (this->direct_dma_map_ok) + if (direct) dma_unmap_single(this->dev, payload_phys, nfc_geo->payload_size, DMA_FROM_DEVICE); @@ -993,7 +992,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, /* Loop over status bytes, accumulating ECC status. */ status = auxiliary_virt + nfc_geo->auxiliary_status_offset; - if (!this->direct_dma_map_ok) + if (!direct) memcpy(buf, this->payload_virt, nfc_geo->payload_size); for (i = 0; i < nfc_geo->ecc_chunk_count; i++, status++) { diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h index fba72ad28263..6aa10d6962d6 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h @@ -141,9 +141,6 @@ struct gpmi_nand_data { int current_chip; unsigned int command_length; - /* for DMA operations */ - bool direct_dma_map_ok; - struct scatterlist cmd_sgl; char *cmd_buffer; @@ -174,7 +171,7 @@ struct gpmi_nand_data { /* Common Services */ int common_nfc_set_geometry(struct gpmi_nand_data *); struct dma_chan *get_dma_chan(struct gpmi_nand_data *); -void prepare_data_dma(struct gpmi_nand_data *, const void *buf, int len, +bool prepare_data_dma(struct gpmi_nand_data *, const void *buf, int len, enum dma_data_direction dr); int start_dma_without_bch_irq(struct gpmi_nand_data *, struct dma_async_tx_descriptor *); From patchwork Fri Apr 20 08:19: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: 901775 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="tdAq40DD"; 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="Vzyt+ilJ"; 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 40S8Qn65Cvz9s1w for ; Fri, 20 Apr 2018 18:38:57 +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=FlCdgahE9dKhL8KLU/9KW0twXCvqJgpNnk6PHpynzb8=; b=tdAq40DDwrimz5wW+BxB6eh66I cXjfngLJ1alhkPYUtK8aWtojYqhd4LVct6yIFpVzCoRG3gn7+UbDeuCiVZb9bLkP5pq42U7QTUgDd SCCXeHpPgviyUL6i75Npty1/s99ycAbvNPeZOoh9s6+N+Q8hdP35cY3VutAcxM167MRKz/tA4J48F LvXfgWL+SxZ/tHxbp0+HVEe9Fl30B3GRdF3eHO48LG0jeeS+C2Zir+CPYGJSUlLmyzoydbzz3bkaH h7mM4/Ed/ngii2kaeFwlcIoFxukPIZucZf3zoYWsoJHn86uOCmOXdLliVbvmMton/EwjZIdtO6XOL L00fvQ3w==; 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 1f9RZ8-0007Vp-Su; Fri, 20 Apr 2018 08:38:46 +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 1f9RMx-0007Zw-1i for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:14 +0000 Received: by mail-wr0-x243.google.com with SMTP id u11-v6so20624234wri.12 for ; Fri, 20 Apr 2018 01:26:02 -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=SGekFQ02Jb2f1MGEXDmz7SUTlE2cwAAgljJr2WU7fT4=; b=Vzyt+ilJRzpOcuQCrY0rvEJ0UUQ36PkkhFsqLwlp1mU0MO7qIdtvl6GcmhAI5gt+nx JBlrvZ0kZRUj+D0F4AFRQJCWDEBXS9l9C7dhE1flTIdK+4qmdIqeY8qo62tKZdxnq86t 7TN8+PtW0wS2i9gwYwCL6/87j68BoXcsc/utJ1yCBBt/nPlENTdii0OdUdBXJdx6qfa9 tF5ZeINzXMvhUaBmCWjXHkU6mZ9ICB+pDZ35IGb+pt+q3XCWJsHP0lGwCML5OsXC5yoa 3WGT8sJBL456JLcQSeHqetjIyzWRXpph7efPparX+TcUYcgKSYcIbHABnekmJ9MOzftb G5PA== 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=SGekFQ02Jb2f1MGEXDmz7SUTlE2cwAAgljJr2WU7fT4=; b=s1jhUa9BOL93MLS1+pRofHuTE7GZpa3MhN+LlBAUbx+JcTADvtVrWiVDB/BKsk69Ex l5e5EFmHw7IufUhPw1gl3dJ+CA03GlxrIJRPWc8fJa/q52HbrIrOE/aBT3SaZid+CPm3 jqnrnoeg9VaFi+aJujx6jXbusON1wKPrH3A9gyrEPEF7KYfD9y3yCTpcW2f60qkFzAWJ 7U8HgeavrQxzxCmy8mDXLArwGZ6bdkeZC/PqeSJVxdRX7WU02ojfYKfl1SVZOubn7/OC SJHw6HjCXrkjAWgZtViWh2Ofyn+FziC6czDSa/tsbzQMGNE/9jwN4yuFTWzHGhtywyxp GevQ== X-Gm-Message-State: ALQs6tDMEdfrdg+0enDA3oNcarXUQzDxGn5nQ+zEbZRRiJxHRCbOAwn9 WNHC3cCGsD1OQh/XugjmpybbjfJs X-Google-Smtp-Source: AIpwx487QTN6cfRy/nXWus5rQ2gZWnJp/Q3OVso8vKK89J0TiA1oCgF/wT9utPAcKF9heeFCNHEXpQ== X-Received: by 10.28.97.139 with SMTP id v133mr1310864wmb.75.1524212760675; Fri, 20 Apr 2018 01:26:00 -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 e64sm1834235wmg.22.2018.04.20.01.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:25:59 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 05/18] mtd: nand: gpmi: return valid value from bch_set_geometry() Date: Fri, 20 Apr 2018 10:19:33 +0200 Message-Id: <20180420081946.16088-6-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012611_148915_4F05333E X-CRM114-Status: GOOD ( 13.52 ) 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sascha Hauer , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer The caller of bch_set_geometry() expects the return value to be an error code, so !0 is not valid. return the error from the just called function instead. Signed-off-by: Sascha Hauer Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v2: rebased --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index 39834bedf460..83697b8df871 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -258,8 +258,9 @@ int bch_set_geometry(struct gpmi_nand_data *this) unsigned int gf_len; int ret; - if (common_nfc_set_geometry(this)) - return !0; + ret = common_nfc_set_geometry(this); + if (ret) + return ret; block_count = bch_geo->ecc_chunk_count - 1; block_size = bch_geo->ecc_chunk_size; From patchwork Fri Apr 20 08:19:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901772 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="SghZK04y"; 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="XQp1c4zO"; 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 40S8NB25nCz9s1w for ; Fri, 20 Apr 2018 18:36:42 +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=zhKkC4s2wwC13HPAVFSN71ZBBSM5+0AKP25hoIPJE8M=; b=SghZK04yymTY54P2CGz7s0LN1K rk/mJLHthRV+bKaUNhfWg8k/6BM7f/MApatQ0/z/P/SbzE2tfInJjkoF3R9a/ZWEL/VPRKMBp5MkJ 6YUSbVdj0Mu7gUrhA/m2ZrQC1IitlZW/iEEMeGWtcLapRLQ/NBZi+RFyK10BNWfKMhBgexKDiol27 E3YeeYTGmfNOtrjhVEyymbwWwk+7btRqu13d7bDOJMm8oYJnPEKF8QynoQWer5SvE0D0ptVyxxArK ZKS5IZch7QrWyAzPNPb7R9N7VplUnehgH2FymkYWj/wucf23KTcbb8hkWrAjpqdj4lhu4aSGb+wHE 28ujJing==; 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 1f9RWy-00067m-Go; Fri, 20 Apr 2018 08:36:32 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RMt-0007as-Q6 for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:09 +0000 Received: by mail-wr0-x241.google.com with SMTP id p18-v6so1481420wrm.1 for ; Fri, 20 Apr 2018 01:26:04 -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=O4tL3lNcneIdb7NLUWzz2/NAU1oYkS00QTarZLM+R18=; b=XQp1c4zOBKvZOuEeXeUIX6bfzsEoHCH7wMJI3Yc+FFxWZdP6tVpiEs+PctqVeBLFpP 1Iu8Rfsk9olctGZ77qPL/JFh/3QHWKW0UDytL3ltjzSWUjmS3VDqhznjK7O4jak0s/S8 RLEryFgs8mFu4N5sHEm1i8uSm/PWtzC0tH/m0PN9rgbtvFXj1C+W7gPgZnX4mDiqG+Me JbfNkNRGEHUs+YuYDig8qGV9dLcfSe6lHSrCHF7IGo2MpfiJC4Krs9PlYHDQ4qrb0qW7 fYLdUyWV01MMF7Xopr4AooUeiVIpW/YMKtawMSTpLVn0qWPPUkw7yuGxHlRhAMQiV6zP Mn4Q== 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=O4tL3lNcneIdb7NLUWzz2/NAU1oYkS00QTarZLM+R18=; b=n1gEiINom7nvWqigdemgqwMoMPKSVweCxMMW3WXEHKLhQKEC+Mz3eQ8/FzmJfk+uad V5tzyYy3fUJEUWG7PW0shBHOfA8M+rHANN69DstIt9fj4fpbLq4HB6Ic+g0tQjl21hss 46DPYlgxuidTAKCILd5uVqyMAeNNZKbyEEJUpxtMa+EtOmDyzvZ3nOR3T3llw8I9ymt8 O1+FGH7oJYAAf0kDD+iOstM/Lk6b8ypRDhQO6arsxthPUlFUa+lO2r/MA4k8XwJnAYX1 UJIPy41WGf+wRieYaIYaWHtpBMY2kSHGmkb1pZckbK0SHsaAcWxXoczpKLXSK2EMXGAo CFWw== X-Gm-Message-State: ALQs6tD9x9olnxkuGea1DnMoV3mGSTiCnDnOTNEli7G3zPBrAtuSHOTN rKVLyo4OL0l5St/BASEdKrVZ/wDD X-Google-Smtp-Source: AIpwx4+osj4RsdM1VLRBG2u6NXnmV6b6z4GsvFuSVbAaqMyMU2RdI9k88yG0iwrv6ekV37kTgfLRTg== X-Received: by 2002:adf:e092:: with SMTP id c18-v6mr5363809wri.70.1524212762430; Fri, 20 Apr 2018 01:26:02 -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 e64sm1834235wmg.22.2018.04.20.01.26.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:01 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 06/18] mtd: nand: gpmi: remove unnecessary variables Date: Fri, 20 Apr 2018 10:19:34 +0200 Message-Id: <20180420081946.16088-7-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012607_868931_2943F948 X-CRM114-Status: GOOD ( 12.87 ) 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:241 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sascha Hauer , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Sascha Hauer Use this->auxiliary_virt and this->auxiliary_phys directly rather than creating extra local variables for them. Signed-off-by: Sascha Hauer Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v2: rebased --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 9ecba7ea0cd5..7ba00b8ab288 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -949,8 +949,6 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, struct mtd_info *mtd = nand_to_mtd(chip); void *payload_virt; dma_addr_t payload_phys; - void *auxiliary_virt; - dma_addr_t auxiliary_phys; unsigned int i; unsigned char *status; unsigned int max_bitflips = 0; @@ -974,11 +972,8 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, } } - auxiliary_virt = this->auxiliary_virt; - auxiliary_phys = this->auxiliary_phys; - /* go! */ - ret = gpmi_read_page(this, payload_phys, auxiliary_phys); + ret = gpmi_read_page(this, payload_phys, this->auxiliary_phys); if (direct) dma_unmap_single(this->dev, payload_phys, nfc_geo->payload_size, @@ -990,7 +985,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, } /* Loop over status bytes, accumulating ECC status. */ - status = auxiliary_virt + nfc_geo->auxiliary_status_offset; + status = this->auxiliary_virt + nfc_geo->auxiliary_status_offset; if (!direct) memcpy(buf, this->payload_virt, nfc_geo->payload_size); @@ -1048,7 +1043,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, buf + i * nfc_geo->ecc_chunk_size, nfc_geo->ecc_chunk_size, eccbuf, eccbytes, - auxiliary_virt, + this->auxiliary_virt, nfc_geo->metadata_size, nfc_geo->ecc_strength); } else { @@ -1076,7 +1071,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, } /* handle the block mark swapping */ - block_mark_swapping(this, buf, auxiliary_virt); + block_mark_swapping(this, buf, this->auxiliary_virt); if (oob_required) { /* @@ -1090,7 +1085,7 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, * the block mark. */ memset(chip->oob_poi, ~0, mtd->oobsize); - chip->oob_poi[0] = ((uint8_t *) auxiliary_virt)[0]; + chip->oob_poi[0] = ((uint8_t *)this->auxiliary_virt)[0]; } return max_bitflips; From patchwork Fri Apr 20 08:19:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901791 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="WX5cxFvX"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="X/c5s/6e"; 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="a2/5+fFl"; 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 40S8gK4GQ0z9s7M for ; Fri, 20 Apr 2018 18:49:49 +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=dCvIHVlM5sd2TcPAztJGaYclUrBuw08MMi75eG3h2x8=; b=WX5cxFvXV+9wvM+ZvjiJcmkTWE mHSWFL0EARQVBE8JrF4bIUmntlRG4ZijRFQ3grPoUb7V3h8vxPrPqrmxoPU2Rbdp0sgLpW6oTuMQx 6Z3ghs0iwQLJGYbUrNkPbtc/Mi0z85jRcSipBO4ok7xtXPkmzUA6kWB53JtTRZK2QWZc+nXpiKM/n K+5ak8TnGNQZT6v/AYCPaxzAx5NOmuXJilBRd3ic7+vAL4pOC7tFScCGTNKT15TKn/SDTjv4VL6kX Yvofa/5eZHI0r1tAKr9YN3v3NwKKnZphUoyChJhUDNoNCLhu+KJp70AcKS/k+hk//O9jDDpl/3FMF ufDrrdpA==; 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 1f9Rjk-0006PW-7m; Fri, 20 Apr 2018 08:49:44 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9Rau-00082X-Bf for linux-mtd@bombadil.infradead.org; Fri, 20 Apr 2018 08:40:36 +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=eFKva//O8Uus0IEfBmSoX0Ac9A2neDyVi6GxfUFIrPQ=; b=X/c5s/6e47cNNZyPtH9SrOguL OFQREscm+qTe61Lfkjqpotw2w+UssKRm8jfXnFD4Yt/VN+zLM0F6kEj6ncMZ/lYdiUxipaU+JWStw cvOkIOLChEruYVir/muqyQoo5ZoWyylJ/3sdNItAQosSio/np+2pxICxJ95XKB9ywW2G+2UE8MhdE jpU3s5Bv8o5OF0HtLywa1ev5hZG+HZQ6KsVa6iH45+f+gP5lgLiT3HAvFW5TUB5x+g90BMD1rUEAx xbdHy9O30LN9IPuJyv+CZAR3TWDAtFFkXX2LX8geMK0Ah9T8evh8WFKUdbB5LtmYFRYz0wvuDY2b+ 8PC35W+wQ==; Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RN2-0001G9-7a for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:18 +0000 Received: by mail-wr0-x242.google.com with SMTP id q3-v6so10625372wrj.6 for ; Fri, 20 Apr 2018 01:26:05 -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=eFKva//O8Uus0IEfBmSoX0Ac9A2neDyVi6GxfUFIrPQ=; b=a2/5+fFlITL21MGgwPgDL6pf8CIcwPF671z16YlpbmWj6wudPyK0bD2k2hs5BPYe9N hLHbTZQqunYzShjWYC/N0wEzGNt5A2eYQ3pNPPWn9xBJUpskw/fFn2ibq5ifjEhu5/zm OoVAgsV140R14UC7HYNMRBh3WvYlleb24ojEYHFbEVO1CKvcwX+5hv66E5+kisODOv9E +qCJx9GVNjV8kCWlzenVaFyhBDOjrS8MB4yumBD+0UzJVHKiA4i2FhX0e+hFJB7O95z7 DD7d0oOIYXlEZb1cThBuKu11NXbyjyqUyUqUHNfWACrAoX35BX0mgMghY5RgEfTT85K5 +9cA== 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=eFKva//O8Uus0IEfBmSoX0Ac9A2neDyVi6GxfUFIrPQ=; b=q47+2GEAVxf2NiKJ3aGNoMy9x2S6u1izVjrFl8ibRkTl1gKs4XUx7gkEnK+1XA4np7 NVP2QQV3ByTIpGJZ2XfNLXjX6mZXMqwZWq2IQRo9G1PYXYgWDSwf8m0fkJoAV/d14rU9 pPq5adDcxsWblN2kKUZiG52Ei2gnLqvaN01OZ6fum/eKZyHyQivBbEIeBilMYDyuXZ8O sXGeJzfVkh4woUp/OgHUE8fNSYp4GfY5NKX4wnYHk5kzgZTUh8CCeg+GMkYAN5xDvEN7 VkzjqAG5vsm6hK+WFZa2usaqrJk33CJGKd9BcwmTVOfNIElvEpAzOzw0W+QHhU/OztH+ 5aRw== X-Gm-Message-State: ALQs6tD8FeIQzj743SkmxM3QoFHHTbbhmB6C039DtUrfbJGQLB7DsYyn 3475bbkCx0xIm2olQdp0FR4/EAdt X-Google-Smtp-Source: AIpwx4+pMoTzfkaBMibvjp7QlXgHyFYKKFMNddRxeXdWjvsAY7/PLk8W+dN5bNcvCNJdKwnPImJyRQ== X-Received: by 2002:adf:8ac5:: with SMTP id z5-v6mr6893551wrz.22.1524212764206; Fri, 20 Apr 2018 01:26:04 -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 e64sm1834235wmg.22.2018.04.20.01.26.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:03 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 07/18] mtd: rawnand: gpmi: return generated errors in gpmi_ecc_read_oob() Date: Fri, 20 Apr 2018 10:19:35 +0200 Message-Id: <20180420081946.16088-8-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_092616_303131_494F364B X-CRM114-Status: GOOD ( 14.49 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) 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:242 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: Han Xu , Sam Lefebvre MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Errors can be generated by nand_read_page_op(). It's important to check the error flags and pass them upwards. Signed-off-by: Sam Lefebvre --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 7ba00b8ab288..3da4c07ce2d9 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -1334,13 +1334,18 @@ static int gpmi_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *chip, int page) { struct gpmi_nand_data *this = nand_get_controller_data(chip); + int ret; dev_dbg(this->dev, "page number is %d\n", page); /* clear the OOB buffer */ memset(chip->oob_poi, ~0, mtd->oobsize); /* Read out the conventional OOB. */ - nand_read_page_op(chip, page, mtd->writesize, NULL, 0); + ret = nand_read_page_op(chip, page, mtd->writesize, NULL, 0); + + if (ret) + return ret; + chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); /* @@ -1350,11 +1355,11 @@ static int gpmi_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *chip, */ if (GPMI_IS_MX23(this)) { /* Read the block mark into the first byte of the OOB buffer. */ - nand_read_page_op(chip, page, 0, NULL, 0); + ret = nand_read_page_op(chip, page, 0, NULL, 0); chip->oob_poi[0] = chip->read_byte(mtd); } - return 0; + return ret; } static int From patchwork Fri Apr 20 08:19:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901779 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="S1r0kJCG"; 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="s2RQQiYT"; 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 40S8Vg495xz9s1B for ; Fri, 20 Apr 2018 18:42:19 +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=Y8E183SBeIK7ziqSZv+3ATvkUhWYeNsN3cq/xLj+qL4=; b=S1r0kJCGpD1HxkgUX5a/J1mMtG 8UtHODC6ABbleHPDlFlmIw4e1FWymZKIUc75W0bN47xn/jR1rBOxngSYDvbk3DX3bzTcbMP1YP19K 5AgG9W+K2KYXcWmqJpWdYYUbKXnculwIEcB1U39wIeGvX/dNMkP8yHlErhkCjZZonUoRideJ1TSXC ZM6I2yw6q9e+dNhGuor69CAVyQ+WYxYgcF7swCNVZOzOyf7Y42lc77HP0KxUPBKe8CoeQ74Edi1jz QNSuHHGi738GnksDAgjlhHruiiDLHCm+XMjBBDz48zMZYzRBeSrGyrN8yUwQQpOafxMG4iv8Vba/e moQJd8sQ==; 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 1f9RcN-0001kN-Nx; Fri, 20 Apr 2018 08:42:07 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RN4-0007ca-1e for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:26 +0000 Received: by mail-wr0-x242.google.com with SMTP id w3-v6so20657619wrg.2 for ; Fri, 20 Apr 2018 01:26:07 -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=4fMVsqQD/StcKry+rIB3M7ybZqR9QTwX1lFg3tLK2ws=; b=s2RQQiYTnAVhm5a1Reo7+hUQaEO/HZ4ohbd05G2jqoyOFYMfnCxTvx0DWoHjUHN4ei ttzODVXOsicUTtF39Q1iKXHYq1BF8wD2O/Da62R/Z1TWLjAy3fwzkGAVcH4MVBAi2ZuM S+KcyrMkxou98tL5D/P84hEkSbXgOoJ/Q/Md+mkhBGqb1WUpPvnCJCPjElSWX2zjqRYI xAqvdtTCuxvtv51/QkFcgYn3oKQkZ1zazVbIfRv38O79/GwhFMCqC/hanGxmeytanaME +eAqSzCg2c/bIuiUJ0cLtVhil05W5R7eGZHS5Okm1jIoVuEzNp3yP0juK1mrHD+cxSJk WjHQ== 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=4fMVsqQD/StcKry+rIB3M7ybZqR9QTwX1lFg3tLK2ws=; b=J4+Dtj2ORVdV10U0unLR0YqbQg3SrhtHgBXM/P1PjLfD/4bAHg+mmEkTsS7ByER/kB FBIH+rhfu1eoZQTn4asTuhjlJ40YEZkLujNgVZMH4Cw3U0Z1dOhKV3wGQMzbXz8hCdUD FZV0Yl+pBmb7+RJPTKvZoaRJWrN9KFsQ7u1qnxLu0gHvqJqDBCVhMEULDdMAl7XA5z7o kVKhTLCVdb2CQtQRxSM8rPnLXbKJnWsG8h+GfCmmTt5oDRDONaziGJeB72qrkYVNSvTq kqCqvfKohpRPj9eIAdZDbNsVO2XviG8nRDifx+2d7uqP9qpkzALzLRX0vmq0TzQvPPr6 2EPQ== X-Gm-Message-State: ALQs6tAc7cz6L0iAf5FNRqVjpZh9LpDiZdG1ilG2pbtnmfkyqVatQc+w 3+xi3AembXw5VFZ9pnY7qGNM+UL7 X-Google-Smtp-Source: AIpwx4/hsteSZBCUVFX0SSMuV4pRAfHHU45KdUytof+fgCD64/yXHNf1GXKXc1Ayvsjqx/NTDSQxAA== X-Received: by 10.28.29.1 with SMTP id d1mr1163587wmd.18.1524212765761; Fri, 20 Apr 2018 01:26:05 -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 e64sm1834235wmg.22.2018.04.20.01.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:04 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 08/18] mtd: rawnand: gpmi: set aggregate ready/busy signalling Date: Fri, 20 Apr 2018 10:19:36 +0200 Message-Id: <20180420081946.16088-9-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012618_247970_BFDA3510 X-CRM114-Status: GOOD ( 13.62 ) 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:242 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The GPMI block by default decouples the ready/busy signal (which is shared between all chip-selects) to separate internal signals per chip-select. However, since the gpmi-nand driver uses DMA0 for all chip-selects, DMA transfers will not be able to see the ready/busy status for any chip-select other than 0. Currently, this happens to work because nand_command() ends with an explicit nand_wait_ready() and the driver only sets up a single command in a DMA chain. nand_wait_ready() polls for the chip-select specific ready/busy status bit. Future patches, however, will set up a DMA chain with several commands, so these will have to wait correctly in the DMA chain itself. To fix this, set the GANGED_RDYBUSY bit in the control1 register. This ties all internal ready/busy signals together, so DMA0 will also see the ready/busy status of chip selects 1-2-3. It's a bit silly that this isn't implied in hardware by the DECOUPLE_CS bit. Signed-off-by: Sam Lefebvre Signed-off-by: Arnout Vandecappelle (Essensium/Mind) Cc: Han Xu --- Tested on an i.MX6Q with two identical chips on CS0 and CS1. --- drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c | 3 +++ drivers/mtd/nand/raw/gpmi-nand/gpmi-regs.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index 83697b8df871..1858afdb400d 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -193,6 +193,9 @@ int gpmi_init(struct gpmi_nand_data *this) */ writel(BM_GPMI_CTRL1_DECOUPLE_CS, r->gpmi_regs + HW_GPMI_CTRL1_SET); + /* Aggregate ready busy signalling. */ + writel(BM_GPMI_CTRL1_GANGED_RDYBUSY, r->gpmi_regs + HW_GPMI_CTRL1_SET); + gpmi_disable_clk(this); return 0; err_out: diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-regs.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-regs.h index d92bf32221ca..e341802c90ac 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-regs.h +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-regs.h @@ -120,6 +120,7 @@ #define BV_GPMI_CTRL1_WRN_DLY_SEL_7_TO_12NS 0x2 #define BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY 0x3 +#define BM_GPMI_CTRL1_GANGED_RDYBUSY (1 << 19) #define BM_GPMI_CTRL1_BCH_MODE (1 << 18) #define BP_GPMI_CTRL1_DLL_ENABLE 17 From patchwork Fri Apr 20 08:19:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901776 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="XsqnVCL3"; 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="P6yriupA"; 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 40S8Rl0yl7z9s1w for ; Fri, 20 Apr 2018 18:39:47 +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=+Ctn8/Aqda6FrlkEk6guZTuwQlBj99xVu2kpOxC9eYs=; b=XsqnVCL3zAz/t+oCrLC7hqxuqp Tjbp+OfEysvC8GSfOksuk1AcKCJMbNcxTaU4RhC4vvx8MWcGKmYxd+K7DTwwfLq9H2ikOrPj5T7+i UrLpD2MwFSTAa7f8EqZf9Ipn351uCmViK128dEnSyvyIQRGt29HUco1IqJoxCrbkxEgkkCivjngt5 h0B7MP1zFBq8d30lRNKDI/wWo2R8lfDgOaNwPR3d+dyygcAhiZ4uSmp1HX1/avyYM610d54eWew2D T7cnjP7t21r3wQk5M2R5Rs8hIGXuaojRY2VMm+qU7xQqdOtu2E7oKPfDt0+fRIf104eSkxXduZMaX VOMVQ80A==; 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 1f9RZy-0007vP-Pk; Fri, 20 Apr 2018 08:39:38 +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 1f9RMx-0007dk-1X for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:14 +0000 Received: by mail-wr0-x243.google.com with SMTP id v24-v6so20633159wra.8 for ; Fri, 20 Apr 2018 01:26:09 -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=L8d5JAisaf7aASeq98OqG8t3DFRBBtY6lc0+whHBIzk=; b=P6yriupAVDIxRRrVPQYdMiJdz0FGY8ULSquaINJ0YYOBL9juDUrF2Q+7HdyPdP5OC9 7YlOBkNYTq3ZvqmNEA588w4QbKjZ6/ckPn4kSiUD+etuvppE2aV09qVjF/+TAzLeVf6F ewZrKOVBiGnWiyfYEO5bV09B8Mrj4wZ0/uBKnUTGGR3xAKu2zGYBZeG8HZxi9VNR0/O6 YAo5QZV6yTF+p91RYft5AZ0KbtEbzNRxtrlSFakuDXIeeK4gu/XlbbOW/+V3xYTA0bxd H+IwZ3WzjA2YTG6n1qEtkRYgq1clAvEDRytPCtUmDDpekAXWEYDVnljlxCYONUBQ/nCS qL0A== 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=L8d5JAisaf7aASeq98OqG8t3DFRBBtY6lc0+whHBIzk=; b=tDr2pgwu93WNaAyM2+t0XsEiOsVRJr8SHF0eHAzwnQ176g5nHYmwVLqQOKM4OWrMec 8/geJJST2HNuluHqgSCf2LZHWYrc9ouptaImzShuBcKczLx6H7ue9Q2hsXrP3TsWV7AM 7hbuHUqVu+aEdAugtH5oNVHf+b5TxNMpmSAV/XuPg7ooga22lFr/pf/7JtWEY9O1kMmZ wJwmo/cGuPGCDsmmDCxyjxb6ES07u20OZrtDgIJSj34N8lV/PUNui0+CF69OBmSc3662 Vjm52rXk6napWJYH05BYUS/gTvhR6sXi1XBWpHkzRvUcnprqu0z7N9YGJsKNOslyCcnZ DSNw== X-Gm-Message-State: ALQs6tD3MMxPRbSCRoe5hPpdB36HQWy0Xk+hHiYrEG7agwfYUwOq4Smv msHZpv7Zo+M91JSAz6o+mMSGC91d X-Google-Smtp-Source: AIpwx48TP0520wSkj3x172DrDlaR3nJH6N3aDnp/vtM2I1yL7m+IjMEsIfSLb+CBu8aNxk6bpYgOAA== X-Received: by 10.28.8.212 with SMTP id 203mr1289981wmi.9.1524212767490; Fri, 20 Apr 2018 01:26:07 -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 e64sm1834235wmg.22.2018.04.20.01.26.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:06 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 09/18] mtd: rawnand: make nand_command() and nand_command_lp() more similar Date: Fri, 20 Apr 2018 10:19:37 +0200 Message-Id: <20180420081946.16088-10-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012611_146253_53F41849 X-CRM114-Status: GOOD ( 16.81 ) 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" The nand_command() and nand_command_lp() functions are very similar, but there are slight typographic differences. As a preparation for unifying the two later, make them more similar now. This includes the following changes. In nand_command(): - use explicit NAND_NCE | NAND_{A,C}LE instead of NAND_CTRL_{A,C}LE (the explicit form seems to be used more often tree-wide). - proper line-wrapping. In nand_command_lp(): - use the ctrl local variable wherever appropriate. - remove the additional 'if (column != -1 || page_addr != -1)' around the two individual conditions. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- Note that I don't have access to a small-page device, so only tested on large-page devices. Also only tested on i.MX6Q (gpmi-nand). Note that this patch can be removed from the series without affecting the rest. --- drivers/mtd/nand/raw/nand_base.c | 59 +++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 72f3a89da513..bcc0344b1f27 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -761,7 +761,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { register struct nand_chip *chip = mtd_to_nand(mtd); - int ctrl = NAND_CTRL_CLE | NAND_CTRL_CHANGE; + int ctrl = NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE; /* Write out the command to the device */ if (command == NAND_CMD_SEQIN) { @@ -785,7 +785,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, chip->cmd_ctrl(mtd, command, ctrl); /* Address cycle, when necessary */ - ctrl = NAND_CTRL_ALE | NAND_CTRL_CHANGE; + ctrl = NAND_NCE | NAND_ALE | NAND_CTRL_CHANGE; /* Serially input address */ if (column != -1) { /* Adjust columns for 16 bit buswidth */ @@ -825,9 +825,9 @@ static void nand_command(struct mtd_info *mtd, unsigned int command, break; udelay(chip->chip_delay); chip->cmd_ctrl(mtd, NAND_CMD_STATUS, - NAND_CTRL_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, - NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ nand_wait_status_ready(mtd, 250); return; @@ -896,6 +896,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { register struct nand_chip *chip = mtd_to_nand(mtd); + int ctrl = NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE; /* Emulate NAND_CMD_READOOB */ if (command == NAND_CMD_READOOB) { @@ -905,33 +906,29 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, /* Command latch cycle */ if (command != NAND_CMD_NONE) - chip->cmd_ctrl(mtd, command, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, command, ctrl); - if (column != -1 || page_addr != -1) { - int ctrl = NAND_CTRL_CHANGE | NAND_NCE | NAND_ALE; - - /* Serially input address */ - if (column != -1) { - /* Adjust columns for 16 bit buswidth */ - if (chip->options & NAND_BUSWIDTH_16 && - !nand_opcode_8bits(command)) - column >>= 1; - chip->cmd_ctrl(mtd, column, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; - - /* Only output a single addr cycle for 8bits opcodes. */ - if (!nand_opcode_8bits(command)) - chip->cmd_ctrl(mtd, column >> 8, ctrl); - } - if (page_addr != -1) { - chip->cmd_ctrl(mtd, page_addr, ctrl); - chip->cmd_ctrl(mtd, page_addr >> 8, - NAND_NCE | NAND_ALE); - if (chip->options & NAND_ROW_ADDR_3) - chip->cmd_ctrl(mtd, page_addr >> 16, - NAND_NCE | NAND_ALE); - } + /* Address cycle, when necessary */ + ctrl = NAND_NCE | NAND_ALE | NAND_CTRL_CHANGE; + /* Serially input address */ + if (column != -1) { + /* Adjust columns for 16 bit buswidth */ + if (chip->options & NAND_BUSWIDTH_16 && + !nand_opcode_8bits(command)) + column >>= 1; + chip->cmd_ctrl(mtd, column, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; + + /* Only output a single addr cycle for 8bits opcodes. */ + if (!nand_opcode_8bits(command)) + chip->cmd_ctrl(mtd, column >> 8, ctrl); + } + if (page_addr != -1) { + chip->cmd_ctrl(mtd, page_addr, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; + chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); + if (chip->options & NAND_ROW_ADDR_3) + chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); } chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); From patchwork Fri Apr 20 08:19:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901781 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="JQEiE5NI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="P0oxFfCY"; 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="R2+Fmher"; 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 40S8WV6dhHz9s1w for ; Fri, 20 Apr 2018 18:43:02 +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=tynM8OJqdHS58I/hkGHX1j8Mz1cosXGHGpOFD4EALAI=; b=JQEiE5NIY0KFzKTZmlIeUAnMe2 gifDPlVaRK5dIDjtm7F8NPtcH9Pn1TBh92ytOF3LgkRek8MtP2mOJAegyenFEgwxngEN00EH95/Lf b9u7Ux/xqh+p9rJzEkXxyyVjhWcfRpK8b7msX9kerdcQTr5OhzMgzyQ5syGGjxXXJkaK2XkPAPDMD R3Al0ezBPeqjQ0+1Envy9iSSvhKD3dRv/kMTc8KlUtwI23WlkQI1NkIujZgSooals2HLw06sc161c d6Rh3UEcBVGweySYQ+wuElSLL783pPvrBkeWtGKXRLznOklQ2Gkab6KXsamN7sfkc/vxUijQSmYkg cb5L2e1w==; 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 1f9Rd7-00023e-F9; Fri, 20 Apr 2018 08:42:53 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNE-0007sA-Pd for linux-mtd@bombadil.infradead.org; Fri, 20 Apr 2018 08:26:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=MmQh88UNlXPi/jfuc9deTzYpxooZvRs1aQOPb5HIspc=; b=P0oxFfCYcuEuNqnJeb2DeJ90T OisPGc7o2W3dGWuGnhEFKEhkSy7KhmmO7VgFuvc+WJLJB0sSmpZgUf/giSTsOAEvQYVXHiyX5dKxq x7Bmui3Kw/g4gQP6USElvVKoQY9Hye69HBtiAfBqg6wETGYUhqoBL1o7bZugJyg/udSPiS4eeIOQv W8w4Pi/P1+ItGpxGs4hlf1f/ZM2pEKbB+G+GxLHRhO7Pt7Zngu50UB/UP+uFpwDs5mBkDZ8hsG5wW RGG/MA4JVL6Jld6clZ58P8gmyuJ879Di+GeP0UKnoAAogTGWVeGkcSV5rdlSiizqYR47mmB6P7T3G VOm7/FrIg==; Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNA-0001zQ-U5 for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:26 +0000 Received: by mail-wr0-x241.google.com with SMTP id v15-v6so2563441wrm.10 for ; Fri, 20 Apr 2018 01:26:12 -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=MmQh88UNlXPi/jfuc9deTzYpxooZvRs1aQOPb5HIspc=; b=R2+Fmherrzakq7PTN7iigoBhIVfYcxj2bBrbXpEco0bqCCIpLFtbGmdNWZjcOVfsGF B4cejDpl1qYOM9/o98NXxTaEZPqQJAiuzd9Xxknk0dj+ubwNHTCDPMxdC8P8bQMTwuJT Z7PpZIXRZmdxvUHZibyQsTnsssOuQtZCUgsuE6zOF0aEzRl87W3fiQsHCwidpaHkiCqY 9iY7dvrgkvlIVIbc+15SZraoZlCPf0+comGsBJpfrB+EkRdNrnN1DIsMIzeDgATcWxLE Ky2VoD4AAdhNLHmlAPHrj/JRCCkyBfLv+KjDiYln4UFSw4hMhF804mV6pQqRMc1PccAx 4AKw== 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=MmQh88UNlXPi/jfuc9deTzYpxooZvRs1aQOPb5HIspc=; b=b+vthcnSij3GjZvf4qHJLfqyls9Yujqg6x/7uqa2G6Oz4XYyW1xnj9B+Yr4CjzlRz3 2mifedUHuICDfSecePRWLSleXifiIzrGkpYJU7weuOfDnn3j3TZ7Km1uUYbYvGswoC9w WT3E+21dozmcTsqVbnyid+mUEZfcbCUFd08pj2NN4RDptU+drsWxOWABYHjOaKP/nBms iHdQTSrQ3Uvn5ybrZo4KToFP1rxLu3I+hZJyPxVDL3GHAtkVKObJagD1K/GCOw+3pjwr DpKwU0ppO22/wwaSW8apP+NV6jTZjpay9yY65+wv14ZeBodxMmpO6gR00Xvuti4LsMJv /QHQ== X-Gm-Message-State: ALQs6tA2F02Zkh5G8o5d9DrxcUvDMQQUq8JEPETV1B3b7s9BQr6Hgqj3 OOYjJ+RmpG+OLVlQ9Gaop9QLtuvi X-Google-Smtp-Source: AIpwx4/8y3dei6Jnojp/tQ4q8tZ0Q5o3MaUUlCLKMXunPICBec4dl+EHuHYA62QZoMe9DEsI3hKOog== X-Received: by 2002:adf:e549:: with SMTP id z9-v6mr1044172wrm.186.1524212769399; Fri, 20 Apr 2018 01:26:09 -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 e64sm1834235wmg.22.2018.04.20.01.26.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:08 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 10/18] mtd: rawnand: factor nand_command_lp() into nand_command() Date: Fri, 20 Apr 2018 10:19:38 +0200 Message-Id: <20180420081946.16088-11-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_042625_119205_02AF7A32 X-CRM114-Status: GOOD ( 31.71 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.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:241 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" The nand_command() and nand_command_lp() functions are very similar. Factor them into a single function, and use conditions on writesize to identify the differences. is_lp checks are added everywhere to make sure the behaviour is exactly the same as before. Most likely, the checks in CACHEDPROG, RNDIN and RNDOUT are not needed since these commands are only valid for LP devices. But since I'm not sure of that, I'm leaving it as is. The only side effect of this patch is that the large-page behaviour is activated a little bit earlier: as soon as writesize is set. However, only SEQIN, READOOB, READ0, CACHEDPROG, RNDIN and RNDOUT behave differently between small and large page. Of these, only RNDOUT is used in nand_detect(). RNDOUT is used by nand_change_read_column_op() which is called by nand_flash_detect_ext_param_page(). Before this patch, the switch to nand_command_lp was already made just before calling that function so the behaviour doesn't change. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- Note that I don't have access to a small-page device, so only tested on large-page devices. Also only tested on i.MX6Q (gpmi-nand). I only verified the lack of change in behaviour during nand_detect by reading the code, so it's possible that I missed something. Testing on various devices (ONFI, JEDEC, non-ONFI/JEDEC) is needed to be really sure that nothing breaks. Note that this patch can be removed from the series without affecting the rest. --- drivers/mtd/nand/raw/nand_base.c | 236 ++++++++++++--------------------------- 1 file changed, 70 insertions(+), 166 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index bcc0344b1f27..320efbe41bd6 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -747,121 +747,6 @@ int nand_soft_waitrdy(struct nand_chip *chip, unsigned long timeout_ms) }; EXPORT_SYMBOL_GPL(nand_soft_waitrdy); -/** - * nand_command - [DEFAULT] Send command to NAND device - * @mtd: MTD device structure - * @command: the command to be sent - * @column: the column address for this command, -1 if none - * @page_addr: the page address for this command, -1 if none - * - * Send command to NAND device. This function is used for small page devices - * (512 Bytes per page). - */ -static void nand_command(struct mtd_info *mtd, unsigned int command, - int column, int page_addr) -{ - register struct nand_chip *chip = mtd_to_nand(mtd); - int ctrl = NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE; - - /* Write out the command to the device */ - if (command == NAND_CMD_SEQIN) { - int readcmd; - - if (column >= mtd->writesize) { - /* OOB area */ - column -= mtd->writesize; - readcmd = NAND_CMD_READOOB; - } else if (column < 256) { - /* First 256 bytes --> READ0 */ - readcmd = NAND_CMD_READ0; - } else { - column -= 256; - readcmd = NAND_CMD_READ1; - } - chip->cmd_ctrl(mtd, readcmd, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; - } - if (command != NAND_CMD_NONE) - chip->cmd_ctrl(mtd, command, ctrl); - - /* Address cycle, when necessary */ - ctrl = NAND_NCE | NAND_ALE | NAND_CTRL_CHANGE; - /* Serially input address */ - if (column != -1) { - /* Adjust columns for 16 bit buswidth */ - if (chip->options & NAND_BUSWIDTH_16 && - !nand_opcode_8bits(command)) - column >>= 1; - chip->cmd_ctrl(mtd, column, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; - } - if (page_addr != -1) { - chip->cmd_ctrl(mtd, page_addr, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; - chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); - if (chip->options & NAND_ROW_ADDR_3) - chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); - } - chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); - - /* - * Program and erase have their own busy handlers status and sequential - * in needs no delay - */ - switch (command) { - - case NAND_CMD_NONE: - case NAND_CMD_PAGEPROG: - case NAND_CMD_ERASE1: - case NAND_CMD_ERASE2: - case NAND_CMD_SEQIN: - case NAND_CMD_STATUS: - case NAND_CMD_READID: - case NAND_CMD_SET_FEATURES: - return; - - case NAND_CMD_RESET: - if (chip->dev_ready) - break; - udelay(chip->chip_delay); - chip->cmd_ctrl(mtd, NAND_CMD_STATUS, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ - nand_wait_status_ready(mtd, 250); - return; - - /* This applies to read commands */ - case NAND_CMD_READ0: - /* - * READ0 is sometimes used to exit GET STATUS mode. When this - * is the case no address cycles are requested, and we can use - * this information to detect that we should not wait for the - * device to be ready. - */ - if (column == -1 && page_addr == -1) - return; - - default: - /* - * If we don't have access to the busy pin, we apply the given - * command delay - */ - if (!chip->dev_ready) { - udelay(chip->chip_delay); - return; - } - } - /* - * Apply this short delay always to ensure that we do wait tWB in - * any case on any machine. - */ - ndelay(100); - - nand_wait_ready(mtd); -} - static void nand_ccs_delay(struct nand_chip *chip) { /* @@ -882,26 +767,48 @@ static void nand_ccs_delay(struct nand_chip *chip) } /** - * nand_command_lp - [DEFAULT] Send command to NAND large page device + * nand_command - [DEFAULT] Send command to NAND device * @mtd: MTD device structure * @command: the command to be sent * @column: the column address for this command, -1 if none * @page_addr: the page address for this command, -1 if none * - * Send command to NAND device. This is the version for the new large page - * devices. We don't have the separate regions as we have in the small page - * devices. We must emulate NAND_CMD_READOOB to keep the code compatible. + * Send command to NAND device. */ -static void nand_command_lp(struct mtd_info *mtd, unsigned int command, +static void nand_command(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { register struct nand_chip *chip = mtd_to_nand(mtd); int ctrl = NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE; + /* Large page devices (> 512 bytes) behave slightly differently. */ + bool is_lp = mtd->writesize > 512; - /* Emulate NAND_CMD_READOOB */ - if (command == NAND_CMD_READOOB) { - column += mtd->writesize; - command = NAND_CMD_READ0; + if (is_lp) { + /* Large page devices don't have the separate regions as we + * have in the small page devices. We must emulate + * NAND_CMD_READOOB to keep the code compatible. + */ + if (command == NAND_CMD_READOOB) { + column += mtd->writesize; + command = NAND_CMD_READ0; + } + } else if (command == NAND_CMD_SEQIN) { + /* Write out the command to the device */ + int readcmd; + + if (column >= mtd->writesize) { + /* OOB area */ + column -= mtd->writesize; + readcmd = NAND_CMD_READOOB; + } else if (column < 256) { + /* First 256 bytes --> READ0 */ + readcmd = NAND_CMD_READ0; + } else { + column -= 256; + readcmd = NAND_CMD_READ1; + } + chip->cmd_ctrl(mtd, readcmd, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; } /* Command latch cycle */ @@ -920,7 +827,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, ctrl &= ~NAND_CTRL_CHANGE; /* Only output a single addr cycle for 8bits opcodes. */ - if (!nand_opcode_8bits(command)) + if (is_lp && !nand_opcode_8bits(command)) chip->cmd_ctrl(mtd, column >> 8, ctrl); } if (page_addr != -1) { @@ -939,7 +846,6 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, switch (command) { case NAND_CMD_NONE: - case NAND_CMD_CACHEDPROG: case NAND_CMD_PAGEPROG: case NAND_CMD_ERASE1: case NAND_CMD_ERASE2: @@ -949,9 +855,17 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, case NAND_CMD_SET_FEATURES: return; + case NAND_CMD_CACHEDPROG: + if (is_lp) + return; + break; + case NAND_CMD_RNDIN: - nand_ccs_delay(chip); - return; + if (is_lp) { + nand_ccs_delay(chip); + return; + } + break; case NAND_CMD_RESET: if (chip->dev_ready) @@ -966,40 +880,44 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned int command, return; case NAND_CMD_RNDOUT: - /* No ready / busy check necessary */ - chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - - nand_ccs_delay(chip); - return; + if (is_lp) { + /* No ready / busy check necessary */ + chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); + + nand_ccs_delay(chip); + return; + } + break; case NAND_CMD_READ0: /* * READ0 is sometimes used to exit GET STATUS mode. When this * is the case no address cycles are requested, and we can use - * this information to detect that READSTART should not be - * issued. + * this information to detect that that we should not wait for + * the device to be ready and READSTART should not be issued. */ if (column == -1 && page_addr == -1) return; - chip->cmd_ctrl(mtd, NAND_CMD_READSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - - /* This applies to read commands */ - default: - /* - * If we don't have access to the busy pin, we apply the given - * command delay. - */ - if (!chip->dev_ready) { - udelay(chip->chip_delay); - return; + if (is_lp) { + chip->cmd_ctrl(mtd, NAND_CMD_READSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); } + /* Read commands must wait */ + break; + } + /* + * If we don't have access to the busy pin, we apply the given command + * delay. + */ + if (!chip->dev_ready) { + udelay(chip->chip_delay); + return; } /* @@ -5180,16 +5098,6 @@ static int nand_flash_detect_onfi(struct nand_chip *chip) chip->ecc_step_ds = 512; } else if (chip->parameters.onfi.version >= 21 && (le16_to_cpu(p->features) & ONFI_FEATURE_EXT_PARAM_PAGE)) { - - /* - * The nand_flash_detect_ext_param_page() uses the - * Change Read Column command which maybe not supported - * by the chip->cmdfunc. So try to update the chip->cmdfunc - * now. We do not replace user supplied command function. - */ - if (mtd->writesize > 512 && chip->cmdfunc == nand_command) - chip->cmdfunc = nand_command_lp; - /* The Extended Parameter Page is supported since ONFI 2.1. */ if (nand_flash_detect_ext_param_page(chip, p)) pr_warn("Failed to detect ONFI extended param page\n"); @@ -5686,10 +5594,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type) chip->badblockbits = 8; chip->erase = single_erase; - /* Do not replace user supplied command function! */ - if (mtd->writesize > 512 && chip->cmdfunc == nand_command) - chip->cmdfunc = nand_command_lp; - pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", maf_id, dev_id); pr_info("%s %s\n", nand_manufacturer_name(manufacturer), From patchwork Fri Apr 20 08:19:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901782 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="NT2ukNls"; 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="aXypnHpV"; 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 40S8XG06z4z9s1w for ; Fri, 20 Apr 2018 18:43:42 +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=yA9oO+Dj5WWuPyWIheRCGrgob8mcbGRE25d4jiYZEwU=; b=NT2ukNlsPf2rm1JIBwyFW/0vhw 9MnQBg3rKk01qK8hi7loi4v7i0U3e/YWC7RSDmv39hHLCzmiKeF8AE1/AhvhPvPKGvrHgk3xPAhpW MdmLAzkR9E5H00ZPu406NZSLd4eKsxxlcjx8Q8riLPVNmMYnlT2sgZh1hxBB2jbD3ZqMQ31K+nl2a R+BauQJZzQfJs7AiGU9c+dj4qM/Zs1hft+zNS+mDH7RVWFzkqxhUg0UO3gTiqYv1l6Y7tKmB1opy9 Sc5otfKFEfLRWEXDlcW34/pm4Zkh5pZy19V9SvTNj93QgUuNOHcizMmcwpCmDO7FYjrj/hUo2j96/ +zczvfyA==; 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 1f9Rdn-0002R8-Gs; Fri, 20 Apr 2018 08:43:35 +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 1f9RN9-0007kw-BQ for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:35 +0000 Received: by mail-wr0-x243.google.com with SMTP id w3-v6so20658291wrg.2 for ; Fri, 20 Apr 2018 01:26:13 -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=gYH2iLxncXP+BK5orIMYFTVkKc1jLDdi5IHySroNaKs=; b=aXypnHpV/qUoPmUeHzhY1piByI5R7Kb7DZVxmXGbytJZZ5b7FHtt3r8k5JFvZ1AVCm 0veWTGRDxfSv4sDFTJxOMjQNvOUZiJnufSwMsmYVeTtkaTN7pYgnmU6d/c661FKnynK9 9r3fS5Nqg1Xb7nG0tRcBVlDXlX0n5uSVU8P/8PXnvWmViS13QbJGcS50pJhVA2cDTSoo ky06vZwa7dOuiOj7uTa0umMdsM+5vnJ0TMMrONQINX77bxLp1XNVJn6uDzVnd13UWBFG eH4H8NppLiN3M+3adnbZEA3Qq1TFjTRFc3WY22VmV2VJfq6i8Ejs7v8c4WGtB4Qxhwkk okyQ== 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=gYH2iLxncXP+BK5orIMYFTVkKc1jLDdi5IHySroNaKs=; b=bEJcQIR5SJSOYDTRhzZjR9O03wLYcyhWDInQSbYuiNlzVW21rtCYm/zrbNyIHd2Gh/ gzK3HCOlpoppK9FR6/fjB86LsfBacfwEalziKgBd8Ysym15X3hrzdIaSeDSsbN69yIEB q95cvUET3mTDkV9Cacr9Thi4TRn38GY6GO7ad3KWwMpm5FB/qsdlxpmiYcwoqqj0FkcI CoNI1P9+7cs90k5uFA28qnZ08yCXFYETaR/QEgJ0oAUbFCRgSJMMoB6rVOCq5Lfm6YOP 4b4yiCz1Rv81EH9CP8gbveLsn2YUhqzUzMSrqmrKbAXmSlPOhPPfaVHe9blyXFrWhtfn REyA== X-Gm-Message-State: ALQs6tAL2ZiPEc871J9vTjzGsBxybVAu++f0JaWsZxiPrSvFZh9yJTL2 Zw4Uf5mhF/FqSrF1MXMuYwwo/Xof X-Google-Smtp-Source: AIpwx49Oc252/T5ugTa4YdRp2l6GuXOitcCftx1OSuhVOTEJGzeRjKXHw3CHM3xNqz7k1cPDjInB+w== X-Received: by 2002:adf:d0ce:: with SMTP id z14-v6mr7384508wrh.157.1524212771161; Fri, 20 Apr 2018 01:26:11 -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 e64sm1834235wmg.22.2018.04.20.01.26.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:10 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 11/18] mtd: rawnand: gpmi: instantiate cmdfunc Date: Fri, 20 Apr 2018 10:19:39 +0200 Message-Id: <20180420081946.16088-12-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012623_492095_CA39AF4E X-CRM114-Status: GOOD ( 21.07 ) 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_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" Later patches will optimize the command handling for gpmi. This requires a gpmmi-specific implementation of cmdfunc. As a first step, nand_command() is copied literally from nand_base.c (after merging nand_command() and nand_command_lp()). The auxiliary functions nand_ccs_delay() and nand_wait_status_ready() also need to be copied, together with the includes they need. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 205 +++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 3da4c07ce2d9..69bdee0ca679 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -19,11 +19,13 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include +#include #include #include #include #include #include +#include #include #include #include "gpmi-nand.h" @@ -1091,6 +1093,208 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, return max_bitflips; } +static void gpmi_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) +{ + register struct nand_chip *chip = mtd_to_nand(mtd); + int ret; + + timeo = jiffies + msecs_to_jiffies(timeo); + do { + u8 status; + + ret = nand_read_data_op(chip, &status, sizeof(status), true); + if (ret) + return; + + if (status & NAND_STATUS_READY) + break; + touch_softlockup_watchdog(); + } while (time_before(jiffies, timeo)); +}; + +static void gpmi_ccs_delay(struct nand_chip *chip) +{ + /* + * The controller already takes care of waiting for tCCS when the RNDIN + * or RNDOUT command is sent, return directly. + */ + if (!(chip->options & NAND_WAIT_TCCS)) + return; + + /* + * Wait tCCS_min if it is correctly defined, otherwise wait 500ns + * (which should be safe for all NANDs). + */ + if (chip->setup_data_interface) + ndelay(chip->data_interface.timings.sdr.tCCS_min / 1000); + else + ndelay(500); +} + +/** + * gpmi_nand_command - Send command to NAND device + * @mtd: MTD device structure + * @command: the command to be sent + * @column: the column address for this command, -1 if none + * @page_addr: the page address for this command, -1 if none + * + * Send command to NAND device. + */ +static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, + int column, int page_addr) +{ + register struct nand_chip *chip = mtd_to_nand(mtd); + int ctrl = NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE; + /* Large page devices (> 512 bytes) behave slightly differently. */ + bool is_lp = mtd->writesize > 512; + + if (is_lp) { + /* Large page devices don't have the separate regions as we + * have in the small page devices. We must emulate + * NAND_CMD_READOOB to keep the code compatible. + */ + if (command == NAND_CMD_READOOB) { + column += mtd->writesize; + command = NAND_CMD_READ0; + } + } else if (command == NAND_CMD_SEQIN) { + /* Write out the command to the device */ + int readcmd; + + if (column >= mtd->writesize) { + /* OOB area */ + column -= mtd->writesize; + readcmd = NAND_CMD_READOOB; + } else if (column < 256) { + /* First 256 bytes --> READ0 */ + readcmd = NAND_CMD_READ0; + } else { + column -= 256; + readcmd = NAND_CMD_READ1; + } + chip->cmd_ctrl(mtd, readcmd, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; + } + + /* Command latch cycle */ + if (command != NAND_CMD_NONE) + chip->cmd_ctrl(mtd, command, ctrl); + + /* Address cycle, when necessary */ + ctrl = NAND_NCE | NAND_ALE | NAND_CTRL_CHANGE; + /* Serially input address */ + if (column != -1) { + /* Adjust columns for 16 bit buswidth */ + if (chip->options & NAND_BUSWIDTH_16 && + !nand_opcode_8bits(command)) + column >>= 1; + chip->cmd_ctrl(mtd, column, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; + + /* Only output a single addr cycle for 8bits opcodes. */ + if (is_lp && !nand_opcode_8bits(command)) + chip->cmd_ctrl(mtd, column >> 8, ctrl); + } + if (page_addr != -1) { + chip->cmd_ctrl(mtd, page_addr, ctrl); + ctrl &= ~NAND_CTRL_CHANGE; + chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); + if (chip->options & NAND_ROW_ADDR_3) + chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); + } + chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + + /* + * Program and erase have their own busy handlers status, sequential + * in and status need no delay. + */ + switch (command) { + + case NAND_CMD_NONE: + case NAND_CMD_PAGEPROG: + case NAND_CMD_ERASE1: + case NAND_CMD_ERASE2: + case NAND_CMD_SEQIN: + case NAND_CMD_STATUS: + case NAND_CMD_READID: + case NAND_CMD_SET_FEATURES: + return; + + case NAND_CMD_CACHEDPROG: + if (is_lp) + return; + break; + + case NAND_CMD_RNDIN: + if (is_lp) { + gpmi_ccs_delay(chip); + return; + } + break; + + case NAND_CMD_RESET: + if (chip->dev_ready) + break; + udelay(chip->chip_delay); + chip->cmd_ctrl(mtd, NAND_CMD_STATUS, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); + /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ + gpmi_wait_status_ready(mtd, 250); + return; + + case NAND_CMD_RNDOUT: + if (is_lp) { + /* No ready / busy check necessary */ + chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); + + gpmi_ccs_delay(chip); + return; + } + break; + + case NAND_CMD_READ0: + /* + * READ0 is sometimes used to exit GET STATUS mode. When this + * is the case no address cycles are requested, and we can use + * this information to detect that that we should not wait for + * the device to be ready and READSTART should not be issued. + */ + if (column == -1 && page_addr == -1) + return; + + if (is_lp) { + chip->cmd_ctrl(mtd, NAND_CMD_READSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); + } + /* Read commands must wait */ + break; + } + /* + * If we don't have access to the busy pin, we apply the given command + * delay. + */ + if (!chip->dev_ready) { + udelay(chip->chip_delay); + return; + } + + /* + * Apply this short delay always to ensure that we do wait tWB in + * any case on any machine. + */ + ndelay(100); + + nand_wait_ready(mtd); +} + + static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { @@ -1895,6 +2099,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) chip->select_chip = gpmi_select_chip; chip->setup_data_interface = gpmi_setup_data_interface; chip->cmd_ctrl = gpmi_cmd_ctrl; + chip->cmdfunc = gpmi_nand_command; chip->dev_ready = gpmi_dev_ready; chip->read_byte = gpmi_read_byte; chip->read_buf = gpmi_read_buf; From patchwork Fri Apr 20 08:19:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901790 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="PTYiFeRT"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="Azy/bboF"; 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="XxhHmmxG"; 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 40S8ff1Fvcz9s1w for ; Fri, 20 Apr 2018 18:49:14 +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=4AP1Y3FjeqLSJAjHydSBKvkEDjWMsa4hT2NvKnOkI0c=; b=PTYiFeRTJ2yYgtl7pXuZDPj8Bf LpPDWf7ILhqyv8fuWtCYCo8sTXerZQtqdJY7RJC1Q41CsZ2e6GB04rIe4MZ0aADZKuD25mGRAetKM 8yJsqgm4eyFtKxZ71Y5SrNZC1n8YdU/JjqGyetPKE2PjAeD0LcUnMrYvZW4NA23FWEXNtrMLww+OC epQ/A37iDd61aO6kbgHmr8Ki8Vk/j/r6+jNy6pJQMd7S4wQAzmh8hjnIMtY9H49nKiZoQq5hcCc32 8FWs4hOfMwCsujmZko4PvvfyA2xIIqngbkLcfyKhhLB3/VKBN2fWUyraiQG9VZsKeJpwYRzAniYNS UKYNEf4g==; 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 1f9Rj4-00060X-E1; Fri, 20 Apr 2018 08:49:02 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9Rat-0000DM-DP for linux-mtd@bombadil.infradead.org; Fri, 20 Apr 2018 08:40:35 +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=7H8CfQyl9LYicnmODhH1leuhwRqswYBh9B1RRnSYe1Y=; b=Azy/bboFBXqMZX5uZABnpl/QC vKgQe8wDf/eVZx2GWA27lpwM2XqHxUENaqWwi/L4bU1IankJRYiaUfGvXra8kYm+fCSJ7L6cvaie0 eubqWz/e3Vr+lpErtOJvgkJI6psMmLde10Fncbd62vRaARyeylOJbQL4kp3PynxVOdsBniBDE9p2j LfhrrPyGi1RQMtu7It3fsFeHW5PfK9k5KRuqF7GNaLruU8T51l7KWQj8oMAvKiEHJ8i0w8hl/a+c3 LJ3E+Xqp1oXzzjvZOodDYrs8VKHUzB9Uf5KXGDDnxZSbPNxXjtl2HwzkocKs1Po1Cjo8MNU7AThBD 8SPfxTgew==; Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNA-0001GW-Eq for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:26 +0000 Received: by mail-wr0-x241.google.com with SMTP id o15-v6so20639119wro.11 for ; Fri, 20 Apr 2018 01:26: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=7H8CfQyl9LYicnmODhH1leuhwRqswYBh9B1RRnSYe1Y=; b=XxhHmmxGxWwYJ6kR4veIxN1RdlQecZbs/W7OWS1C7HEjZD0pW5bv+yah0T2Q0FUx2a 4NbyCks1hGnB4vaOTlL8izhv92ernNvSnAkxyq/8VrQnMp7ZuaJAsn6LxQVEd7ceKXeL NhmxwOnmdAXwFO48hIhGKm4yDdJx4f9CImSrLjlHfagkwXXAU+75cyfCrSXfBkFe9v42 CQztC0Ra2YMw6IjFHh2tzQ/tO0eIBVxOxWMhnGBxDcDYGqyKAQzJIU9gyEPZ2hq/myt4 WsrRxmnbwPkj/Xc3+8wTQB+jLdLbbCWvt/vA1wRqqND8fwyqNG83hmL/CS0NQB2bKCdc rHUw== 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=7H8CfQyl9LYicnmODhH1leuhwRqswYBh9B1RRnSYe1Y=; b=quCI7Xq0b1sMvWMGjDlEYCx3ralzAZILZrb5qFTWaqy9DXWH2S4uAO5r25BxBjfXLe BqKeNtmv8EB2bY5GHftJkzXDC9RQH3vKWCmrunfvlKmETZmuIs3MsMVl4/GbmeC/zTtp sEMyz8fs7WZj/9hG0p9BgRp+E+kzRrj2SGGAIRBIH5/k9l0Fgzc4oWAVK5n6cWAlS4KK jFKXuUhjqTnA5m9O5eUIihxJjx9vkDxDdSfC/090IYxCfYiy56+NCsHr5CjkAm6XOWvC SqLtTX4s8Q3qgUd8llNcgQCdTy6gIhQCFVe+pRo9VSXLlFNF9RlS1NXR2Nm0MHA8cMqV xy4Q== X-Gm-Message-State: ALQs6tAXILWM382VHxXQg2PthCHXhS5fBy9sF8BGC7V0eNyShaUfAGdK 1Uxpq9Zw8m2FYTW3TvrXBP+bJ0xm X-Google-Smtp-Source: AIpwx4+N03PLL7ClTN37Mjd81vSm5LRaSAGDY8ybFaIcV2RrRenDLvq/Gyx00CrVsMkC/4IGic8A2A== X-Received: by 10.28.1.1 with SMTP id 1mr357438wmb.28.1524212772882; Fri, 20 Apr 2018 01:26:12 -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 e64sm1834235wmg.22.2018.04.20.01.26.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:12 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 12/18] mtd: rawnand: gpmi: gpmi_ccs_delay() is not needed Date: Fri, 20 Apr 2018 10:19:40 +0200 Message-Id: <20180420081946.16088-13-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_092624_551804_31751D3F X-CRM114-Status: GOOD ( 13.84 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) 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:241 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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" The controller already takes care of waiting for tCCS when the RNDIN or RNDOUT command is sent. That is, the NAND_WAIT_TCCS option is not set for gpmi-nand. Therefore, the gpmi_ccs_delay() calls are not needed. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 69bdee0ca679..ccde6500f981 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -1112,25 +1112,6 @@ static void gpmi_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) } while (time_before(jiffies, timeo)); }; -static void gpmi_ccs_delay(struct nand_chip *chip) -{ - /* - * The controller already takes care of waiting for tCCS when the RNDIN - * or RNDOUT command is sent, return directly. - */ - if (!(chip->options & NAND_WAIT_TCCS)) - return; - - /* - * Wait tCCS_min if it is correctly defined, otherwise wait 500ns - * (which should be safe for all NANDs). - */ - if (chip->setup_data_interface) - ndelay(chip->data_interface.timings.sdr.tCCS_min / 1000); - else - ndelay(500); -} - /** * gpmi_nand_command - Send command to NAND device * @mtd: MTD device structure @@ -1227,7 +1208,6 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, case NAND_CMD_RNDIN: if (is_lp) { - gpmi_ccs_delay(chip); return; } break; @@ -1251,8 +1231,6 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); - - gpmi_ccs_delay(chip); return; } break; From patchwork Fri Apr 20 08:19:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901778 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="I3A684yj"; 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="JvCZiUrR"; 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 40S8Tk49Whz9s1w for ; Fri, 20 Apr 2018 18:41:30 +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=TV/Vi4sZC1IOZOu4VcYecFEagRLEAA87i2ZkhaBy4Yw=; b=I3A684yjElxBnVh6eUgHdQ5255 scLiYy8FVqdPRSAHp/uw20YHezAdh54zrHW4g0HMbBverCN1QipGwEjlNl23xNOMUNnDzttLdtDqy 55OKUb88rU7Mq5HVBWRZX+Z+V7yMZztelDhb1qiWXkW47czopl8ereWxeXSaL434RNqUmrmPq2GcI WJZqPd/Ya6fV6GzCLnuWPlVHVVvk7ubB1vg+nGEhIgotIxvLwYiB2tLk+TubvfZPuwUkJMV6Kuhfp 4uahPvWTWY21JvmMqUZxLJa5zXpSm7glXClSsJgld3OnSRbYJs9jc5YTgYWDrJXhPYkKQCVX+Zy3G zIX9kHxA==; 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 1f9RbZ-0001Pf-Oa; Fri, 20 Apr 2018 08:41:17 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RN4-0007mc-1U for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:24 +0000 Received: by mail-wr0-x242.google.com with SMTP id s18-v6so20638598wrg.9 for ; Fri, 20 Apr 2018 01:26:16 -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=4XQed94eAwHRQHjJMlYkDDZMjnqvHoAJhXZ1XCP63ho=; b=JvCZiUrR1MFs5LZg9obC/5L6kJ3TT2nt0Jd1wsDUNVtyAwuy+lKZa6h5cIgd0QtI1a NIKBCgth26F5+ncRI7Pf6g3U4ZEnW41IBSXxsnq7jCRanRcCPSuKKQ6A+6Bk+T+alLgG dOSin9nJQIj+3D82ZgT3qbP4V5bK4BGIfQldTddBYGEcRHuC1IzEYhY4LOhWos2I7R4J XoKKVceVp7ep+rjOfMpyRM66cLtIcfSg6LqytUtQh7XuCpF+FNBxho4skWKETbDaHi12 EyqOzlEbkb9ZHC5LlMLBkEAJPBE2mHlm5Y3P/49nqVdjqeMH3lFsU3OSHXNP2ZovZZhh scqw== 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=4XQed94eAwHRQHjJMlYkDDZMjnqvHoAJhXZ1XCP63ho=; b=YY1+e15qwPxpxyafZSIujpBTpmrNh7Chy3nzSyKSL94cJm28KEPReDV+DADe2JC3Pb vEj6YVr28Dc1iJ+aqLC/wSMmlSUj/oMdKYEPjBjqhn+fKXFsGtF+nBM+6TcRSvW15lXg MuE733preZ+5B2Gywa6Q3IgkUJRsU1gXu3heqnVrgoTcD9HbExBkcUCcBFvGi727VgR4 15w8sAPPnTIBbEPzzTzWTLy7klxliT24HbYGY125Panv/ByKJRXfiqz//HS+cnZKC7kb e1HXMdM+HhN+/gtCK4O/RDqNqXT9AwPOcTqArKo6dHE73Qbt8oHxnWnVyQL575qe0aol 3RsQ== X-Gm-Message-State: ALQs6tC++u1eYa3LE8ysIxMYSdyO8jI/sfKk6bfqldVqvNtS8edhoi4/ UWN066woU8fharvcCnkHwtHgcJii X-Google-Smtp-Source: AIpwx49yYijVZD8wc6pOOm4nz0mm5c4Hvq1cKWD4fyl56wq4s4Y5uwRqYQuo/wzQly+HFetOj3DuQQ== X-Received: by 2002:adf:9cc5:: with SMTP id h5-v6mr6929718wre.11.1524212774574; Fri, 20 Apr 2018 01:26:14 -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 e64sm1834235wmg.22.2018.04.20.01.26.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:13 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 13/18] mtd: rawnand: gpmi: explicit delays are not needed Date: Fri, 20 Apr 2018 10:19:41 +0200 Message-Id: <20180420081946.16088-14-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012618_251392_4B54410D X-CRM114-Status: GOOD ( 13.56 ) 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:242 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" gpmi-nand implements the dev_ready function, so explicit delays are not needed for the RESET and READ0 commands. Therefore, the gpmi_wait_status_ready() function and the includes it brings in are not needed. The RESET command just falls through to the nand_wait_ready() call. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 40 ------------------------------ 1 file changed, 40 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index ccde6500f981..8531bc8d531d 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include "gpmi-nand.h" @@ -1093,25 +1092,6 @@ static int gpmi_ecc_read_page_data(struct nand_chip *chip, return max_bitflips; } -static void gpmi_wait_status_ready(struct mtd_info *mtd, unsigned long timeo) -{ - register struct nand_chip *chip = mtd_to_nand(mtd); - int ret; - - timeo = jiffies + msecs_to_jiffies(timeo); - do { - u8 status; - - ret = nand_read_data_op(chip, &status, sizeof(status), true); - if (ret) - return; - - if (status & NAND_STATUS_READY) - break; - touch_softlockup_watchdog(); - } while (time_before(jiffies, timeo)); -}; - /** * gpmi_nand_command - Send command to NAND device * @mtd: MTD device structure @@ -1212,18 +1192,6 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, } break; - case NAND_CMD_RESET: - if (chip->dev_ready) - break; - udelay(chip->chip_delay); - chip->cmd_ctrl(mtd, NAND_CMD_STATUS, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - /* EZ-NAND can take upto 250ms as per ONFi v4.0 */ - gpmi_wait_status_ready(mtd, 250); - return; - case NAND_CMD_RNDOUT: if (is_lp) { /* No ready / busy check necessary */ @@ -1254,14 +1222,6 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, /* Read commands must wait */ break; } - /* - * If we don't have access to the busy pin, we apply the given command - * delay. - */ - if (!chip->dev_ready) { - udelay(chip->chip_delay); - return; - } /* * Apply this short delay always to ensure that we do wait tWB in From patchwork Fri Apr 20 08:19:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901783 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="d+IoU8ZF"; 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="gGlLJJBF"; 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 40S8YP4HT2z9s1w for ; Fri, 20 Apr 2018 18:44:41 +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=IgIWMKd1xbRO0z4in8DKMztgnCG7YJSjnf59/+FPldQ=; b=d+IoU8ZFWlcOuhCEADffESGoZ0 9xfVXaxqRbPIpYJf0HcFTBHo/gnqm/C4Y2b0Y2U/SgAJZAPLMFl9g/zLnpCtgp+YPlloTWML2nxOy qWUz/K/B/QrRUD7+ChCoTmrhNAEXpmMiFRKf++zNJgTs+nurrM742KcIF7vkP5XILGmBVhaJug5dZ uxvXWM3hEnytZSIGzg8goFN4BO1aN38/TPi2UeDWhIsnIR+wTaek3BPuBFGGalEf0xjR0hLcE9IA4 H3cS4umxu/ZLCZq5te2zAGvVC+As1L0DFZ0klQijFfdewf0kd7vGStAj68UtjiZ5mWGu282AiK6t5 Npr2pWvg==; 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 1f9Ref-0002nV-53; Fri, 20 Apr 2018 08:44:29 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNE-0007nk-4G for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:36 +0000 Received: by mail-wr0-x244.google.com with SMTP id s18-v6so20638810wrg.9 for ; Fri, 20 Apr 2018 01:26:18 -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=S90hotP28GJoXPWMPY8N/GrellNTO8UCtZez86c3C18=; b=gGlLJJBFrtL8CnPnOUBYfTbyhXJnWkSBzcgDswRXe9ZY6hV/ZS9pxB4zvGXoaLQ9WA TRV68WiI2Xo7/4DV0Cggqkv/3tPx21xUZ2ogPeFr4XnPzq1j5rd8Kf7vKdz83Qf4tVGx PcBEfT/E/eKSk7dly+ELYtIP40o9o5d+ftd0wkVUU7wOF0espRToGpzAPJTtsMC/Iy1c hPkCs6/U92JKYY0zmxQK1KXrzBeKDWuLqfI7RFiWdaBJF45qcEV86K/GHiRXRZyuqrqq GuifD17Gh3/77YUHlNzpa7Af8rYLgaFtq+sN/FPHZfmxxbnY05n4Yk4M+vnF6vRU9i95 50tA== 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=S90hotP28GJoXPWMPY8N/GrellNTO8UCtZez86c3C18=; b=VWnxg/3F+h6HiTyIgDZnExiu3gUtyEusHMJg+BOxPDaEB64JY0NvPU8RCj8PC8cgP8 /Yit7gamuCxyb/J56blCUksZzMy5E/BC+CbOE0dcMj/fUbFhgmdlMYnt91wcuCcXeSiI ZoDn7Tjtjrqu5P7dc0Kv+u0lZbBZYTQcYgRimQWT5ghmF/yA+g7HW/7e1QdnWHCuuAuE Aslepe0QTokBsjdjVsk9YMn7cf0EI2PeKb+Bof9fgWR3dznXtzsuO2yufSlh36rkphZe sIuGR4S5DilDDPqRaUm+ZshtXhPsuHT/2ahnPYyx56kID4M28XBA9r1cHHO+OFjLzgR/ cD0A== X-Gm-Message-State: ALQs6tBExpFr54RZN8yfJ66e5qGLUpwpXRi2qbSxy/cAAhrljv8kCeY9 xhFmbS7ggUwzLrist/52hehkefHH X-Google-Smtp-Source: AIpwx4+lDpiXj5laMaBAYIbggP8RbiftCEcvZYygESbo4wyfxuw64jb/26NEXXrbkHfllr4TgDRpog== X-Received: by 2002:adf:c992:: with SMTP id f18-v6mr7341786wrh.202.1524212776243; Fri, 20 Apr 2018 01:26:16 -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 e64sm1834235wmg.22.2018.04.20.01.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:15 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 14/18] mtd: rawnand: gpmi: no explicit wait is needed after sending a command Date: Fri, 20 Apr 2018 10:19:42 +0200 Message-Id: <20180420081946.16088-15-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012628_210395_5F71B38A X-CRM114-Status: GOOD ( 15.54 ) 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:244 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" Commands are send using DMA, and the DMA already waits for the ready/busy signal from the NAND. So no explicit delay and call to nand_wait_ready() is needed. This makes it possible to simplify the switch in gpmi_nand_command() a lot. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 62 +++++++----------------------- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 8531bc8d531d..5ae5713090a4 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -19,7 +19,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include -#include #include #include #include @@ -1163,44 +1162,20 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, if (chip->options & NAND_ROW_ADDR_3) chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); } - chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); - /* - * Program and erase have their own busy handlers status, sequential - * in and status need no delay. - */ - switch (command) { + /* This starts the DMA for the command and waits for it to finish. */ + chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); - case NAND_CMD_NONE: - case NAND_CMD_PAGEPROG: - case NAND_CMD_ERASE1: - case NAND_CMD_ERASE2: - case NAND_CMD_SEQIN: - case NAND_CMD_STATUS: - case NAND_CMD_READID: - case NAND_CMD_SET_FEATURES: + if (!is_lp) return; - case NAND_CMD_CACHEDPROG: - if (is_lp) - return; - break; - - case NAND_CMD_RNDIN: - if (is_lp) { - return; - } - break; - + switch (command) { case NAND_CMD_RNDOUT: - if (is_lp) { - /* No ready / busy check necessary */ - chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - return; - } + /* No ready / busy check necessary */ + chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); break; case NAND_CMD_READ0: @@ -1213,23 +1188,12 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, if (column == -1 && page_addr == -1) return; - if (is_lp) { - chip->cmd_ctrl(mtd, NAND_CMD_READSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); - } - /* Read commands must wait */ + chip->cmd_ctrl(mtd, NAND_CMD_READSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + chip->cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); break; } - - /* - * Apply this short delay always to ensure that we do wait tWB in - * any case on any machine. - */ - ndelay(100); - - nand_wait_ready(mtd); } From patchwork Fri Apr 20 08:19:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901784 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="UV8tQn9I"; 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="BVfWNekn"; 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 40S8ZH2Dllz9s1w for ; Fri, 20 Apr 2018 18:45:27 +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=B6mNznZGE1LW9KfmB2Jyw9eOm303AJTnfhV+zT63fTE=; b=UV8tQn9IfIP7uagy49GY6tYeFE HgmGS3VPB/gdV+daZ+7EvT6hWeo3IWKDtqjfBYlGvfZ9iktPy32nBUxTU/AJkrGzuHj6ZFadRQ4e5 NBicjo7XCcm2VU/3iJvBTY0u/OVyo6QUhP3kxYVdYCsRkeiCqG5wjm18NocBFiPK7zZDQU0vbYxHi C+Yvc3DuEJssRtJ6Ijo/egWnTR2XZIs5YGMzruzGV6EMM24BaX8A3olUnGU8fMQImJvXbUwyig4m/ 9fpXx5+dLDCPYLwpJ4vnF6rzMm9UUtnb3KXMKJh5z2xMENDAqsbAUqxPWb23VqKwkKCpa4EbIZ3se MLcEFWhQ==; 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 1f9RfR-0003V8-64; Fri, 20 Apr 2018 08:45:17 +0000 Received: from mail-wr0-f193.google.com ([209.85.128.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNG-0007ow-Ne for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:41 +0000 Received: by mail-wr0-f193.google.com with SMTP id d1-v6so20640816wrj.13 for ; Fri, 20 Apr 2018 01:26:20 -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=5iRBU6gd09rZoebuX/lpYvgLrSWcdbaCElHabdixcWU=; b=BVfWNekns8VwJ5APnxAHce/bDYIa0xBrkSZfCcpBFmlg+rwh6J0S5VvtX1xx3pnF0U uTrei/kAACY1n8M1iaNMFO0vPosqMTOwhRuG8cYhrXsK/h5kR4ZuojPsk9aCvFu+kI2E xS8L3wsUmsWbZevCZj5Dmi7rvhP3cwQUyQ52NFlbF0ujSllkl/K7Vf4s4FfQ8fqWZJwO 5uehWqujw+tkvhmgbYuxPJ+f06HiDzR35jUl1RmSMBC93hGHevtmNfo4DXaIZX8wdxM3 I2kj36D9gqS/BIsI9dp2BYgLSoPs69LF7nsvuaZbo0bcVEbinze/PIVB4hQLJkKxyttF PG+w== 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=5iRBU6gd09rZoebuX/lpYvgLrSWcdbaCElHabdixcWU=; b=UMY3L9L7BFSsdaFMazqYCh0U824N6m+5i/8YgKHOoC9SRVz9HGocnESS6KD064XQGk gYw4cESwubK0hIqb1cjTFKEtwx0+c7sjhkJVd7+bz9l5Fj6lQN+1EVF5uPQMn3ddq9ai +VGzQ/HzVvSXmuEXgrfxVZ201vmicloJGIavXYqQx9SXgwZDyeVKx3Zi+ReTpNPbcAj8 kCjKRxwu2DeAfwkvCqRt5P8+UNAzAUhW87fNexXBNSXr9gbNszIbJsyA1nHxxeY6RtWP caZUGgCaV+lQbDFGJT5XuHDDd5874PvfvVexTcjidE2JKcDUatnK6lcEv3qTa/zlY3tC Gjrw== X-Gm-Message-State: ALQs6tB4lnraW4u7UzUJPqL0FdnIJozM2ZMq27p8IyK8U9cu96kHdkWl vI3JJUCg0x8I0RClycX+OS85NUlG X-Google-Smtp-Source: AIpwx4+P6KR+nRBzMR8Ikrwbzr682lnzYSbPMjtkk+KZbRKn3fb+FTJTuDBeqHJaN0j0cd5GuNqQ6w== X-Received: by 2002:adf:9607:: with SMTP id b7-v6mr6731718wra.129.1524212778089; Fri, 20 Apr 2018 01:26:18 -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 e64sm1834235wmg.22.2018.04.20.01.26.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:17 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 15/18] mtd: rawnand: gpmi: cmd_ctrl is no longer needed Date: Fri, 20 Apr 2018 10:19:43 +0200 Message-Id: <20180420081946.16088-16-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012630_803359_378F139A X-CRM114-Status: GOOD ( 12.49 ) 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 [209.85.128.193 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.193 listed in wl.mailspike.net] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" Since gpmi-nand now implements cmdfunc, it is no longer needed to implement cmd_ctrl. Call gpmi_cmd_ctrl directly. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 5ae5713090a4..5700ca1d2ae6 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -1132,13 +1132,13 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, column -= 256; readcmd = NAND_CMD_READ1; } - chip->cmd_ctrl(mtd, readcmd, ctrl); + gpmi_cmd_ctrl(mtd, readcmd, ctrl); ctrl &= ~NAND_CTRL_CHANGE; } /* Command latch cycle */ if (command != NAND_CMD_NONE) - chip->cmd_ctrl(mtd, command, ctrl); + gpmi_cmd_ctrl(mtd, command, ctrl); /* Address cycle, when necessary */ ctrl = NAND_NCE | NAND_ALE | NAND_CTRL_CHANGE; @@ -1148,23 +1148,23 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, if (chip->options & NAND_BUSWIDTH_16 && !nand_opcode_8bits(command)) column >>= 1; - chip->cmd_ctrl(mtd, column, ctrl); + gpmi_cmd_ctrl(mtd, column, ctrl); ctrl &= ~NAND_CTRL_CHANGE; /* Only output a single addr cycle for 8bits opcodes. */ if (is_lp && !nand_opcode_8bits(command)) - chip->cmd_ctrl(mtd, column >> 8, ctrl); + gpmi_cmd_ctrl(mtd, column >> 8, ctrl); } if (page_addr != -1) { - chip->cmd_ctrl(mtd, page_addr, ctrl); + gpmi_cmd_ctrl(mtd, page_addr, ctrl); ctrl &= ~NAND_CTRL_CHANGE; - chip->cmd_ctrl(mtd, page_addr >> 8, ctrl); + gpmi_cmd_ctrl(mtd, page_addr >> 8, ctrl); if (chip->options & NAND_ROW_ADDR_3) - chip->cmd_ctrl(mtd, page_addr >> 16, ctrl); + gpmi_cmd_ctrl(mtd, page_addr >> 16, ctrl); } /* This starts the DMA for the command and waits for it to finish. */ - chip->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + gpmi_cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); if (!is_lp) return; @@ -1172,10 +1172,10 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, switch (command) { case NAND_CMD_RNDOUT: /* No ready / busy check necessary */ - chip->cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); + gpmi_cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + gpmi_cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); break; case NAND_CMD_READ0: @@ -1188,10 +1188,10 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, if (column == -1 && page_addr == -1) return; - chip->cmd_ctrl(mtd, NAND_CMD_READSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - chip->cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); + gpmi_cmd_ctrl(mtd, NAND_CMD_READSTART, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + gpmi_cmd_ctrl(mtd, NAND_CMD_NONE, + NAND_NCE | NAND_CTRL_CHANGE); break; } } @@ -2000,7 +2000,6 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) nand_set_flash_node(chip, this->pdev->dev.of_node); chip->select_chip = gpmi_select_chip; chip->setup_data_interface = gpmi_setup_data_interface; - chip->cmd_ctrl = gpmi_cmd_ctrl; chip->cmdfunc = gpmi_nand_command; chip->dev_ready = gpmi_dev_ready; chip->read_byte = gpmi_read_byte; From patchwork Fri Apr 20 08:19:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901785 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="gO2rTqQN"; 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="y9LhDe+C"; 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 40S8b95WWbz9s1w for ; Fri, 20 Apr 2018 18:46:13 +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=blcQGKD1oFZe40z8zV7JOn8lMUpIDNsyccAdOKI0BIQ=; b=gO2rTqQNMkCQ9CdhNUAyznE1kP F+q4Pma76FwChpl3mtZ3kdKV8Xw1pZmWEa6M7dmN27usE00JvAgoDRXMkdafja7ZLVHTTvZns6hD4 ruBYB1z6zgFJ0MpRUVYZMxjkQVWglSHA53LL5AG8uYt/vRFoo+pVzhbGeLJx/THAuNO/fIGgCT/Za uZQIuDklvkVbzoVRiIVk5ZUrDoda3nlB4/R6au1/3QxLYbbO9P/D907oSqa1MRiEdGhEFRCxt0JY0 HHeB1LVQ36IydR2u68iuCYssYPz+mrX1mSy7XYAVU7Tl8qzQ+bOjaOOeyKIBfEOYXfV8IqsnIVTzE ixdR+3VQ==; 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 1f9RgA-0004dq-7D; Fri, 20 Apr 2018 08:46:02 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNI-0007pg-4K for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:46 +0000 Received: by mail-wr0-x241.google.com with SMTP id h3-v6so20667133wrh.5 for ; Fri, 20 Apr 2018 01:26:21 -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=m6L70KfI8oLKlKhrVgHXC26GPJaBxpmAt1rsbO1db2s=; b=y9LhDe+CHfPwCqdQUYcerhtqTx96IA3wfyYVlEuG3QVCyNfDtP8MM5HZq7DdUTInmH cqlnwQB/qQEJdXIs6b4bVVgmWFWGyTvQExtHNy2BxofTvw5R4rzJB/wJvRZBHGcma88U RxFzohjFVGz/hyjvA7OUVBW5PyoPNPT5XAsU484xRW9Bu6GJNp1vdyD8qegqiftdMjnb JFbqXU+cd6AvSdX8/ePzcuR/kdFIMBMXm3fb6RWKY70vM0AMnPkYl00EFzl76iT7LWdk HzpsJYswnCMpyS0IzRqDQ+UkmizkX1glNilPML3jOUlJSwQQmlB67Khxp0OxIdRzxoyz gWPw== 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=m6L70KfI8oLKlKhrVgHXC26GPJaBxpmAt1rsbO1db2s=; b=jaPm075+LNGJAVMgaCbYDUC+Naf5mWXStKSEoK6bpatZR1NcYQTsv+uVwYLYtQ0cl9 rnsf0BhdEVMzOMlaz8+kflF8158LKriNBH3WVX6RZer1n9B28+1LtVWo9ZCn2eR9EBso bw/lDnsQwoZ4pUQAzCYMcPT1iUZSBnSk9YMQJsNHDOgRCpJIaf5QF4ck24YIdr5Dy+Dt 5fPI2M4jJPODXza0TiHKsLZ+QQDiQurHc9PEuNhyuWSuaJdTj0W4VScUAcOaty0BYWKN C5zWIyf3z4wkb5Qp/AOrTMfa1/uJYB0dRMOIAtGvw1U6rzzsY5/17KaxQqSSi6bPTI2C nC4w== X-Gm-Message-State: ALQs6tDI0MZejR7K0CyKeL0VigwTdNkj+YIrs0AK3S9AU9AeeiDQ8mng HiZWD/5YZ7O/6pZifwOs4GR3/hzD X-Google-Smtp-Source: AIpwx497hiL4rAPGY7SkHO78gjfYClfVD5AKjR89J2GyXmuKKnwt+fC/E6OwI7/rf51FSQkjZBYFUA== X-Received: by 2002:adf:884c:: with SMTP id e12-v6mr7540516wre.30.1524212779773; Fri, 20 Apr 2018 01:26:19 -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 e64sm1834235wmg.22.2018.04.20.01.26.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:18 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 16/18] mtd: rawnand: gpmi: inline gpmi_cmd_ctrl() Date: Fri, 20 Apr 2018 10:19:44 +0200 Message-Id: <20180420081946.16088-17-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012632_247205_A26E5868 X-CRM114-Status: GOOD ( 17.86 ) 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:241 listed in] [list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , "Arnout Vandecappelle \(Essensium/Mind\)" MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: "Arnout Vandecappelle (Essensium/Mind)" gpmi_cmd_ctrl() has two "states": * ALE or CLE is set, in this case the command/control data is buffered. These calls are replaced with this->cmd_buffer[this->command_length++] = data; * ALE and CLE are not set, in this case the command is sent (DMA is started). These calls are replaced with ret = gpmi_send_command(this); if (ret) dev_err(this->dev, "Chip: %u, Error %d\n", this->current_chip, ret); this->command_length = 0; The 'ctrl' variable/parameter is not used. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 85 ++++++++++-------------------- 1 file changed, 29 insertions(+), 56 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 5700ca1d2ae6..97d44fe212c9 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -786,40 +786,6 @@ static int gpmi_alloc_dma_buffer(struct gpmi_nand_data *this) return -ENOMEM; } -static void gpmi_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl) -{ - struct nand_chip *chip = mtd_to_nand(mtd); - struct gpmi_nand_data *this = nand_get_controller_data(chip); - int ret; - - /* - * Every operation begins with a command byte and a series of zero or - * more address bytes. These are distinguished by either the Address - * Latch Enable (ALE) or Command Latch Enable (CLE) signals being - * asserted. When MTD is ready to execute the command, it will deassert - * both latch enables. - * - * Rather than run a separate DMA operation for every single byte, we - * queue them up and run a single DMA operation for the entire series - * of command and data bytes. NAND_CMD_NONE means the END of the queue. - */ - if ((ctrl & (NAND_ALE | NAND_CLE))) { - if (data != NAND_CMD_NONE) - this->cmd_buffer[this->command_length++] = data; - return; - } - - if (!this->command_length) - return; - - ret = gpmi_send_command(this); - if (ret) - dev_err(this->dev, "Chip: %u, Error %d\n", - this->current_chip, ret); - - this->command_length = 0; -} - static int gpmi_dev_ready(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); @@ -1104,7 +1070,8 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { register struct nand_chip *chip = mtd_to_nand(mtd); - int ctrl = NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE; + struct gpmi_nand_data *this = nand_get_controller_data(chip); + int ret; /* Large page devices (> 512 bytes) behave slightly differently. */ bool is_lp = mtd->writesize > 512; @@ -1132,39 +1099,41 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, column -= 256; readcmd = NAND_CMD_READ1; } - gpmi_cmd_ctrl(mtd, readcmd, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; + this->cmd_buffer[this->command_length++] = readcmd; } /* Command latch cycle */ if (command != NAND_CMD_NONE) - gpmi_cmd_ctrl(mtd, command, ctrl); + this->cmd_buffer[this->command_length++] = command; - /* Address cycle, when necessary */ - ctrl = NAND_NCE | NAND_ALE | NAND_CTRL_CHANGE; /* Serially input address */ if (column != -1) { /* Adjust columns for 16 bit buswidth */ if (chip->options & NAND_BUSWIDTH_16 && !nand_opcode_8bits(command)) column >>= 1; - gpmi_cmd_ctrl(mtd, column, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; + this->cmd_buffer[this->command_length++] = column; /* Only output a single addr cycle for 8bits opcodes. */ if (is_lp && !nand_opcode_8bits(command)) - gpmi_cmd_ctrl(mtd, column >> 8, ctrl); + this->cmd_buffer[this->command_length++] = column >> 8; } if (page_addr != -1) { - gpmi_cmd_ctrl(mtd, page_addr, ctrl); - ctrl &= ~NAND_CTRL_CHANGE; - gpmi_cmd_ctrl(mtd, page_addr >> 8, ctrl); + this->cmd_buffer[this->command_length++] = page_addr; + this->cmd_buffer[this->command_length++] = page_addr >> 8; if (chip->options & NAND_ROW_ADDR_3) - gpmi_cmd_ctrl(mtd, page_addr >> 16, ctrl); + this->cmd_buffer[this->command_length++] = page_addr >> 16; } /* This starts the DMA for the command and waits for it to finish. */ - gpmi_cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); + if (this->command_length > 0) { + ret = gpmi_send_command(this); + if (ret) + dev_err(this->dev, "Chip: %u, Error %d\n", + this->current_chip, ret); + + this->command_length = 0; + } if (!is_lp) return; @@ -1172,10 +1141,12 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, switch (command) { case NAND_CMD_RNDOUT: /* No ready / busy check necessary */ - gpmi_cmd_ctrl(mtd, NAND_CMD_RNDOUTSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - gpmi_cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); + this->cmd_buffer[this->command_length++] = NAND_CMD_RNDOUTSTART; + ret = gpmi_send_command(this); + if (ret) + dev_err(this->dev, "Chip: %u, Error %d\n", + this->current_chip, ret); + this->command_length = 0; break; case NAND_CMD_READ0: @@ -1188,10 +1159,12 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, if (column == -1 && page_addr == -1) return; - gpmi_cmd_ctrl(mtd, NAND_CMD_READSTART, - NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); - gpmi_cmd_ctrl(mtd, NAND_CMD_NONE, - NAND_NCE | NAND_CTRL_CHANGE); + this->cmd_buffer[this->command_length++] = NAND_CMD_READSTART; + ret = gpmi_send_command(this); + if (ret) + dev_err(this->dev, "Chip: %u, Error %d\n", + this->current_chip, ret); + this->command_length = 0; break; } } From patchwork Fri Apr 20 08:19:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901786 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="PyzjzYVR"; 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="NECJP7Tn"; 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 40S8c41FB5z9s1w for ; Fri, 20 Apr 2018 18:47:00 +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=CIsaVdXkHfIJvUNERTHyqB0strS6ofEW0pA5dyLfDck=; b=PyzjzYVROLknUPc4JL7BHAVKXE H0g7OzY5t2p6v9KVCkf+ANL4segdQKEaXm962Ultx65e/mvYqIQIBh69Os6XxWgcJLExZOpjPyoWE novfB3weZ239BD4QiScqNc+EHDXZZJoEqKlv9KvIgC2C12xu/nTTfa625LzAEbbROI8YYvbiqZJYa dahVKTLaMoiiQfly/0uOx5P5YyKEK3FPp25venQI8cbag+8zlyZlh/YPYthSpdIfy9kzHJptbq526 nIuvUD9QGaPXzHEQBybxAVZYA5FGYzOYdx3Lcq/hoKkQqel/O1fJGDxsSX4o/0YfIjLAGP4kt1sjJ gClNCKlg==; 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 1f9Rgv-0004yH-8Q; Fri, 20 Apr 2018 08:46:49 +0000 Received: from mail-wr0-f196.google.com ([209.85.128.196]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNK-0007qi-FU for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:51 +0000 Received: by mail-wr0-f196.google.com with SMTP id w3-v6so20659505wrg.2 for ; Fri, 20 Apr 2018 01:26:24 -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=vtmA95re5JCmDMiOnjeuO/oHHCTwG1PSaGjBzdd31Ic=; b=NECJP7TnvcetYN1sRnKQA4amlsAifo0y5n7ND6VuuH5Gf2ZwpT2DsC94FvSzFzTOAq dLWwzBqzt0A1Vl0VEesz7qdC44unTwTLs8GlygfW54AsXTFDjbo/WlVLp5MspmtSbqFB PWlculFeTO4ybfYkjDzQPQQK41ktou8YTeQ1RJ9G3s5KEoekeqFpuOH2mNn+fBNbUt0j etZeMe2X9KIl6SlW9SoMtV5rjD8h6TpdwLl918Mpph1ND4E2SGe+40iffUUia9/EXUCP JodwdM2tHMI/L3si2cF6UtIdVFs0XlR3a1mgeOLuohahjjUU/CA2Zs3u3shTR/I7TNl2 jJuQ== 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=vtmA95re5JCmDMiOnjeuO/oHHCTwG1PSaGjBzdd31Ic=; b=L1FQK/hs1MPou6m/OTpBX2WCjquLLNE8tH61FEYb69t3MvCVxcugKkX0FfHr9fBBbn 5g16VFRAGmNiCd1fu4nKbQQ20aMWxYjiw4uwU2TvdDt2MkmggFpxniZxFn5HYuxlaY3Q Rodo+GRLLDw3m8H2K4bw6xgyt+Aus+0hSYPio5KAQZ6T/TkLsG/pr4C2X7If3SiOfZA8 TRFuQwyFs9uK5sZBgvsNVGbNaGFbr1cF5FV/pmWwVzxQ5K495N7rk9WxP06FVO1PE9Ln TdaaQfXAmG9wNdpbroBUr7+iXyZX0K4t4+nOFOwY7bePYETXDIBrzISCuE61SLDmOeec L5VA== X-Gm-Message-State: ALQs6tBnwJ8QyJTIyfcc2pWL8DOEPdKb8BTEBXgylTvRwOJ72Se+hc5I IsmvsKRRF2uTSLPssqPctm2kJW/e X-Google-Smtp-Source: AIpwx4+INrsgYMDLOdas2EfWj2M5aZEnJbpTIEdeOfaPKGmb0t6ZRcUgObGE2W+GjTYBifQRyMy9fw== X-Received: by 10.28.48.14 with SMTP id w14mr1292556wmw.21.1524212781498; Fri, 20 Apr 2018 01:26:21 -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 e64sm1834235wmg.22.2018.04.20.01.26.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:20 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 17/18] mtd: rawnand: gpmi: gpmi_nand_command(): use separate sgl for the two commands Date: Fri, 20 Apr 2018 10:19:45 +0200 Message-Id: <20180420081946.16088-18-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_012634_564441_745E356D X-CRM114-Status: GOOD ( 20.91 ) 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 [209.85.128.196 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.196 listed in wl.mailspike.net] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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: Han Xu , Sam Lefebvre , Arnout Vandecappelle MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To enable chaining the two DMAs corresponding to the two commands that can be issued by gpmi_nand_command(), duplicate the cmd_sgl and command_length. For cmd_buffer, instead of duplicating it, we can use a fixed offset within the buffer. The appropriate sgl and command_length is passed to gpmi_send_command(), and the sg_init_one(), dma_map_sg() and dma_unmap_sg() calls are hoisted out of it. This is needed because the unmapping should only be done after both commands have finished. 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 | 68 +++++++++++++++++------------- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h | 9 +++- 3 files changed, 49 insertions(+), 40 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c index 1858afdb400d..46b2208df30e 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-lib.c @@ -548,11 +548,11 @@ int gpmi_is_ready(struct gpmi_nand_data *this, unsigned chip) return reg & mask; } -int gpmi_send_command(struct gpmi_nand_data *this) +int gpmi_send_command(struct gpmi_nand_data *this, struct scatterlist *sgl, + unsigned int command_length) { struct dma_chan *channel = get_dma_chan(this); struct dma_async_tx_descriptor *desc; - struct scatterlist *sgl; int chip = this->current_chip; int ret; u32 pio[3]; @@ -564,7 +564,7 @@ int gpmi_send_command(struct gpmi_nand_data *this) | BF_GPMI_CTRL0_LOCK_CS(LOCK_CS_ENABLE, this) | BF_GPMI_CTRL0_ADDRESS(BV_GPMI_CTRL0_ADDRESS__NAND_CLE) | BM_GPMI_CTRL0_ADDRESS_INCREMENT - | BF_GPMI_CTRL0_XFER_COUNT(this->command_length); + | BF_GPMI_CTRL0_XFER_COUNT(command_length); pio[1] = pio[2] = 0; desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)pio, @@ -573,10 +573,6 @@ int gpmi_send_command(struct gpmi_nand_data *this) return -EINVAL; /* [2] send out the COMMAND + ADDRESS string stored in @buffer */ - sgl = &this->cmd_sgl; - - sg_init_one(sgl, this->cmd_buffer, this->command_length); - dma_map_sg(this->dev, sgl, 1, DMA_TO_DEVICE); desc = dmaengine_prep_slave_sg(channel, sgl, 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK); @@ -586,8 +582,6 @@ int gpmi_send_command(struct gpmi_nand_data *this) /* [3] submit the DMA */ ret = start_dma_without_bch_irq(this, desc); - dma_unmap_sg(this->dev, sgl, 1, DMA_TO_DEVICE); - 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 97d44fe212c9..4455ea428255 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -1075,6 +1075,9 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, /* Large page devices (> 512 bytes) behave slightly differently. */ bool is_lp = mtd->writesize > 512; + BUG_ON(this->command_length != 0); + BUG_ON(this->command_length2 != 0); + if (is_lp) { /* Large page devices don't have the separate regions as we * have in the small page devices. We must emulate @@ -1125,47 +1128,54 @@ static void gpmi_nand_command(struct mtd_info *mtd, unsigned int command, this->cmd_buffer[this->command_length++] = page_addr >> 16; } + /* Reuse the same cmd_buffer for the possible second command. The address + * must be word-aligned. For convenience, use a fixed offset of 64, much + * larger than the maximum command_length. */ + if (is_lp) + switch (command) { + case NAND_CMD_RNDOUT: + /* No ready / busy check necessary */ + this->cmd_buffer[64 + this->command_length2++] = NAND_CMD_RNDOUTSTART; + break; + + case NAND_CMD_READ0: + /* + * READ0 is sometimes used to exit GET STATUS mode. When this + * is the case no address cycles are requested, and we can use + * this information to detect that that we should not wait for + * the device to be ready and READSTART should not be issued. + */ + if (column != -1 || page_addr != -1) + this->cmd_buffer[64 + this->command_length2++] = NAND_CMD_READSTART; + break; + } + /* This starts the DMA for the command and waits for it to finish. */ if (this->command_length > 0) { - ret = gpmi_send_command(this); + 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); if (ret) dev_err(this->dev, "Chip: %u, Error %d\n", this->current_chip, ret); - - this->command_length = 0; } - if (!is_lp) - return; - - switch (command) { - case NAND_CMD_RNDOUT: - /* No ready / busy check necessary */ - this->cmd_buffer[this->command_length++] = NAND_CMD_RNDOUTSTART; - ret = gpmi_send_command(this); + 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); if (ret) dev_err(this->dev, "Chip: %u, Error %d\n", this->current_chip, ret); - this->command_length = 0; - break; - - case NAND_CMD_READ0: - /* - * READ0 is sometimes used to exit GET STATUS mode. When this - * is the case no address cycles are requested, and we can use - * this information to detect that that we should not wait for - * the device to be ready and READSTART should not be issued. - */ - if (column == -1 && page_addr == -1) - return; + } - this->cmd_buffer[this->command_length++] = NAND_CMD_READSTART; - ret = gpmi_send_command(this); - if (ret) - dev_err(this->dev, "Chip: %u, Error %d\n", - this->current_chip, ret); + if (this->command_length > 0) { + dma_unmap_sg(this->dev, &this->cmd_sgl, 1, DMA_TO_DEVICE); this->command_length = 0; - break; + } + if (this->command_length2 > 0) { + dma_unmap_sg(this->dev, &this->cmd_sgl2, 1, DMA_TO_DEVICE); + this->command_length2 = 0; } } diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h index 6aa10d6962d6..9dc3dd16fa0b 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.h @@ -139,11 +139,15 @@ struct gpmi_nand_data { /* General-use Variables */ int current_chip; - unsigned int command_length; + unsigned int command_length; struct scatterlist cmd_sgl; char *cmd_buffer; + unsigned int command_length2; + struct scatterlist cmd_sgl2; + char *cmd_buffer2; + struct scatterlist data_sgl; char *data_buffer_dma; @@ -184,7 +188,8 @@ void gpmi_clear_bch(struct gpmi_nand_data *); 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 *); +int gpmi_send_command(struct gpmi_nand_data *, struct scatterlist *sgl, + unsigned int command_length); 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, From patchwork Fri Apr 20 08:19:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Lefebvre X-Patchwork-Id: 901788 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="O07iXtCy"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="alSC6t2z"; 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="JV+cDM7U"; 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 40S8dp6QQrz9s1w for ; Fri, 20 Apr 2018 18:48:30 +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=94w5iiyeTiZcB5vz81iJoZUAbAoo/3wnwaOQH5139Uk=; b=O07iXtCyTQ25iBorJ8bGjvDy7a ge98YpQiKp/5W93gDSmHDaRrlhv57TrKxGt8WEL/1QNVgemku4WLfA/a2EPxdWusEIlQY/C1FhtOi X1IZDCx/VUhyUv8vuFxhzHgoTCeISeQlCmlcAbtuKmM5cU5mwxkBdLyp8BvvX/yDW2b7JsWYp9iip oJICQRm55zPv7mr4WwYmfD9VgcQFm8QgIRUMkbn5hq6VI3ns6y3lp+cJkqvhMOJSDxrm7eDMkIAsr kuLyHAXrzZjsrtHz6eg3TbxEa2WB6M8lqQtQ4srIcUi94WU6CDxBtXJWvZy/Ltw1yN2PqAzwDTXZF hACSfzlw==; 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 1f9RiQ-0005c5-91; Fri, 20 Apr 2018 08:48:22 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9Ras-0000DM-5Z for linux-mtd@bombadil.infradead.org; Fri, 20 Apr 2018 08:40: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=lhGyCDY1r3tGeyMsiRQe/+prUaiv+uy2Uy582JL0D+g=; b=alSC6t2zBvZcMgbgLXVtGpx6P UDyEEQqzlf73yObtldgFIs6f9tv3ZetEGgP4ArHWskdqPx7k2CU3r8rhvtzP2vg0QcN0NS6x68s8h ug1n5UD3fFYSc75HKeb4BWDSMbmDnga1YbK5zx/cofY5JX4zVz1X/AsrZvA34BfOrLfsGZ+ng0yLf eyN41aPtAPvHbkkashpYWOfU3LfyfhAbfomupUhcWaA49jK4xLTe283es1F2ED2R3XwLzgggVlHZm WPXgxOTN04PEYgUJGx2I+l3ktcrlSSwo6O30OxMuRfsKYhKy3o0xAfyzKLZZH/MlbLOaMpJxM1RbI 1NKeNzL4w==; Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9RNK-0001HH-J0 for linux-mtd@lists.infradead.org; Fri, 20 Apr 2018 08:26:36 +0000 Received: by mail-wr0-x242.google.com with SMTP id v24-v6so20635097wra.8 for ; Fri, 20 Apr 2018 01:26:24 -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=lhGyCDY1r3tGeyMsiRQe/+prUaiv+uy2Uy582JL0D+g=; b=JV+cDM7UbtQEMi7O8VdzJWQJXy9m1LwYc8JuX3D2wWFlbMJ1JWgFP8dzFTI5yPdMIX ChvUabta5s5M8tupjYRs55OX6GEdSdBLOgntlNfO1vWWgH4jeFu3XvJAArlFHo2xx1sS 9zxjndcovBkLgyzHjU1DsL1eFW+UjLNMWeSFFuE7D2prKPZXchs3rXl86Le1sML8ku+q n/Vn8nCpQ/5gBgk8XF29ShOOXXb6AQUzDQh6x3oPn7YK0YLF60Tml8qOhycBFE697oh/ 1Bk46/CFclZr9HLgCI0cCKjmRsx+I/jnF0X9cKT8UnnP+Zylddy0rv+rNa6WEZKr5JhV sYeg== 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=lhGyCDY1r3tGeyMsiRQe/+prUaiv+uy2Uy582JL0D+g=; b=LlK+kroobW/8syYvoXXRChtj+8HoV9S1U/8bzatqckIL+W1K9rbUdpX22QWZHObDfv /SZ4nwUR0gW3llpdgJpazCw0fZT/THByf9Xr2Bu2zHG8knPW4SojB5ZAjJijOeFrVv7J ZLtWyKi58SMfe9K2Jlln0ru5fvG5kTY4rvwVgLmbEFr1wq2Rt1VPDQjlbFE9MYHtBZ17 kuHYJHBnXxZFMxHXLMguysHQJ9TmA0DCzIyrOUI7mFlFEytC4y1eUpBlbhwjyTID/nBB kxmZqdxHwdle+xRaA9oyMjtQkQ6vzmwrt2OjWgE1qMFSx8BA6enE6vb2EN5Qt7xb5J6x 97Tg== X-Gm-Message-State: ALQs6tBPwlgpFJD3cqd1DH58x1uEBXe8OtBk6c/EBuZB5XfPT9s2oahk PRjYGY+5wmgBBUiQ1sPnzBrzXsSf X-Google-Smtp-Source: AB8JxZroCH1j/B0ltc1PhuIamRqUwiKwwbMdBgA2HCN+p/v4MxKFP6CrFL49INOgUYs3fFVwIre4Fw== X-Received: by 10.28.51.79 with SMTP id z76mr1331673wmz.113.1524212783276; Fri, 20 Apr 2018 01:26:23 -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 e64sm1834235wmg.22.2018.04.20.01.26.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Apr 2018 01:26:22 -0700 (PDT) From: Sam Lefebvre To: linux-mtd@lists.infradead.org Subject: [PATCH 18/18] mtd: rawnand: gpmi: issue two commands in a single DMA chain Date: Fri, 20 Apr 2018 10:19:46 +0200 Message-Id: <20180420081946.16088-19-sam.lefebvre@essensium.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180420081946.16088-1-sam.lefebvre@essensium.com> References: <20180420081946.16088-1-sam.lefebvre@essensium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180420_092634_615628_4812A3CB X-CRM114-Status: GOOD ( 17.04 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) 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:242 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: Han Xu , Sam Lefebvre , Arnout Vandecappelle 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 4455ea428255..abf227148b01 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -1150,11 +1150,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); @@ -1163,7 +1164,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,