Patch "mtd: nand: sunxi: fix OOB handling in ->write_xxx() functions" has been added to the 4.2-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
mtd: nand: sunxi: fix OOB handling in ->write_xxx() functions
to the 4.2-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
mtd-nand-sunxi-fix-oob-handling-in-write_xxx-functions.patch
and it can be found in the queue-4.2 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
03a0e8a7c5ea29b5c4e72dfd64900b47a8fb6f2dMon Sep 17 00:00:00 2001
From: Boris BREZILLON <[email protected]>
Date: Mon, 14 Sep 2015 10:41:03 +0200
Subject: mtd: nand: sunxi: fix OOB handling in ->write_xxx() functions
From: Boris BREZILLON <[email protected]>
commit 03a0e8a7c5ea29b5c4e72dfd64900b47a8fb6f2d upstream.
The USER_DATA register cannot be accessed using byte accessors on A13 SoCs, thus triggering a bug when using memcpy_toio on this register. Declare an helper macros to convert an OOB buffer into a suitable USER_DATA value and vice-versa.
This patch also fixes an error in the oob_required logic (some OOB data are not written even if the user required it) by removing the oob_required condition, which is perfectly valid since the core already fill ->oob_poi with FFs when oob_required is false.
--- drivers/mtd/nand/sunxi_nand.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/mtd/nand/sunxi_nand.c +9 -17
@@ -138,6 +138,10 @@#define NFC_ECC_MODE GENMASK(15, 12)#define NFC_RANDOM_SEED GENMASK(30, 16) +/* NFC_USER_DATA helper macros */ +#define NFC_BUF_TO_USER_DATA (buf) ((buf)[0] | ((buf)[1] << 8) | \ + ((buf)[2] << 16) | ((buf)[3] << 24)) +#define NFC_DEFAULT_TIMEOUT_MS 1000#define NFC_SRAM_SIZE 1024
@@ -632,15 +636,9 @@ static int sunxi_nfc_hw_ecc_write_page(s offset = layout->eccpos[i * ecc->bytes] -4 + mtd->writesize;/* Fill OOB data in */ -if (oob_required) { - tmp =0xffffffff ; -memcpy_toio (nfc->regs +NFC_REG_USER_DATA_BASE , &tmp, -4 ); - }else { -memcpy_toio (nfc->regs +NFC_REG_USER_DATA_BASE , - chip->oob_poi + offset - mtd->writesize, -4 ); - } +writel (NFC_BUF_TO_USER_DATA (chip->oob_poi + + layout->oobfree[i].offset), + nfc->regs +NFC_REG_USER_DATA_BASE ); chip->cmdfunc (mtd,NAND_CMD_RNDIN , offset,-1 );
@@ -770,14 +768,8 @@ static int sunxi_nfc_hw_syndrome_ecc_wri offset += ecc->size;/* Fill OOB data in */ -if (oob_required) { - tmp =0xffffffff ; -memcpy_toio (nfc->regs +NFC_REG_USER_DATA_BASE , &tmp, -4 ); - }else { -memcpy_toio (nfc->regs +NFC_REG_USER_DATA_BASE , oob, -4 ); - } +writel (NFC_BUF_TO_USER_DATA (oob), + nfc->regs +NFC_REG_USER_DATA_BASE ); tmp =NFC_DATA_TRANS |NFC_DATA_SWAP_METHOD |NFC_ACCESS_DIR | (1 <<30 );
Patches currently in stable-queue which might be from [email protected] are
queue-4.2/mtd-nand-sunxi-fix-sunxi_nand_chips_cleanup.patch queue-4.2/mtd-nand-sunxi-fix-oob-handling-in-write_xxx-functions.patch queue-4.2/irqchip-atmel-aic5-use-per-chip-mask-caches-in-mask-unmask.patch