Skip to content

BACKPORT: spi: geni-qcom: Fix sub-byte transfer packing and length calculation - #1616

Open
somesh77qc wants to merge 1 commit into
qualcomm-linux:qcom-6.18.yfrom
somesh77qc:spi-geni-subbyte-fix
Open

somesh77qc wants to merge 1 commit into
qualcomm-linux:qcom-6.18.yfrom
somesh77qc:spi-geni-subbyte-fix

Conversation

@somesh77qc

Copy link
Copy Markdown

On iq-9075-evk, short four-bit SPI loopback transfers can time out immediately after boot. The failure is reproduced with spidev_test:

./spidev_test -D /dev/spidev0.0 -s 2500000 -b 4 -l -I 10 -v

The test reports "can't send spi message: Connection timed out", with the following kernel messages:

[ 732.730335] spidev spi0.0: SPI transfer timed out
[ 732.735216] geni_spi 880000.spi: Can't set CS when prev xfer running
[ 732.742882] spi_master spi0: failed to transfer one message from queue
[ 732.749619] spi_master spi0: noqueue transfer failed

At BPW 4, the driver requests eight protocol words per 32-bit FIFO entry. The GENI helper needs one packing vector per sub-byte word but only supports four vectors, so it returns without programming the packing registers. This leaves the transfer dependent on the previous packing configuration.

The driver also assumes that a buffer byte contains two four-bit words. Linux SPI buffers store each sub-byte word in a separate byte, so the programmed transfer length can exceed the available data.

Use byte-sized packing slots for sub-byte transfers and derive word counts from spi_bpw_to_bytes(). Share the packing count across hardware configuration, FIFO accounting and DMA selection. Account for storage padding in the last received word, and drain leftover FIFO entries without relying on a cached word width.

Link: https://lore.kernel.org/all/20261118-spi-bpw-fix-v1-1-e475586ca8e8@oss.qualcomm.com/
Fixes: 561de45 ("spi: spi-geni-qcom: Add SPI driver support for GENI based QUP")

CRs-Fixed: 4457566

…lculation

On iq-9075-evk, short four-bit SPI loopback transfers can time out
immediately after boot. The failure is reproduced with spidev_test:

  ./spidev_test -D /dev/spidev0.0 -s 2500000 -b 4 -l -I 10 -v

The test reports "can't send spi message: Connection timed out", with
the following kernel messages:

  [  732.730335] spidev spi0.0: SPI transfer timed out
  [  732.735216] geni_spi 880000.spi: Can't set CS when prev xfer running
  [  732.742882] spi_master spi0: failed to transfer one message from queue
  [  732.749619] spi_master spi0: noqueue transfer failed

At BPW 4, the driver requests eight protocol words per 32-bit FIFO
entry. The GENI helper needs one packing vector per sub-byte word
but only supports four vectors, so it returns without programming
the packing registers. This leaves the transfer dependent on the
previous packing configuration.

The driver also assumes that a buffer byte contains two four-bit
words. Linux SPI buffers store each sub-byte word in a separate byte,
so the programmed transfer length can exceed the available data.

Use byte-sized packing slots for sub-byte transfers and derive word
counts from spi_bpw_to_bytes(). Share the packing count across hardware
configuration, FIFO accounting and DMA selection. Account for storage
padding in the last received word, and drain leftover FIFO entries
without relying on a cached word width.

Link: https://lore.kernel.org/all/20261118-spi-bpw-fix-v1-1-e475586ca8e8@oss.qualcomm.com/
Fixes: 561de45 ("spi: spi-geni-qcom: Add SPI driver support for GENI based QUP")
Signed-off-by: Somesh Dey <somesh.dey@oss.qualcomm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant