Message ID | 20190429063834.45967-6-xiaolei.li@mediatek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | MTK NAND driver improvements and fixes | expand |
Hi Xiaolei, Xiaolei Li <xiaolei.li@mediatek.com> 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@mediatek.com> > --- > 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
Hi Miquel, On Mon, 2019-04-29 at 11:22 +0200, Miquel Raynal wrote: > Hi Xiaolei, > > Xiaolei Li <xiaolei.li@mediatek.com> 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 ? Sorry for the typo. Will fix it. > > 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? Yes. This feature is always on. NAND Controller counts zero bit when read data, and compare zero bit count with empty threshold to determine whether data is mostly 0xff. If zero bit count is less than the threshold, bit[12] of register NFI_STA, STA_EMP_PAGE in mtk_nand.c, will be set as 1. > > s/ecc/ECC/ OK. > > > > > Fixes: 93db446a424c ("mtd: nand: move raw NAND related code to the raw/ subdir") > > Ditto. OK. > > > Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> > > --- > > 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 Thanks, Xiaolei
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) {
MTK NAND Controller has the ability to check whether read data are mostly 0xff by comparing zero bit conut of read data with empty 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. Fixes: 93db446a424c ("mtd: nand: move raw NAND related code to the raw/ subdir") Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> --- drivers/mtd/nand/raw/mtk_nand.c | 5 +++++ 1 file changed, 5 insertions(+)