mtd: nand: vf610_nfc: Freescale NFC for VF610
Subsystems (3)
v10 cover mtd: nand: vf610_nfc: Freescale NFC for VF610
The 10th revision includes some more review comments, including an improved handling of empty NAND pages with hardware ECC.
More information and the full test log of earlier patchset version can be found in the cover letter of the last revision v6:
http://thread.gmane.org/gmane.linux.kernel/1979868
Changes since v9:
- Remove inline of vf610_nfc_done
- Add __iomem to src argument of vf610_nfc_memcpy
- Handle return value of mtd_device_parse_register correctly
- Count bits in OOB too (only non-ECC bits)
- Return bitflips in ecc.read_page callback vf610_nfc_read_page
- Fall-through ALT_BUF_ONFI
- Use BIT macros
Changes since v8:
- Fix 16-Bit NAND flash support by splitting up initialization (introduce vf610_nfc_preinit_controller)
- Updated comments in initialziation functions
Changes since v7:
- vf610-twr.dts: Moved NFC pinmux into the existing iomuxc node and sort new nfc node behind the existing iomuxc node as well.
- vf610-twr.dts/vf-colibri.dtsi: Dropped _1 suffixes
Changes since v6:
- Rebased ontop of l2-mtd/master (v4.2-rc1 based)
- Removed HAVE_NAND_VF610_NFC and use depends on. This made "[PATCH v6 4/6] ARM: vf610: enable NAND Flash Controller" unnecessary
Changes since v5:
- Removed fsl,mpc5125-nfc compatible string
- Removed readl/writel_relaxed
- Change interface of vf610_nfc_transfer_size to match other accessors
Changes since v4:
- Rebased ontop of l2-mtd/master (v4.1-rc4 based)
- Eliminate unnecessary page read (NAND_CMD_SEQIN) since the driver does not support sub-page writes anyway (improves write performance)
- Support ONFI by enabling READID command with offset and parameter page reads (CMD_PARAM)
- Change to dedicated read_page/write_page function, enables raw writes
- Use __LITTLE_ENDIAN to distingush between LE/BE relevant statements
- Eliminated vf610_nfc_probe_dt in favor of common DT init code
- Use wait_for_completion_timeout
- Some style fixes (spaces, etc.)
Changes since v3:
- Make the driver selectable when COMPILE_TEST is set
- Fix compile error due to superfluous ECC_STATUS configuration in initial patch (without ECC correction ECC_STATUS does not need to be configured)
- Remove custom BBT pattern and switch to in-band BBT in the initial patch
- Include two bug fixes, for details see the corresponding U-Boot patches:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/215802
Changes since v2:
- Updated binding documentation
Changes since v1:
- Nest nfc_config struct within the main nfc struct
- Use assigned clock binding to specify NFC clock
- Rebased ontop of MSCM IR patchset (driver parts have been merged)
- Split out arch Kconfig in a separate config
- Fix module license
- Updated MAINTAINERS
Changes since RFC (Bill Pringlemeir):
- Renamed driver from fsl_nfc to vf610_nfc
- Use readl/writel for all register in accessor functions
- Optimized field accessor functions
- Implemented PM (suspend/resume) functions
- Implemented basic support for ECC strength/ECC step size from dt
- Improved performance of count_written_bits by using hweight32
- Support ECC with 60-bytes to correct up to 32 bit errors
- Changed to in-band BBT (NAND_BBT_NO_OOB) which also allows ECC modes which uses up to 60 bytes on 64 byte OOB
- Removed custom (downstream) BBT pattern since BBT table won't be compatible anyway (due to the change above)
*** SUBJECT HERE ***
*** BLURB HERE ***
Stefan Agner (5):
mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
mtd: nand: vf610_nfc: add hardware BCH-ECC support
mtd: nand: vf610_nfc: add device tree bindings
ARM: dts: vf610twr: add NAND flash controller peripherial
ARM: dts: vf-colibri: enable NAND flash controller
.../devicetree/bindings/mtd/vf610-nfc.txt | 45 ++ MAINTAINERS | 6 + arch/arm/boot/dts/vf-colibri.dtsi | 32 + arch/arm/boot/dts/vf610-twr.dts | 40 + arch/arm/boot/dts/vfxxx.dtsi | 8 + drivers/mtd/nand/Kconfig | 11 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/vf610_nfc.c | 849 +++++++++++++++++++++ 8 files changed, 992 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/vf610-nfc.txt create mode 100644 drivers/mtd/nand/vf610_nfc.c
Signature · 1 line
2.5.0
PATCH v10 1/5 mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
This driver supports Freescale NFC (NAND flash controller) found on Vybrid (VF610), MPC5125, MCF54418 and Kinetis K70. The driver has been tested on 8-bit and 16-bit NAND interface and supports ONFI parameter page reading.
Limitations:
- DMA and pipelining not used
- Pages larger than 2k are not supported
- No hardware ECC
The driver has only been tested on Vybrid SoC VF610 and VF500.
Some paths have been hand-optimized and evaluated by measurements made using mtd_speedtest.ko on a 100MB MTD partition.
Colibri VF50
eb write % eb read % page write % page read %
rel/opt 5175 11537 4560 11039 opt 5164 -0.21 11420 -1.01 4737 +3.88 10918 -1.10 none 5113 -1.20 11352 -1.60 4490 -1.54 10865 -1.58
Colibri VF61
eb write % eb read % page write % page read %
rel/opt 5766 13096 5459 12846 opt 5883 +2.03 13064 -0.24 5561 +1.87 12802 -0.34 none 5701 -1.13 12980 -0.89 5488 +0.53 12735 -0.86
rel = using readl_relaxed/writel_relaxed in optimized paths opt = hand-optimized by combining multiple accesses into one read/write
The measurements have not been statistically verfied, hence use them with care. The author came to the conclusion that using the relaxed variants of readl/writel are not worth the additional code.
--- MAINTAINERS | 6 + drivers/mtd/nand/Kconfig | 9 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/vf610_nfc.c | 645 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 661 insertions(+) create mode 100644 drivers/mtd/nand/vf610_nfc.c
MAINTAINERS +6 -0
@@ -10835,6 +10835,12 @@ S: Maintained F: Documentation/fb/uvesafb.txt F: drivers/video/fbdev/uvesafb.* +VF610 NAND DRIVER +M: Stefan Agner <[email protected]> +L: linux-mtd at lists.infradead.org +S: Supported +F: drivers/mtd/nand/vf610_nfc.c + VFAT/FAT/MSDOS FILESYSTEM M: OGAWA Hirofumi <[email protected]> S: Maintained
drivers/mtd/nand/Kconfig +9 -0
@@ -463,6 +463,15 @@ config MTD_NAND_MPC5121_NFC This enables the driver for the NAND flash controller on the MPC5121 SoC. +config MTD_NAND_VF610_NFC + tristate "Support for Freescale NFC for VF610/MPC5125" + depends on (SOC_VF610 || COMPILE_TEST) + help + Enables support for NAND Flash Controller on some Freescale + processors like the VF610, MPC5125, MCF54418 or Kinetis K70. + The driver supports a maximum 2k page size. The driver + currently does not support hardware ECC. + config MTD_NAND_MXC tristate "MXC NAND support" depends on ARCH_MXC
drivers/mtd/nand/Makefile +1 -0
@@ -45,6 +45,7 @@ obj-$(CONFIG_MTD_NAND_SOCRATES) += socrates_nand.o obj-$(CONFIG_MTD_NAND_TXX9NDFMC) += txx9ndfmc.o obj-$(CONFIG_MTD_NAND_NUC900) += nuc900_nand.o obj-$(CONFIG_MTD_NAND_MPC5121_NFC) += mpc5121_nfc.o +obj-$(CONFIG_MTD_NAND_VF610_NFC) += vf610_nfc.o obj-$(CONFIG_MTD_NAND_RICOH) += r852.o obj-$(CONFIG_MTD_NAND_JZ4740) += jz4740_nand.o obj-$(CONFIG_MTD_NAND_GPMI_NAND) += gpmi-nand/
drivers/mtd/nand/vf610_nfc.c new file +645 -0
645 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 2/5 mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Stefan AgnerThis adds hardware ECC support using the BCH encoder in the NFC IP. The ECC encoder supports up to 32-bit correction by using 60 error correction bytes. There is no sub-page ECC step, ECC is calculated always accross the whole page (up to 2k pages). Raw writes writes are possible through the common nand_write_page_raw implementation, however raw reads are not possible since the hardware ECC mode need to be enabled at command time.
--- drivers/mtd/nand/Kconfig | 6 +- drivers/mtd/nand/vf610_nfc.c | 206 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 209 insertions(+), 3 deletions(-)
drivers/mtd/nand/Kconfig +4 -2
@@ -469,8 +469,10 @@ config MTD_NAND_VF610_NFC help Enables support for NAND Flash Controller on some Freescale processors like the VF610, MPC5125, MCF54418 or Kinetis K70. - The driver supports a maximum 2k page size. The driver - currently does not support hardware ECC. + The driver supports a maximum 2k page size. With 2k pages and + 64 bytes or more of OOB, hardware ECC with up to 32-bit error + correction is supported. Hardware ECC is only enabled through + device tree. config MTD_NAND_MXC tristate "MXC NAND support"
drivers/mtd/nand/vf610_nfc.c +205 -1
299 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH v10 3/5 mtd: nand: vf610_nfc: add device tree bindings
In reply to Stefan Agner--- .../devicetree/bindings/mtd/vf610-nfc.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/vf610-nfc.txt
Documentation/devicetree/bindings/mtd/vf610-nfc.txt new file +45 -0
@@ -0,0 +1,45 @@ +Freescale's NAND flash controller (NFC) + +This variant of the Freescale NAND flash controller (NFC) can be found on +Vybrid (vf610), MPC5125, MCF54418 and Kinetis K70. + +Required properties: +- compatible: Should be set to "fsl,vf610-nfc" +- reg: address range of the NFC +- interrupts: interrupt of the NFC +- nand-bus-width: see nand.txt +- nand-ecc-mode: see nand.txt +- nand-on-flash-bbt: see nand.txt +- assigned-clocks: main clock from the SoC, for Vybrid <&clks VF610_CLK_NFC>; +- assigned-clock-rates: The NAND bus timing is derived from this clock + rate and should not exceed maximum timing for any NAND memory chip + in a board stuffing. Typical NAND memory timings derived from this + clock are found in the SoC hardware reference manual. Furthermore, + there might be restrictions on maximum rates when using hardware ECC. + +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +Required properties for hardware ECC: +- nand-ecc-strength: supported strengths are 24 and 32 bit (see nand.txt) +- nand-ecc-step-size: step size equals page size, currently only 2k pages are + supported + +Example: + + nfc: nand at 400e0000 { + compatible = "fsl,vf610-nfc"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x400e0000 0x4000>; + interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks VF610_CLK_NFC>; + clock-names = "nfc"; + assigned-clocks = <&clks VF610_CLK_NFC>; + assigned-clock-rates = <33000000>; + nand-bus-width = <8>; + nand-ecc-mode = "hw"; + nand-ecc-strength = <32>; + nand-ecc-step-size = <2048>; + nand-on-flash-bbt; + };
Signature · 1 line
2.5.0
PATCH v10 4/5 ARM: dts: vf610twr: add NAND flash controller peripherial
In reply to Stefan AgnerThis adds the NAND flash controller (NFC) peripherial. The driver supports the SLC NAND chips found on Freescale's Vybrid Tower System Module. The Micron NAND chip on the module needs 4-bit ECC per 512 byte page. Use 24-bit ECC per 2k page, which is supported by the driver.
--- arch/arm/boot/dts/vf610-twr.dts | 40 ++++++++++++++++++++++++++++++++++++++++ arch/arm/boot/dts/vfxxx.dtsi | 8 ++++++++ 2 files changed, 48 insertions(+)
arch/arm/boot/dts/vf610-twr.dts +40 -0
@@ -237,6 +237,33 @@ >; }; + pinctrl_nfc: nfcgrp { + fsl,pins = < + VF610_PAD_PTD31__NF_IO15 0x28df + VF610_PAD_PTD30__NF_IO14 0x28df + VF610_PAD_PTD29__NF_IO13 0x28df + VF610_PAD_PTD28__NF_IO12 0x28df + VF610_PAD_PTD27__NF_IO11 0x28df + VF610_PAD_PTD26__NF_IO10 0x28df + VF610_PAD_PTD25__NF_IO9 0x28df + VF610_PAD_PTD24__NF_IO8 0x28df + VF610_PAD_PTD23__NF_IO7 0x28df + VF610_PAD_PTD22__NF_IO6 0x28df + VF610_PAD_PTD21__NF_IO5 0x28df + VF610_PAD_PTD20__NF_IO4 0x28df + VF610_PAD_PTD19__NF_IO3 0x28df + VF610_PAD_PTD18__NF_IO2 0x28df + VF610_PAD_PTD17__NF_IO1 0x28df + VF610_PAD_PTD16__NF_IO0 0x28df + VF610_PAD_PTB24__NF_WE_B 0x28c2 + VF610_PAD_PTB25__NF_CE0_B 0x28c2 + VF610_PAD_PTB27__NF_RE_B 0x28c2 + VF610_PAD_PTC26__NF_RB_B 0x283d + VF610_PAD_PTC27__NF_ALE 0x28c2 + VF610_PAD_PTC28__NF_CLE 0x28c2 + >; + }; + pinctrl_pwm0: pwm0grp { fsl,pins = < VF610_PAD_PTB0__FTM0_CH0 0x1582
@@ -274,6 +301,19 @@ }; }; +&nfc { + assigned-clocks = <&clks VF610_CLK_NFC>; + assigned-clock-rates = <33000000>; + nand-bus-width = <16>; + nand-ecc-mode = "hw"; + nand-ecc-step-size = <2048>; + nand-ecc-strength = <24>; + nand-on-flash-bbt; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_nfc>; + status = "okay"; +}; + &pwm0 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pwm0>;
arch/arm/boot/dts/vfxxx.dtsi +8 -0
@@ -520,6 +520,14 @@ status = "disabled"; }; + nfc: nand at 400e0000 { + compatible = "fsl,vf610-nfc"; + reg = <0x400e0000 0x4000>; + interrupts = <83 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks VF610_CLK_NFC>; + clock-names = "nfc"; + status = "disabled"; + }; }; }; };
Signature · 1 line
2.5.0
PATCH v10 5/5 ARM: dts: vf-colibri: enable NAND flash controller
In reply to Stefan AgnerEnable NAND access by adding pinmux and NAND flash controller node to device tree. The NAND chips currently used on the Colibri VF61 requires 8-bit ECC per 512 byte page, hence specify 32-bit ECC strength per 2k page size.
--- arch/arm/boot/dts/vf-colibri.dtsi | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
arch/arm/boot/dts/vf-colibri.dtsi +32 -0
@@ -52,6 +52,19 @@ pinctrl-0 = <&pinctrl_i2c0>; }; +&nfc { + assigned-clocks = <&clks VF610_CLK_NFC>; + assigned-clock-rates = <33000000>; + nand-bus-width = <8>; + nand-ecc-mode = "hw"; + nand-ecc-step-size = <2048>; + nand-ecc-strength = <32>; + nand-on-flash-bbt; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_nfc>; + status = "okay"; +}; + &pwm0 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_pwm0>;
@@ -156,6 +169,25 @@ >; }; + pinctrl_nfc: nfcgrp { + fsl,pins = < + VF610_PAD_PTD23__NF_IO7 0x28df + VF610_PAD_PTD22__NF_IO6 0x28df + VF610_PAD_PTD21__NF_IO5 0x28df + VF610_PAD_PTD20__NF_IO4 0x28df + VF610_PAD_PTD19__NF_IO3 0x28df + VF610_PAD_PTD18__NF_IO2 0x28df + VF610_PAD_PTD17__NF_IO1 0x28df + VF610_PAD_PTD16__NF_IO0 0x28df + VF610_PAD_PTB24__NF_WE_B 0x28c2 + VF610_PAD_PTB25__NF_CE0_B 0x28c2 + VF610_PAD_PTB27__NF_RE_B 0x28c2 + VF610_PAD_PTC26__NF_RB_B 0x283d + VF610_PAD_PTC27__NF_ALE 0x28c2 + VF610_PAD_PTC28__NF_CLE 0x28c2 + >; + }; + pinctrl_pwm0: pwm0grp { fsl,pins = < VF610_PAD_PTB0__FTM0_CH0 0x1182
Signature · 1 line
2.5.0
Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Stefan AgnerHi Brian,
On 2015-08-03 11:27, Stefan Agner wrote:
<snip>
Quoted 14 lines
drivers/mtd/nand/vf610_nfc.c +14
-0+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; +
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 573
Quoted 10 lines
drivers/mtd/nand/vf610_nfc.c +10
-0+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
Hi Stefan,
Le Mon, 3 Aug 2015 11:27:25 +0200, Stefan Agner <[email protected]> a ?crit :
Quoted 67 lines
The 10th revision includes some more review comments, including an improved handling of empty NAND pages with hardware ECC.
More information and the full test log of earlier patchset version can be found in the cover letter of the last revision v6:
http://thread.gmane.org/gmane.linux.kernel/1979868Changes since v9:
- Remove inline ofvf610_nfc_done
- Add__iomemto src argument ofvf610_nfc_memcpy
- Handle return value ofmtd_device_parse_registercorrectly
- Count bits in OOB too (only non-ECC bits)
- Return bitflips in ecc.read_page callbackvf610_nfc_read_page
- Fall-throughALT_BUF_ONFI
- Use BIT macrosChanges since v8:
- Fix 16-Bit NAND flash support by splitting up initialization (introducevf610_nfc_preinit_controller)
- Updated comments in initialziation functionsChanges since v7:
-vf610-twr.dts: Moved NFC pinmux into the existing iomuxc node and sort new nfc node behind the existing iomuxc node as well.
-vf610-twr.dts/vf-colibri.dtsi: Dropped _1 suffixesChanges since v6:
- Rebased ontop of l2-mtd/master (v4.2-rc1 based)
- RemovedHAVE_NAND_VF610_NFCand use depends on. This made "[PATCH v6 4/6] ARM: vf610: enable NAND Flash Controller" unnecessaryChanges since v5:
- Removed fsl,mpc5125-nfc compatible string
- Removed readl/writel_relaxed
- Change interface ofvf610_nfc_transfer_sizeto match other accessorsChanges since v4:
- Rebased ontop of l2-mtd/master (v4.1-rc4 based)
- Eliminate unnecessary page read (NAND_CMD_SEQIN) since the driver does not support sub-page writes anyway (improves write performance)
- Support ONFI by enabling READID command with offset and parameter page reads (CMD_PARAM)
- Change to dedicated read_page/write_page function, enables raw writes
- Use__LITTLE_ENDIANto distingush between LE/BE relevant statements
- Eliminatedvf610_nfc_probe_dtin favor of common DT init code
- Usewait_for_completion_timeout
- Some style fixes (spaces, etc.)Changes since v3:
- Make the driver selectable whenCOMPILE_TESTis set
- Fix compile error due to superfluousECC_STATUSconfiguration in initial patch (without ECC correctionECC_STATUSdoes not need to be configured)
- Remove custom BBT pattern and switch to in-band BBT in the initial patch
- Include two bug fixes, for details see the corresponding U-Boot patches:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/215802Changes since v2:
- Updated binding documentationChanges since v1:
- Nestnfc_configstruct within the main nfc struct
- Use assigned clock binding to specify NFC clock
- Rebased ontop of MSCM IR patchset (driver parts have been merged)
- Split out archKconfigin a separate config
- Fix module license
- UpdatedMAINTAINERS
Quoted 12 lines
Changes since RFC (Bill Pringlemeir):
- Renamed driver fromfsl_nfctovf610_nfc
- Use readl/writel for all register in accessor functions
- Optimized field accessor functions
- Implemented PM (suspend/resume) functions
- Implemented basic support for ECC strength/ECC step size from dt
- Improved performance ofcount_written_bitsby using hweight32
- Support ECC with 60-bytes to correct up to 32 bit errors
- Changed to in-band BBT (NAND_BBT_NO_OOB) which also allows ECC modes which uses up to 60 bytes on 64 byte OOB
- Removed custom (downstream) BBT pattern since BBT table won't be compatible anyway (due to the change above)
For the sake of regression testing:
Still works fine here on a Vybrid and 16-bit Micron NAND.
Cordialement,
Albert ARIBAUD
3ADEV
Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Stefan AgnerQuoted 11 lines · Stefan Agner
On 2015-08-03 11:27, Stefan Agner wrote:
<snip>drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 558
Quoted 9 lines
drivers/mtd/nand/vf610_nfc.c +9
-0+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 );
Why __raw_readb()? That's not normally encourage, and it has issues with endianness. It looks like maybe this is actulaly a 32-bit register, and you're having trouble when trying to do bytewise access? I see this earlier:
/*
* ECC status is stored at NFC_CFG[ECCADD] +4 for little-endian
* and +7 for big-endian SoCs.
*/
#ifdef __LITTLE_ENDIAN
#define ECC_OFFSET 4
#else
#define ECC_OFFSET 7
#endif
So maybe you really just want:
#define ECC_OFFSET 4
...
ecc_status = vf610_nfc_read(ECC_SRAM_ADDR * 8 + ECC_OFFSET) & 0xff;
?
Quoted 5 lines
Quoted 5 lines
drivers/mtd/nand/vf610_nfc.c +5
-0+ ecc_count = ecc_status &ECC_ERR_COUNT ; + +if (!(ecc_status &ECC_STATUS_MASK )) +return ecc_count; +
Quoted 8 lines
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 571
Quoted 8 lines
drivers/mtd/nand/vf610_nfc.c +8
-0+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);
Another side note: why are you using ecc_count as a max threshold? AIUI, an ECC algorithm doesn't really report useful error count information if it's above the correction limit. So wouldn't we be looking to count up to our SW threshold? i.e., ecc.strength / 2, or similar? Similar comments below.
Quoted 10 lines
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 573
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c +2
-0+ 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 0000 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
Hmm, that's not really good. The point is that we need to make sure that everything that could have been programmed (including the ECC area) was not actually programmed. But your ECC controller is not, contrary to MTD's expectations, dumping raw uncorrected data here.
Quoted 4 lines
[ 22.209698] vf610_nfc_correct_data, flips 1Not sure if this is acceptable, but I now only count the bits in the non-ECC area of the OOB.
That's not the intention of my suggestion. You're still missing out on a class of patterns that might look close to all 0xff but are not actually.
If the HW ECC really doesn't give you valid data+OOB at this point, then you might have to re-read with ECC disabled. Of course, that's got a performance cost...
Or perhaps Boris has a better suggestion? He's been surveying other NAND drivers that need to do similar things, and he's working on providing some support code for common design patterns.
Quoted 4 lines
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
I'm a little confused there. Why would you be expecting to get a count of bitflips, when the ECC engine can't correct all errors? How is it supposed to know what the "right" data is if the bit errors are beyond the correction strength?
Brian
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Stefan AgnerA few more comments.
Quoted 6 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@
...
drivers/mtd/nand/vf610_nfc.c line 449
Quoted 6 lines
drivers/mtd/nand/vf610_nfc.c new file +6
-0+/* +* This function supports Vybrid only (MPC5125 would have full RB and four CS) +*/ +static void vf610_nfc_select_chip (struct mtd_info *mtd,int chip) +{ +#ifdef CONFIG_SOC_VF610
Why the #ifdef? I don't see anything compile-time specific to SOC_VF610.
If this is trying to handle the comment above ("This function supports Vybrid only (MPC5125 would have full RB and four CS)") then that's the wrong way of doing it, as you need to support multiplatform kernels. You'll need to have a way to differentiate the different platform support at runtime, not compile time.
drivers/mtd/nand/vf610_nfc.c line 459
Quoted 10 lines
drivers/mtd/nand/vf610_nfc.c new file +10
-0+struct vf610_nfc *nfc =mtd_to_nfc (mtd); +u32 tmp =vf610_nfc_read (nfc,NFC_ROW_ADDR ); + + tmp &= ~(ROW_ADDR_CHIP_SEL_RB_MASK |ROW_ADDR_CHIP_SEL_MASK ); + tmp |=1 <<ROW_ADDR_CHIP_SEL_RB_SHIFT ; + +if (chip ==0 ) + tmp |=1 <<ROW_ADDR_CHIP_SEL_SHIFT ; +else if (chip ==1 ) + tmp |=2 <<ROW_ADDR_CHIP_SEL_SHIFT ;
else ... ?
Maybe you can write this as a formulaic pattern (e.g.:
tmp |= (chip + 1) << ROW_ADDR_CHIP_SEL_SHIFT;
) and just do the "max # of chips" checks on a per-platform basis in the probe(). Then I'm guessing this same function can apply to both platforms. (I'm not looking@HW datasheets for this, BTW, just guessing based on the context here.)
But wait...I see that you call nand_scan_ident() with a max of 1 chip. So you won't ever see the chip > 0 case, right?
So does this driver support multiple flash attached or not? Looks like you're assuming you'll only be using chip-select 0. (This is fine for now, but at least your code should acknowledge this. Perhaps a comment at the top under "limitations.")
Quoted 4 lines
drivers/mtd/nand/vf610_nfc.c new file +4
-0+ +vf610_nfc_write (nfc,NFC_ROW_ADDR , tmp); +#endif +}
...
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c new file +2
-0+static int vf610_nfc_probe (struct platform_device *pdev) +{
...
drivers/mtd/nand/vf610_nfc.c line 559
Quoted 5 lines
drivers/mtd/nand/vf610_nfc.c new file +5
-0+/* first scan to find the device and get the page size */ +if (nand_scan_ident (mtd,1 ,NULL )) { + err = -ENXIO ; + goto error; + }
...
Brian
Re: [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings
In reply to Stefan AgnerSorry, I realized a potential issue here.
Quoted 17 lines · Stefan Agner
Signed-off-by Bill Pringlemeir <[email protected]>Acked-by Shawn Guo <[email protected]>Reviewed-by Brian Norris <[email protected]>Signed-off-by Stefan Agner <[email protected]>--- .../devicetree/bindings/mtd/vf610-nfc.txt | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/vf610-nfc.txtDocumentation/devicetree/bindings/mtd/vf610-nfc.txt new file +2
-0@@ -0,0 +1,45 @@ +Freescale's NAND flash controller (NFC) +
Documentation/devicetree/bindings/mtd/vf610-nfc.txt line 12
Quoted 10 lines
Documentation/devicetree/bindings/mtd/vf610-nfc.txt new file +10
-0+This variant of the Freescale NAND flash controller (NFC) can be found on +Vybrid (vf610), MPC5125, MCF54418 and Kinetis K70. + +Required properties: +- compatible: Should be set to "fsl,vf610-nfc" +- reg: address range of the NFC +- interrupts: interrupt of the NFC +- nand-bus-width: see nand.txt +- nand-ecc-mode: see nand.txt +- nand-on-flash-bbt: see nand.txt
Stumbling across the "multi-CS" questions on the driver reminds me: it typically makes sense to define new NAND bindings using separate NAND *controller* and *flash* device nodes. The above 3 properties, at least, would apply on a per-flash basis, not per-controller typically. See sunxi-nand, for instance:
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/mtd/sunxi-nand.txt
brcmnand had a similar pattern:
(Perhaps it's time we standardized this a little more formally...)
Quoted 23 lines
Documentation/devicetree/bindings/mtd/vf610-nfc.txt new file +23
-0+- assigned-clocks: main clock from the SoC, for Vybrid <&clks VF610_CLK_NFC>; +- assigned-clock-rates: The NAND bus timing is derived from this clock + rate and should not exceed maximum timing for any NAND memory chip + in a board stuffing. Typical NAND memory timings derived from this + clock are found in the SoC hardware reference manual. Furthermore, + there might be restrictions on maximum rates when using hardware ECC. + +- #address-cells, #size-cells : Must be present if the device has sub-nodes + representing partitions. + +Required properties for hardware ECC: +- nand-ecc-strength: supported strengths are 24 and 32 bit (see nand.txt) +- nand-ecc-step-size: step size equals page size, currently only 2k pages are + supported + +Example: + + nfc: nand at 400e0000 { + compatible = "fsl,vf610-nfc"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x400e0000 0x4000>; + interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
Documentation/devicetree/bindings/mtd/vf610-nfc.txt line 45
Quoted 10 lines
Documentation/devicetree/bindings/mtd/vf610-nfc.txt new file +10
-0+ clocks = <&clks VF610_CLK_NFC>; + clock-names = "nfc"; + assigned-clocks = <&clks VF610_CLK_NFC>; + assigned-clock-rates = <33000000>; + nand-bus-width = <8>; + nand-ecc-mode = "hw"; + nand-ecc-strength = <32>; + nand-ecc-step-size = <2048>; + nand-on-flash-bbt; + };
Brian
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Stefan AgnerOne more thing...
Quoted 3 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@
...
drivers/mtd/nand/vf610_nfc.c line 135
Quoted 8 lines
drivers/mtd/nand/vf610_nfc.c new file +8
-0+struct vf610_nfc { +struct mtd_info mtd; +struct nand_chip chip; +struct device *dev; +void __iomem *regs; +struct completion cmd_done; +uint buf_offset; +int page_sz;
AFAICT (even with the 2nd patch), you never really use this field. You just set it/increment it, but don't use it for anything. Kill it?
drivers/mtd/nand/vf610_nfc.c line 142
Quoted 7 lines
drivers/mtd/nand/vf610_nfc.c new file +7
-0+/* Status and ID are in alternate locations. */ +int alt_buf; +#define ALT_BUF_ID 1 +#define ALT_BUF_STAT 2 +#define ALT_BUF_ONFI 3 +struct clk *clk; +};
Brian
Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Brian NorrisBrian, Stefan,
Quoted 47 lines · On Tue, 25 Aug 2015 12:54:11 -0700 Brian Norris <[email protected]>…
Quoted 11 lines · Stefan Agner
On 2015-08-03 11:27, Stefan Agner wrote:
<snip>drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 558
Quoted 9 lines
drivers/mtd/nand/vf610_nfc.c +9
-0+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 );Why
__raw_readb()? That's not normally encourage, and it has issues with endianness. It looks like maybe this is actulaly a 32-bit register, and you're having trouble when trying to do bytewise access? I see this earlier:/*
* ECC status is stored at NFC_CFG[ECCADD] +4 for little-endian
* and +7 for big-endian SoCs.
*/
#ifdef__LITTLE_ENDIAN
#defineECC_OFFSET4
#else
#defineECC_OFFSET7
#endifSo maybe you really just want:
#define
ECC_OFFSET4
...ecc_status = vf610_nfc_read(ECC_SRAM_ADDR * 8 + ECC_OFFSET) & 0xff;?
Quoted 11 lines
Quoted 11 lines
drivers/mtd/nand/vf610_nfc.c +11
-0+ 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.
Quoted 8 lines
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 571
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c +2
-0+*/ + flip =count_written_bits (dat, nfc->chip.ecc.size, ecc_count);Another side note: why are you using
ecc_countas a max threshold? AIUI, an ECC algorithm doesn't really report useful error count information if it's above the correction limit. So wouldn't we be looking to count up to our SW threshold? i.e., ecc.strength / 2, or similar? Similar comments below.
The exact threshold value is still something I'm not sure about, though I'm sure it should be correlated to ecc.strength value (whether it's directly set to ecc.strength or less than ecc.strength is something we'll have to figure out).
Quoted 8 lines
Quoted 8 lines
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 573
Quoted 3 lines
drivers/mtd/nand/vf610_nfc.c +2
-0+ 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:
Quoted 8 lines
Quoted 3 lines
[ 22.190273] ff ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0000 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
Hmm, that's not really good. The point is that we need to make sure that everything that could have been programmed (including the ECC area) was not actually programmed. But your ECC controller is not, contrary to MTD's expectations, dumping raw uncorrected data here.
Yep, for this test we really need the ECC bytes generated for the chunk you're currently testing.
How to retrieve those bytes really depends on your NAND controller, but such controllers usually provides a way to disable the ECC engine. The only thing you'll have to do in this case is disable the ECC engine and read the OOB data (using RNDOUT and read_buf for example).
Quoted 9 lines
Quoted 5 lines
[ 22.209698] vf610_nfc_correct_data, flips 1Not sure if this is acceptable, but I now only count the bits in the non-ECC area of the OOB.
That's not the intention of my suggestion. You're still missing out on a class of patterns that might look close to all
0xffbut are not actually.
Exactly.
Quoted 4 lines
If the HW ECC really doesn't give you valid data+OOB at this point, then you might have to re-read with ECC disabled. Of course, that's got a performance cost...
As suggested above, if that's possible, reading the OOB area (or a portion of the OOB area) with the ECC engine disabled should be enough.
Quoted 4 lines
Or perhaps Boris has a better suggestion? He's been surveying other NAND drivers that need to do similar things, and he's working on providing some support code for common design patterns.
Yep, the patch series is here in case you want to have a look [1].
Best Regards,
Boris
[1]https://patchwork.ozlabs.org/patch/509970/
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings
In reply to Brian NorrisQuoted 29 lines · computersforpeace at gmail.com
Sorry, I realized a potential issue here.
Quoted 16 lines · Stefan Agner
Signed-off-by Bill Pringlemeir <[email protected]>Acked-by Shawn Guo <[email protected]>Reviewed-by Brian Norris <[email protected]>Signed-off-by Stefan Agner <[email protected]>---
.../devicetree/bindings/mtd/vf610-nfc.txt| 45 ++++++++++++++++++++++1 file changed, 45 insertions(+) create mode 100644
Documentation/devicetree/bindings/mtd/vf610-nfc.txtDocumentation/devicetree/bindings/mtd/vf610-nfc.txt new file +0
-0Quoted 1 line
Quoted 1 line
-0,0 +1,45 @@
Quoted 3 lines
+- nand-bus-width: see nand.txt +- nand-ecc-mode: see nand.txt +- nand-on-flash-bbt: see nand.txtStumbling across the "multi-CS" questions on the driver reminds me: it typically makes sense to define new NAND bindings using separate NAND *controller* and *flash* device nodes. The above 3 properties, at least, would apply on a per-flash basis, not per-controller typically. See sunxi-nand, for instance:
Quoted 7 lines
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/mtd/sunxi-nand.txt
brcmnand had a similar pattern:
(Perhaps it's time we standardized this a little more formally...)
These would apply per chip, but the controller has to be configured to support each and every one. Every time an operation was performed, we would have to check the chip type and reconfigure the controller. Currently, the driver does not support this and it would add a lot of overhead in some cases unless a register cache was used.
Is the flexibility of using a system with combined 8/16bit devices really worth all the overhead? Isn't it sort of brain dead hardware not to make all of the chips similar? Why would everyone have to pay for such a crazy setup?
To separate it would at least be a lie versus the code in the current form. As well, there are only a few SOC which support multiple chip selects. The 'multi-CS' register bits of this controller varies between PowerPC, 68K/Coldfire and ARM platforms.
I looked briefly at the brcmnand.c and it seems that it is not supporting different ECC per chip even though the nodes are broken out this way. In fact, if some raw functions are called, I think it will put it in ECC mode even if it wasn't before? Well, I agree that this would be good generically, I think it puts a lot of effort in the drivers for not so much payoff?
Fwiw,
Bill Pringlemeir.
Re: [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings
Hi Bill,
Quoted 55 lines · On Wed, 26 Aug 2015 11:26:36 -0400 Bill Pringlemeir <[email protected]>…
Quoted 29 lines · computersforpeace at gmail.com
Sorry, I realized a potential issue here.
Quoted 16 lines · Stefan Agner
Signed-off-by Bill Pringlemeir <[email protected]>Acked-by Shawn Guo <[email protected]>Reviewed-by Brian Norris <[email protected]>Signed-off-by Stefan Agner <[email protected]>---
.../devicetree/bindings/mtd/vf610-nfc.txt| 45 ++++++++++++++++++++++1 file changed, 45 insertions(+) create mode 100644
Documentation/devicetree/bindings/mtd/vf610-nfc.txtDocumentation/devicetree/bindings/mtd/vf610-nfc.txt new file +0
-0Quoted 1 line
Quoted 1 line
-0,0 +1,45 @@
Quoted 3 lines
+- nand-bus-width: see nand.txt +- nand-ecc-mode: see nand.txt +- nand-on-flash-bbt: see nand.txtStumbling across the "multi-CS" questions on the driver reminds me: it typically makes sense to define new NAND bindings using separate NAND *controller* and *flash* device nodes. The above 3 properties, at least, would apply on a per-flash basis, not per-controller typically. See sunxi-nand, for instance:
Quoted 7 lines
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/mtd/sunxi-nand.txt
brcmnand had a similar pattern:
(Perhaps it's time we standardized this a little more formally...)
These would apply per chip, but the controller has to be configured to support each and every one. Every time an operation was performed, we would have to check the chip type and reconfigure the controller. Currently, the driver does not support this and it would add a lot of overhead in some cases unless a register cache was used.
Is the flexibility of using a system with combined 8/16bit devices really worth all the overhead? Isn't it sort of brain dead hardware not to make all of the chips similar? Why would everyone have to pay for such a crazy setup?
To separate it would at least be a lie versus the code in the current form. As well, there are only a few SOC which support multiple chip selects. The 'multi-CS' register bits of this controller varies between PowerPC, 68K/Coldfire and ARM platforms.
Quoted 6 lines
I looked briefly at the
brcmnand.cand it seems that it is not supporting different ECC per chip even though the nodes are broken out this way. In fact, if some raw functions are called, I think it will put it in ECC mode even if it wasn't before? Well, I agree that this would be good generically, I think it puts a lot of effort in the drivers for not so much payoff?
Hm, the sunxi driver supports it, and it does not add such a big overhead...
The only thing you have to do is cache a bunch of register values per-chip and restore/apply them when the chip is selected (in your ->select_chip() implementation).
Anyway, even if the suggested DT representation is a lie in regards to your implementation, it's actually pretty accurate from an hardware POV, and this is exactly what DT is supposed to represent.
Best Regards,
Boris
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Brian NorrisQuoted 28 lines · Brian Norris
Quoted 11 lines · Stefan Agner
On 2015-08-03 11:27, Stefan Agner wrote:
<snip>drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 558
Quoted 9 lines
drivers/mtd/nand/vf610_nfc.c +9
-0+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 );Why
__raw_readb()? That's not normally encourage, and it has issues with endianness. It looks like maybe this is actulaly a 32-bit register, and you're having trouble when trying to do bytewise access? I see this earlier:/*
* ECC status is stored at NFC_CFG[ECCADD] +4 for little-endian
* and +7 for big-endian SoCs.
*/
#ifdef__LITTLE_ENDIAN
#defineECC_OFFSET4
#else
#defineECC_OFFSET7
#endif
Quoted 8 lines
So maybe you really just want:
#define
ECC_OFFSET4
...ecc_status = vf610_nfc_read(ECC_SRAM_ADDR * 8 + ECC_OFFSET) & 0xff;?
Agreed, much cleaner.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/mtd/nand/vf610_nfc.c +11
-0+ 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.
Quoted 9 lines
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 571
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c +2
-0+*/ + flip =count_written_bits (dat, nfc->chip.ecc.size, ecc_count);Another side note: why are you using
ecc_countas a max threshold? AIUI, an ECC algorithm doesn't really report useful error count information if it's above the correction limit. So wouldn't we be looking to count up to our SW threshold? i.e., ecc.strength / 2, or similar? Similar comments below.
Initially, that was the only threshold below, hence it made sense. But I agree, we should count up to the threshold used below...
Quoted 21 lines
Quoted 10 lines
drivers/mtd/nand/vf610_nfc.c static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip) · line 573
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c +2
-0+ 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 0000 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
Hmm, that's not really good. The point is that we need to make sure that everything that could have been programmed (including the ECC area) was not actually programmed. But your ECC controller is not, contrary to MTD's expectations, dumping raw uncorrected data here.
Quoted 4 lines
[ 22.209698] vf610_nfc_correct_data, flips 1Not sure if this is acceptable, but I now only count the bits in the non-ECC area of the OOB.
Quoted 7 lines
That's not the intention of my suggestion. You're still missing out on a class of patterns that might look close to all
0xffbut are not actually.If the HW ECC really doesn't give you valid data+OOB at this point, then you might have to re-read with ECC disabled. Of course, that's got a performance cost...
Yes I can do that. Not sure yet how it will look like exactly, maybe I only need to reread the OOB area and (re-)use the main data part since those arrive uncorrected in the error case.
Quoted 10 lines
Or perhaps Boris has a better suggestion? He's been surveying other NAND drivers that need to do similar things, and he's working on providing some support code for common design patterns.
Quoted 4 lines
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
Quoted 4 lines
I'm a little confused there. Why would you be expecting to get a count of bitflips, when the ECC engine can't correct all errors? How is it supposed to know what the "right" data is if the bit errors are beyond the correction strength?
When printing the ECC error count on ECC fail when reading an erased NAND flash, the numbers of bit flips (stuck at zero) seem to widely correlate with the number returned by the controller. While it seems to correlate widely, there are exceptions, as discussed in the thread:
http://thread.gmane.org/gmane.linux.ports.arm.kernel/295424
Maybe this is an artifact of the ECC algorithm we just can't/shouldn't rely on? I am not sure where this originated, I did not found any indication in the reference manual about what that value contains in the error case.
Bill, do you have an idea why we used that value as threshold in early implementations?
Otherwise I also think we should just drop the use of this value.
--
Stefan
Re: [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings
In reply to Boris BrezillonQuoted 59 lines · Boris Brezillon
Hi Bill,
Quoted 54 lines · On Wed, 26 Aug 2015 11:26:36 -0400 Bill Pringlemeir <[email protected]>…
Quoted 29 lines · computersforpeace at gmail.com
Sorry, I realized a potential issue here.
Quoted 16 lines · Stefan Agner
Signed-off-by Bill Pringlemeir <[email protected]>Acked-by Shawn Guo <[email protected]>Reviewed-by Brian Norris <[email protected]>Signed-off-by Stefan Agner <[email protected]>---
.../devicetree/bindings/mtd/vf610-nfc.txt| 45 ++++++++++++++++++++++1 file changed, 45 insertions(+) create mode 100644
Documentation/devicetree/bindings/mtd/vf610-nfc.txtDocumentation/devicetree/bindings/mtd/vf610-nfc.txt new file +0
-0Quoted 1 line
Quoted 1 line
-0,0 +1,45 @@
Quoted 3 lines
+- nand-bus-width: see nand.txt +- nand-ecc-mode: see nand.txt +- nand-on-flash-bbt: see nand.txtStumbling across the "multi-CS" questions on the driver reminds me: it typically makes sense to define new NAND bindings using separate NAND *controller* and *flash* device nodes. The above 3 properties, at least, would apply on a per-flash basis, not per-controller typically. See sunxi-nand, for instance:
Quoted 7 lines
http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/mtd/sunxi-nand.txt
brcmnand had a similar pattern:
(Perhaps it's time we standardized this a little more formally...)
These would apply per chip, but the controller has to be configured to support each and every one. Every time an operation was performed, we would have to check the chip type and reconfigure the controller. Currently, the driver does not support this and it would add a lot of overhead in some cases unless a register cache was used.
Is the flexibility of using a system with combined 8/16bit devices really worth all the overhead? Isn't it sort of brain dead hardware not to make all of the chips similar? Why would everyone have to pay for such a crazy setup?
To separate it would at least be a lie versus the code in the current form. As well, there are only a few SOC which support multiple chip selects. The 'multi-CS' register bits of this controller varies between PowerPC, 68K/Coldfire and ARM platforms.
The DT can be a lie versus the code. The DT should reflect how the hardware is wired, afaik, if we take shortcuts in the driver code, that is fine. If we don't support a certain configuration right now (e.g. second NAND chip), the driver can just return an appropriate error code.
Quoted 14 lines
Quoted 7 lines
I looked briefly at the
brcmnand.cand it seems that it is not supporting different ECC per chip even though the nodes are broken out this way. In fact, if some raw functions are called, I think it will put it in ECC mode even if it wasn't before? Well, I agree that this would be good generically, I think it puts a lot of effort in the drivers for not so much payoff?Hm, the sunxi driver supports it, and it does not add such a big overhead...
The only thing you have to do is cache a bunch of register values per-chip and restore/apply them when the chip is selected (in your ->select_chip() implementation).
Quoted 3 lines
Anyway, even if the suggested DT representation is a lie in regards to your implementation, it's actually pretty accurate from an hardware POV, and this is exactly what DT is supposed to represent.
I agree with both of you. I don't see much value implementing multi-NAND chip support, especially with different configurations, at the moment. I am not aware of any hardware making use of that now.
I will update the driver to parse a NAND sub node and get the ECC properties from the per flash configuration. However, I won't add chip select or multi-NAND support right now...
Any objection?
--
Stefan
Re: [PATCH v10 3/5] mtd: nand: vf610_nfc: add device tree bindings
Quoted 19 lines · Stefan Agner
Quoted 13 lines · Boris Brezillon
Quoted 11 lines · On Wed, 26 Aug 2015 11:26:36 -0400 Bill Pringlemeir <[email protected]>…
These would apply per chip, but the controller has to be configured to support each and every one. Every time an operation was performed, we would have to check the chip type and reconfigure the controller. Currently, the driver does not support this and it would add a lot of overhead in some cases unless a register cache was used.
Is the flexibility of using a system with combined 8/16bit devices really worth all the overhead? Isn't it sort of brain dead hardware not to make all of the chips similar? Why would everyone have to pay for such a crazy setup?
Quoted 4 lines
Quoted 4 lines
To separate it would at least be a lie versus the code in the current form. As well, there are only a few SOC which support multiple chip selects. The 'multi-CS' register bits of this controller varies between PowerPC, 68K/Coldfire and ARM platforms.
Quoted 4 lines
The DT can be a lie versus the code. The DT should reflect how the hardware is wired, afaik, if we take shortcuts in the driver code, that is fine. If we don't support a certain configuration right now (e.g. second NAND chip), the driver can just return an appropriate error code.
Right, I was only asking for:
(1) a more accurate DT and
(2) clarity in the driver; the clarity might just be "we don't support multi-CS"
Quoted 21 lines
Quoted 13 lines
Quoted 6 lines
I looked briefly at the
brcmnand.cand it seems that it is not supporting different ECC per chip even though the nodes are broken out this way. In fact, if some raw functions are called, I think it will put it in ECC mode even if it wasn't before? Well, I agree that this would be good generically, I think it puts a lot of effort in the drivers for not so much payoff?Hm, the sunxi driver supports it, and it does not add such a big overhead...
The only thing you have to do is cache a bunch of register values per-chip and restore/apply them when the chip is selected (in your ->select_chip() implementation).Quoted 3 lines
Anyway, even if the suggested DT representation is a lie in regards to your implementation, it's actually pretty accurate from an hardware POV, and this is exactly what DT is supposed to represent.
I agree with both of you. I don't see much value implementing multi-NAND chip support, especially with different configurations, at the moment. I am not aware of any hardware making use of that now.
Quoted 5 lines
I will update the driver to parse a NAND sub node and get the ECC properties from the per flash configuration. However, I won't add chip select or multi-NAND support right now...
Any objection?
Nope, sounds good to me.
A few tips:
* be defensive; i.e., error out if someone specifies 2 flash in the DT
* use the 'reg' property to be the addressing index in the flash sub-node; i.e., the chip-select. This fits the practice done by most others, I think.
Regards,
Brian
Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Stefan AgnerQuoted 18 lines · Stefan Agner
Quoted 10 lines · Brian Norris
Quoted 4 lines · Stefan Agner
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/357439I'm a little confused there. Why would you be expecting to get a count of bitflips, when the ECC engine can't correct all errors? How is it supposed to know what the "right" data is if the bit errors are beyond the correction strength?
When printing the ECC error count on ECC fail when reading an erased NAND flash, the numbers of bit flips (stuck at zero) seem to widely correlate with the number returned by the controller. While it seems to correlate widely, there are exceptions, as discussed in the thread:
http://thread.gmane.org/gmane.linux.ports.arm.kernel/295424
Quoted 4 lines
Maybe this is an artifact of the ECC algorithm we just can't/shouldn't rely on? I am not sure where this originated, I did not found any indication in the reference manual about what that value contains in the error case.
Doesn't sound too reliable to me. And I'm not sure even if it was reliable, that it would provide much value. We have to a lot of re-counting anyway, so we might as well just be using our own threshold. Or maybe I'm missing the point.
Quoted 4 lines
Bill, do you have an idea why we used that value as threshold in early implementations?
Otherwise I also think we should just drop the use of this value.
Brian
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Brian NorrisQuoted 21 lines · Brian Norris
A few more comments.
Quoted 6 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@...
drivers/mtd/nand/vf610_nfc.c line 449
Quoted 6 lines
drivers/mtd/nand/vf610_nfc.c new file +6
-0+/* +* This function supports Vybrid only (MPC5125 would have full RB and four CS) +*/ +static void vf610_nfc_select_chip (struct mtd_info *mtd,int chip) +{ +#ifdef CONFIG_SOC_VF610 Why the #ifdef? I don't see anything compile-time specific to
SOC_VF610.
Quoted 5 lines
If this is trying to handle the comment above ("This function supports Vybrid only (MPC5125 would have full RB and four CS)") then that's the wrong way of doing it, as you need to support multiplatform kernels. You'll need to have a way to differentiate the different platform support at runtime, not compile time.
Yes it is trying to handle the comment above. Well, the other two platforms I am aware of are also different architectures... (PowerPC and ColdFire). I think we won't have a multi-architecture kernel anytime soon, hence I think removing the code at compile time is the right thing todo.
However, probably CONFIG_SOC_VF610 is the wrong symbol then, I could just use CONFIG_ARM and add a comment that this might be different on another other ARM SoC than VF610.
Just checked CodingStyle, and I see that IS_ENABLED is the preferred way for conditional compiling.
So my suggestion:
static void vf610_nfc_select_chip(struct mtd_info *mtd, int chip)
{
struct vf610_nfc *nfc = mtd_to_nfc(mtd);
u32 tmp = vf610_nfc_read(nfc, NFC_ROW_ADDR);
if (!IS_ENABLED(CONFIG_ARM))
return;
/*
* This code is only tested on the ARM platform VF610
* PowerPC based MPC5125 would have full RB and four CS
*/....
With that the compiler should be able to remove this (currently) ARM VF610 specific code on the other supported architectures...
What do you think?
Quoted 14 lines
drivers/mtd/nand/vf610_nfc.c line 459
Quoted 11 lines
drivers/mtd/nand/vf610_nfc.c new file +10
-0+struct vf610_nfc *nfc =mtd_to_nfc (mtd); +u32 tmp =vf610_nfc_read (nfc,NFC_ROW_ADDR ); + + tmp &= ~(ROW_ADDR_CHIP_SEL_RB_MASK |ROW_ADDR_CHIP_SEL_MASK ); + tmp |=1 <<ROW_ADDR_CHIP_SEL_RB_SHIFT ; + +if (chip ==0 ) + tmp |=1 <<ROW_ADDR_CHIP_SEL_SHIFT ; +else if (chip ==1 ) + tmp |=2 <<ROW_ADDR_CHIP_SEL_SHIFT ;else ... ?
Quoted 8 lines
Maybe you can write this as a formulaic pattern (e.g.:
tmp |= (chip + 1) << ROW_ADDR_CHIP_SEL_SHIFT;) and just do the "max # of chips" checks on a per-platform basis in the
probe(). Then I'm guessing this same function can apply to both platforms. (I'm not looking at HW datasheets for this, BTW, just guessing based on the context here.)
It seems that MCP5125 is different than VF610. MCP5125 has 4 chip selects and 4 R/B signals, whereas VF610 has only 2 chip selects and just 1 R/B signals...
Quoted 8 lines
But wait...I see that you call
nand_scan_ident()with a max of 1 chip. So you won't ever see the chip > 0 case, right?So does this driver support multiple flash attached or not? Looks like you're assuming you'll only be using chip-select 0. (This is fine for now, but at least your code should acknowledge this. Perhaps a comment at the top under "limitations.")
Ok, will add that information under limitations.
Quoted 12 lines
Quoted 4 lines
drivers/mtd/nand/vf610_nfc.c new file +4
-0+ +vf610_nfc_write (nfc,NFC_ROW_ADDR , tmp); +#endif +}...
Quoted 2 lines
drivers/mtd/nand/vf610_nfc.c new file +2
-0+static int vf610_nfc_probe (struct platform_device *pdev) +{...
Quoted 5 lines
drivers/mtd/nand/vf610_nfc.c line 559
Quoted 5 lines
drivers/mtd/nand/vf610_nfc.c new file +5
-0+/* first scan to find the device and get the page size */ +if (nand_scan_ident (mtd,1 ,NULL )) { + err = -ENXIO ; + goto error; + }
--
Stefan
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Brian NorrisQuoted 7 lines · Brian Norris
One more thing...
Quoted 3 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@...
Quoted 11 lines
drivers/mtd/nand/vf610_nfc.c line 135
Quoted 8 lines
drivers/mtd/nand/vf610_nfc.c new file +8
-0+struct vf610_nfc { +struct mtd_info mtd; +struct nand_chip chip; +struct device *dev; +void __iomem *regs; +struct completion cmd_done; +uint buf_offset; +int page_sz;AFAICT (even with the 2nd patch), you never really use this field. You just set it/increment it, but don't use it for anything. Kill it?
It is used in the write path, I think I meant to use it for subpage writes, when I thought it would just mean to transfer only parts of the page to the controller.
However, as the subpage discussion basically concluded in not using it for now on this controller, we can as well transfer the complete page (page_sz). Or is there another case in which vf610_nfc_write_buf could be called with less than page_sz?
--
Stefan
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Stefan AgnerQuoted 26 lines · Stefan Agner
Quoted 19 lines · Brian Norris
Quoted 6 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@...
drivers/mtd/nand/vf610_nfc.c line 449
Quoted 6 lines
drivers/mtd/nand/vf610_nfc.c new file +6
-0+/* +* This function supports Vybrid only (MPC5125 would have full RB and four CS) +*/ +static void vf610_nfc_select_chip (struct mtd_info *mtd,int chip) +{ +#ifdef CONFIG_SOC_VF610 Why the #ifdef? I don't see anything compile-time specific to
SOC_VF610.Quoted 5 lines
If this is trying to handle the comment above ("This function supports Vybrid only (MPC5125 would have full RB and four CS)") then that's the wrong way of doing it, as you need to support multiplatform kernels. You'll need to have a way to differentiate the different platform support at runtime, not compile time.
Quoted 4 lines
Yes it is trying to handle the comment above. Well, the other two platforms I am aware of are also different architectures... (PowerPC and ColdFire). I think we won't have a multi-architecture kernel anytime soon,
Ha, right. Sorry, I don't really know this particular IP.
Quoted 2 lines
hence I think removing the code at compile time is the right thing todo.
I don't believe that conclusion follows though.
Quoted 21 lines
However, probably
CONFIG_SOC_VF610is the wrong symbol then, I could just useCONFIG_ARMand add a comment that this might be different on another other ARM SoC than VF610.Just checked CodingStyle, and I see that
IS_ENABLEDis the preferred way for conditional compiling.So my suggestion:
static void
vf610_nfc_select_chip(struct mtd_info *mtd, int chip){ struct vf610_nfc *nfc = mtd_to_nfc(mtd); u32 tmp = vf610_nfc_read(nfc, NFC_ROW_ADDR); if (!IS_ENABLED(CONFIG_ARM)) return; /* * This code is only tested on the ARM platform VF610 * PowerPC based MPC5125 would have full RB and four CS */
Quoted 6 lines
....
With that the compiler should be able to remove this (currently) ARM VF610 specific code on the other supported architectures...
What do you think?
The code structure isn't bad, and yes, IS_ENABLED() would be preferable, as it removes some of the problems with #ifdef, but I still don't think the processor architecture has much to do with the version of the IP. The canonical way of distiguishing per-IP revisions is to key on the compatible property. So you'd have some kind of enum, which would currently only have an entry for VF610. i.e.:
/* MPC5125 not yet supported */ if (nfc->revision != NAND_VFC610) return;
Quoted 17 lines
Quoted 17 lines
drivers/mtd/nand/vf610_nfc.c line 459
Quoted 10 lines
drivers/mtd/nand/vf610_nfc.c new file +10
-0+struct vf610_nfc *nfc =mtd_to_nfc (mtd); +u32 tmp =vf610_nfc_read (nfc,NFC_ROW_ADDR ); + + tmp &= ~(ROW_ADDR_CHIP_SEL_RB_MASK |ROW_ADDR_CHIP_SEL_MASK ); + tmp |=1 <<ROW_ADDR_CHIP_SEL_RB_SHIFT ; + +if (chip ==0 ) + tmp |=1 <<ROW_ADDR_CHIP_SEL_SHIFT ; +else if (chip ==1 ) + tmp |=2 <<ROW_ADDR_CHIP_SEL_SHIFT ;else ... ?Maybe you can write this as a formulaic pattern (e.g.:
tmp |= (chip + 1) << ROW_ADDR_CHIP_SEL_SHIFT;
Quoted 8 lines
Quoted 4 lines
) and just do the "max # of chips" checks on a per-platform basis in the
probe(). Then I'm guessing this same function can apply to both platforms. (I'm not looking at HW datasheets for this, BTW, just guessing based on the context here.)It seems that MCP5125 is different than VF610. MCP5125 has 4 chip selects and 4 R/B signals, whereas VF610 has only 2 chip selects and just 1 R/B signals...
OK I don't presume to know what the different IP versions look like. And if you just note they are unsupported/untested, you're fine.
Brian
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Stefan AgnerQuoted 20 lines · Stefan Agner
Quoted 7 lines · Brian Norris
One more thing...
Quoted 3 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@...
Quoted 11 lines
drivers/mtd/nand/vf610_nfc.c line 135
Quoted 8 lines
drivers/mtd/nand/vf610_nfc.c new file +8
-0+struct vf610_nfc { +struct mtd_info mtd; +struct nand_chip chip; +struct device *dev; +void __iomem *regs; +struct completion cmd_done; +uint buf_offset; +int page_sz;AFAICT (even with the 2nd patch), you never really use this field. You just set it/increment it, but don't use it for anything. Kill it?
Quoted 3 lines
It is used in the write path, I think I meant to use it for subpage writes, when I thought it would just mean to transfer only parts of the page to the controller.
Ah, you're right. Sorry, I missed that. I got mixed up seeing most of your uses of 'page_sz' were for a local variable of the same name, not this field.
Quoted 4 lines
However, as the subpage discussion basically concluded in not using it for now on this controller, we can as well transfer the complete page (
page_sz). Or is there another case in whichvf610_nfc_write_bufcould be called with less thanpage_sz?
I'll leave that up to you. I'm perfectly fine leaving it in, now that I see its proper use. Just in case things change in the future, I think it does help to clarify the flow of information a little. Although, I might recommend a change in naming, since it could get confused with the actual page size -- which is normally constant -- whereas this field changes dynamically depending on the command-in-flight.
Perhaps the struct could have 'write_len' (to help represent an action) and the local variable in vf610_nfc_command() could be 'tfr_len' (to distinguish how it isn't necessarily identical to 'write_len')? Just throwing (likely bad) ideas out there.
Regards,
Brian
Re: [PATCH v10 1/5] mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others
In reply to Brian NorrisQuoted 62 lines · Brian Norris
Quoted 26 lines · Stefan Agner
Quoted 19 lines · Brian Norris
Quoted 6 lines · Stefan Agner
drivers/mtd/nand/vf610_nfc.c new file +0
-0@@ -0,0 +1,645 @@...
drivers/mtd/nand/vf610_nfc.c line 449
Quoted 6 lines
drivers/mtd/nand/vf610_nfc.c new file +6
-0+/* +* This function supports Vybrid only (MPC5125 would have full RB and four CS) +*/ +static void vf610_nfc_select_chip (struct mtd_info *mtd,int chip) +{ +#ifdef CONFIG_SOC_VF610 Why the #ifdef? I don't see anything compile-time specific to
SOC_VF610.Quoted 5 lines
If this is trying to handle the comment above ("This function supports Vybrid only (MPC5125 would have full RB and four CS)") then that's the wrong way of doing it, as you need to support multiplatform kernels. You'll need to have a way to differentiate the different platform support at runtime, not compile time.
Quoted 4 lines
Yes it is trying to handle the comment above. Well, the other two platforms I am aware of are also different architectures... (PowerPC and ColdFire). I think we won't have a multi-architecture kernel anytime soon,
Ha, right. Sorry, I don't really know this particular IP.
Quoted 2 lines
hence I think removing the code at compile time is the right thing todo.
I don't believe that conclusion follows though.
Quoted 23 lines
However, probably
CONFIG_SOC_VF610is the wrong symbol then, I could just useCONFIG_ARMand add a comment that this might be different on another other ARM SoC than VF610.Just checked CodingStyle, and I see that
IS_ENABLEDis the preferred way for conditional compiling.So my suggestion:
static void
vf610_nfc_select_chip(struct mtd_info *mtd, int chip){ struct vf610_nfc *nfc = mtd_to_nfc(mtd); u32 tmp = vf610_nfc_read(nfc, NFC_ROW_ADDR); if (!IS_ENABLED(CONFIG_ARM)) return; /* * This code is only tested on the ARM platform VF610 * PowerPC based MPC5125 would have full RB and four CS */....
Quoted 8 lines
Quoted 4 lines
With that the compiler should be able to remove this (currently) ARM VF610 specific code on the other supported architectures...
What do you think?
The code structure isn't bad, and yes,
IS_ENABLED()would be preferable, as it removes some of the problems with #ifdef, but I still don't think the processor architecture has much to do with the version of the IP.
Well yes, the processor architecture has probably not much to do with the IP version.
However, that particular problem, the wiring up of the CS/RB signals, is probably more SoC (as a whole) specific, and how that is done might have some relation which architecture is in use...
I do not have a strong opinion on this, so we might as well go with the run-time distinction using compatible. If there are different IP variants within one architecture, we anyway would need to do that.
Quoted 8 lines
The canonical way of distiguishing per-IP revisions is to key on the compatible property. So you'd have some kind of enum, which would currently only have an entry for VF610. i.e.:
/* MPC5125 not yet supported */ if (nfc->revision != NAND_VFC610) return;
Ok, just checked, I can use the data field of the of table to assign specific data to a compatible string, similar to how pxa3xx_nand.c does it.
--
Stefan
Re: [PATCH v10 2/5] mtd: nand: vf610_nfc: add hardware BCH-ECC support
In reply to Brian NorrisQuoted 12 lines · computersforpeace at gmail.com
Quoted 10 lines · Stefan Agner
When printing the ECC error count on ECC fail when reading an erased NAND flash, the numbers of bit flips (stuck at zero) seem to widely correlate with the number returned by the controller. While it seems to correlate widely, there are exceptions, as discussed in the
thread: http://thread.gmane.org/gmane.linux.ports.arm.kernel/295424Maybe this is an artifact of the ECC algorithm we just can't/shouldn't rely on? I am not sure where this originated, I did not found any indication in the reference manual about what that value contains in the error case.
Quoted 9 lines
Doesn't sound too reliable to me. And I'm not sure even if it was reliable, that it would provide much value. We have to a lot of re-counting anyway, so we might as well just be using our own threshold. Or maybe I'm missing the point.
Quoted 4 lines
Bill, do you have an idea why we used that value as threshold in early implementations?
Otherwise I also think we should just drop the use of this value.
Yes, using this value is not especially useful if we re-read with ECC
disabled to count the bit flips for erased pages. I think this is what
Stefan has done in the 11th patch set.
Signature · 2 lines
Married men live longer than single men, but married men are much more willing to die - Dilworth