From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: linux-mtd@lists.infradead.org,
Tudor Ambarus <tudor.ambarus@microchip.com>,
David Woodhouse <dwmw2@infradead.org>,
Vignesh Raghavendra <vigneshr@ti.com>,
Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH 12/17] mtd: rawnand: cafe: Don't split things when reading/writing a page
Date: Mon, 27 Apr 2020 21:53:53 +0200 [thread overview]
Message-ID: <20200427215353.3ced34d3@xps13> (raw)
In-Reply-To: <20200427082028.394719-13-boris.brezillon@collabora.com>
Hi Boris,
Boris Brezillon <boris.brezillon@collabora.com> wrote on Mon, 27 Apr
2020 10:20:22 +0200:
> Calling nand_read_page_op(pagesize)/nand_prog_page_begin_op(pagesize)
> and expecting to get a pagesize+oobsize read from/written to the
> read/write buffer is fragile and only works because of hacks done
> in cmdfunc(). Let's read/write the page in one go, using the page
> cache buffer as a bounce buffer.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
> ---
> drivers/mtd/nand/raw/cafe_nand.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/raw/cafe_nand.c b/drivers/mtd/nand/raw/cafe_nand.c
> index 31493a201a02..edf65197604b 100644
> --- a/drivers/mtd/nand/raw/cafe_nand.c
> +++ b/drivers/mtd/nand/raw/cafe_nand.c
> @@ -472,6 +472,7 @@ static int cafe_nand_read_page(struct nand_chip *chip, uint8_t *buf,
> {
> struct mtd_info *mtd = nand_to_mtd(chip);
> struct cafe_priv *cafe = nand_get_controller_data(chip);
> + void *pagebuf = nand_get_data_buf(chip);
> unsigned int max_bitflips = 0;
> u32 ecc_result, status;
>
> @@ -479,8 +480,11 @@ static int cafe_nand_read_page(struct nand_chip *chip, uint8_t *buf,
> cafe_readl(cafe, NAND_ECC_RESULT),
> cafe_readl(cafe, NAND_ECC_SYN_REG(0)));
>
> - nand_read_page_op(chip, page, 0, buf, mtd->writesize);
> - chip->legacy.read_buf(chip, chip->oob_poi, mtd->oobsize);
> + nand_read_page_op(chip, page, 0, pagebuf,
> + mtd->writesize + mtd->oobsize);
> +
> + if (buf != pagebuf)
> + memcpy(buf, pagebuf, mtd->writesize);
>
> ecc_result = cafe_readl(cafe, NAND_ECC_RESULT);
> status = CAFE_FIELD_GET(NAND_ECC_RESULT, STATUS, ecc_result);
> @@ -642,15 +646,17 @@ static int cafe_nand_write_page(struct nand_chip *chip,
> {
> struct mtd_info *mtd = nand_to_mtd(chip);
> struct cafe_priv *cafe = nand_get_controller_data(chip);
> + void *pagebuf = nand_get_data_buf(chip);
> int ret;
>
> - nand_prog_page_begin_op(chip, page, 0, buf, mtd->writesize);
> - chip->legacy.write_buf(chip, chip->oob_poi, mtd->oobsize);
> + if (pagebuf != buf)
> + memcpy(pagebuf, buf, mtd->writesize);
>
> /* Set up ECC autogeneration */
> cafe->ctl2 |= CAFE_NAND_CTRL2_AUTO_WRITE_ECC;
>
> - ret = nand_prog_page_end_op(chip);
> + ret = nand_prog_page_op(chip, page, 0, pagebuf,
> + mtd->writesize + mtd->oobsize);
>
> /*
> * And clear it before returning so that following write operations
You are replacing ->read/write_buf() calls into memcpy() calls,
shouldn't this be cleaned before? or at least mentioned?
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-04-27 19:54 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 8:20 [PATCH 00/17] mtd: rawnand: cafe: Convert to exec_op() (and more) Boris Brezillon
2020-04-27 8:20 ` [PATCH 01/17] mtd: rawnand: cafe: Get rid of an inaccurate kernel doc header Boris Brezillon
2020-04-27 19:33 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 02/17] mtd: rawnand: cafe: Rename cafe_nand_write_page_lowlevel() Boris Brezillon
2020-04-27 19:33 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 03/17] mtd: rawnand: cafe: Use a correct ECC mode and pass the ECC alg Boris Brezillon
2020-04-27 19:34 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 04/17] mtd: rawnand: cafe: Include linux/io.h instead of asm/io.h Boris Brezillon
2020-04-27 19:35 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 05/17] mtd: rawnand: cafe: Demistify register fields Boris Brezillon
2020-04-27 19:42 ` Miquel Raynal
2020-04-28 6:06 ` Boris Brezillon
2020-04-27 8:20 ` [PATCH 06/17] mtd: rawnand: cafe: Factor out the controller initialization logic Boris Brezillon
2020-04-27 19:45 ` Miquel Raynal
2020-04-28 6:06 ` Boris Brezillon
2020-04-27 8:20 ` [PATCH 07/17] mtd: rawnand: cafe: Get rid of the debug module param Boris Brezillon
2020-04-27 19:46 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 08/17] mtd: rawnand: cafe: Use devm_kzalloc and devm_request_irq() Boris Brezillon
2020-04-27 19:47 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 09/17] mtd: rawnand: cafe: Get rid of a useless label Boris Brezillon
2020-04-27 19:47 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 10/17] mtd: rawnand: cafe: Explicitly inherit from nand_controller Boris Brezillon
2020-04-27 19:49 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 11/17] mtd: rawnand: cafe: Don't leave ECC enabled in the write path Boris Brezillon
2020-04-27 19:51 ` Miquel Raynal
2020-04-28 6:08 ` Boris Brezillon
2020-04-27 8:20 ` [PATCH 12/17] mtd: rawnand: cafe: Don't split things when reading/writing a page Boris Brezillon
2020-04-27 19:53 ` Miquel Raynal [this message]
2020-04-28 6:20 ` Boris Brezillon
2020-04-28 7:44 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 13/17] mtd: rawnand: cafe: Add exec_op() support Boris Brezillon
2020-04-27 19:59 ` Miquel Raynal
2020-04-28 6:24 ` Boris Brezillon
[not found] ` <20200502111410.330584-1-lkundrak@v3.sk>
2020-05-02 13:18 ` Boris Brezillon
[not found] ` <20200502191843.GA363829@furthur.local>
2020-05-02 22:34 ` Boris Brezillon
[not found] ` <20200503060610.GA386731@furthur.local>
2020-05-03 7:04 ` Boris Brezillon
2020-05-03 7:26 ` Boris Brezillon
[not found] ` <20200503175537.GA404453@furthur.local>
2020-05-03 19:49 ` Boris Brezillon
[not found] ` <20200503075208.GA387473@furthur.local>
2020-05-03 8:13 ` Boris Brezillon
2020-05-03 8:35 ` Boris Brezillon
2020-05-09 20:10 ` Boris Brezillon
2020-04-27 8:20 ` [PATCH 14/17] mtd: rawnand: cafe: Get rid of the legacy interface implementation Boris Brezillon
2020-04-27 20:00 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 15/17] mtd: rawnand: cafe: Adjust the cafe_{read, write}_buf() prototypes Boris Brezillon
2020-04-27 20:00 ` [PATCH 15/17] mtd: rawnand: cafe: Adjust the cafe_{read,write}_buf() prototypes Miquel Raynal
2020-04-28 6:24 ` Boris Brezillon
2020-04-27 8:20 ` [PATCH 16/17] mtd: rawnand: cafe: Handle non-32bit aligned reads/writes Boris Brezillon
2020-04-27 20:04 ` Miquel Raynal
2020-04-28 6:26 ` Boris Brezillon
2020-04-27 8:20 ` [PATCH 17/17] mtd: rawnand: cafe: s/uint{8,16,32}_t/u{8,16,32}/ Boris Brezillon
2020-04-27 20:05 ` Miquel Raynal
2020-04-27 8:20 ` [PATCH 17/17] mtd: rawnand: s/uint{8,16,32}_t/u{8,16,32}/ Boris Brezillon
2020-04-27 8:25 ` Boris Brezillon
2020-04-29 6:37 ` [PATCH 00/17] mtd: rawnand: cafe: Convert to exec_op() (and more) Thomas Petazzoni
2020-04-29 8:28 ` Boris Brezillon
[not found] ` <20200501055209.GA44510@furthur.local>
2020-05-01 6:21 ` Boris Brezillon
[not found] ` <20200502112732.330971-1-lkundrak@v3.sk>
2020-05-02 13:15 ` Boris Brezillon
2020-05-08 10:32 ` Miquel Raynal
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=20200427215353.3ced34d3@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=boris.brezillon@collabora.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=tudor.ambarus@microchip.com \
--cc=vigneshr@ti.com \
/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;
as well as URLs for NNTP newsgroup(s).