Revision 6af8ae321a801a4e20183454c65eb0d23069d8ac authored by Phil Elwell on 28 January 2021, 11:30:04 UTC, committed by Phil Elwell on 28 January 2021, 11:46:41 UTC
A relatively recent commit ([1]) contained optimisation for the PIO
SPI FIFO-filling functions. The commit message includes the phrase
"[t]he blind and counted loops are always called with nonzero count".
This is technically true, but it is still possible for count to become
zero before the loop is entered - if tfr->len is zero. Moving the loop
exit condition to the end of the loop saves a few cycles, but results
in a near-infinite loop should the revised count be zero on entry.

Strangely, zero-lengthed transfers aren't filtered by the SPI framework
and, even more strangely, the Python3 spidev library is triggering them
for no obvious reason.

Avoid the problem completely by bailing out of the main transfer
function early if trf->len is zero, although there may be a case for
moving the mitigation into the framework.

See: https://github.com/raspberrypi/linux/issues/4100

Signed-off-by: Phil Elwell <phil@raspberrypi.com>

[1] 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops")
1 parent c5f51df
History
File Mode Size
Makefile -rw-r--r-- 1.9 KB
arm-mem.h -rw-r--r-- 5.3 KB
ashldi3.S -rw-r--r-- 1.6 KB
ashrdi3.S -rw-r--r-- 1.6 KB
backtrace-clang.S -rw-r--r-- 6.8 KB
backtrace.S -rw-r--r-- 3.1 KB
bitops.h -rw-r--r-- 2.1 KB
bswapsdi2.S -rw-r--r-- 649 bytes
call_with_stack.S -rw-r--r-- 577 bytes
changebit.S -rw-r--r-- 250 bytes
clear_user.S -rw-r--r-- 1.3 KB
clearbit.S -rw-r--r-- 248 bytes
copy_from_user.S -rw-r--r-- 2.5 KB
copy_page.S -rw-r--r-- 1.1 KB
copy_template.S -rw-r--r-- 6.7 KB
copy_to_user.S -rw-r--r-- 2.4 KB
csumipv6.S -rw-r--r-- 550 bytes
csumpartial.S -rw-r--r-- 2.9 KB
csumpartialcopy.S -rw-r--r-- 979 bytes
csumpartialcopygeneric.S -rw-r--r-- 6.7 KB
csumpartialcopyuser.S -rw-r--r-- 1.6 KB
delay-loop.S -rw-r--r-- 1.0 KB
delay.c -rw-r--r-- 2.4 KB
div64.S -rw-r--r-- 3.8 KB
exports_rpi.c -rw-r--r-- 1.8 KB
findbit.S -rw-r--r-- 4.7 KB
getuser.S -rw-r--r-- 3.4 KB
io-readsb.S -rw-r--r-- 2.3 KB
io-readsl.S -rw-r--r-- 1.4 KB
io-readsw-armv3.S -rw-r--r-- 1.6 KB
io-readsw-armv4.S -rw-r--r-- 2.2 KB
io-writesb.S -rw-r--r-- 1.5 KB
io-writesl.S -rw-r--r-- 1.1 KB
io-writesw-armv3.S -rw-r--r-- 2.0 KB
io-writesw-armv4.S -rw-r--r-- 1.5 KB
lib1funcs.S -rw-r--r-- 8.1 KB
lshrdi3.S -rw-r--r-- 1.6 KB
memchr.S -rw-r--r-- 373 bytes
memcmp_rpi.S -rw-r--r-- 8.5 KB
memcpy.S -rw-r--r-- 1.3 KB
memcpy_rpi.S -rw-r--r-- 2.1 KB
memcpymove.h -rw-r--r-- 15.2 KB
memmove.S -rw-r--r-- 4.7 KB
memmove_rpi.S -rw-r--r-- 2.2 KB
memset.S -rw-r--r-- 2.9 KB
memset_rpi.S -rw-r--r-- 4.1 KB
muldi3.S -rw-r--r-- 771 bytes
putuser.S -rw-r--r-- 2.0 KB
setbit.S -rw-r--r-- 230 bytes
strchr.S -rw-r--r-- 404 bytes
strrchr.S -rw-r--r-- 383 bytes
testchangebit.S -rw-r--r-- 269 bytes
testclearbit.S -rw-r--r-- 271 bytes
testsetbit.S -rw-r--r-- 267 bytes
uaccess_with_memcpy.c -rw-r--r-- 9.0 KB
ucmpdi2.S -rw-r--r-- 648 bytes
xor-neon.c -rw-r--r-- 1.2 KB

back to top