[PATCH 3/6] spi: spi-fsl-dspi: Fix oper_word_size of zero for DMA mode

From: Vladimir Oltean
Date: Mon Mar 09 2020 - 10:56:50 EST


From: Vladimir Oltean <vladimir.oltean@xxxxxxx>

In DMA mode, dspi_setup_accel does not get called, which results in the
dspi->oper_word_size variable (which is used by dspi_dma_xfer) to not be
initialized properly.

Because oper_word_size is zero, a few calculations end up being
incorrect, and the DMA transfer eventually times out instead of sending
anything on the wire.

Set up native transfers (or 8-on-16 acceleration) using dspi_setup_accel
for DMA mode too.

Fixes: 6c1c26ecd9a3 ("spi: spi-fsl-dspi: Accelerate transfers using larger word size if possible")
Signed-off-by: Vladimir Oltean <vladimir.oltean@xxxxxxx>
---
drivers/spi/spi-fsl-dspi.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index a8e56abe20ac..5624b9ee77db 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -372,6 +372,8 @@ static void dspi_rx_dma_callback(void *arg)
complete(&dma->cmd_rx_complete);
}

+static void dspi_setup_accel(struct fsl_dspi *dspi);
+
static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi)
{
struct device *dev = &dspi->pdev->dev;
@@ -459,9 +461,10 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi)
int bytes_per_buffer;
int ret = 0;

+ dspi_setup_accel(dspi);
+
curr_remaining_bytes = dspi->len;
- bytes_per_buffer = dspi->devtype_data->dma_bufsize /
- dspi->devtype_data->fifo_size;
+ bytes_per_buffer = dspi->devtype_data->dma_bufsize;
while (curr_remaining_bytes) {
/* Check if current transfer fits the DMA buffer */
dma->curr_xfer_len = curr_remaining_bytes /
--
2.17.1