public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Miquel Raynal <miquel.raynal@free-electrons.com>
Cc: Richard Weinberger <richard@nod.at>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
	linux-mtd@lists.infradead.org (open list:NAND FLASH SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list)
Subject: Re: [PATCH] nand: fix wrong default oob layout for small pages using soft ecc
Date: Mon, 31 Jul 2017 18:31:59 +0200	[thread overview]
Message-ID: <20170731183159.664e4c1c@bbrezillon> (raw)
In-Reply-To: <20170705090453.7e412982@bbrezillon>

On Wed, 5 Jul 2017 09:04:53 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> Hi Miquel,
> 
> On Wed,  5 Jul 2017 08:51:09 +0200
> Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> 
> > When using soft ecc, if no ooblayout is given, the core automatically
> > uses one of the nand_ooblayout_{sp,lp}*() functions to determine the
> > layout inside the out of band data.
> > 
> > Until kernel version 4.6, struct nand_ecclayout was used for that
> > purpose. During the migration from 4.6 to 4.7, an error shown up in the
> > small page layout, in the case oob section is only 8 bytes long.
> > 
> > The layout was using three bytes (0, 1, 2) for ecc, two bytes (3, 4)
> > as free bytes, one byte (5) for bad block marker and finally
> > two bytes (6, 7) as free bytes, as shown there:
> > 
> > [linux-4.6] drivers/mtd/nand/nand_base.c:52
> > static struct nand_ecclayout nand_oob_8 = {
> > 	.eccbytes = 3,
> > 	.eccpos = {0, 1, 2},
> > 	.oobfree = {
> > 		{.offset = 3,
> > 		 .length = 2},
> > 		{.offset = 6,
> > 		 .length = 2} }
> > };
> > 
> > This fixes the current implementation which is incoherent. It
> > references bit 3 at the same time as an ecc byte and a free byte.
> > 
> > Furthermore, it is clear with the previous implementation that there
> > is only one ecc section with 8 bytes oob sections. We shall return
> > -ERANGE in the nand_ooblayout_ecc_sp() function when asked for the
> > second section.

Applied to nand/fixes.

Thanks,

Boris

> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>  
> 
> Looks good to me. BTW, it looks like a good candidate for stable.
> No need to send a v2, I'll add the following when applying:
> 
> Fixes: 41b207a70d3a ("mtd: nand: implement the default mtd_ooblayout_ops")
> Cc: <stable@vger.kernel.org>
> 
> Thanks,
> 
> Boris
> 
> > ---
> >  drivers/mtd/nand/nand_base.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > index b1dd12729f19..c5221795a1e8 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -65,8 +65,14 @@ static int nand_ooblayout_ecc_sp(struct mtd_info *mtd, int section,
> >  
> >  	if (!section) {
> >  		oobregion->offset = 0;
> > -		oobregion->length = 4;
> > +		if (mtd->oobsize == 16)
> > +			oobregion->length = 4;
> > +		else
> > +			oobregion->length = 3;
> >  	} else {
> > +		if (mtd->oobsize == 8)
> > +			return -ERANGE;
> > +
> >  		oobregion->offset = 6;
> >  		oobregion->length = ecc->total - 4;
> >  	}  
> 

      reply	other threads:[~2017-07-31 16:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-05  6:51 [PATCH] nand: fix wrong default oob layout for small pages using soft ecc Miquel Raynal
2017-07-05  7:04 ` Boris Brezillon
2017-07-31 16:31   ` Boris Brezillon [this message]

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=20170731183159.664e4c1c@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=miquel.raynal@free-electrons.com \
    --cc=richard@nod.at \
    /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