From: NeilBrown <neil@brown.name>
To: Ulf Hansson <ulf.hansson@linaro.org>,
Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mmc <linux-mmc@vger.kernel.org>
Subject: [PATCH 2/4] mmc/core: add pm_runtime tracking to mmc_host devices.
Date: Wed, 25 Mar 2015 07:56:10 +1100 [thread overview]
Message-ID: <20150324205610.20572.73676.stgit@notabene.brown> (raw)
In-Reply-To: <20150324205316.20572.30538.stgit@notabene.brown>
Enable runtime pm for mmc_host devices, and take a
reference while the host is claimed.
Use an autosuspend timeout so that the device isn't
put to sleep until we have been idle for a while.
Set the parent to ignore children, so the PM status of
the host does not affect the controller at all.
This functionality will be used in a future patch to allow
commands to be sent to the device when the host is idle.
Signed-off-by: NeilBrown <neil@brown.name>
---
drivers/mmc/core/core.c | 5 +++++
drivers/mmc/core/host.c | 23 +++++++++++++++++++++--
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 23f10f72e5f3..ca475a5c8d94 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -900,6 +900,7 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)
might_sleep();
+ pm_runtime_get_sync(&host->class_dev);
add_wait_queue(&host->wq, &wait);
spin_lock_irqsave(&host->lock, flags);
while (1) {
@@ -922,6 +923,8 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)
remove_wait_queue(&host->wq, &wait);
if (host->ops->enable && !stop && host->claim_cnt == 1)
host->ops->enable(host);
+ if (stop)
+ pm_runtime_put(&host->class_dev);
return stop;
}
@@ -953,6 +956,8 @@ void mmc_release_host(struct mmc_host *host)
spin_unlock_irqrestore(&host->lock, flags);
wake_up(&host->wq);
}
+ pm_runtime_mark_last_busy(&host->class_dev);
+ pm_runtime_put_autosuspend(&host->class_dev);
}
EXPORT_SYMBOL(mmc_release_host);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 8be0df758e68..c205c4531b44 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -22,6 +22,7 @@
#include <linux/leds.h>
#include <linux/slab.h>
#include <linux/suspend.h>
+#include <linux/pm_runtime.h>
#include <linux/mmc/host.h>
#include <linux/mmc/card.h>
@@ -490,6 +491,11 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
host->class_dev.parent = dev;
host->class_dev.class = &mmc_host_class;
device_initialize(&host->class_dev);
+ if (dev)
+ /*
+ * The device can sleep even when host is claimed.
+ */
+ pm_suspend_ignore_children(dev, true);
if (mmc_gpio_alloc(host)) {
put_device(&host->class_dev);
@@ -532,15 +538,25 @@ EXPORT_SYMBOL(mmc_alloc_host);
int mmc_add_host(struct mmc_host *host)
{
int err;
+ struct device *dev = &host->class_dev;
WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
!host->ops->enable_sdio_irq);
- err = device_add(&host->class_dev);
+ err = device_add(dev);
if (err)
return err;
+ pm_runtime_enable(dev);
+ /*
+ * The host should be able to suspend while the attached card
+ * stays awake.
+ */
+ pm_suspend_ignore_children(dev, true);
+ pm_runtime_get_sync(dev);
+ pm_runtime_set_autosuspend_delay(dev, 100);
+ pm_runtime_use_autosuspend(dev);
- led_trigger_register_simple(dev_name(&host->class_dev), &host->led);
+ led_trigger_register_simple(dev_name(dev), &host->led);
#ifdef CONFIG_DEBUG_FS
mmc_add_host_debugfs(host);
@@ -550,6 +566,9 @@ int mmc_add_host(struct mmc_host *host)
mmc_start_host(host);
register_pm_notifier(&host->pm_notify);
+ pm_runtime_mark_last_busy(dev);
+ pm_runtime_put_autosuspend(dev);
+
return 0;
}
prev parent reply other threads:[~2015-03-24 21:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-24 20:56 [PATCH/RFC 0/4] Use runtime-pm to switch sdio to 1-bit when idle NeilBrown
2015-03-24 20:56 ` [PATCH 3/4] mmc/sdio: keep device awake when interrupts expected in 4bit mode NeilBrown
2015-03-24 20:56 ` [PATCH 1/4] mmc: core: fold mmc_set_bus_width calls into sdio_enable_4bit_bus NeilBrown
2015-03-24 21:18 ` Ulf Hansson
2015-03-24 20:56 ` [PATCH 4/4] mmc/host: use runtime_pm to switch to 1-bit mode NeilBrown
2015-03-24 20:56 ` NeilBrown [this message]
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=20150324205610.20572.73676.stgit@notabene.brown \
--to=neil@brown.name \
--cc=adrian.hunter@intel.com \
--cc=linux-mmc@vger.kernel.org \
--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