Skip to content

Commit c1ca59c

Browse files
geertubroonie
authored andcommitted
spi: rspi: Fix invalid SPI use during system suspend
If the SPI queue is running during system suspend, the system may lock up. Fix this by stopping/restarting the queue during system suspend/resume, by calling spi_master_suspend()/spi_master_resume() from the PM callbacks. In-kernel users will receive an -ESHUTDOWN error while system suspend/resume is in progress. Based on a patch for sh-msiof by Gaku Inami. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent 31a5fae commit c1ca59c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/spi/spi-rspi.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,12 +1350,36 @@ static const struct platform_device_id spi_driver_ids[] = {
13501350

13511351
MODULE_DEVICE_TABLE(platform, spi_driver_ids);
13521352

1353+
#ifdef CONFIG_PM_SLEEP
1354+
static int rspi_suspend(struct device *dev)
1355+
{
1356+
struct platform_device *pdev = to_platform_device(dev);
1357+
struct rspi_data *rspi = platform_get_drvdata(pdev);
1358+
1359+
return spi_master_suspend(rspi->master);
1360+
}
1361+
1362+
static int rspi_resume(struct device *dev)
1363+
{
1364+
struct platform_device *pdev = to_platform_device(dev);
1365+
struct rspi_data *rspi = platform_get_drvdata(pdev);
1366+
1367+
return spi_master_resume(rspi->master);
1368+
}
1369+
1370+
static SIMPLE_DEV_PM_OPS(rspi_pm_ops, rspi_suspend, rspi_resume);
1371+
#define DEV_PM_OPS &rspi_pm_ops
1372+
#else
1373+
#define DEV_PM_OPS NULL
1374+
#endif /* CONFIG_PM_SLEEP */
1375+
13531376
static struct platform_driver rspi_driver = {
13541377
.probe = rspi_probe,
13551378
.remove = rspi_remove,
13561379
.id_table = spi_driver_ids,
13571380
.driver = {
13581381
.name = "renesas_spi",
1382+
.pm = DEV_PM_OPS,
13591383
.of_match_table = of_match_ptr(rspi_of_match),
13601384
},
13611385
};

0 commit comments

Comments
 (0)