Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'tags/nand-fixes-for-4.8-rc8' of git://git.infradead.org/linux-ubifs

Pull MTD fixes from Richard Weinberger:
"NAND Fixes for 4.8-rc8.

This contains fixes for bugs which got introduced in -rc1. Usually
Brian takes NAND patches from Boris, but since Brian is very busy
these days with other stuff and Boris is not yet member of the
kernel.org web of trust I stepped in.

Boris will be in Berlin at ELCE, I'll sign his key and hopefully other
Kernel developers too such that he can issue his own pull requests
soon.

Summary:

- Fix a wrong OOB layout definition in the mxc driver
- Fix incorrect ECC handling in the mtk driver"

* tag 'tags/nand-fixes-for-4.8-rc8' of git://git.infradead.org/linux-ubifs:
mtd: nand: mxc: fix obiwan error in mxc_nand_v[12]_ooblayout_free() functions
mtd: nand: fix chances to create incomplete ECC data when writing
mtd: nand: fix generating over-boundary ECC data when writing

+14 -7
+8 -4
drivers/mtd/nand/mtk_ecc.c
··· 366 366 u8 *data, u32 bytes) 367 367 { 368 368 dma_addr_t addr; 369 - u32 *p, len, i; 369 + u8 *p; 370 + u32 len, i, val; 370 371 int ret = 0; 371 372 372 373 addr = dma_map_single(ecc->dev, data, bytes, DMA_TO_DEVICE); ··· 393 392 394 393 /* Program ECC bytes to OOB: per sector oob = FDM + ECC + SPARE */ 395 394 len = (config->strength * ECC_PARITY_BITS + 7) >> 3; 396 - p = (u32 *)(data + bytes); 395 + p = data + bytes; 397 396 398 397 /* write the parity bytes generated by the ECC back to the OOB region */ 399 - for (i = 0; i < len; i++) 400 - p[i] = readl(ecc->regs + ECC_ENCPAR(i)); 398 + for (i = 0; i < len; i++) { 399 + if ((i % 4) == 0) 400 + val = readl(ecc->regs + ECC_ENCPAR(i / 4)); 401 + p[i] = (val >> ((i % 4) * 8)) & 0xff; 402 + } 401 403 timeout: 402 404 403 405 dma_unmap_single(ecc->dev, addr, bytes, DMA_TO_DEVICE);
+5 -2
drivers/mtd/nand/mtk_nand.c
··· 93 93 #define NFI_FSM_MASK (0xf << 16) 94 94 #define NFI_ADDRCNTR (0x70) 95 95 #define CNTR_MASK GENMASK(16, 12) 96 + #define ADDRCNTR_SEC_SHIFT (12) 97 + #define ADDRCNTR_SEC(val) \ 98 + (((val) & CNTR_MASK) >> ADDRCNTR_SEC_SHIFT) 96 99 #define NFI_STRADDR (0x80) 97 100 #define NFI_BYTELEN (0x84) 98 101 #define NFI_CSEL (0x90) ··· 702 699 } 703 700 704 701 ret = readl_poll_timeout_atomic(nfc->regs + NFI_ADDRCNTR, reg, 705 - (reg & CNTR_MASK) >= chip->ecc.steps, 702 + ADDRCNTR_SEC(reg) >= chip->ecc.steps, 706 703 10, MTK_TIMEOUT); 707 704 if (ret) 708 705 dev_err(dev, "hwecc write timeout\n"); ··· 905 902 dev_warn(nfc->dev, "read ahb/dma done timeout\n"); 906 903 907 904 rc = readl_poll_timeout_atomic(nfc->regs + NFI_BYTELEN, reg, 908 - (reg & CNTR_MASK) >= sectors, 10, 905 + ADDRCNTR_SEC(reg) >= sectors, 10, 909 906 MTK_TIMEOUT); 910 907 if (rc < 0) { 911 908 dev_err(nfc->dev, "subpage done timeout\n");
+1 -1
drivers/mtd/nand/mxc_nand.c
··· 943 943 struct nand_chip *nand_chip = mtd_to_nand(mtd); 944 944 int stepsize = nand_chip->ecc.bytes == 9 ? 16 : 26; 945 945 946 - if (section > nand_chip->ecc.steps) 946 + if (section >= nand_chip->ecc.steps) 947 947 return -ERANGE; 948 948 949 949 if (!section) {