public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Andrea Adami <andrea.adami@gmail.com>
Cc: "Dmitry Eremin-Solenikov" <dbaryshkov@gmail.com>,
	"Richard Weinberger" <richard@nod.at>,
	"Robert Jarzmik" <robert.jarzmik@free.fr>,
	linux-kernel@vger.kernel.org,
	"Haojian Zhuang" <haojian.zhuang@gmail.com>,
	"Marek Vasut" <marek.vasut@gmail.com>,
	linux-mtd@lists.infradead.org,
	"Cyrille Pitchen" <cyrille.pitchen@wedev4u.fr>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"Brian Norris" <computersforpeace@gmail.com>,
	"David Woodhouse" <dwmw2@infradead.org>
Subject: Re: [PATCH v6] mtd: sharpslpart: Add sharpslpart partition parser
Date: Sat, 26 Aug 2017 07:59:38 +0200	[thread overview]
Message-ID: <20170826075938.5a9b861d@bbrezillon> (raw)
In-Reply-To: <20170825001129.091badb4@bbrezillon>

On Fri, 25 Aug 2017 00:11:29 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:


> > +/*
> > + * The logical block number assigned to a physical block is stored in the OOB
> > + * of the first page, in 3 16-bit copies with the following layout:
> > + *
> > + * 01234567 89abcdef
> > + * -------- --------
> > + * ECC BB   xyxyxy
> > + *
> > + * When reading we check that the first two copies agree.
> > + * In case of error, matching is tried using the following pairs.
> > + * Reserved values 0xffff mean the block is kept for wear leveling.
> > + *
> > + * 01234567 89abcdef
> > + * -------- --------
> > + * ECC BB   xyxy    oob[8]==oob[10] && oob[9]==oob[11]   -> byte0=8   byte1=9
> > + * ECC BB     xyxy  oob[10]==oob[12] && oob[11]==oob[13] -> byte0=10  byte1=11
> > + * ECC BB   xy  xy  oob[12]==oob[8] && oob[13]==oob[9]   -> byte0=12  byte1=13  
> 
> I know there's a depends on "MTD_NAND_SHARPSL || MTD_NAND_TMIO" in the
> Kconfig entry, but one could enable those options just to use the sharpsl
> part parser even if the OOB layout is incompatible with the sharpsl FTL.
> 
> I'd recommend that you check that OOB bytes 8 to 15 are actually free
> to be used by the MTD user in sharpsl_parse_mtd_partitions().
> 
> Can be done with something like that:
> 
> static int sharpsl_nand_check_ooblayout(struct mtd_info *mtd)
> {
> 	u8 freebytes = 0;
> 	int section = 0;
> 
> 	while (true) {
> 		struct mtd_oob_region oobfree = { };
> 		int ret, i;
> 
> 		ret = mtd_ooblayout_free(mtd, section++, &oobfree);
> 		if (ret)
> 			break;
> 
> 		if (!oobfree.length || oobfree.offset > 15 ||
> 		    (oobfree.offset + oobfree.length) < 8)
> 			continue;
> 
> 		i = oobfree.offset >= 8 ? : 8;

As you reported on IRC there's an mistake here, it should be:

		i = oobfree.offset >= 8 ? oobfree.offset : 8

> 		for (; i < oobfree.offset + oobfree.length && i < 16; i++)
> 			freebytes |= BIT(i - 8);
> 
> 		if (freebytes == 0xff)
> 			return 0;
> 	}
> 
> 	return -ENOTSUPP;
> }

      reply	other threads:[~2017-08-26  6:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22  9:42 [PATCH v6] mtd: sharpslpart: Add sharpslpart partition parser Andrea Adami
2017-08-22 12:54 ` Boris Brezillon
2017-08-24  9:19   ` Andrea Adami
2017-08-24 10:04     ` Boris Brezillon
2017-08-24 10:30       ` Andrea Adami
2017-08-24 11:27         ` Boris Brezillon
2017-08-25  4:53           ` Brian Norris
2017-08-25 17:50             ` Andrea Adami
2017-08-25 21:48               ` Boris Brezillon
2017-08-25 22:09                 ` Andrea Adami
2017-08-26  6:58                   ` Boris Brezillon
2017-08-24 22:11 ` Boris Brezillon
2017-08-26  5:59   ` 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=20170826075938.5a9b861d@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=andrea.adami@gmail.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=haojian.zhuang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=robert.jarzmik@free.fr \
    /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