mtd: gpmi: Bitflip support in erased regions
Subsystems (2)
PATCH 1/1 mtd: gpmi: Bitflip support in erased regions
Fixed cc to linux-mtd, please ignore my previous version.
Hello all,
I bumped into an issue on a custom board with an i.MX28 and a Micron MT29F4G08 NAND flash. My system running a 3.9.0 failed to boot during upgrade testing due to UBI errors related to a bitflips in NAND:
[ 3.831323] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry [ 3.845026] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry [ 3.858710] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry [ 3.872408] UBI error: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read 16384 bytes ... [ 4.011529] UBIFS error (pid 36): ubifs_recover_leb: corrupt empty space LEB 27:237568, corruption starts at 9815 [ 4.021897] UBIFS error (pid 36): ubifs_scanned_corruption: corruption at LEB 27:247383 [ 4.030000] UBIFS error (pid 36): ubifs_scanned_corruption: first 6569 bytes from LEB 27:247383
Diving a bit deeper with nanddump:
root@(none):~# nanddump -a /dev/mtd8 > /dev/null ECC failed: 8 ECC corrected: 0 Number of bad blocks: 0 Number of bbt blocks: 0 Block size 262144, page size 4096, OOB size 224 Dumping data starting at 0x00000000 and ending at 0x1ea00000... ECC: 1 corrected bitflip(s) at offset 0x042c2000 ECC: 1 uncorrectable bitflip(s) at offset 0x06efe000 root@(none):~# nanddump -s 116129792 -c --noecc -l 262144 /dev/mtd8 ... 0x06efe6a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7f |................|
Which is points to a well know 'corrupt empty space' issue, which appears every now and then:
- http://permalink.gmane.org/gmane.linux.drivers.mtd/46617
- http://lists.infradead.org/pipermail/linux-mtd/2012-January/039254.html
Hence I went on a quest to teach my NAND driver how to do this, gpmi-nand in question. The problem is that although on properly written data which gets streamed through the BCH block we get 16 bit ecc, if we erase block we git like 0 bit ecc, since erase is a command, not a stream of data travelling through the BCH block. The BCH block (see i.MX28 reference manual chapters 15 GPMI and 16 BCH) can tell us of protected chunks:
- if they are error free (if ecc data is present)
- the amount of bitflips they contain (if ecc data is present)
- if they are fully erased (all 0xFF's)
- if they are uncorrectable (# bitflips > ecc_strength, or 0xFF with
bitflips).
In the current situation as soon as a single bitflip exists in a region where the parity information is all 0xFF (looking like it's erased) the block is marked as uncorrectable. Which is a pity since I can peform this kind of ECC by hand.
Quote datasheet:
"As the BCH decoder reads the data and parity blocks, it records a special condition, i.e., that all of the bits of a payload data block or metadata block are one, including any associated parity bytes. The all-ones case for both parity and data indicates an erased block in the NAND device."
Fortunately we can more or less tune this parameter by using the ERASE_THRESHOLD in HW_BCH_MODE register:
"This value indicates the maximum number of zero bits on a flash page for it to be considered erased. For SLC NAND devices, this value should be programmed to 0 (meaning that the entire page should consist of bytes of 0xFF. For MLC NAND devices, bit errors may occur on reads (even on blank pages), so this threshold can be used to tune the erased page checking algorithm."
So as my solution I'm setting this erase threshold to the ecc_strength derived from the geometry, meaning that I will tolerate the same number of bitflips the BCH block would consider correctable.
The side effect is that whever I'm reading a page (gpmi_ecc_read_page() ) which the BCH block marked as "erased" I need to take a software approach. The software approach is inspired on what is currently
done in the omap2 driver (but not free from discussion). At that point I now that the page can contain up to ecc_strenght bitflips, so I need to count and correct them if necessary. This obviously gives a slight overhead
when compared to a normal read of erased pages but is more polite towards
upper layers.
On the other hand, the upper layers should also show some intelligence when it comes to reading erased pages which doesn't make much sense either.
I considered alternatives based upon the 'let it fails as it does now, and try to intelligently figure out whether or not it's an erased page or not' possibly using additional byte in the metadata or something based on fuzzy rules, but this is actually the solution which ended up giving most certainty.
I have tested this on a 3.9/i.MX28 and after applying this patch my board went from a stubbornly-whining-about-corrupt-empty-space to happily mounting the partition and even the trace of my stuck bit disappeared:
root@(none):~# nanddump -a /dev/mtd8 > /dev/null ECC failed: 0 ECC corrected: 1 Number of bad blocks: 0 Number of bbt blocks: 0 Block size 262144, page size 4096, OOB size 224 Dumping data starting at 0x00000000 and ending at 0x1ea00000... ECC: 1 corrected bitflip(s) at offset 0x042c2000
I have also seen Pekon is eagerly trying to get the code removed from omap2,
(e.g. http://lists.infradead.org/pipermail/linux-mtd/2013-July/047548.html )
but even though his set of patches is currently in their 4th version I haven't seen any proper solution to handling bitflips in erased pages without iterating through them.
Any suggestions or feedback is welcomed.
E.
Elie De Brauwer (1):
mtd: gpmi: Deal with bitflips in erased regions regions
drivers/mtd/nand/gpmi-nand/bch-regs.h | 1 + drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 7 ++++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 40 +++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/1 mtd: gpmi: Deal with bitflips in erased regions regions
The BCH block typically used with a i.MX28 and GPMI block is only able to correct bitflips on data actually streamed through the block. When erasing a block the data does not stream through the BCH block and therefore not ECC data is written to the NAND chip. This causes gpmi_ecc_read_page to return failure as soon as a single non-1-bit is found in an erased page. Typically causing problems at higher levels (ubifs corrupted empty space warnings).
This patch configures the BCH block to mark a block as 'erased' if no more than ecc_strength bitflips are found. The result is that erased blocks are doublechecked by software for bitflips and that bitflips are corrected and reported, allowing the upper layers to take proper actions.
--- drivers/mtd/nand/gpmi-nand/bch-regs.h | 1 + drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 7 ++++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 40 +++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-)
drivers/mtd/nand/gpmi-nand/bch-regs.h +1 -0
@@ -31,6 +31,7 @@#define HW_BCH_STATUS0 0x00000010#define HW_BCH_MODE 0x00000020 +#define BM_BCH_MODE_ERASE_THRESHOLD_MASK 0xff#define HW_BCH_ENCODEPTR 0x00000030#define HW_BCH_DATAPTR 0x00000040#define HW_BCH_METAPTR 0x00000050
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +7 -0
@@ -286,6 +286,13 @@ int bch_set_geometry(struct gpmi_nand_data *this) | BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this), r->bch_regs + HW_BCH_FLASH0LAYOUT1); +/* +* Set the tolerance for bitflips when reading erased blocks +* equal to the ecc_strength. +*/ +writel (bch_geo->ecc_strength &BM_BCH_MODE_ERASE_THRESHOLD_MASK , + r->bch_regs +HW_BCH_MODE ); +/* Set *all* chip selects to use layout 0. */ writel (0 , r->bch_regs +HW_BCH_LAYOUTSELECT );
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +37 -3
@@ -1012,6 +1012,30 @@ static void block_mark_swapping(struct gpmi_nand_data *this, p[1 ] = (p[1 ] & mask) | (from_oob >> (8 - bit)); } +/* +* Count the number of 0 bits in a supposed to be +* erased region and correct them. Return the number +* of bitflips or zero when the region was correct. +*/ +static unsigned int erased_sector_bitflips (unsigned char *data, +unsigned int chunk, +struct bch_geometry *geo) +{ +unsigned int flip_bits =0 ; +int i; +int base = geo->ecc_chunk_size * chunk; + +/* Count bitflips */ +for (i =0 ; i < geo->ecc_chunk_size; i++) + flip_bits +=hweight8 (~data[base + i]); + +/* Correct bitflips by 0xFF'ing this chunk. */ +if (flip_bits) +memset (&data[base],0xFF , geo->ecc_chunk_size); + +return flip_bits; +} +static int gpmi_ecc_read_page (struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page) {
@@ -1023,6 +1047,7 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,dma_addr_t auxiliary_phys;unsigned int i;unsigned char *status; +unsigned int flips;unsigned int max_bitflips =0 ;int ret;
@@ -1057,15 +1082,24 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, status = auxiliary_virt + nfc_geo->auxiliary_status_offset;for (i =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { -if ((*status ==STATUS_GOOD ) || (*status ==STATUS_ERASED )) +if (*status ==STATUS_GOOD )continue ;if (*status ==STATUS_UNCORRECTABLE ) { mtd->ecc_stats.failed++;continue ; } - mtd->ecc_stats.corrected += *status; - max_bitflips = max_t(unsigned int, max_bitflips, *status); + +if (*status ==STATUS_ERASED ) +/* Erased block, check/correct bitflips manually. */ + flips =erased_sector_bitflips (payload_virt, i, + nfc_geo); +else +/* BCH block corrected some errors for us. */ + flips = *status; + + mtd->ecc_stats.corrected += flips; + max_bitflips = max_t(unsigned int, max_bitflips, flips); }if (oob_required) {
Signature · 1 line
1.7.10.4
Re: [PATCH v1] mtd: gpmi: Deal with bitflips in erased regions regions
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Elie" == Elie De Brauwer <[email protected]> writes:
The BCH block typically used with a i.MX28 and GPMI block is only able to correct bitflips on data actually streamed through the block. When erasing a block the data does not stream through the BCH block and therefore not ECC data is written to the NAND chip. This causes
s/not/no/
Quoted 11 lines
gpmi_ecc_read_pageto return failure as soon as a single non-1-bit is found in an erased page. Typically causing problems at higher levels (ubifs corrupted empty space warnings).This patch configures the BCH block to mark a block as 'erased' if no more than
ecc_strengthbitflips are found. The result is that erased blocks are doublechecked by software for bitflips and that bitflips are corrected and reported, allowing the upper layers to take proper actions.Signed-off-by Elie De Brauwer <[email protected]>
Looks good otherwise.
Quoted 23 lines
--- drivers/mtd/nand/gpmi-nand/bch-regs.h | 1 + drivers/mtd/nand/gpmi-nand/gpmi-lib.c | 7 ++++++ drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 40 +++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 3 deletions(-)drivers/mtd/nand/gpmi-nand/bch-regs.h +1
-0@@ -31,6 +31,7 @@#define HW_BCH_STATUS0 0x00000010#define HW_BCH_MODE 0x00000020 +#define BM_BCH_MODE_ERASE_THRESHOLD_MASK 0xff#define HW_BCH_ENCODEPTR 0x00000030#define HW_BCH_DATAPTR 0x00000040#define HW_BCH_METAPTR 0x00000050drivers/mtd/nand/gpmi-nand/gpmi-lib.c +0
-0
drivers/mtd/nand/gpmi-nand/gpmi-lib.c int bch_set_geometry(struct gpmi_nand_data *this) · line 286
Quoted 1 line
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +0
-0@@ -286,6 +286,13 @@ int bch_set_geometry(struct gpmi_nand_data *this) | BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this),
r-> bch_regs + HW_BCH_FLASH0LAYOUT1);
Quoted 54 lines
drivers/mtd/nand/gpmi-nand/gpmi-lib.c +7
-0+/* +* Set the tolerance for bitflips when reading erased blocks +* equal to the ecc_strength. +*/ +writel (bch_geo->ecc_strength &BM_BCH_MODE_ERASE_THRESHOLD_MASK , + r->bch_regs +HW_BCH_MODE ); +/* Set *all* chip selects to use layout 0. */ writel (0 , r->bch_regs +HW_BCH_LAYOUTSELECT );drivers/mtd/nand/gpmi-nand/gpmi-nand.c +25
-0@@ -1012,6 +1012,30 @@ static void block_mark_swapping(struct gpmi_nand_data *this, p[1 ] = (p[1 ] & mask) | (from_oob >> (8 - bit)); } +/* +* Count the number of 0 bits in a supposed to be +* erased region and correct them. Return the number +* of bitflips or zero when the region was correct. +*/ +static unsigned int erased_sector_bitflips (unsigned char *data, +unsigned int chunk, +struct bch_geometry *geo) +{ +unsigned int flip_bits =0 ; +int i; +int base = geo->ecc_chunk_size * chunk; + +/* Count bitflips */ +for (i =0 ; i < geo->ecc_chunk_size; i++) + flip_bits +=hweight8 (~data[base + i]); + +/* Correct bitflips by 0xFF'ing this chunk. */ +if (flip_bits) +memset (&data[base],0xFF , geo->ecc_chunk_size); + +return flip_bits; +} +static int gpmi_ecc_read_page (struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page) {@@ -1023,6 +1047,7 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip,dma_addr_t auxiliary_phys;unsigned int i;unsigned char *status; +unsigned int flips;unsigned int max_bitflips =0 ;int ret;
drivers/mtd/nand/gpmi-nand/gpmi-nand.c static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, · line 1088
Quoted 8 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +1
-1@@ -1057,15 +1082,24 @@ static int gpmi_ecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, status = auxiliary_virt + nfc_geo->auxiliary_status_offset;for (i =0 ; i < nfc_geo->ecc_chunk_count; i++, status++) { -if ((*status ==STATUS_GOOD ) || (*status ==STATUS_ERASED )) +if (*status ==STATUS_GOOD )continue ;if (*status ==STATUS_UNCORRECTABLE ) {
mtd-> ecc_stats.failed++;
Quoted 25 lines
drivers/mtd/nand/gpmi-nand/gpmi-nand.c +11
-2continue ; } - mtd->ecc_stats.corrected += *status; - max_bitflips = max_t(unsigned int, max_bitflips, *status); + +if (*status ==STATUS_ERASED ) +/* Erased block, check/correct bitflips manually. */ + flips =erased_sector_bitflips (payload_virt, i, + nfc_geo); +else +/* BCH block corrected some errors for us. */ + flips = *status; + + mtd->ecc_stats.corrected += flips; + max_bitflips = max_t(unsigned int, max_bitflips, flips); }if (oob_required) {Signature · 6 lines
1.7.10.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Signature · 1 line
Bye, Peter Korsgaard
Quoted 8 lines · Elie De Brauwer
Fixed cc to linux-mtd, please ignore my previous version.
Hello all,
I bumped into an issue on a custom board with an i.MX28 and a Micron MT29F4G08 NAND flash. My system running a 3.9.0 failed to boot during upgrade testing due to UBI errors related to a bitflips in NAND:
Quoted 8 lines
[ 3.831323] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry [ 3.845026] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry [ 3.858710] UBI warning: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read only 16384 bytes, retry [ 3.872408] UBI error: ubi_io_read: error -74 (ECC error) while reading 16384 bytes from PEB 443:245760, read 16384 bytes ... [ 4.011529] UBIFS error (pid 36): ubifs_recover_leb: corrupt empty space LEB 27:237568, corruption starts at 9815 [ 4.021897] UBIFS error (pid 36): ubifs_scanned_corruption: corruption at LEB 27:247383 [ 4.030000] UBIFS error (pid 36): ubifs_scanned_corruption: first 6569 bytes from LEB 27:247383
thanks a lot for this patch.
I met the "corrupt empty space" issue too.
Quoted 42 lines
Diving a bit deeper with nanddump:
root@(none):~# nanddump -a /dev/mtd8 > /dev/null ECC failed: 8 ECC corrected: 0 Number of bad blocks: 0 Number of bbt blocks: 0 Block size 262144, page size 4096, OOB size 224 Dumping data starting at 0x00000000 and ending at 0x1ea00000... ECC: 1 corrected bitflip(s) at offset 0x042c2000 ECC: 1 uncorrectable bitflip(s) at offset 0x06efe000 root@(none):~# nanddump -s 116129792 -c --noecc -l 262144 /dev/mtd8 ... 0x06efe6a0: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 7f |................|Which is points to a well know 'corrupt empty space' issue, which appears every now and then:
- http://permalink.gmane.org/gmane.linux.drivers.mtd/46617
- http://lists.infradead.org/pipermail/linux-mtd/2012-January/039254.htmlHence I went on a quest to teach my NAND driver how to do this, gpmi-nand in question. The problem is that although on properly written data which gets streamed through the BCH block we get 16 bit ecc, if we erase block we git like 0 bit ecc, since erase is a command, not a stream of data travelling through the BCH block. The BCH block (see i.MX28 reference manual chapters 15 GPMI and 16 BCH) can tell us of protected chunks:
- if they are error free (if ecc data is present)
- the amount of bitflips they contain (if ecc data is present)
- if they are fully erased (all 0xFF's)
- if they are uncorrectable (# bitflips >ecc_strength, or0xFFwith
bitflips).
In the current situation as soon as a single bitflip exists in a region where the parity information is all0xFF(looking like it's erased) the block is marked as uncorrectable. Which is a pity since I can peform this kind of ECC by hand.Quote datasheet:
"As the BCH decoder reads the data and parity blocks, it records a special condition, i.e., that all of the bits of a payload data block or metadata block are one, including any associated parity bytes. The all-ones case for both parity and data indicates an erased block in the NAND device."
Quoted 4 lines
Fortunately we can more or less tune this parameter by using the
ERASE_THRESHOLDinHW_BCH_MODEregister:
"This value indicates the maximum number of zero bits on a flash page for it to be considered erased. For SLC NAND devices, this value should be
I met the "correct empty space" with a Toshiba SLC nand. The spec tells us it should be 0 for the SLC nand.
I will double-check it tomorrow.
Quoted 5 lines
programmed to 0 (meaning that the entire page should consist of bytes of
0xFF. For MLC NAND devices, bit errors may occur on reads (even on blank pages), so this threshold can be used to tune the erased page checking algorithm."
Quoted 8 lines
So as my solution I'm setting this erase threshold to the
ecc_strengthderived from the geometry, meaning that I will tolerate the same number of bitflips the BCH block would consider correctable.
The side effect is that whever I'm reading a page (gpmi_ecc_read_page()) which the BCH block marked as "erased" I need to take a software approach. The software approach is inspired on what is currently
done in the omap2 driver (but not free from discussion). At that point I now that the page can contain up toecc_strenghtbitflips, so I need to
The ecc_strength can be 40 sometimes.
I really donot know what is the proper value for the ERASE_THRESHOLD.
Maybe set ERASE_THRESHOLD with 2 is ok?
I think the ecc_strength is a little large.
Quoted 26 lines
count and correct them if necessary. This obviously gives a slight overhead
when compared to a normal read of erased pages but is more polite towards
upper layers.
On the other hand, the upper layers should also show some intelligence when it comes to reading erased pages which doesn't make much sense either.I considered alternatives based upon the 'let it fails as it does now, and try to intelligently figure out whether or not it's an erased page or not' possibly using additional byte in the metadata or something based on fuzzy rules, but this is actually the solution which ended up giving most certainty.
I have tested this on a 3.9/i.MX28 and after applying this patch my board went from a stubbornly-whining-about-corrupt-empty-space to happily mounting the partition and even the trace of my stuck bit disappeared:
root@(none):~# nanddump -a /dev/mtd8 > /dev/null ECC failed: 0 ECC corrected: 1 Number of bad blocks: 0 Number of bbt blocks: 0 Block size 262144, page size 4096, OOB size 224 Dumping data starting at 0x00000000 and ending at 0x1ea00000... ECC: 1 corrected bitflip(s) at offset 0x042c2000
Quoted 6 lines
I have also seen Pekon is eagerly trying to get the code removed from omap2,
(e.g. http://lists.infradead.org/pipermail/linux-mtd/2013-July/047548.html )
but even though his set of patches is currently in their 4th version I haven't seen any proper solution to handling bitflips in erased pages without iterating through them.
I will read it.
Please give us more time about this issue.
I will discuss it with out IC guy.
thanks
Huang Shijie
Quoted 13 lines · Huang Shijie
Quoted 11 lines · Elie De Brauwer
Quote datasheet:
"As the BCH decoder reads the data and parity blocks, it records a special condition, i.e., that all of the bits of a payload data block or metadata block are one, including any associated parity bytes. The all-ones case for both parity and data indicates an erased block in the NAND device."Fortunately we can more or less tune this parameter by using the
ERASE_THRESHOLDinHW_BCH_MODEregister:
"This value indicates the maximum number of zero bits on a flash page for it to be considered erased. For SLC NAND devices, this value should be
Quoted 4 lines
I met the "correct empty space" with a Toshiba SLC nand. The spec tells us it should be 0 for the SLC nand.
I will double-check it tomorrow.
I confirm that a SLC nand can meet this issue too.
Quoted 10 lines
Quoted 10 lines
programmed to 0 (meaning that the entire page should consist of bytes of
0xFF. For MLC NAND devices, bit errors may occur on reads (even on blank pages), so this threshold can be used to tune the erased page checking algorithm."So as my solution I'm setting this erase threshold to the
ecc_strengthderived from the geometry, meaning that I will tolerate the same number of bitflips the BCH block would consider correctable.
The side effect is that whever I'm reading a page (gpmi_ecc_read_page())
A solution is to check the HW_BCH_STATUS0:ALLONES.
If it is all ones, we do not check it by software.
Quoted 6 lines
Quoted 4 lines
which the BCH block marked as "erased" I need to take a software approach. The software approach is inspired on what is currently
done in the omap2 driver (but not free from discussion). At that point I now that the page can contain up toecc_strenghtbitflips, so I need toThe
ecc_strengthcan be 40 sometimes.
The only problem is what is the proper value for ERASE_THRESHOLD.
still need more investigate.
thanks
Huang Shijie
Quoted 7 lines · Huang Shijie
Quoted 6 lines · Huang Shijie
Quoted 5 lines · Elie De Brauwer
programmed to 0 (meaning that the entire page should consist of bytes of
0xFF. For MLC NAND devices, bit errors may occur on reads (even on blank pages), so this threshold can be used to tune the erased page checking algorithm."
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
So as my solution I'm setting this erase threshold to the
ecc_strengthderived from the geometry, meaning that I will tolerate the same number of bitflips the BCH block would consider correctable.
The side effect is that whever I'm reading a page (gpmi_ecc_read_page())A solution is to check the HW_BCH_STATUS0:ALLONES.
If it is all ones, we do not check it by software.
Ah, the HW_BCH_STATUS0 register does indeed contain some interesting bits:
- ALLONES 1 = All data bits of this transaction are ONE (source: imx datasheet page 1292)
Hence I will change gpmi_err_read_page() from my original patch gpmi_ecc_read_page(). Going from something like:
if (*status == STATUS_ERASED)
/* Erased block, check/correct bitflips manually. */
flips = erased_sector_bitflips(payload_virt, i, nfc_geo);else
/* BCH block corrected some errors for us. */
flips = *status;
Into something more
if (*status == STATUS_ERASED)
if (readl(HW_BCH_STATUS0 & BM_BCH_STATUS0_ALLONES))
flips = 0;
else
/* Erased block, check/correct bitflips manually. */
flips = erased_sector_bitflips(payload_virt, i, nfc_geo);else
/* BCH block corrected some errors for us. */
flips = *status;
(Hiding the readl() in a function in gpmi-lib.c since all register peek-n-poke is occuring there). And this way only doing the soft-bitflip-check where absolutely necessary (where necessary is defined on a page granularity).
I will provide a v2 of my patch incorporating these changes after I've had a chance to test them on hardware. (Somewhere this evening/tomorrow).
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
which the BCH block marked as "erased" I need to take a software approach. The software approach is inspired on what is currently
done in the omap2 driver (but not free from discussion). At that point I now that the page can contain up toecc_strenghtbitflips, so I need to
Quoted 5 lines
Quoted 1 line
The
ecc_strengthcan be 40 sometimes.The only problem is what is the proper value for
ERASE_THRESHOLD.still need more investigate.
Okay, I'm awaiting input on this.
The reason why I set this to ecc_strength was because I assumed that the BCH could correct up to ecc_strength biterrors, hence I could fix this amount of bitflips myself. But I agree it can be rough estimate. In my specific case hardcoding it to 1 would have already fixed it.
Thanks for your feedback !
Signature · 1 line
Elie De Brauwer