mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-10 07:50:04 +00:00
mtd: nand: fix chances to create incomplete ECC data when writing
When mtk_nfc_do_write_page() comparing the sector number,because the sector number field is at the 12th-bit position of NFI_BYTELEN register,the masked register should be shifted 12 bits before being compared.The result of this bug may cause the second subpage has incomplete ECC parity bytes. Signed-off-by: RogerCC Lin <rogercc.lin@mediatek.com> Fixes: 1d6b1e464950 ("mtd: mediatek: driver for MTK Smart Device") Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
This commit is contained in:
parent
7a35328992
commit
559e58e7ed
@ -93,6 +93,9 @@
|
||||
#define NFI_FSM_MASK (0xf << 16)
|
||||
#define NFI_ADDRCNTR (0x70)
|
||||
#define CNTR_MASK GENMASK(16, 12)
|
||||
#define ADDRCNTR_SEC_SHIFT (12)
|
||||
#define ADDRCNTR_SEC(val) \
|
||||
(((val) & CNTR_MASK) >> ADDRCNTR_SEC_SHIFT)
|
||||
#define NFI_STRADDR (0x80)
|
||||
#define NFI_BYTELEN (0x84)
|
||||
#define NFI_CSEL (0x90)
|
||||
@ -699,7 +702,7 @@ static int mtk_nfc_do_write_page(struct mtd_info *mtd, struct nand_chip *chip,
|
||||
}
|
||||
|
||||
ret = readl_poll_timeout_atomic(nfc->regs + NFI_ADDRCNTR, reg,
|
||||
(reg & CNTR_MASK) >= chip->ecc.steps,
|
||||
ADDRCNTR_SEC(reg) >= chip->ecc.steps,
|
||||
10, MTK_TIMEOUT);
|
||||
if (ret)
|
||||
dev_err(dev, "hwecc write timeout\n");
|
||||
@ -902,7 +905,7 @@ static int mtk_nfc_read_subpage(struct mtd_info *mtd, struct nand_chip *chip,
|
||||
dev_warn(nfc->dev, "read ahb/dma done timeout\n");
|
||||
|
||||
rc = readl_poll_timeout_atomic(nfc->regs + NFI_BYTELEN, reg,
|
||||
(reg & CNTR_MASK) >= sectors, 10,
|
||||
ADDRCNTR_SEC(reg) >= sectors, 10,
|
||||
MTK_TIMEOUT);
|
||||
if (rc < 0) {
|
||||
dev_err(nfc->dev, "subpage done timeout\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user