Skip to content

Commit 7684580

Browse files
krzkbroonie
authored andcommitted
spi: spi-fsl-dspi: Fix lockup if device is removed during SPI transfer
During device removal, the driver should unregister the SPI controller and stop the hardware. Otherwise the dspi_transfer_one_message() could wait on completion infinitely. Additionally, calling spi_unregister_controller() first in device removal reverse-matches the probe function, where SPI controller is registered at the end. Fixes: 05209f4 ("spi: fsl-dspi: add missing clk_disable_unprepare() in dspi_remove()") Reported-by: Vladimir Oltean <[email protected]> Signed-off-by: Krzysztof Kozlowski <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 06096cc commit 7684580

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

drivers/spi/spi-fsl-dspi.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,9 +1434,18 @@ static int dspi_remove(struct platform_device *pdev)
14341434
struct fsl_dspi *dspi = spi_controller_get_devdata(ctlr);
14351435

14361436
/* Disconnect from the SPI framework */
1437+
spi_unregister_controller(dspi->ctlr);
1438+
1439+
/* Disable RX and TX */
1440+
regmap_update_bits(dspi->regmap, SPI_MCR,
1441+
SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF,
1442+
SPI_MCR_DIS_TXF | SPI_MCR_DIS_RXF);
1443+
1444+
/* Stop Running */
1445+
regmap_update_bits(dspi->regmap, SPI_MCR, SPI_MCR_HALT, SPI_MCR_HALT);
1446+
14371447
dspi_release_dma(dspi);
14381448
clk_disable_unprepare(dspi->clk);
1439-
spi_unregister_controller(dspi->ctlr);
14401449

14411450
return 0;
14421451
}

0 commit comments

Comments
 (0)