]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.131/spi-rspi-fix-invalid-spi-use-during-system-suspend.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.131 / spi-rspi-fix-invalid-spi-use-during-system-suspend.patch
CommitLineData
003ffd0a
GKH
1From c1ca59c22c56930b377a665fdd1b43351887830b Mon Sep 17 00:00:00 2001
2From: Geert Uytterhoeven <geert+renesas@glider.be>
3Date: Wed, 5 Sep 2018 10:49:38 +0200
4Subject: spi: rspi: Fix invalid SPI use during system suspend
5
6From: Geert Uytterhoeven <geert+renesas@glider.be>
7
8commit c1ca59c22c56930b377a665fdd1b43351887830b upstream.
9
10If the SPI queue is running during system suspend, the system may lock
11up.
12
13Fix this by stopping/restarting the queue during system suspend/resume,
14by calling spi_master_suspend()/spi_master_resume() from the PM
15callbacks. In-kernel users will receive an -ESHUTDOWN error while
16system suspend/resume is in progress.
17
18Based on a patch for sh-msiof by Gaku Inami.
19
20Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
21Signed-off-by: Mark Brown <broonie@kernel.org>
22Cc: stable@vger.kernel.org
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24
25---
26 drivers/spi/spi-rspi.c | 24 ++++++++++++++++++++++++
27 1 file changed, 24 insertions(+)
28
29--- a/drivers/spi/spi-rspi.c
30+++ b/drivers/spi/spi-rspi.c
31@@ -1313,12 +1313,36 @@ static const struct platform_device_id s
32
33 MODULE_DEVICE_TABLE(platform, spi_driver_ids);
34
35+#ifdef CONFIG_PM_SLEEP
36+static int rspi_suspend(struct device *dev)
37+{
38+ struct platform_device *pdev = to_platform_device(dev);
39+ struct rspi_data *rspi = platform_get_drvdata(pdev);
40+
41+ return spi_master_suspend(rspi->master);
42+}
43+
44+static int rspi_resume(struct device *dev)
45+{
46+ struct platform_device *pdev = to_platform_device(dev);
47+ struct rspi_data *rspi = platform_get_drvdata(pdev);
48+
49+ return spi_master_resume(rspi->master);
50+}
51+
52+static SIMPLE_DEV_PM_OPS(rspi_pm_ops, rspi_suspend, rspi_resume);
53+#define DEV_PM_OPS &rspi_pm_ops
54+#else
55+#define DEV_PM_OPS NULL
56+#endif /* CONFIG_PM_SLEEP */
57+
58 static struct platform_driver rspi_driver = {
59 .probe = rspi_probe,
60 .remove = rspi_remove,
61 .id_table = spi_driver_ids,
62 .driver = {
63 .name = "renesas_spi",
64+ .pm = DEV_PM_OPS,
65 .of_match_table = of_match_ptr(rspi_of_match),
66 },
67 };