From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: "Álvaro Fernández Rojas" <noltari@gmail.com>,
christophe.kerello@st.com, vigneshr@ti.com, richard@nod.at,
s.hauer@pengutronix.de, devik@eaxlabs.cz,
linux-kernel@vger.kernel.org, stefan@agner.ch,
linux-mtd@lists.infradead.org, tglx@linutronix.de,
masonccyang@mxic.com.tw, piotrs@cadence.com
Subject: Re: [PATCH] nand: raw: use write_oob_raw for MTD_OPS_AUTO_OOB mode
Date: Mon, 11 May 2020 18:29:23 +0200 [thread overview]
Message-ID: <20200511182923.6a4961ab@xps13> (raw)
In-Reply-To: <20200504123237.5c128668@collabora.com>
Hello,
Boris Brezillon <boris.brezillon@collabora.com> wrote on Mon, 4 May
2020 12:32:37 +0200:
> On Mon, 4 May 2020 11:42:53 +0200
> Álvaro Fernández Rojas <noltari@gmail.com> wrote:
>
> > Some NAND controllers change the ECC bytes when OOB is written with ECC
> > enabled.
> > This is a problem in brcmnand, since adding JFFS2 cleanmarkers after the page
> > has been erased will change the ECC bytes to 0 and the controller will think
> > the block is bad.
> > It can be fixed by using write_oob_raw, which ensures ECC is disabled.
> >
> > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> > ---
> > drivers/mtd/nand/raw/nand_base.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> > index c24e5e2ba130..755d25200520 100644
> > --- a/drivers/mtd/nand/raw/nand_base.c
> > +++ b/drivers/mtd/nand/raw/nand_base.c
> > @@ -488,7 +488,7 @@ static int nand_do_write_oob(struct nand_chip *chip, loff_t to,
> >
> > nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops);
> >
> > - if (ops->mode == MTD_OPS_RAW)
> > + if (ops->mode == MTD_OPS_AUTO_OOB || ops->mode == MTD_OPS_RAW)
> > status = chip->ecc.write_oob_raw(chip, page & chip->pagemask);
>
> The doc says:
>
> @MTD_OPS_PLACE_OOB: OOB data are placed at the given offset (default)
> @MTD_OPS_AUTO_OOB: OOB data are automatically placed at the free areas
> which are defined by the internal ecclayout
> @MTD_OPS_RAW: data are transferred as-is, with no error
> correction; this mode implies %MTD_OPS_PLACE_OOB
>
> To me, that means MTD_OPS_PLACE_OOB and MTD_OPS_AUTO_OOB do not imply
> MTD_OPS_RAW. Anyway those modes are just too vague. We really should
> separate the ECC-disabled/ECC-enabled concept (AKA raw vs non-raw mode)
> from the OOB placement scheme. IIRC, Miquel had a patchset doing that.
>
> We also should have the concept of protected OOB-region vs
> unprotected-OOB-region if we want JFFS2 to work with controllers that
> protect part of the OOB region. Once we have that we can patch JFFS2
> to write things with "ECC-disabled"+"auto-OOB-placement-on-unprotected
> area".
I see the problem but as Boris said the fix is not valid as-is.
Problem is: I don't have a better proposal yet.
Is forcing JFFS2 to write cleanmarkers in raw mode only an option?
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Boris Brezillon <boris.brezillon@collabora.com>
Cc: "Álvaro Fernández Rojas" <noltari@gmail.com>,
richard@nod.at, vigneshr@ti.com, s.hauer@pengutronix.de,
masonccyang@mxic.com.tw, christophe.kerello@st.com,
stefan@agner.ch, piotrs@cadence.com, devik@eaxlabs.cz,
tglx@linutronix.de, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nand: raw: use write_oob_raw for MTD_OPS_AUTO_OOB mode
Date: Mon, 11 May 2020 18:29:23 +0200 [thread overview]
Message-ID: <20200511182923.6a4961ab@xps13> (raw)
In-Reply-To: <20200504123237.5c128668@collabora.com>
Hello,
Boris Brezillon <boris.brezillon@collabora.com> wrote on Mon, 4 May
2020 12:32:37 +0200:
> On Mon, 4 May 2020 11:42:53 +0200
> Álvaro Fernández Rojas <noltari@gmail.com> wrote:
>
> > Some NAND controllers change the ECC bytes when OOB is written with ECC
> > enabled.
> > This is a problem in brcmnand, since adding JFFS2 cleanmarkers after the page
> > has been erased will change the ECC bytes to 0 and the controller will think
> > the block is bad.
> > It can be fixed by using write_oob_raw, which ensures ECC is disabled.
> >
> > Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> > ---
> > drivers/mtd/nand/raw/nand_base.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> > index c24e5e2ba130..755d25200520 100644
> > --- a/drivers/mtd/nand/raw/nand_base.c
> > +++ b/drivers/mtd/nand/raw/nand_base.c
> > @@ -488,7 +488,7 @@ static int nand_do_write_oob(struct nand_chip *chip, loff_t to,
> >
> > nand_fill_oob(chip, ops->oobbuf, ops->ooblen, ops);
> >
> > - if (ops->mode == MTD_OPS_RAW)
> > + if (ops->mode == MTD_OPS_AUTO_OOB || ops->mode == MTD_OPS_RAW)
> > status = chip->ecc.write_oob_raw(chip, page & chip->pagemask);
>
> The doc says:
>
> @MTD_OPS_PLACE_OOB: OOB data are placed at the given offset (default)
> @MTD_OPS_AUTO_OOB: OOB data are automatically placed at the free areas
> which are defined by the internal ecclayout
> @MTD_OPS_RAW: data are transferred as-is, with no error
> correction; this mode implies %MTD_OPS_PLACE_OOB
>
> To me, that means MTD_OPS_PLACE_OOB and MTD_OPS_AUTO_OOB do not imply
> MTD_OPS_RAW. Anyway those modes are just too vague. We really should
> separate the ECC-disabled/ECC-enabled concept (AKA raw vs non-raw mode)
> from the OOB placement scheme. IIRC, Miquel had a patchset doing that.
>
> We also should have the concept of protected OOB-region vs
> unprotected-OOB-region if we want JFFS2 to work with controllers that
> protect part of the OOB region. Once we have that we can patch JFFS2
> to write things with "ECC-disabled"+"auto-OOB-placement-on-unprotected
> area".
I see the problem but as Boris said the fix is not valid as-is.
Problem is: I don't have a better proposal yet.
Is forcing JFFS2 to write cleanmarkers in raw mode only an option?
next prev parent reply other threads:[~2020-05-11 16:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-04 9:42 [PATCH] nand: raw: use write_oob_raw for MTD_OPS_AUTO_OOB mode Álvaro Fernández Rojas
2020-05-04 9:42 ` Álvaro Fernández Rojas
2020-05-04 10:32 ` Boris Brezillon
2020-05-04 10:32 ` Boris Brezillon
2020-05-11 16:29 ` Miquel Raynal [this message]
2020-05-11 16:29 ` Miquel Raynal
2020-05-12 8:36 ` Álvaro Fernández Rojas
2020-05-12 8:36 ` Álvaro Fernández Rojas
2020-05-12 8:44 ` Miquel Raynal
2020-05-12 8:44 ` Miquel Raynal
2020-05-12 8:54 ` Boris Brezillon
2020-05-12 8:54 ` Boris Brezillon
2020-06-05 17:09 ` Álvaro Fernández Rojas
2020-06-05 17:09 ` Álvaro Fernández Rojas
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=20200511182923.6a4961ab@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=boris.brezillon@collabora.com \
--cc=christophe.kerello@st.com \
--cc=devik@eaxlabs.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=masonccyang@mxic.com.tw \
--cc=noltari@gmail.com \
--cc=piotrs@cadence.com \
--cc=richard@nod.at \
--cc=s.hauer@pengutronix.de \
--cc=stefan@agner.ch \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.