Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp981523imm; Mon, 9 Jul 2018 14:35:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdi5NX6RZfE42jybK392aBH1uQ6BnUi1y+taSnt5MpIMUdj4QZKtdiWKQd66rXn2a8LwBkb X-Received: by 2002:a62:3a9d:: with SMTP id v29-v6mr22936644pfj.215.1531172140637; Mon, 09 Jul 2018 14:35:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531172140; cv=none; d=google.com; s=arc-20160816; b=aFtpBbS7HUrUb12atFRZP8fGY96qR0N32mboAGCU1jU3TK7CETIRD+USZfzYscDqXb qfh/ObafubqhhnxtufE7fLErQacdO5rjLATcEbWrJ1Jwfo4qb10+EcA2c/0M6Fof/t3o xVMokgni0GnmgXpW2qXHqBu46cr7EBv7J1Un0Ao6qNfI/bR8zr3S5nygy+hTfOx7jZhO Qb3XlCi6wNnHghDU1jTxXZ9fIfKl4GF4xCJYI0Nugln7QHAwc841BQ28bKN2M3XdEVf/ TMvWFKhtI+yCEnRX+TlDW2olSldNy+XeUXukhy/VeSCHBS1u8b0oKjQWo5s10E/NTiOQ t8Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=hsNOuG1LCpDzqJzGvxLmOzQajW1v/8qEgIj3w47xbH8=; b=PGlk9HPVM3b8jlnjFuOpUSuyjoHl3Tj0M3OdBaC8uu+hXrZQoDfjI4JuDksPYGhnxU QG7yMXhAKCQo4L0cTPGrSqvV/RXRu749rClru+XmcQXjcHrQEF6GZt81b17HI7+nGKMN ESnkdoX6b/RFqrWe+3Ge/DtCXaM846393lRFpFHtnXJ3cO39bm6JWf5h4Brmf6Td3Ur5 R8Ip4NNGNFgx5+GLkNDf/XbWpNbUl3cmcsRFD2P7+QZDtJX5lCEBF2OQIHuuF4ZpJmu4 7rYrQmQqLb+S7l2XZVGbOww7bxqMsncSAsjwWKaT063/Vn09tPMRUeMlJyybPPqjVwJC p9oA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j190-v6si15233378pfb.211.2018.07.09.14.35.25; Mon, 09 Jul 2018 14:35:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933218AbeGIVeb (ORCPT + 99 others); Mon, 9 Jul 2018 17:34:31 -0400 Received: from mail.bootlin.com ([62.4.15.54]:43624 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933060AbeGIVea (ORCPT ); Mon, 9 Jul 2018 17:34:30 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id C979A20733; Mon, 9 Jul 2018 23:34:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 74E4320012; Mon, 9 Jul 2018 23:34:28 +0200 (CEST) Date: Mon, 9 Jul 2018 23:34:27 +0200 From: Boris Brezillon To: Yogesh Gaur Cc: linux-mtd@lists.infradead.org, frieder.schrempf@exceet.de, computersforpeace@gmail.com, david.wolfe@nxp.com, han.xu@nxp.com, festevam@gmail.com, marek.vasut@gmail.com, prabhakar.kushwaha@nxp.com, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Fabio Estevam Subject: Re: [PATCH] mtd: spi-nor: Support controllers with limited TX FIFO size Message-ID: <20180709233427.1a714de7@bbrezillon> In-Reply-To: <1528870092-14526-1-git-send-email-yogeshnarayan.gaur@nxp.com> References: <1528870092-14526-1-git-send-email-yogeshnarayan.gaur@nxp.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Fabio Hi Yogesh, On Wed, 13 Jun 2018 11:38:12 +0530 Yogesh Gaur wrote: > Some SPI controllers can't write nor->page_size bytes in a single > step because their TX FIFO is too small. > > Allow nor->write() to return a size that is smaller than the requested > write size to gracefully handle this case. There's been a discussion between Marek and I regarding this patch and patch "mtd: devices: m25p80: Make sure WRITE_EN is issued before each write". Marek would like to avoid letting drivers do non-aligned page writes when the MTD user requested full page writes. So, the question is, is the FSL QSPI engine capable of handling that when the NOR page is being than the TX FIFO? According to the current implementation it's not [1], but it looks like we have a way to know when the TX FIFO is not full so we could potentially refill the FIFO either from the CPU or using DMA if that's possible (not sure the eDMA engine can fill the QSPI TX FIFO directly). What I find worrisome with this solution is this particular statement in the datasheet: " When the QuadSPI module tries to pull data out of an empty TX Buffer the TX Buffer underrun is signaled by the QSPI_FR[TBUF] flag. The current IP Command leading to the underrun condition is continued until the specified number of bytes has been sent to the serial flash device, in the underrun condition when QuadSPI module tries to pull out data of empty TX buffer, the data transferred is undefined i.e. once the underrun flag is set, it will return the garbage value until the required number of bytes are not sent. " If we fail to fill the TX FIFO fast enough for any reasons (contention on the APB/AHB/AXI bus in case of DMA, task being scheduled out in case of PIO access), that means we transfer garbage to the NOR... Clearly something we should avoid at any cost. Yogesh, Fabio, Han, any comment on this? Thanks, Boris [1]https://elixir.bootlin.com/linux/v4.18-rc4/source/drivers/mtd/spi-nor/fsl-quadspi.c#L1117 > > Signed-off-by: Yogesh Gaur > --- > drivers/mtd/spi-nor/spi-nor.c | 7 ------- > 1 file changed, 7 deletions(-) > > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > index 5bfa36e..3e63543 100644 > --- a/drivers/mtd/spi-nor/spi-nor.c > +++ b/drivers/mtd/spi-nor/spi-nor.c > @@ -1431,13 +1431,6 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len, > goto write_err; > *retlen += written; > i += written; > - if (written != page_remain) { > - dev_err(nor->dev, > - "While writing %zu bytes written %zd bytes\n", > - page_remain, written); > - ret = -EIO; > - goto write_err; > - } > } > > write_err: