linux-stable/drivers/memory
Andrew Gabbasov 1869023e24 memory: renesas-rpc-if: Avoid unaligned bus access for HyperFlash
HyperFlash devices in Renesas SoCs use 2-bytes addressing, according
to HW manual paragraph 62.3.3 (which officially describes Serial Flash
access, but seems to be applicable to HyperFlash too). And 1-byte bus
read operations to 2-bytes unaligned addresses in external address space
read mode work incorrectly (returns the other byte from the same word).

Function memcpy_fromio(), used by the driver to read data from the bus,
in ARM64 architecture (to which Renesas cores belong) uses 8-bytes
bus accesses for appropriate aligned addresses, and 1-bytes accesses
for other addresses. This results in incorrect data read from HyperFlash
in unaligned cases.

This issue can be reproduced using something like the following commands
(where mtd1 is a parition on Hyperflash storage, defined properly
in a device tree):

[Correct fragment, read from Hyperflash]

    root@rcar-gen3:~# dd if=/dev/mtd1 of=/tmp/zz bs=32 count=1
    root@rcar-gen3:~# hexdump -C /tmp/zz
    00000000  f4 03 00 aa f5 03 01 aa  f6 03 02 aa f7 03 03 aa  |................|
    00000010  00 00 80 d2 40 20 18 d5  00 06 81 d2 a0 18 a6 f2  |....@ ..........|
    00000020

[Incorrect read of the same fragment: see the difference at offsets 8-11]

    root@rcar-gen3:~# dd if=/dev/mtd1 of=/tmp/zz bs=12 count=1
    root@rcar-gen3:~# hexdump -C /tmp/zz
    00000000  f4 03 00 aa f5 03 01 aa  03 03 aa aa              |............|
    0000000c

Fix this issue by creating a local replacement of the copying function,
that performs only properly aligned bus accesses, and is used for reading
from HyperFlash.

Fixes: ca7d8b980b ("memory: add Renesas RPC-IF driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Link: https://lore.kernel.org/r/20210922184830.29147-1-andrew_gabbasov@mentor.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
2021-09-28 12:34:08 +02:00
..
samsung Power management updates for 5.13-rc1 2021-04-26 15:10:25 -07:00
tegra memory: tegra: fix unused-function warning 2021-07-23 08:25:34 +02:00
.gitignore .gitignore: prefix local generated files with a slash 2021-05-02 00:43:35 +09:00
Kconfig Char/Misc driver patches for 5.12-rc1 2021-02-24 10:25:37 -08:00
Makefile memory: dfl-emif: add the DFL EMIF private feature driver 2021-01-07 15:21:27 +01:00
atmel-ebi.c memory: atmel-ebi: add missing of_node_put for loop iteration 2021-05-11 08:49:18 -04:00
atmel-sdramc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 340 2019-06-05 17:37:07 +02:00
brcmstb_dpfe.c memory: brcmstb_dpfe: Simplify with dev_err_probe() 2020-09-02 17:22:31 +02:00
bt1-l2-ctl.c memory: bt1-l2-ctl: Add blank lines after declarations 2020-07-27 11:13:33 +02:00
da8xx-ddrctl.c memory: da8xx-ddrctl: Remove unused 'node' variable 2020-07-24 16:18:32 +02:00
dfl-emif.c memory: dfl-emif: add the DFL EMIF private feature driver 2021-01-07 15:21:27 +01:00
emif-asm-offsets.c memory: emif-asm-offsets: Add GPLv2 SPDX license header 2020-07-24 16:18:32 +02:00
emif.c memory: emif: remove unused frequency and voltage notifiers 2021-06-10 09:24:46 +02:00
emif.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
fsl-corenet-cf.c memory: fsl-corenet-cf: Remove redundant dev_err call in ccf_probe() 2021-04-01 19:56:52 +02:00
fsl_ifc.c memory: fsl_ifc: fix leak of private memory on probe failure 2021-06-10 09:24:37 +02:00
jedec_ddr.h memory: Extend of_memory with LPDDR3 support 2019-10-01 20:28:38 +02:00
jedec_ddr_data.c ARM: SoC-related driver updates 2019-07-19 17:13:56 -07:00
jz4780-nemc.c memory: jz4780_nemc: Fix potential NULL dereference in jz4780_nemc_probe() 2020-12-05 14:57:52 +01:00
mtk-smi.c memory: mtk-smi: Add device-link between smi-larb and smi-common 2021-04-13 16:56:31 +02:00
mvebu-devbus.c memory: mvebu-devbus: Align with open parenthesis 2020-07-27 11:13:33 +02:00
of_memory.c memory: of: Correct kerneldoc 2020-07-27 11:13:33 +02:00
of_memory.h memory: of: Remove unneeded extern from function declarations 2020-07-24 16:18:32 +02:00
omap-gpmc.c memory: omap-gpmc: Drop custom PM calls with cpu_pm notifier 2021-07-29 09:02:27 +02:00
pl172.c amba: Make the remove callback return void 2021-02-02 14:25:50 +01:00
pl353-smc.c Memory controller drivers for v5.14 - PL353 2021-06-12 08:53:06 -07:00
renesas-rpc-if.c memory: renesas-rpc-if: Avoid unaligned bus access for HyperFlash 2021-09-28 12:34:08 +02:00
stm32-fmc2-ebi.c memory: stm32-fmc2-ebi: add missing of_node_put for loop iteration 2021-05-11 08:49:18 -04:00
ti-aemif.c memory: ti-aemif: Drop child node when jumping out loop 2021-01-25 20:18:42 +01:00
ti-emif-pm.c memory: ti-emif-pm: Drop of_match_ptr from of_device_id table 2021-02-08 18:13:24 +01:00
ti-emif-sram-pm.S memory: ti-emif-sram: move driver-specific asm-offset.h to drivers/memory/ 2019-07-17 10:25:10 +09:00