]> git.baikalelectronics.ru Git - kernel.git/commit
spi: spi-imx: spi_imx_transfer_one(): check for DMA transfer first
authorMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 16 Nov 2022 16:49:30 +0000 (17:49 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 18 Nov 2022 11:39:50 +0000 (11:39 +0000)
commit348287c7b7f6a784ca7fb6626b93b357a69e6339
treeba72501b5822dd99567637659576bf633341f907
parent379751fd237eadd7d2df193e9af620a28d94f05c
spi: spi-imx: spi_imx_transfer_one(): check for DMA transfer first

The SPI framework checks for each transfer (with the struct
spi_controller::can_dma callback) whether the driver wants to use DMA
for the transfer. If the driver returns true, the SPI framework will
map the transfer's data to the device, start the actual transfer and
map the data back.

In commit ffa85d09f4b6 ("spi: spi-imx: add PIO polling support") the
spi-imx driver's spi_imx_transfer_one() function was extended. If the
estimated duration of a transfer does not exceed a configurable
duration, a polling transfer function is used. This check happens
before checking if the driver decided earlier for a DMA transfer.

If spi_imx_can_dma() decided to use a DMA transfer, and the user
configured a big maximum polling duration, a polling transfer will be
used. The DMA unmap after the transfer destroys the transferred data.

To fix this problem check in spi_imx_transfer_one() if the driver
decided for DMA transfer first, then check the limits for a polling
transfer.

Fixes: ffa85d09f4b6 ("spi: spi-imx: add PIO polling support")
Link: https://lore.kernel.org/all/20221111003032.82371-1-festevam@gmail.com
Reported-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reported-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Fabio Estevam <festevam@gmail.com>
Cc: David Jander <david@protonic.nl>
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Link: https://lore.kernel.org/r/20221116164930.855362-1-mkl@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-imx.c