• P
    spi: bcm2835: Workaround/fix for zero-length transfers · fc2b0ccc
    Phil Elwell 提交于
    raspberrypi inclusion
    category: feature
    bugzilla: 50432
    
    --------------------------------
    
    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/4100Signed-off-by: NPhil Elwell <phil@raspberrypi.com>
    
    [1] 26751de2 ("spi: bcm2835: Micro-optimise FIFO loops")
    Signed-off-by: NFang Yafen <yafen@iscas.ac.cn>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    fc2b0ccc
spi-bcm2835.c 41.2 KB