Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1198676

Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support

From Stefan Agner <stefan@agner.ch>
Newsgroups linux.kernel
Subject Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
Date 2015-08-03 11:40 +0200
Message-ID <pTknU-7ws-35@gated-at.bofh.it> (permalink)
References <pTked-7lf-3@gated-at.bofh.it> <pTkee-7lf-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v10 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Stefan Agner <stefan@agner.ch> - 2015-08-03 11:30 +0200
  [PATCH v10 5/5] ARM: dts: vf-colibri: enable NAND flash controller Stefan Agner <stefan@agner.ch> - 2015-08-03 11:30 +0200
  [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings Stefan Agner <stefan@agner.ch> - 2015-08-03 11:30 +0200
  [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support Stefan Agner <stefan@agner.ch> - 2015-08-03 11:30 +0200
    Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC  support Stefan Agner <stefan@agner.ch> - 2015-08-03 11:40 +0200
  [PATCH v10 4/5] ARM: dts: vf610twr: add NAND flash controller peripherial Stefan Agner <stefan@agner.ch> - 2015-08-03 11:30 +0200
  [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others Stefan Agner <stefan@agner.ch> - 2015-08-03 11:30 +0200
  Re: [PATCH v10 0/5] mtd: nand: vf610_nfc: Freescale NFC for VF610 Albert ARIBAUD <albert.aribaud@3adev.fr> - 2015-08-03 12:40 +0200

csiph-web