Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2814815imm; Fri, 24 Aug 2018 05:58:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY1BhE/RSqQ2nOhr/8wpqjT7uGHHQ0YFYVnuoEF3eWmBcF3LE2UKd0PhiKDnEtfU1URrCny X-Received: by 2002:a62:f555:: with SMTP id n82-v6mr1878958pfh.59.1535115524427; Fri, 24 Aug 2018 05:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535115524; cv=none; d=google.com; s=arc-20160816; b=mPM7/DuKTwGr2pI3+EjSao88g5ySvmxAL3EkQ7tFYAJHN7uf3h+6WrFuJP3ETx+9LQ /uvmiEY25AOl4FuKKLDb+OLMeI83RxuOYIXiBgrFHmXRh4F5YzvDF3k5wDF6LvNzyCkL 69fZ0f15hSyWe5jQIpQsYHfs2GHognu3Pt2y5ZuNNGDkS87mA2FUCPvcvY52KkkK2q/L gHgSEtmeI7Ageho2ersrtdScDo+ULT42waH5L3cHQXYtaZiWICrRz1/iA3No0qH1eORF rnBydGhlAkrC4exQxlb7gHp6vQuPgdKkoOGKuQnPT4OyYRLQ/7939himOOypC3SWynod BKYw== 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=ECnSXN5K9uxAQ8/e7jVVsGJDfOqrA+LIRlImxr0vo7Q=; b=AQNu1loWgDaYDo+2EzPoE6PlYHIfNXaukxnD3vwBdMQNpWp7bQtNfVkXX6L8b/y4J3 32zU5mINv0KXI0Z3sFwAvxvZF3m0MFnP7dnPiCO/bt81JVDdvuculNzMfXRlN96sR0UK Bhcbypg1TMPpGNw+/1dWC1o3W6ITvIkdni8Y55+L+c2J1/XppYp89WGhf97sqpzaE5n6 byScxq2VGHdPTPjq6e5DJwMdaioBF2uNU2TmLrOthrnFtspmjZEUCjAjb15EqWJDbI8K jvPrM7R/PzYxtHWZ2yuyhPNyWk7b9G7yO5pxQZEfB9vuTr8QHnsNl3NN9YSv2qYBQ2og fQyg== 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 22-v6si7077220pfb.215.2018.08.24.05.58.28; Fri, 24 Aug 2018 05:58:44 -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 S1727160AbeHXQb5 (ORCPT + 99 others); Fri, 24 Aug 2018 12:31:57 -0400 Received: from mail.bootlin.com ([62.4.15.54]:47963 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbeHXQb4 (ORCPT ); Fri, 24 Aug 2018 12:31:56 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 608AF2072C; Fri, 24 Aug 2018 14:57:23 +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, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from bbrezillon (AAubervilliers-681-1-53-19.w90-88.abo.wanadoo.fr [90.88.170.19]) by mail.bootlin.com (Postfix) with ESMTPSA id C01C2206A6; Fri, 24 Aug 2018 14:57:19 +0200 (CEST) Date: Fri, 24 Aug 2018 14:57:18 +0200 From: Boris Brezillon To: Janusz Krzysztofik Cc: Miquel Raynal , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/3] mtd: rawnand: ams-delta: Set port direction when needed Message-ID: <20180824145718.07defe03@bbrezillon> In-Reply-To: <20180820213904.13475-4-jmkrzyszt@gmail.com> References: <20180813223448.21316-1-jmkrzyszt@gmail.com> <20180820213904.13475-1-jmkrzyszt@gmail.com> <20180820213904.13475-4-jmkrzyszt@gmail.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 On Mon, 20 Aug 2018 23:39:04 +0200 Janusz Krzysztofik wrote: > In its current shape, the driver sets data port direction before each > byte read/write operation, even during multi-byte transfers. Improve > performance of the driver by setting the port direction only when > needed. > > This optimisation will become particularly important as soon as > planned conversion of the driver to GPIO API for data I/O will be > implemented. > > Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon > --- > drivers/mtd/nand/raw/ams-delta.c | 68 ++++++++++++++++++++++++++-------------- > 1 file changed, 45 insertions(+), 23 deletions(-) > > diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c > index 48233d638d2a..4d5e5790f18e 100644 > --- a/drivers/mtd/nand/raw/ams-delta.c > +++ b/drivers/mtd/nand/raw/ams-delta.c > @@ -45,6 +45,7 @@ struct ams_delta_nand { > struct gpio_desc *gpiod_ale; > struct gpio_desc *gpiod_cle; > void __iomem *io_base; > + bool data_in; > }; > > /* > @@ -72,50 +73,65 @@ static const struct mtd_partition partition_info[] = { > .size = 3 * SZ_256K }, > }; > > -static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) > +static void ams_delta_io_write(struct ams_delta_nand *priv, u8 byte) > { > - struct nand_chip *this = mtd_to_nand(mtd); > - struct ams_delta_nand *priv = nand_get_controller_data(this); > - void __iomem *io_base = priv->io_base; > - > - writew(0, io_base + OMAP_MPUIO_IO_CNTL); > - writew(byte, this->IO_ADDR_W); > + writew(byte, priv->nand_chip.IO_ADDR_W); > gpiod_set_value(priv->gpiod_nwe, 0); > ndelay(40); > gpiod_set_value(priv->gpiod_nwe, 1); > } > > -static u_char ams_delta_read_byte(struct mtd_info *mtd) > +static u8 ams_delta_io_read(struct ams_delta_nand *priv) > { > - u_char res; > - struct nand_chip *this = mtd_to_nand(mtd); > - struct ams_delta_nand *priv = nand_get_controller_data(this); > - void __iomem *io_base = priv->io_base; > + u8 res; > > gpiod_set_value(priv->gpiod_nre, 0); > ndelay(40); > - writew(~0, io_base + OMAP_MPUIO_IO_CNTL); > - res = readw(this->IO_ADDR_R); > + res = readw(priv->nand_chip.IO_ADDR_R); > gpiod_set_value(priv->gpiod_nre, 1); > > return res; > } > > -static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, > - int len) > +static void ams_delta_dir_input(struct ams_delta_nand *priv, bool in) > { > + writew(in ? ~0 : 0, priv->io_base + OMAP_MPUIO_IO_CNTL); > + priv->data_in = in; > +} > + > +static void ams_delta_write_buf(struct mtd_info *mtd, const u8 *buf, int len) > +{ > + struct nand_chip *this = mtd_to_nand(mtd); > + struct ams_delta_nand *priv = nand_get_controller_data(this); > int i; > > - for (i=0; i - ams_delta_write_byte(mtd, buf[i]); > + if (priv->data_in) > + ams_delta_dir_input(priv, false); > + > + for (i = 0; i < len; i++) > + ams_delta_io_write(priv, buf[i]); > } > > -static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) > +static void ams_delta_read_buf(struct mtd_info *mtd, u8 *buf, int len) > { > + struct nand_chip *this = mtd_to_nand(mtd); > + struct ams_delta_nand *priv = nand_get_controller_data(this); > int i; > > - for (i=0; i - buf[i] = ams_delta_read_byte(mtd); > + if (!priv->data_in) > + ams_delta_dir_input(priv, true); > + > + for (i = 0; i < len; i++) > + buf[i] = ams_delta_io_read(priv); > +} > + > +static u8 ams_delta_read_byte(struct mtd_info *mtd) > +{ > + u8 res; > + > + ams_delta_read_buf(mtd, &res, 1); > + > + return res; > } > > /* > @@ -138,8 +154,11 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, > gpiod_set_value(priv->gpiod_ale, !!(ctrl & NAND_ALE)); > } > > - if (cmd != NAND_CMD_NONE) > - ams_delta_write_byte(mtd, cmd); > + if (cmd != NAND_CMD_NONE) { > + u8 byte = cmd; > + > + ams_delta_write_buf(mtd, &byte, 1); > + } > } > > static int ams_delta_nand_ready(struct mtd_info *mtd) > @@ -262,6 +281,9 @@ static int ams_delta_init(struct platform_device *pdev) > goto out_mtd; > } > > + /* Initialize data port direction to a known state */ > + ams_delta_dir_input(priv, true); > + > /* Scan to find existence of the device */ > err = nand_scan(mtd, 1); > if (err)