From: Albert ARIBAUD <albert.u.boot@aribaud.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 1/2] Optimized nand_read_buf for kirkwood
Date: Thu, 27 Jun 2013 12:02:40 +0200 [thread overview]
Message-ID: <20130627120240.5875f2f5@lilith> (raw)
In-Reply-To: <1372271126-2642-2-git-send-email-phil.sutter@viprinet.com>
Hi Phil,
On Wed, 26 Jun 2013 20:25:25 +0200, Phil Sutter
<phil.sutter@viprinet.com> wrote:
> The basic idea is taken from the linux-kernel, but further optimized.
>
> First align the buffer to 8 bytes, then use ldrd/strd to read and store
> in 8 byte quantities, then do the final bytes.
>
> Tested using: 'date ; nand read.raw 0xE00000 0x0 0x10000 ; date'.
> Without this patch, NAND read of 132MB took 49s (~2.69MB/s). With this
> patch in place, reading the same amount of data was done in 27s
> (~4.89MB/s). So read performance is increased by ~80%!
>
> Signed-off-by: Nico Erfurth <ne@erfurth.eu>
> Tested-by: Phil Sutter <phil.sutter@viprinet.com>
> Cc: Prafulla Wadaskar <prafulla@marvell.com>
> ---
Patch history missing.
> drivers/mtd/nand/kirkwood_nand.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/drivers/mtd/nand/kirkwood_nand.c b/drivers/mtd/nand/kirkwood_nand.c
> index 0a99a10..85ea5d2 100644
> --- a/drivers/mtd/nand/kirkwood_nand.c
> +++ b/drivers/mtd/nand/kirkwood_nand.c
> @@ -38,6 +38,37 @@ struct kwnandf_registers {
> static struct kwnandf_registers *nf_reg =
> (struct kwnandf_registers *)KW_NANDF_BASE;
>
> +
> +/*
> + * The basic idea is stolen from the linux kernel, but the inner loop is
> + * optimized a bit more.
> + */
> +static void kw_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
> +{
> + struct nand_chip *chip = mtd->priv;
> +
> + while (len && (unsigned long)buf & 7) {
> + *buf++ = readb(chip->IO_ADDR_R);
> + len--;
> + };
> +
> + /* This loop reads and writes 64bit per round. */
> + asm volatile (
> + "1:\n"
> + " subs %0, #8\n"
> + " ldrpld r2, [%2]\n"
> + " strpld r2, [%1], #8\n"
> + " bhi 1b\n"
> + " addne %0, #8\n"
> + : "+&r" (len), "+&r" (buf)
> + : "r" (chip->IO_ADDR_R)
> + : "r2", "r3", "memory", "cc"
> + );
Are assembler instructions *really* required? IOW, can you not get
enough performance simply with a cleverly written C loop?
> + while (len--)
> + *buf++ = readb(chip->IO_ADDR_R);
> +}
> +
> /*
> * hardware specific access to control-lines/bits
> */
> @@ -80,6 +111,7 @@ int board_nand_init(struct nand_chip *nand)
> nand->ecc.mode = NAND_ECC_SOFT;
> #endif
> nand->cmd_ctrl = kw_nand_hwcontrol;
> + nand->read_buf = kw_nand_read_buf;
> nand->chip_delay = 40;
> nand->select_chip = kw_nand_select_chip;
> return 0;
Amicalement,
--
Albert.
next prev parent reply other threads:[~2013-06-27 10:02 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-21 12:59 [U-Boot] [PATCH 1/4] Optimized nand_read_buf for kirkwood Phil Sutter
2012-11-21 12:59 ` [U-Boot] [PATCH 2/4] env_nand.c: support falling back to redundant env when writing Phil Sutter
2012-11-27 22:04 ` Scott Wood
2012-11-28 21:06 ` Phil Sutter
2012-12-06 18:18 ` Scott Wood
2012-12-07 11:53 ` Phil Sutter
2012-12-07 16:58 ` Phil Sutter
2012-12-07 17:38 ` Scott Wood
2012-12-10 13:41 ` Phil Sutter
2012-12-11 23:12 ` Scott Wood
2012-12-20 21:28 ` Phil Sutter
2012-12-20 21:41 ` Scott Wood
2012-12-21 10:34 ` Phil Sutter
2012-12-22 2:29 ` Scott Wood
2012-11-21 12:59 ` [U-Boot] [PATCH 3/4] env_nand.c: do warn only if really no valid environment could be loaded Phil Sutter
2012-11-27 22:06 ` Scott Wood
2012-11-27 22:07 ` Scott Wood
2013-02-20 0:33 ` Scott Wood
2012-11-21 12:59 ` [U-Boot] [PATCH 4/4] common/env_nand.c: calculate crc only when readenv was OK Phil Sutter
2012-11-26 3:46 ` [U-Boot] [PATCH 1/4] Optimized nand_read_buf for kirkwood Prafulla Wadaskar
2012-11-26 10:29 ` Phil Sutter
2012-11-26 10:33 ` Phil Sutter
2012-11-26 23:39 ` Scott Wood
2012-12-20 6:44 ` Prafulla Wadaskar
2012-12-20 10:55 ` Phil Sutter
2013-02-21 17:21 ` [U-Boot] Version 2 of Kirkwood and env_nand improvements Phil Sutter
2013-02-21 17:21 ` [U-Boot] [PATCHv2 1/4] Optimized nand_read_buf for kirkwood (V3) Phil Sutter
2013-02-23 1:26 ` Scott Wood
2013-02-21 17:21 ` [U-Boot] [PATCHv2 2/4] env_nand.c: support falling back to redundant env when writing Phil Sutter
2013-02-23 1:32 ` Scott Wood
2013-02-21 17:21 ` [U-Boot] [PATCHv2 3/4] env_nand.c: clarify log messages when env reading fails Phil Sutter
2013-02-23 1:59 ` Scott Wood
2013-02-25 9:39 ` Phil Sutter
2013-02-25 22:40 ` Scott Wood
2013-02-21 17:21 ` [U-Boot] [PATCHv2 4/4] common/env_nand.c: calculate crc only when readenv was OK Phil Sutter
2013-02-23 2:00 ` Scott Wood
2013-06-26 18:25 ` [U-Boot] Version 3 of Kirkwood and env_nand improvements Phil Sutter
2013-06-26 18:25 ` [U-Boot] [PATCH v3 1/2] Optimized nand_read_buf for kirkwood Phil Sutter
2013-06-27 10:02 ` Albert ARIBAUD [this message]
2013-08-19 23:29 ` [U-Boot] [U-Boot,v3,1/2] " Scott Wood
2013-06-26 18:25 ` [U-Boot] [PATCH v3 2/2] env_nand.c: support falling back to redundant env when writing Phil Sutter
2013-07-17 22:25 ` Scott Wood
2013-07-19 10:09 ` Phil Sutter
2013-07-19 10:20 ` [U-Boot] [PATCH] " Phil Sutter
2013-07-19 10:30 ` Phil Sutter
2013-08-22 22:50 ` [U-Boot] " Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130627120240.5875f2f5@lilith \
--to=albert.u.boot@aribaud.net \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox