Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5068896imm; Tue, 7 Aug 2018 12:05:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpenbYwkUonsNjcJw/iRk2ooMMoIP5CSVQgKmZrfrnCjqtPFg8JLhTy2JtaDo/fnaOFJi9Ap X-Received: by 2002:a17:902:7481:: with SMTP id h1-v6mr19313941pll.183.1533668700154; Tue, 07 Aug 2018 12:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533668700; cv=none; d=google.com; s=arc-20160816; b=L9fIXyDGiU9iuHnhocz3VQS+ZndG7Hh1qDdlcnfGFwjpdjrfedC0lOMeR/TM8Fj2iW yc7JpW44u7kMQ8AAuJJAqd0+MR6OJuB1Sx6Iwj+uis6RlT3PKxksOmakjQ3sy10fp2WY 5so5K6C9/3RBQ7jeWHEOxSEX6nyIHCMr9XEqDIWgNap0vTVGup3IiviTuSph7ZvfIYYQ sXs8GIuHJH7+N4hNp8C628OyP7QNvWbDqvr3BsmWktrKs2Os8qqiviHV1y2BKqlr5/hI nMjAEXPaJTzqEXW5ibxE5yiCMQUQlMXhcZZcLeRtADgXqO3k+O2N7EFHgv2X82JHujs6 vDIQ== 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=uS7FAXMDXQ19b25W9/MzW7ke4KaZF7g4/msuyTxdNXg=; b=edGtAhkEmE56ZHaX/4dfTp6iY6d7KKFFfgWjcEl/MIw753hI/13QQ83W38GFgRyCWS rQjWZutcTfEpWT1A2NVqtoWVhkJiHK+EaR5xn7z2wqLPQUwWrEPHRNXV+y4RMVkL+4tJ WRxdSXtH96n+4gX9imFLXh3ea4GDLOP1qXpAlMybiIplqsnrvTq6kMAaEviDcm4r/gYU F2oxrzlKFxhl0DgJj9vtighq5yApAgQukSJwKgJ0RH8BehGJ+LdNtMSNsOFuGTdtTetw HcYJ22fQXi1b91wVYssvn0UPZZxoeBpQEqfckWpyf4p8HsQw7q7GjkVxrjhfFWY5kx+j tygw== 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 s17-v6si1609125plr.120.2018.08.07.12.04.45; Tue, 07 Aug 2018 12:05:00 -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 S2390833AbeHGVNu (ORCPT + 99 others); Tue, 7 Aug 2018 17:13:50 -0400 Received: from mail.bootlin.com ([62.4.15.54]:40334 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389581AbeHGVNs (ORCPT ); Tue, 7 Aug 2018 17:13:48 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 2ADF92084E; Tue, 7 Aug 2018 20:58:02 +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 B051D207E5; Tue, 7 Aug 2018 20:57:51 +0200 (CEST) Date: Tue, 7 Aug 2018 20:57:52 +0200 From: Boris Brezillon To: Janusz Krzysztofik Cc: Linus Walleij , linux-omap@vger.kernel.org, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org Subject: Re: [RFC PATCH v2 07/12] mtd: rawnand: ams-delta: Set port direction once per transfer Message-ID: <20180807205752.32cd3e53@bbrezillon> In-Reply-To: <20180806222918.12644-8-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> <20180806222918.12644-8-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 Tue, 7 Aug 2018 00:29:13 +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. Since > performance of the driver is completely not acceptable on Amstrad Delta > after it has been converted to GPIO bitbang, try to improve things a > bit by setting the port direction only on first byte of each transfer. > > Resulting performance on Amstrad Delta is still far from acceptable. > > Signed-off-by: Janusz Krzysztofik > --- > drivers/mtd/nand/raw/ams-delta.c | 58 ++++++++++++++++++++++++++++++++-------- > 1 file changed, 47 insertions(+), 11 deletions(-) > > diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c > index 78996ddf82e0..d02c48c013e8 100644 > --- a/drivers/mtd/nand/raw/ams-delta.c > +++ b/drivers/mtd/nand/raw/ams-delta.c > @@ -69,6 +69,30 @@ static const struct mtd_partition partition_info[] = { > .size = 3 * SZ_256K }, > }; > > +static void ams_delta_write_commit(struct ams_delta_nand *priv) > +{ > + gpiod_set_value(priv->gpiod_nwe, 0); > + ndelay(40); > + gpiod_set_value(priv->gpiod_nwe, 1); > +} > + > +static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) > +{ > + struct nand_chip *this = mtd_to_nand(mtd); > + struct ams_delta_nand *priv = nand_get_controller_data(this); > + struct gpio_descs *data_gpiods = priv->data_gpiods; > + unsigned long bits = byte; > + int i, value_array[data_gpiods->ndescs]; > + > + for (i = 0; i < data_gpiods->ndescs; i++) > + value_array[i] = test_bit(i, &bits); > + > + gpiod_set_raw_array_value(data_gpiods->ndescs, data_gpiods->desc, > + value_array); > + > + ams_delta_write_commit(priv); > +} > + > static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) > { > struct nand_chip *this = mtd_to_nand(mtd); > @@ -81,12 +105,10 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) > gpiod_direction_output_raw(data_gpiods->desc[i], > test_bit(i, &bits)); > > - gpiod_set_value(priv->gpiod_nwe, 0); > - ndelay(40); > - gpiod_set_value(priv->gpiod_nwe, 1); > + ams_delta_write_commit(priv); > } > > -static u_char ams_delta_read_byte(struct mtd_info *mtd) > +static u_char ams_delta_read_next_byte(struct mtd_info *mtd) > { > struct nand_chip *this = mtd_to_nand(mtd); > struct ams_delta_nand *priv = nand_get_controller_data(this); > @@ -94,9 +116,6 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) > unsigned long bits = 0; > int i, value_array[data_gpiods->ndescs]; > > - for (i = 0; i < data_gpiods->ndescs; i++) > - gpiod_direction_input(data_gpiods->desc[i]); > - > gpiod_set_value(priv->gpiod_nre, 0); > ndelay(40); > > @@ -112,21 +131,38 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) > return bits; > } > > +static u_char ams_delta_read_byte(struct mtd_info *mtd) > +{ > + struct nand_chip *this = mtd_to_nand(mtd); > + struct ams_delta_nand *priv = nand_get_controller_data(this); > + struct gpio_descs *data_gpiods = priv->data_gpiods; > + int i; > + > + for (i = 0; i < data_gpiods->ndescs; i++) > + gpiod_direction_input(data_gpiods->desc[i]); > + > + return ams_delta_read_next_byte(mtd); > +} > + > static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, > int len) > { > int i; > > - for (i=0; i - ams_delta_write_byte(mtd, buf[i]); > + if (len > 0) > + ams_delta_write_byte(mtd, buf[0]); > + for (i = 1; i < len; i++) > + ams_delta_write_next_byte(mtd, buf[i]); > } > > static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) > { > int i; > > - for (i=0; i - buf[i] = ams_delta_read_byte(mtd); > + if (len > 0) > + buf[0] = ams_delta_read_byte(mtd); > + for (i = 1; i < len; i++) > + buf[i] = ams_delta_read_next_byte(mtd); > } I'd suggest a slightly different approach where the data pins direction state is stored in the the priv struct and only changed when required. This way you just have to add a test in ams_delta_read/write_byte().