From: Jonghwa Lee <jonghwa3.lee@samsung.com>
To: linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org, rjw@rjwysocki.net, pavel@ucw.cz,
len.brown@intel.com, gregkh@linuxfoundation.org,
cw00.choi@samsung.com, myungjoo.ham@samsung.com,
jy0922.shim@samsung.com, inki.dae@samsung.com,
Jonghwa Lee <jonghwa3.lee@samsung.com>
Subject: [RFC PATCH] PM: Domain: Add flag to assure that device's runtime pm callback is called at once.
Date: Wed, 11 Jun 2014 09:33:20 +0900 [thread overview]
Message-ID: <1402446800-4043-1-git-send-email-jonghwa3.lee@samsung.com> (raw)
When device uses generic pm domain, its own runtime suspend callback will be
executed only when all devices in the same domain are suspended. However, some
device needs sychronized runtime suspend and not to be deffered.
For those devices, Generic pm domain adds new API for adding device with flag,
which shows that it guerantees driver's runtime suspend will be executed right
away not at the time domain is really powered off.
Existed API, pm_genpd_add_device(), now adds device with flag representing this
device is not needed sychrnoized callback. It will work as same as before.
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
---
drivers/base/power/domain.c | 17 ++++++++++++++---
include/linux/pm_domain.h | 19 ++++++++++++++++---
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index ae098a2..6c7a786 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -503,6 +503,9 @@ static int pm_genpd_poweroff(struct generic_pm_domain *genpd)
genpd->poweroff_task = current;
list_for_each_entry_reverse(pdd, &genpd->dev_list, list_node) {
+ if (dev_gpd_data(pdd->dev)->rpmflags & GENPD_RPM_SYNC)
+ continue;
+
ret = atomic_read(&genpd->sd_count) == 0 ?
__pm_genpd_save_device(pdd, genpd) : -EBUSY;
@@ -625,6 +628,9 @@ static int pm_genpd_runtime_suspend(struct device *dev)
if (stop_ok && !stop_ok(dev))
return -EBUSY;
+ if (dev_gpd_data(dev)->rpmflags & GENPD_RPM_SYNC)
+ genpd_save_dev(genpd, dev);
+
ret = genpd_stop_dev(genpd, dev);
if (ret)
return ret;
@@ -1416,7 +1422,7 @@ static void __pm_genpd_free_dev_data(struct device *dev,
* @td: Set of PM QoS timing parameters to attach to the device.
*/
int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
- struct gpd_timing_data *td)
+ struct gpd_timing_data *td, enum genpd_rpmflags flags)
{
struct generic_pm_domain_data *gpd_data_new, *gpd_data = NULL;
struct pm_domain_data *pdd;
@@ -1472,6 +1478,7 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
gpd_data->need_restore = genpd->status == GPD_STATE_POWER_OFF;
gpd_data->td.constraint_changed = true;
gpd_data->td.effective_constraint_ns = -1;
+ gpd_data->rpmflags = flags;
mutex_unlock(&gpd_data->lock);
out:
@@ -1494,6 +1501,7 @@ int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev,
struct gpd_timing_data *td)
{
struct generic_pm_domain *genpd = NULL, *gpd;
+ enum genpd_rpmflags rpmflags;
dev_dbg(dev, "%s()\n", __func__);
@@ -1512,7 +1520,9 @@ int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev,
if (!genpd)
return -EINVAL;
- return __pm_genpd_add_device(genpd, dev, td);
+ rpmflags = of_property_read_bool(dev->of_node, "pm-genpd-rpmsync");
+
+ return __pm_genpd_add_device(genpd, dev, td, rpmflags);
}
@@ -1525,7 +1535,8 @@ int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev,
int __pm_genpd_name_add_device(const char *domain_name, struct device *dev,
struct gpd_timing_data *td)
{
- return __pm_genpd_add_device(pm_genpd_lookup_name(domain_name), dev, td);
+ struct generic_pm_domain *genpd = pm_genpd_lookup_name(domain_name);
+ return __pm_genpd_add_device(genpd, dev, td, GENPD_RPM_ASYNC);
}
/**
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 7c1d252..d36e5cf 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -106,6 +106,11 @@ struct gpd_timing_data {
bool cached_stop_ok;
};
+enum genpd_rpmflags {
+ GENPD_RPM_ASYNC = 0,
+ GENPD_RPM_SYNC,
+};
+
struct generic_pm_domain_data {
struct pm_domain_data base;
struct gpd_dev_ops ops;
@@ -114,6 +119,7 @@ struct generic_pm_domain_data {
struct mutex lock;
unsigned int refcount;
bool need_restore;
+ enum genpd_rpmflags rpmflags;
};
#ifdef CONFIG_PM_GENERIC_DOMAINS
@@ -132,7 +138,8 @@ extern struct dev_power_governor simple_qos_governor;
extern struct generic_pm_domain *dev_to_genpd(struct device *dev);
extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
struct device *dev,
- struct gpd_timing_data *td);
+ struct gpd_timing_data *td,
+ enum genpd_rpmflags flags);
extern int __pm_genpd_of_add_device(struct device_node *genpd_node,
struct device *dev,
@@ -180,7 +187,8 @@ static inline struct generic_pm_domain *dev_to_genpd(struct device *dev)
}
static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd,
struct device *dev,
- struct gpd_timing_data *td)
+ struct gpd_timing_data *td,
+ enum genpd_rpmflags flags);
{
return -ENOSYS;
}
@@ -263,10 +271,15 @@ static inline bool default_stop_ok(struct device *dev)
#define pm_domain_always_on_gov NULL
#endif
+static inline int pm_genpd_add_device_rpmsync(struct generic_pm_domain *genpd,
+ struct device *dev)
+{
+ return __pm_genpd_add_device(genpd, dev, NULL, GENPD_RPM_SYNC);
+}
static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
struct device *dev)
{
- return __pm_genpd_add_device(genpd, dev, NULL);
+ return __pm_genpd_add_device(genpd, dev, NULL, GENPD_RPM_ASYNC);
}
static inline int pm_genpd_of_add_device(struct device_node *genpd_node,
--
1.7.9.5
next reply other threads:[~2014-06-11 0:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 0:33 Jonghwa Lee [this message]
2014-06-11 8:27 ` Ulf Hansson
2014-06-11 10:31 ` jonghwa3.lee
2014-06-11 18:44 ` Rafael J. Wysocki
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=1402446800-4043-1-git-send-email-jonghwa3.lee@samsung.com \
--to=jonghwa3.lee@samsung.com \
--cc=cw00.choi@samsung.com \
--cc=gregkh@linuxfoundation.org \
--cc=inki.dae@samsung.com \
--cc=jy0922.shim@samsung.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=pavel@ucw.cz \
--cc=rjw@rjwysocki.net \
/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®