android_kernel_samsung_a7y1.../drivers/mtd
Miquel Raynal 8a932fe9a3 mtd: spear_smi: Fix Write Burst mode
commit 69c7f4618c16b4678f8a4949b6bb5ace259c0033 upstream.

Any write with either dd or flashcp to a device driven by the
spear_smi.c driver will pass through the spear_smi_cpy_toio()
function. This function will get called for chunks of up to 256 bytes.
If the amount of data is smaller, we may have a problem if the data
length is not 4-byte aligned. In this situation, the kernel panics
during the memcpy:

    # dd if=/dev/urandom bs=1001 count=1 of=/dev/mtd6
    spear_smi_cpy_toio [620] dest c9070000, src c7be8800, len 256
    spear_smi_cpy_toio [620] dest c9070100, src c7be8900, len 256
    spear_smi_cpy_toio [620] dest c9070200, src c7be8a00, len 256
    spear_smi_cpy_toio [620] dest c9070300, src c7be8b00, len 233
    Unhandled fault: external abort on non-linefetch (0x808) at 0xc90703e8
    [...]
    PC is at memcpy+0xcc/0x330

The above error occurs because the implementation of memcpy_toio()
tries to optimize the number of I/O by writing 4 bytes at a time as
much as possible, until there are less than 4 bytes left and then
switches to word or byte writes.

Unfortunately, the specification states about the Write Burst mode:

        "the next AHB Write request should point to the next
	incremented address and should have the same size (byte,
	half-word or word)"

This means ARM architecture implementation of memcpy_toio() cannot
reliably be used blindly here. Workaround this situation by update the
write path to stick to byte access when the burst length is not
multiple of 4.

Fixes: f18dbbb1bfe0 ("mtd: ST SPEAr: Add SMI driver for serial NOR flash")
Cc: Russell King <linux@armlinux.org.uk>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-07 13:06:47 +02:00
..
chips mtd: cfi_cmdset_0002: Use chip_good() to retry in do_write_oneword() 2020-04-07 07:36:30 +02:00
devices mtd: spear_smi: Fix Write Burst mode 2020-04-07 13:06:47 +02:00
lpddr A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
maps mtd: physmap_of: Release resources on error 2020-04-07 12:32:41 +02:00
nand mtd: rawnand: sh_flctl: Use proper enum for flctl_dma_fifo0_transfer 2020-04-07 12:32:27 +02:00
onenand A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
spi-nor A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
tests A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ubi ubi: Do not drop UBI device reference before using 2020-04-07 12:41:31 +02:00
afs.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ar7part.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bcm47xxpart.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
bcm63xxpart.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
cmdlinepart.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ftl.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
inftlcore.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
inftlmount.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Kconfig A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtd_blkdevs.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdblock_ro.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdblock.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdchar.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdconcat.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdcore.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdcore.h mtd: Check add_mtd_device() ret code 2020-04-07 12:42:46 +02:00
mtdoops.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdpart.c mtd: Remove a debug trace in mtdpart.c 2020-04-07 12:43:14 +02:00
mtdsuper.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
mtdswap.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
nftlcore.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
nftlmount.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ofpart.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
redboot.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
rfd_ftl.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sm_ftl.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
sm_ftl.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
ssfdc.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30