summaryrefslogtreecommitdiffstats
path: root/drivers/ddr/microchip/ddr2.c
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2021-05-13 16:46:17 +0800
committerLeo Yu-Chi Liang <ycliang@andestech.com>2021-05-17 16:47:33 +0800
commit703b84ec29fe3ffe2299596ba302570fb38e3976 (patch)
tree2f0dde1d634bd4e1b155862e273a8d0b077f5f82 /drivers/ddr/microchip/ddr2.c
parente90cb0db34ec4bd1141ea8255efa5a42f6c0a225 (diff)
downloadu-boot-703b84ec29fe3ffe2299596ba302570fb38e3976.tar.gz
u-boot-703b84ec29fe3ffe2299596ba302570fb38e3976.tar.xz
u-boot-703b84ec29fe3ffe2299596ba302570fb38e3976.zip
riscv: Fix memmove and optimise memcpy when misalign
At present U-Boot SPL fails to boot on SiFive Unleashed board, due to a load address misaligned exception happens when loading the FIT image in spl_load_simple_fit(). The exception happens in memmove() which is called by fdt_splice_(). Commit 8f0dc4cfd106 introduces an assembly version of memmove but it does take misalignment into account (it checks if length is a multiple of machine word size but pointers need also be aligned). As a result it will generate misaligned load/store for the majority of cases and causes significant performance regression on hardware that traps misaligned load/store and emulate them using firmware. The current behaviour of memcpy is that it checks if both src and dest pointers are co-aligned (aka congruent modular SZ_REG). If aligned, it will copy data word-by-word after first aligning pointers to word boundary. If src and dst are not co-aligned, however, byte-wise copy will be performed. This patch was taken from the Linux kernel patch [1], which has not been applied at the time being. It fixes the memmove and optimises memcpy for misaligned cases. It will first align destination pointer to word-boundary regardless whether src and dest are co-aligned or not. If they indeed are, then wordwise copy is performed. If they are not co-aligned, then it will load two adjacent words from src and use shifts to assemble a full machine word. Some additional assembly level micro-optimisation is also performed to ensure more instructions can be compressed (e.g. prefer a0 to t6). With this patch, U-Boot boots again on SiFive Unleashed board. [1] https://patchwork.kernel.org/project/linux-riscv/patch/20210216225555.4976-1-gary@garyguo.net/ Fixes: 8f0dc4cfd106 ("riscv: assembler versions of memcpy, memmove, memset") Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers/ddr/microchip/ddr2.c')
0 files changed, 0 insertions, 0 deletions