]>
Commit | Line | Data |
---|---|---|
003ffd0a GKH |
1 | From c1ca59c22c56930b377a665fdd1b43351887830b Mon Sep 17 00:00:00 2001 |
2 | From: Geert Uytterhoeven <geert+renesas@glider.be> | |
3 | Date: Wed, 5 Sep 2018 10:49:38 +0200 | |
4 | Subject: spi: rspi: Fix invalid SPI use during system suspend | |
5 | ||
6 | From: Geert Uytterhoeven <geert+renesas@glider.be> | |
7 | ||
8 | commit c1ca59c22c56930b377a665fdd1b43351887830b upstream. | |
9 | ||
10 | If the SPI queue is running during system suspend, the system may lock | |
11 | up. | |
12 | ||
13 | Fix this by stopping/restarting the queue during system suspend/resume, | |
14 | by calling spi_master_suspend()/spi_master_resume() from the PM | |
15 | callbacks. In-kernel users will receive an -ESHUTDOWN error while | |
16 | system suspend/resume is in progress. | |
17 | ||
18 | Based on a patch for sh-msiof by Gaku Inami. | |
19 | ||
20 | Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> | |
21 | Signed-off-by: Mark Brown <broonie@kernel.org> | |
22 | Cc: stable@vger.kernel.org | |
23 | Signed-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 | }; |