mtd: nand: OMAP: ELM error correction support for BCH ecc
Subsystems (3)
v4 cover mtd: nand: OMAP: ELM error correction support for BCH ecc
Support to use ELM as BCH 4 & 8 bit error correction module. Also performance enhancement by adding single shot read_page and write_page functions for the nand flashes with page size less than 4 KB.
ELM module can be used to correct errors reported by BCH 4, 8 & 16 bit ECC scheme. For now only 4 & 8 bit support is added.
BCH 4 & 8 bit error detection support is already available in mainline kernel and works with software error correction.
This series is based on linux 3.8-rc2 and tested with [1]. Also this patch series depend on [1] for NAND flash device tree data and gpmc nand device tree binding documentation updates.
1. [PATCH v7 0/5] OMAP GPMC DT bindings
http://www.spinics.net/lists/linux-omap/msg83505.html
Tested on am335x-evm for BCH 4 and 8 bit error correction.
Changes since v1:
- Erased page is identified by checking byte [13/7] in read ecc. To filter out bit flips in OOB area, check 0 bits in the byte greater than 4.
- GPMC ecc engine configuration moves to omap2.c NAND driver.
Changes since v2:
- Added runtime detection of elm module, instead of depending on platform data.
- Added bit flip correction in OOB ecc data if bit flip happen OOB data.
Changes since v3:
- Availability and usability of ELM module is detected from device tree nodes by checking availability of ELM node in device tree.
Philip Avinash (3):
mtd: nand: omap2: Update nerrors using ecc.strength
mtd: devices: elm: Add support for ELM error correction
mtd: nand: omap2: Support for hardware BCH error correction.
Documentation/devicetree/bindings/mtd/elm.txt | 16 + .../devicetree/bindings/mtd/gpmc-nand.txt | 4 + drivers/mtd/devices/Makefile | 4 +- drivers/mtd/devices/elm.c | 405 ++++++++++++++ drivers/mtd/nand/omap2.c | 583 ++++++++++++++++++-- include/linux/platform_data/elm.h | 54 ++ 6 files changed, 1023 insertions(+), 43 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/elm.txt create mode 100644 drivers/mtd/devices/elm.c create mode 100644 include/linux/platform_data/elm.h
Signature · 1 line
1.7.9.5
PATCH v4 1/3 mtd: nand: omap2: Update nerrors using ecc.strength
Remove check of ecc bytes with 13, number of errors can directly update from nand ecc strength. This will increase re-usability of the code. Also add macro definitions BCH8_ERROR_MAX & BCH4_ERROR_MAX for better readability and cleaner code.
---
Changes since v3:
- Update commit message.
drivers/mtd/nand/omap2.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/mtd/nand/omap2.c +8 -4
@@ -117,6 +117,9 @@#define OMAP24XX_DMA_GPMC 4 +#define BCH8_MAX_ERROR 8/* upto 8 bit correctable */ +#define BCH4_MAX_ERROR 4/* upto 4 bit correctable */ +/* oob info generated runtime depending on ecc algorithm and layout selected */ static struct nand_ecclayout omap_oobinfo;/* Define some generic bad / good block scan pattern which are used
@@ -1041,7 +1044,7 @@ static void omap3_enable_hwecc_bch(struct mtd_info *mtd, int mode)struct nand_chip *chip = mtd->priv;u32 val; - nerrors = (info->nand.ecc.bytes ==13 ) ?8 :4 ; + nerrors = info->nand.ecc.strength; dev_width = (chip->options &NAND_BUSWIDTH_16 ) ?1 :0 ; nsectors =1 ;/*
@@ -1218,13 +1221,14 @@ static int omap3_init_bch(struct mtd_info *mtd, int ecc_opt) struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, mtd);#ifdef CONFIG_MTD_NAND_OMAP_BCH8 -const int hw_errors =8 ; +const int hw_errors =BCH8_MAX_ERROR ;#else -const int hw_errors =4 ; +const int hw_errors =BCH4_MAX_ERROR ;#endif info->bch =NULL ; - max_errors = (ecc_opt ==OMAP_ECC_BCH8_CODE_HW ) ?8 :4 ; + max_errors = (ecc_opt ==OMAP_ECC_BCH8_CODE_HW ) ? +BCH8_MAX_ERROR :BCH4_MAX_ERROR ;if (max_errors != hw_errors) {pr_err ("cannot configure %d-bit BCH ecc, only %d-bit supported" , max_errors, hw_errors);
Signature · 1 line
1.7.9.5
PATCH v4 2/3 mtd: devices: elm: Add support for ELM error correction
In reply to Philip AvinashThe ELM hardware module can be used to speedup BCH 4/8/16 ECC scheme error correction.
For now only 4 & 8 bit support is added
---
Changes since v3:
- Remove export symbol and API support for elm_request and provided export_symbol support for elm_config.
Changes since v2:
- Remove __devinit & __devexit annotations
Changes since v1:
- Change build attribute to CONFIG_MTD_NAND_OMAP_BCH
- Reduced indentation using by passing elm_info , offset to elm_read & elm_write
- Removed syndrome manipulation functions.
Documentation/devicetree/bindings/mtd/elm.txt | 16 + drivers/mtd/devices/Makefile | 4 +- drivers/mtd/devices/elm.c | 404 +++++++++++++++++++++++++ include/linux/platform_data/elm.h | 53 ++++ 4 files changed, 477 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/mtd/elm.txt create mode 100644 drivers/mtd/devices/elm.c create mode 100644 include/linux/platform_data/elm.h
Documentation/devicetree/bindings/mtd/elm.txt new file +16 -0
@@ -0,0 +1,16 @@ +Error location module + +Required properties: +- compatible: Must be "ti,am33xx-elm" +- reg: physical base address and size of the registers map. +- interrupts: Interrupt number for the elm. + +Optional properties: +- ti,hwmods: Name of the hwmod associated to the elm + +Example: +elm: elm at 0 { + compatible = "ti,am33xx-elm"; + reg = <0x48080000 0x2000>; + interrupts = <4>; +};
drivers/mtd/devices/Makefile +3 -1
@@ -17,8 +17,10 @@ obj-$(CONFIG_MTD_LART) += lart.o obj-$(CONFIG_MTD_BLOCK2MTD) += block2mtd.o obj-$(CONFIG_MTD_DATAFLASH) += mtd_dataflash.o obj-$(CONFIG_MTD_M25P80) += m25p80.o +obj-$(CONFIG_MTD_NAND_OMAP_BCH) += elm.o obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o obj-$(CONFIG_MTD_SST25L) += sst25l.o obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o -CFLAGS_docg3.o += -I$(src) + +CFLAGS_docg3.o += -I$(src)
drivers/mtd/devices/elm.c new file +404 -0
404 lines not on this page · raw message
include/linux/platform_data/elm.h new file +53 -0
53 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v4 3/3 mtd: nand: omap2: Support for hardware BCH error correction.
In reply to Philip AvinashELM module can be used for hardware error correction of BCH 4 & 8 bit. ELM module functionality is verified by checking the availability of handle for ELM module in device tree. Hence supporting
1. ELM module available, BCH error correction done by ELM module. Also support read & write page in one shot by adding custom read_page and write_page methods. This helps in optimizing code for NAND flashes with page size less than 4 KB.
2. If ELM module not available fall back to software BCH error correction support.
New structure member is added to omap_nand_info
1. "is_elm_used" to know the status of whether the ELM module is used for error correction or not.
2. "elm_dev" device pointer to elm device on detection of ELM module.
Also being here update the device tree documentation of gpmc-nand for adding optional property elm_id.
Note:
ECC layout uses 1 extra bytes for 512 byte of data to handle erased pages. Extra byte programmed to zero for programmed pages. Also BCH8 requires 14 byte ecc to maintain compatibility with RBL ECC layout. This results a common ecc layout across RBL, U-boot & Linux with BCH8.
---
This patch depend on http://www.spinics.net/lists/linux-omap/msg83504.html
for GPMC DT binding.
Changes since v3:
- ELM module availability is find by checking device tree handle for ELM module. Hence remove support for elm_request and configure ELM module directly from NAND driver for required BCH ecc algorithm.
- device tree binding document update for gpmc nand.
Changes since v2:
- Threshold for erased bit flip in erased page set to minimum of 4 or half of ecc.strength. So max bit flips allowed at fixed offset is 4.
- Add dependency on runtime detection of ELM module instead of platform data. Dependency on is_elm_used flag in platform data removed.
- Return number of bit flips from read_page().
- Add bit correction support in case of bit flip in OOB as BCH scheme can correct bit flips in ECC.
Changes since v1:
- Incorporated GPMC modification to nand driver
- Erased page detects by checking OOB byte at fixed offset.
.../devicetree/bindings/mtd/gpmc-nand.txt | 4 + drivers/mtd/nand/omap2.c | 573 ++++++++++++++++++-- include/linux/platform_data/elm.h | 3 +- 3 files changed, 540 insertions(+), 40 deletions(-)
Documentation/devicetree/bindings/mtd/gpmc-nand.txt +4 -0
@@ -29,6 +29,9 @@ Optional properties: "bch4" 4-bit BCH ecc code "bch8" 8-bit BCH ecc code + - elm_id: Specifies elm device node. This is required to support BCH + error correction using ELM module. + For inline partiton table parsing (optional): - #address-cells: should be set to 1
@@ -46,6 +49,7 @@ Example for an AM33xx board: #address-cells = <2>; #size-cells = <1>; ranges = <0 0 0x08000000 0x2000>; /* CS0: NAND */ + elm_id = <&elm>; nand at 0,0 { reg = <0 0 0>; /* CS0, offset 0 */
drivers/mtd/nand/omap2.c +534 -39
672 lines not on this page · raw message
include/linux/platform_data/elm.h +2 -1
@@ -30,7 +30,8 @@ enum bch_ecc {#define BCH4_ECC_OOB_BYTES 7/* RBL requires 14 byte even though BCH8 uses only 13 byte */ #define BCH8_SIZE (BCH8_ECC_OOB_BYTES + 1) -#define BCH4_SIZE (BCH4_ECC_OOB_BYTES) +/* Uses 1 extra byte to handle erased pages */ +#define BCH4_SIZE (BCH4_ECC_OOB_BYTES + 1)/** * struct elm_errorvec - error vector for elm
Signature · 1 line
1.7.9.5
Hi Artem,
Quoted 10 lines · Avinash
Support to use ELM as BCH 4 & 8 bit error correction module. Also performance enhancement by adding single shot
read_pageandwrite_pagefunctions for the nand flashes with page size less than 4 KB.ELM module can be used to correct errors reported by BCH 4, 8 & 16 bit ECC scheme. For now only 4 & 8 bit support is added.
BCH 4 & 8 bit error detection support is already available in mainline kernel and works with software error correction.
Quoted 8 lines
This series is based on linux 3.8-rc2 and tested with [1]. Also this patch series depend on [1] for NAND flash device tree data and gpmc nand device tree binding documentation updates.
1. [PATCH v7 0/5] OMAP GPMC DT bindings
http://www.spinics.net/lists/linux-omap/msg83505.htmlTested on am335x-evm for BCH 4 and 8 bit error correction.
Can you apply this patch series on l2-mtd tree as it will help RBL compatibility ecc layout for NAND flash in am335x-platforms and hardware based BCH error correction.
Thanks
Avinash
Quoted 37 lines
Changes since v1:
- Erased page is identified by checking byte [13/7] in read ecc. To filter out bit flips in OOB area, check 0 bits in the byte greater than 4.
- GPMC ecc engine configuration moves toomap2.cNAND driver.Changes since v2:
- Added runtime detection of elm module, instead of depending on platform data.
- Added bit flip correction in OOB ecc data if bit flip happen OOB data.Changes since v3:
- Availability and usability of ELM module is detected from device tree nodes by checking availability of ELM node in device tree.Philip Avinash (3):
mtd: nand: omap2: Update nerrors using ecc.strength
mtd: devices: elm: Add support for ELM error correction
mtd: nand: omap2: Support for hardware BCH error correction.Documentation/devicetree/bindings/mtd/elm.txt | 16 + .../devicetree/bindings/mtd/gpmc-nand.txt | 4 + drivers/mtd/devices/Makefile | 4 +- drivers/mtd/devices/elm.c | 405 ++++++++++++++ drivers/mtd/nand/omap2.c | 583 ++++++++++++++++++-- include/linux/platform_data/elm.h | 54 ++ 6 files changed, 1023 insertions(+), 43 deletions(-) create mode 100644 Documentation/devicetree/bindings/mtd/elm.txt create mode 100644 drivers/mtd/devices/elm.c create mode 100644 include/linux/platform_data/elm.hSignature · 1 line
1.7.9.5
Artem Bityutskiy
AppliedQuoted 4 lines · Avinash
Quoted 4 lines
This series is based on linux 3.8-rc2 and tested with [1]. Also this patch series depend on [1] for NAND flash device tree data and gpmc nand device tree binding documentation updates.
Quoted 8 lines
Quoted 4 lines
1. [PATCH v7 0/5] OMAP GPMC DT bindings
http://www.spinics.net/lists/linux-omap/msg83505.htmlTested on am335x-evm for BCH 4 and 8 bit error correction.
Can you apply this patch series on l2-mtd tree as it will help RBL compatibility ecc layout for NAND flash in am335x-platforms and hardware based BCH error correction.
OK, I've applied them. I dropped the part that updates the documentation. Please, handle it separately when Daniel's patches are in.
Pushed to l2-mtd.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 14 lines · Artem Bityutskiy
Quoted 4 lines · Avinash
Quoted 4 lines
This series is based on linux 3.8-rc2 and tested with [1]. Also this patch series depend on [1] for NAND flash device tree data and gpmc nand device tree binding documentation updates.
Quoted 8 lines
Quoted 4 lines
1. [PATCH v7 0/5] OMAP GPMC DT bindings
http://www.spinics.net/lists/linux-omap/msg83505.htmlTested on am335x-evm for BCH 4 and 8 bit error correction.
Can you apply this patch series on l2-mtd tree as it will help RBL compatibility ecc layout for NAND flash in am335x-platforms and hardware based BCH error correction.
Quoted 5 lines
OK, I've applied them. I dropped the part that updates the documentation. Please, handle it separately when Daniel's patches are in.
Pushed to l2-mtd.git, thanks!
Thanks for applying this patch series.
I will update gpmc-nand documentation part in a separate patch.
Thanks,
Avinash
Quoted 5 lines
Signature · 3 lines
-- Best Regards, Artem Bityutskiy