From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: arnd@arndb.de, gregkh@linuxfoundation.org
Cc: ulf.hansson@linaro.org, stern@rowland.harvard.edu,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
Kai-Heng Feng <kai.heng.feng@canonical.com>
Subject: [PATCH 3/5 v7] memstick: Prevent memstick host from getting runtime suspended during card detection
Date: Mon, 5 Nov 2018 16:45:04 +0800 [thread overview]
Message-ID: <20181105084506.6476-4-kai.heng.feng@canonical.com> (raw)
In-Reply-To: <20181105084506.6476-1-kai.heng.feng@canonical.com>
We can use MEMSTICK_POWER_{ON,OFF} along with pm_runtime_{get,put}
helpers to let memstick host support runtime pm.
The rpm count may go down to zero before the memstick host powers on, so
the host can be runtime suspended.
So before doing card detection, increment the rpm count to avoid the
host gets runtime suspended. Balance the rpm count after card detection
is done.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
drivers/memstick/core/memstick.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index 76382c858c35..1246d69ba187 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -18,6 +18,7 @@
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/pm_runtime.h>
#define DRIVER_NAME "memstick"
@@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work)
struct memstick_dev *card;
dev_dbg(&host->dev, "memstick_check started\n");
+ pm_runtime_get_noresume(host->dev.parent);
mutex_lock(&host->lock);
if (!host->card) {
if (memstick_power_on(host))
@@ -479,6 +481,7 @@ static void memstick_check(struct work_struct *work)
host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
mutex_unlock(&host->lock);
+ pm_runtime_put(host->dev.parent);
dev_dbg(&host->dev, "memstick_check finished\n");
}
--
2.19.1
next prev parent reply other threads:[~2018-11-05 8:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 8:45 [PATCH 0/5 v7] Keep rtsx_usb suspended when there's no card Kai-Heng Feng
2018-11-05 8:45 ` [PATCH 1/5 v7] memstick: rtsx_usb_ms: Add missing pm_runtime_disable() in probe function Kai-Heng Feng
2018-11-05 8:45 ` [PATCH 2/5 v7] misc: rtsx_usb: Use USB remote wakeup signaling for card insertion detection Kai-Heng Feng
2018-11-05 8:45 ` Kai-Heng Feng [this message]
2018-11-05 8:45 ` [PATCH 4/5 v7] memstick: rtsx_usb_ms: Use ms_dev() helper Kai-Heng Feng
2018-11-05 8:45 ` [PATCH 5/5 v7] memstick: rtsx_usb_ms: Support runtime power management Kai-Heng Feng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181105084506.6476-4-kai.heng.feng@canonical.com \
--to=kai.heng.feng@canonical.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®