linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: computersforpeace@gmail.com
Cc: sebastian@breakpoint.cc, robh+dt@kernel.org, pawel.moll@arm.com,
	mark.rutland@arm.com, ijc+devicetree@hellion.org.uk,
	galak@codeaurora.org, shawn.guo@linaro.org,
	kernel@pengutronix.de, boris.brezillon@free-electrons.com,
	marb@ixxat.de, aaron@tastycactus.com, bpringlemeir@gmail.com,
	linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, albert.aribaud@3adev.fr,
	klimov.linux@gmail.com, Bill Pringlemeir <bpringlemeir@nbsps.com>
Subject: Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
Date: Mon, 03 Aug 2015 11:28:43 +0200	[thread overview]
Message-ID: <ff2e2716578a1ae5f0c4b0e0ca8bbdc3@agner.ch> (raw)
In-Reply-To: <1438594050-4595-3-git-send-email-stefan@agner.ch>

Hi Brian,

On 2015-08-03 11:27, Stefan Agner wrote:
<snip>
> +static inline int vf610_nfc_correct_data(struct mtd_info *mtd, uint8_t *dat,
> +					 uint8_t *oob, int oob_loaded)
> +{
> +	struct vf610_nfc *nfc = mtd_to_nfc(mtd);
> +	u8 ecc_status;
> +	u8 ecc_count;
> +	int flip;
> +
> +	ecc_status = __raw_readb(nfc->regs + ECC_SRAM_ADDR * 8 + ECC_OFFSET);
> +	ecc_count = ecc_status & ECC_ERR_COUNT;
> +
> +	if (!(ecc_status & ECC_STATUS_MASK))
> +		return ecc_count;
> +
> +	if (!oob_loaded)
> +		vf610_nfc_read_buf(mtd, oob, mtd->oobsize);
> +
> +	/*
> +	 * On an erased page, bit count (including OOB) should be zero or
> +	 * at least less then half of the ECC strength.
> +	 */
> +	flip = count_written_bits(dat, nfc->chip.ecc.size, ecc_count);
> +	flip += count_written_bits(oob, mtd->oobsize - nfc->chip.ecc.bytes,
> +				   ecc_count);

With ECC the controller seems to clear the ECC bytes in SRAM buffer.
This is a dump of 64 Bit OOB with the 32-error ECC mode which requires
60 bytes of OOB for ECC:

[   22.190273] ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[   22.209698] vf610_nfc_correct_data, flips 1

Not sure if this is acceptable, but I now only count the bits in the
non-ECC area of the OOB.

Btw, if the ECC check fails, the controller seems kind of count the
amount of bitflips. It works for most devices reliable, but we had
devices for which that number was not accurate, see:
http://thread.gmane.org/gmane.linux.ports.arm.kernel/357439

--
Stefan

  reply	other threads:[~2015-08-03  9:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03  9:27 [PATCH v10 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Stefan Agner
2015-08-03  9:27 ` [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others Stefan Agner
2015-08-25 20:16   ` Brian Norris
2015-08-27  1:02     ` Stefan Agner
2015-08-27 16:34       ` Brian Norris
2015-08-27 17:25         ` Stefan Agner
2015-08-25 20:34   ` Brian Norris
2015-08-27  1:10     ` Stefan Agner
2015-08-27 16:47       ` Brian Norris
2015-08-03  9:27 ` [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support Stefan Agner
2015-08-03  9:28   ` Stefan Agner [this message]
2015-08-25 19:54     ` Brian Norris
2015-08-25 20:43       ` Boris Brezillon
2015-08-26 17:57       ` Stefan Agner
2015-08-26 21:34         ` Brian Norris
2015-08-28 21:14           ` Bill Pringlemeir
2015-08-03  9:27 ` [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings Stefan Agner
2015-08-25 20:25   ` Brian Norris
2015-08-26 15:26     ` Bill Pringlemeir
2015-08-26 15:39       ` Boris Brezillon
2015-08-26 21:15         ` Stefan Agner
2015-08-26 21:28           ` Brian Norris
2015-08-03  9:27 ` [PATCH v10 4/5] ARM: dts: vf610twr: add NAND flash controller peripherial Stefan Agner
2015-08-03  9:27 ` [PATCH v10 5/5] ARM: dts: vf-colibri: enable NAND flash controller Stefan Agner
2015-08-03 10:35 ` [PATCH v10 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Albert ARIBAUD

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=ff2e2716578a1ae5f0c4b0e0ca8bbdc3@agner.ch \
    --to=stefan@agner.ch \
    --cc=aaron@tastycactus.com \
    --cc=albert.aribaud@3adev.fr \
    --cc=boris.brezillon@free-electrons.com \
    --cc=bpringlemeir@gmail.com \
    --cc=bpringlemeir@nbsps.com \
    --cc=computersforpeace@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=klimov.linux@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marb@ixxat.de \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sebastian@breakpoint.cc \
    --cc=shawn.guo@linaro.org \
    /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).