From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>
Cc: richard@nod.at, dwmw2@infradead.org, computersforpeace@gmail.com,
marek.vasut@gmail.com, cyrille.pitchen@wedev4u.fr,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next v3 2/2] mtd: nand: toshiba: Add support for Toshiba Memory BENAND (Built-in ECC NAND)
Date: Wed, 6 Dec 2017 16:24:04 +0100 [thread overview]
Message-ID: <20171206162404.3a1d83b9@bbrezillon> (raw)
In-Reply-To: <1512569098-30038-3-git-send-email-yoshitake.kobayashi@toshiba.co.jp>
On Wed, 6 Dec 2017 23:04:58 +0900
KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp> wrote:
> This patch enables support for Toshiba Memory BENAND. This checks
> internal ECC status in read operation when using BENAND and selecting
> ECC mode as on-die.
>
> Signed-off-by: KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>
> ---
> drivers/mtd/nand/nand_toshiba.c | 89 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 89 insertions(+)
>
> diff --git a/drivers/mtd/nand/nand_toshiba.c b/drivers/mtd/nand/nand_toshiba.c
> index c2c141b..35c0ddf 100644
> --- a/drivers/mtd/nand/nand_toshiba.c
> +++ b/drivers/mtd/nand/nand_toshiba.c
> @@ -17,6 +17,91 @@
>
> #include <linux/mtd/rawnand.h>
>
> +/* ECC Status Read Command for BENAND */
> +#define TOSHIBA_NAND_CMD_ECC_STATUS 0x7A
> +
> +/* Recommended to rewrite for BENAND */
> +#define TOSHIBA_NAND_STATUS_REWRITE_RECOMMENDED BIT(3)
> +
> +static int toshiba_nand_benand_status_chk(struct mtd_info *mtd,
> + struct nand_chip *chip)
> +{
> + unsigned int max_bitflips = 0;
> + u8 status;
> +
> + /* Check Read Status */
> + chip->cmdfunc(mtd, NAND_CMD_STATUS, -1, -1);
> + status = chip->read_byte(mtd);
Please use the recently introduced nand_status_op() helper.
> +
> + /*
> + * TOSHIBA_NAND_CMD_ECC_STATUS is vendor specific command.
> + * Currently we have no way to send arbitrary sequences of
> + * CMD+ADDR+DATA cycles and thus cannot support this custom
> + * TOSHIBA_NAND_CMD_ECC_STATUS operation.
That's about to change :-), if everything goes well, nand_exec_op()
should be available in 4.16.
> + * For now, we set max_bitflips mtd->bitflip_threshold.
> + */
> + if (status & NAND_STATUS_FAIL) {
> + /* uncorrectable */
> + mtd->ecc_stats.failed++;
> + } else if (status & TOSHIBA_NAND_STATUS_REWRITE_RECOMMENDED) {
> + /* correctable */
> + max_bitflips = mtd->bitflip_threshold;
> + mtd->ecc_stats.corrected += max_bitflips;
> + }
> +
> + return max_bitflips;
> +}
> +
> +static int
> +toshiba_nand_read_page_benand(struct mtd_info *mtd,
> + struct nand_chip *chip, uint8_t *buf,
> + int oob_required, int page)
> +{
> + nand_read_page_raw(mtd, chip, buf, oob_required, page);
Please check the return code of nand_read_page_raw().
> +
> + return toshiba_nand_benand_status_chk(mtd, chip);
> +}
> +
> +static int
> +toshiba_nand_read_subpage_benand(struct mtd_info *mtd,
> + struct nand_chip *chip, uint32_t data_offs,
> + uint32_t readlen, uint8_t *bufpoi, int page)
> +{
> + uint8_t *p;
> +
> + if (data_offs != 0)
> + chip->cmdfunc(mtd, NAND_CMD_RNDOUT, data_offs, -1);
> +
> + p = bufpoi + data_offs;
> + chip->read_buf(mtd, p, readlen);
The core is no longer sending the initial READ0 command, so this should
be turned into:
ret = nand_read_page_op(chip, data_offs, bufpoi + data_offs,
readlen);
if (ret)
return ret;
> +
> + return toshiba_nand_benand_status_chk(mtd, chip);
> +}
> +
> +static void toshiba_nand_benand_init(struct nand_chip *chip)
> +{
> + struct mtd_info *mtd = nand_to_mtd(chip);
> +
> + /*
> + * On BENAND, the entire OOB region can be used by the MTD user.
> + * The calculated ECC bytes are stored into other isolated
> + * area which is not accessible to users.
> + * This is why chip->ecc.bytes = 0.
> + */
> + chip->ecc.bytes = 0;
> + chip->ecc.size = 512;
> + chip->ecc.strength = 8;
> + chip->ecc.read_page = toshiba_nand_read_page_benand;
> + chip->ecc.read_subpage = toshiba_nand_read_subpage_benand;
> + chip->ecc.write_page = nand_write_page_raw;
> + chip->ecc.read_page_raw = nand_read_page_raw;
> + chip->ecc.write_page_raw = nand_write_page_raw;
> +
> + chip->options |= NAND_SUBPAGE_READ;
> +
> + mtd_set_ooblayout(mtd, &nand_ooblayout_lp_ops);
> +}
> +
> static void toshiba_nand_decode_id(struct nand_chip *chip)
> {
> struct mtd_info *mtd = nand_to_mtd(chip);
> @@ -70,6 +155,10 @@ static int toshiba_nand_init(struct nand_chip *chip)
> if (nand_is_slc(chip))
> chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
>
> + if (nand_is_slc(chip) && (chip->id.data[4] & 0x80) /* BENAND */ &&
> + (chip->ecc.mode == NAND_ECC_ON_DIE))
> + toshiba_nand_benand_init(chip);
> +
Please move this block to toshiba_nand_init().
> return 0;
> }
>
next prev parent reply other threads:[~2017-12-06 15:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-06 14:04 [PATCH -next v3 0/2] mtd: nand: toshiba: Add Toshiba BENAND support KOBAYASHI Yoshitake
2017-12-06 14:04 ` [PATCH -next v3 1/2] mtd: nand: toshiba: Retrieve ECC requirements from extended ID KOBAYASHI Yoshitake
2017-12-06 15:08 ` Boris Brezillon
2017-12-19 11:42 ` KOBAYASHI Yoshitake
2017-12-19 11:56 ` Boris Brezillon
2017-12-19 12:11 ` Boris Brezillon
2017-12-27 6:06 ` KOBAYASHI Yoshitake
2018-01-29 23:44 ` KOBAYASHI Yoshitake
2018-01-30 8:04 ` Boris Brezillon
2017-12-06 14:04 ` [PATCH -next v3 2/2] mtd: nand: toshiba: Add support for Toshiba Memory BENAND (Built-in ECC NAND) KOBAYASHI Yoshitake
2017-12-06 15:24 ` Boris Brezillon [this message]
2017-12-19 12:01 ` KOBAYASHI Yoshitake
2017-12-19 12:03 ` Boris Brezillon
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=20171206162404.3a1d83b9@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
--cc=yoshitake.kobayashi@toshiba.co.jp \
/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