Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A23AC433FE for ; Mon, 17 Oct 2022 08:14:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F18AF84F6B; Mon, 17 Oct 2022 10:14:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="FmlMPVr7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B93F784F6D; Mon, 17 Oct 2022 10:14:39 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B03CC84F69 for ; Mon, 17 Oct 2022 10:14:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rogerq@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2368860F1E; Mon, 17 Oct 2022 08:14:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0906C433C1; Mon, 17 Oct 2022 08:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665994472; bh=6Nouvj88QfkW+VyA5SZVesQICIavJhMFNWP0QyD4LB0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=FmlMPVr7pMsg25gnq9jAe1phN/BukT2W5AqNW8WVfRT1avpyjYNJiQ3kO64A8WnBQ S4E3KT0O7ZmWQDqNmlWhsJH0bXu7nsbGs3sqMRLh1CJqY6R5UckGZffX8imsIx/F9j VVl+wcb7VJ9bX3j22vAu+jvhfuHuQCOvMYQcg3dOfNeRqw8ROYTRxXkQQLU+9Azq+e Ne0LXlEZOE4atPMstTrMFIrZ4yvPLE7+yXlOjuxqE6z7r2ikPwVRxg49idjqXVKHsL y/rzJTc17ZZqu++Tdjz7Yv9GVWbb5r3jdPObkMeJKw9r4BHgsruY4wLCfmiZIdNCG8 qoHws1LQdjWHw== Message-ID: Date: Mon, 17 Oct 2022 11:14:29 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [u-boot][PATCH 04/14] mtd: rawnand: omap_gpmc: Optimize NAND reads Content-Language: en-US To: Michael Nazzareno Trimarchi Cc: dario.binacchi@amarulasolutions.com, trini@konsulko.com, u-boot@lists.denx.de References: <20221011115012.6181-1-rogerq@kernel.org> <20221011115012.6181-5-rogerq@kernel.org> <32f321a3-35ad-fed4-12d8-a98877286cd9@kernel.org> From: Roger Quadros In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Michael, On 17/10/2022 09:39, Michael Nazzareno Trimarchi wrote: > Hi Roger > > On Sat, Oct 15, 2022 at 3:29 PM Roger Quadros wrote: >> >> Hi Michael, >> >> On 15/10/2022 10:24, Michael Nazzareno Trimarchi wrote: >>> Hi >>> >>> On Tue, Oct 11, 2022 at 1:50 PM Roger Quadros wrote: >>>> >>>> Rename omap_nand_read() to omap_nand_read_buf() to reflect >>>> actual behaviour. >>>> >>>> Use FIFO read address instead of raw read address for reads. >>>> >>>> The GPMC automatically converts 32-bit/16-bit reads to NAND >>>> device specific reads (8/16 bit). Use the largest possible >>>> read granularity size for more efficient reads. >>>> >>>> Signed-off-by: Roger Quadros >>>> --- >>>> drivers/mtd/nand/raw/omap_gpmc.c | 49 ++++++++++++++++++-------------- >>>> 1 file changed, 28 insertions(+), 21 deletions(-) >>>> >>>> diff --git a/drivers/mtd/nand/raw/omap_gpmc.c b/drivers/mtd/nand/raw/omap_gpmc.c >>>> index d62c3e6fce..b36fe762b3 100644 >>>> --- a/drivers/mtd/nand/raw/omap_gpmc.c >>>> +++ b/drivers/mtd/nand/raw/omap_gpmc.c >>>> @@ -55,6 +55,7 @@ struct omap_nand_info { >>>> enum omap_ecc ecc_scheme; >>>> uint8_t cs; >>>> uint8_t ws; /* wait status pin (0,1) */ >>>> + void __iomem *fifo; >>>> }; >>>> >>>> /* We are wasting a bit of memory but al least we are safe */ >>>> @@ -350,6 +351,20 @@ static int omap_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat, >>>> return 0; >>>> } >>>> >>>> +static inline void omap_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) >>>> +{ >>>> + struct nand_chip *chip = mtd_to_nand(mtd); >>>> + struct omap_nand_info *info = nand_get_controller_data(chip); >>>> + u32 alignment = ((uintptr_t)buf | len) & 3; >>>> + >>>> + if (alignment & 1) >>>> + readsb(info->fifo, buf, len); >>>> + else if (alignment & 3) >>>> + readsw(info->fifo, buf, len >> 1); >>>> + else >>>> + readsl(info->fifo, buf, len >> 2); >>>> +} >>>> + > > Can you optimize more I think here.You can consider the disaligment > portion and then read at max len. You read more > than the actual lens but I think it should not be a big problem. In This will overrun the passed buffer and we don't want to take that risk? > case of SPL you can use byte read and then can reduce > the code size here Apart from some legacy chips SPL size is not a huge problem. So unless we are sure that we can actually run this driver in SPL there is no point in doing any SPL optimizations now. > > Michael cheers, -roger