]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/memstick-prevent-memstick-host-from-getting-runtime-.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / memstick-prevent-memstick-host-from-getting-runtime-.patch
1 From ec2068d582818200eaece8c00e2c92b50e8548f6 Mon Sep 17 00:00:00 2001
2 From: Kai-Heng Feng <kai.heng.feng@canonical.com>
3 Date: Mon, 5 Nov 2018 16:45:04 +0800
4 Subject: memstick: Prevent memstick host from getting runtime suspended during
5 card detection
6
7 [ Upstream commit e03e303edf1c63e6dd455ccd568c74e93ef3ba8c ]
8
9 We can use MEMSTICK_POWER_{ON,OFF} along with pm_runtime_{get,put}
10 helpers to let memstick host support runtime pm.
11
12 The rpm count may go down to zero before the memstick host powers on, so
13 the host can be runtime suspended.
14
15 So before doing card detection, increment the rpm count to avoid the
16 host gets runtime suspended. Balance the rpm count after card detection
17 is done.
18
19 Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
20 Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
21 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
22 Signed-off-by: Sasha Levin <sashal@kernel.org>
23 ---
24 drivers/memstick/core/memstick.c | 3 +++
25 1 file changed, 3 insertions(+)
26
27 diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
28 index 76382c858c35..1246d69ba187 100644
29 --- a/drivers/memstick/core/memstick.c
30 +++ b/drivers/memstick/core/memstick.c
31 @@ -18,6 +18,7 @@
32 #include <linux/delay.h>
33 #include <linux/slab.h>
34 #include <linux/module.h>
35 +#include <linux/pm_runtime.h>
36
37 #define DRIVER_NAME "memstick"
38
39 @@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work)
40 struct memstick_dev *card;
41
42 dev_dbg(&host->dev, "memstick_check started\n");
43 + pm_runtime_get_noresume(host->dev.parent);
44 mutex_lock(&host->lock);
45 if (!host->card) {
46 if (memstick_power_on(host))
47 @@ -479,6 +481,7 @@ out_power_off:
48 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
49
50 mutex_unlock(&host->lock);
51 + pm_runtime_put(host->dev.parent);
52 dev_dbg(&host->dev, "memstick_check finished\n");
53 }
54
55 --
56 2.19.1
57