From: Huang Shijie <b32955@freescale.com>
To: Kamal Dasu <kdasu.kdev@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH v2] mtd: nand: Add support to use nand_base poi databuf as bounce buffer
Date: Mon, 28 Apr 2014 17:16:40 +0800 [thread overview]
Message-ID: <20140428091638.GB21064@localhost> (raw)
In-Reply-To: <1398375634-24759-1-git-send-email-kdasu.kdev@gmail.com>
On Thu, Apr 24, 2014 at 05:40:34PM -0400, Kamal Dasu wrote:
> nand_base can be passed a kmap()'d buffers from highmem by
> filesystems like jffs2. This results in failure to map the
> physical address of the DMA buffer on various contoller
> driver on different platforms. This change adds a chip option
> to use preallocated databuf as bounce buffers used in
> nand_do_read_ops() and nand_do_write_ops().
> This allows for specific nand controller driver to set this
> option as needed.
>
> Signed-off-by: Kamal Dasu <kdasu.kdev@gmail.com>
> ---
>
> Changes since v1:
> * Fix bytes to write calculation in nand_do_write_ops
>
> drivers/mtd/nand/nand_base.c | 28 +++++++++++++++++++++-------
> include/linux/mtd/nand.h | 5 +++++
> 2 files changed, 26 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 9d01c4d..d94242a 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -1501,6 +1501,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
> mtd->oobavail : mtd->oobsize;
>
> uint8_t *bufpoi, *oob, *buf;
> + int use_bufpoi;
> unsigned int max_bitflips = 0;
> int retry_mode = 0;
> bool ecc_fail = false;
> @@ -1522,10 +1523,16 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
>
> bytes = min(mtd->writesize - col, readlen);
> aligned = (bytes == mtd->writesize);
> + use_bufpoi = (chip->options & NAND_USE_BOUNCE_BUFFER) ?
> + !virt_addr_valid(buf) : 0;
I met a compiler error here in the ARM platform.
I think you should add some header.
>
> /* Is the current page in the buffer? */
> if (realpage != chip->pagebuf || oob) {
> - bufpoi = aligned ? buf : chip->buffers->databuf;
> + bufpoi = (aligned && !use_bufpoi) ? buf :
> + chip->buffers->databuf;
> +
> + if (use_bufpoi && aligned)
> + pr_debug("%s: using bounce buffer\n", __func__);
print more info here, such as:
pr_debug("%s: using bounce buffer for buf:%p\n", __func__, buf);
>
> read_retry:
> chip->cmdfunc(mtd, NAND_CMD_READ0, 0x00, page);
> @@ -1547,7 +1554,7 @@ read_retry:
> ret = chip->ecc.read_page(mtd, chip, bufpoi,
> oob_required, page);
> if (ret < 0) {
> - if (!aligned)
> + if (!aligned || use_bufpoi)
> /* Invalidate page cache */
> chip->pagebuf = -1;
> break;
> @@ -1556,7 +1563,7 @@ read_retry:
> max_bitflips = max_t(unsigned int, max_bitflips, ret);
>
> /* Transfer not aligned data */
> - if (!aligned) {
> + if (!aligned || use_bufpoi) {
In actually, the " if (!aligned || use_bufpoi) " is equal to
"if (bufpoi == chip->buffers->databuf)) {"
I am not sure which is more readable. :)
But I prefer to the later.
Let Brian to judge it.
thanks
Huang Shijie
next prev parent reply other threads:[~2014-04-28 10:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-24 21:40 [PATCH v2] mtd: nand: Add support to use nand_base poi databuf as bounce buffer Kamal Dasu
2014-04-25 2:07 ` Huang Shijie
2014-04-25 3:52 ` Kamal Dasu
2014-04-25 7:43 ` Huang Shijie
2014-04-25 7:59 ` Huang Shijie
2014-04-25 16:10 ` Kamal Dasu
2014-04-28 9:08 ` Huang Shijie
2014-04-28 9:16 ` Huang Shijie [this message]
2014-04-28 15:42 ` Huang Shijie
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=20140428091638.GB21064@localhost \
--to=b32955@freescale.com \
--cc=kdasu.kdev@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/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