[QUESTION] MLC NAND and ECC over OOB area

Charles Hardin ckhardin at exablox.com
Thu Oct 11 15:02:51 EDT 2012


On Oct 11, 2012, at 11:22 AM, Charles Hardin wrote:

> Ok, that seems reasonable - and, following this line of thought - then the expectation would be to change the nand_bbt.c code to check for the "weight of a bad block pattern" instead of looking for an exact match on the pattern.
> 
> For example the following would change:
> 
> /**
> * check_short_pattern - [GENERIC] check if a pattern is in the buffer
> * @buf: the buffer to search
> * @td: search pattern descriptor
> *
> * Check for a pattern at the given place. Used to search bad block tables and
> * good / bad block identifiers. Same as check_pattern, but no optional empty
> * check.
> */
> static int check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
> {
>        int i;
>        uint8_t *p = buf;
> 
>        /* Compare the pattern */
>        for (i = 0; i < td->len; i++) {
>                if (p[td->offs + i] != td->pattern[i])
>                        return -1;
>        }
>        return 0;
> }
> 
> to something like the pseudo code below:
> 
> static in check_short_pattern(uint8_t *buf, struct nand_bbt_descr *td)
> {
> 	int i;
> 	int weight = 0;
> 	int tweight = 0;
> 	uint8_t *p = buf;
> 
> 	/* Compute and compare the weight */
> 	for (i = 0; i < td->len; i++) {
> 		uint8_t w;
> 
> 		w = p[td->offs+i];
> 		w = (w & 0x55) + ((w >> 1) & 0x55);
> 		w = (w & 0x33) + ((w >> 2) & 0x33);
> 		w = (w & 0x0f) + ((w >> 4) & 0x0f);
> 		weight += w;
> 
> 		w = td->pattern[i];
> 		w = (w & 0x55) + ((w >> 1) & 0x55);
> 		w = (w & 0x33) + ((w >> 2) & 0x33);
> 		w = (w & 0x0f) + ((w >> 4) & 0x0f);
> 		tweight += w;
> 	}
> 
> 	/* if the weight of the buf is more then half the weight of the pattern */
> 	if (weight > (tweight / 2))
> 		return 0;
> 
> 	return -1;
> }
> 
> This is a not an overly complex concept for nand_bbt code path, but it would change the exact match done currently to a heuristic match done by weight. My guess is that this behavior change will be done by the driver itself and override the nand_scan_bbt functions. However, I don't see an interface to plugin a specific BBT implementation in the underneath the nand_scan_bbt and nand_update_bbt functions currently in the hand drivers.
> 
> Regards,
> Charles


Oops, wrong call path - I just looked into nand_base.c and on the nand_block_bad function, I was looking at the generation of the in core memory bbt - I'll poke around a bit more now on the proper code path to construct a better world view.

Regards,
Charles


More information about the linux-mtd mailing list