Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1352982imm; Wed, 18 Jul 2018 23:28:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpew0P3iVgyto8C7/3X+BEbeSoykAwJ8nar5O0afWpLnAJ6gqUEVX421Fl0UwtH9A3RRNwgB X-Received: by 2002:a63:2246:: with SMTP id t6-v6mr8804137pgm.258.1531981689616; Wed, 18 Jul 2018 23:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531981689; cv=none; d=google.com; s=arc-20160816; b=UymHX4CtqhnkrTLHLHQSG9QMblwix+p1rNhJE7v82iHY+DOqzJOCEv5nsXC7MlksOE kXYtCiQcmjEeKGyH3D5Z5DzIE22TjJcXfUa0HTfo6ifvQYXXmmbhKzb8l+eW5eTuduYb bSnd8cqrO84Q45qod5sWz0Lli81M3Vo9K2nsl4hJxPMDWotHw1hzDzANgaa94epdZ7bR qpffXVYAeo3DiVXCI1qLzGIcf1vcfSdc1ZOYmqkDTHB8K7lQ5qS8+vipDZFHdshZEVG1 9oOyz1aMkuqhzdVb+8snYBBaBIUxHNDl/InGc5ZWW8vSaUYrJ01m8M6tDeveSyKGvvMy wpdg== 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=JXcvMOBg9JJqh1ojL4EUWaxq/QWKmBleAgF3R3oNr88=; b=TcSh/hyizt8fawyaEE5ueuIOVjj54Mi8NoNYDzzhxJepCcA5wkGCsDxduVVtheXw3Y GfKBA4yfEKsluisOEXqjzU8vHBID2vp/BYV+zObCEdH4bCZjCCwM69DqhC42ArFDbdRR Ttoqw+g4vbiWtuU8aMesW4yt4lLUbZLH9GlBs5CakLwFu2d6jAyrKVYxEFP2HOUhQb0s c8bs2MUDL0AJ7YVqsoNDFXNjLbRx1p4DeC7e8D0maUYNfwPrYBs08jGkfkNwyMZJ0xDj ljrfizqFEPJaoyA68gc5IFzlfmlV4ZpseELgGmSPTLMJZBIOSmZqZmKN0H13g8q8baXj QImw== 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 t61-v6si1996070plb.253.2018.07.18.23.27.32; Wed, 18 Jul 2018 23:28:09 -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 S1731105AbeGSHHL (ORCPT + 99 others); Thu, 19 Jul 2018 03:07:11 -0400 Received: from mail.bootlin.com ([62.4.15.54]:51134 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727487AbeGSHHL (ORCPT ); Thu, 19 Jul 2018 03:07:11 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id B571120884; Thu, 19 Jul 2018 08:25:39 +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 44F70206F3; Thu, 19 Jul 2018 08:25:39 +0200 (CEST) Date: Thu, 19 Jul 2018 08:25:38 +0200 From: Boris Brezillon To: Janusz Krzysztofik Cc: Miquel Raynal , Tony Lindgren , Aaro Koskinen , Grygorii Strashko , Santosh Shilimkar , Kevin Hilman , Linus Walleij , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Bityutskiy Subject: Re: [RFC PATCH 4/8] mtd: rawnand: ams-delta: Optimize pointer resolution on read/write Message-ID: <20180719082538.222396bf@bbrezillon> In-Reply-To: <20180718235710.18242-5-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180718235710.18242-5-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 Thu, 19 Jul 2018 01:57:06 +0200 Janusz Krzysztofik wrote: > Further optimize processing speed of read/write callback functions by > resolving private structure pointer only once per callback and passing > it to all subfunctions instead of mtd_info. Not sure this has a real impact on perfs, but I also prefer not using mtd_info objects within NAND drivers, so I'm good with the change itself (its probably worth changing the commit message though) > > Signed-off-by: Janusz Krzysztofik > --- > drivers/mtd/nand/raw/ams-delta.c | 44 +++++++++++++++++++++++----------------- > 1 file changed, 25 insertions(+), 19 deletions(-) > > diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c > index dfefcd79b420..d7e4c9dbef67 100644 > --- a/drivers/mtd/nand/raw/ams-delta.c > +++ b/drivers/mtd/nand/raw/ams-delta.c > @@ -72,10 +72,9 @@ static const struct mtd_partition partition_info[] = { > .size = 3 * SZ_256K }, > }; > > -static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) > +static void ams_delta_write_next_byte(struct ams_delta_nand *priv, u_char byte) > { > - struct nand_chip *this = mtd_to_nand(mtd); > - struct ams_delta_nand *priv = nand_get_controller_data(this); > + struct nand_chip *this = &priv->nand_chip; > > writew(byte, this->IO_ADDR_W); > gpiod_set_value(priv->gpiod_nwe, 0); > @@ -83,21 +82,18 @@ static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) > gpiod_set_value(priv->gpiod_nwe, 1); > } > > -static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) > +static void ams_delta_write_first_byte(struct ams_delta_nand *priv, u_char 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); > > - ams_delta_write_next_byte(mtd, byte); > + ams_delta_write_next_byte(priv, byte); > } > > -static u_char ams_delta_read_next_byte(struct mtd_info *mtd) > +static u_char ams_delta_read_next_byte(struct ams_delta_nand *priv) > { > - struct nand_chip *this = mtd_to_nand(mtd); > - struct ams_delta_nand *priv = nand_get_controller_data(this); > + struct nand_chip *this = &priv->nand_chip; > u_char res; > > gpiod_set_value(priv->gpiod_nre, 0); > @@ -108,36 +104,46 @@ static u_char ams_delta_read_next_byte(struct mtd_info *mtd) > return res; > } > > -static u_char ams_delta_read_byte(struct mtd_info *mtd) > +static u_char ams_delta_read_first_byte(struct ams_delta_nand *priv) > { > - 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); > > - return ams_delta_read_next_byte(mtd); > + return ams_delta_read_next_byte(priv); > +} > + > +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); > + > + return ams_delta_read_first_byte(priv); > } > > static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, > int len) > { > + struct nand_chip *this = mtd_to_nand(mtd); > + struct ams_delta_nand *priv = nand_get_controller_data(this); > int i; > > if (len > 0) > - ams_delta_write_byte(mtd, buf[0]); > + ams_delta_write_first_byte(priv, buf[0]); > for (i = 1; i < len; i++) > - ams_delta_write_next_byte(mtd, buf[i]); > + ams_delta_write_next_byte(priv, buf[i]); > } > > static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) > { > + struct nand_chip *this = mtd_to_nand(mtd); > + struct ams_delta_nand *priv = nand_get_controller_data(this); > int i; > > if (len > 0) > - buf[0] = ams_delta_read_byte(mtd); > + buf[0] = ams_delta_read_first_byte(priv); > for (i = 1; i < len; i++) > - buf[i] = ams_delta_read_next_byte(mtd); > + buf[i] = ams_delta_read_next_byte(priv); > } > > /* > @@ -161,7 +167,7 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, > } > > if (cmd != NAND_CMD_NONE) > - ams_delta_write_byte(mtd, cmd); > + ams_delta_write_first_byte(priv, cmd); > } > > static int ams_delta_nand_ready(struct mtd_info *mtd)