Hi Xiaolei, Xiaolei Li <xiaolei.li@xxxxxxxxxxxx> wrote on Mon, 29 Apr 2019 14:38:34 +0800: > MTK NAND Controller has the ability to check whether read data are > mostly 0xff by comparing zero bit conut of read data with empty count ? > threshold automatically. > > But now we never set this threshold and always make it be default value > which is 10. > > This patch fixes this problem by setting empty threshold as the product > of read sector count and ecc strength. Do we use these feature yet? s/ecc/ECC/ > > Fixes: 93db446a424c ("mtd: nand: move raw NAND related code to the raw/ subdir") Ditto. > Signed-off-by: Xiaolei Li <xiaolei.li@xxxxxxxxxxxx> > --- > drivers/mtd/nand/raw/mtk_nand.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c > index cf5e50e704ae..675d4faa3480 100644 > --- a/drivers/mtd/nand/raw/mtk_nand.c > +++ b/drivers/mtd/nand/raw/mtk_nand.c > @@ -94,6 +94,7 @@ > #define NFI_MASTER_STA (0x224) > #define MASTER_STA_MASK (0x0FFF) > #define NFI_EMPTY_THRESH (0x23C) > +#define EMPTY_THRESH_MASK GENMASK(7, 0) > > #define MTK_NAME "mtk-nand" > #define KB(x) ((x) * 1024UL) > @@ -931,6 +932,10 @@ static int mtk_nfc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, > return -EINVAL; > } > > + /* Setup empty threshold */ > + reg = max(sectors * chip->ecc.strength, EMPTY_THRESH_MASK); > + nfi_writel(nfc, reg, NFI_EMPTY_THRESH); > + > reg = nfi_readw(nfc, NFI_CNFG); > reg |= CNFG_READ_EN | CNFG_DMA_BURST_EN | CNFG_AHB; > if (!raw) { Thanks, Miquèl ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/