linux-sh.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Linux-sh list <linux-sh@vger.kernel.org>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
	Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
	Magnus Damm <magnus.damm@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [RFC][PATCH 3/4] PM / QoS: Introduce dev_pm_qos_add_ancestor_request()
Date: Fri, 09 Dec 2011 23:45:31 +0000	[thread overview]
Message-ID: <201112100045.31677.rjw@sisk.pl> (raw)
In-Reply-To: <201112100042.45168.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Some devices, like the I2C controller on SH7372, are not
necessary for providing power to their children or forwarding
wakeup signals (and generally interrupts) from them.  They are
only needed by their children when there's some data to transfer,
so they may be suspended for the majority of time and resumed
on demand, when the children have data to send or receive.  For this
purpose, however, their power.ignore_children flags have to be set,
or the PM core wouldn't allow them to be suspended while their
children were active.

Unfortunately, in some situations it may take too much time to
resume such devices so that they can assist their children in
transferring data.  For example, if such a device belongs to a PM
domain which goes to the "power off" state when that device is
suspended, it may take too much time to restore power to the
domain in response to the request from one of the device's
children.  In that case, if the parent's resume time is critical,
the domain should stay in the "power on" state, although it still may
be desirable to power manage the parent itself (e.g. by manipulating
its clock).

In general, device PM QoS may be used to address this problem.
Namely, if the device's children added PM QoS latency constraints
for it, they would be able to prevent it from being put into an
overly deep low-power state.  However, in some cases the devices
needing to be serviced are not the immediate children of a
"children-ignoring" device, but its grandchildren or even less
direct descendants.  In those cases, the entity wanting to add a
PM QoS request for a given device's ancestor that ignores its
children will have to find it in the first place, so introduce a new
helper function that may be used to achieve that.  This function,
dev_pm_qos_add_ancestor_request(), will search for the first
ancestor of the given device whose power.ignore_children flag is
set and will add a device PM QoS latency request for that ancestor
on behalf of the caller.  The request added this way may be removed
with the help of dev_pm_qos_remove_request() in the future, like
any other device PM QoS latency request.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/qos.c |   25 +++++++++++++++++++++++++
 include/linux/pm_qos.h   |    5 +++++
 2 files changed, 30 insertions(+)

Index: linux/drivers/base/power/qos.c
=================================--- linux.orig/drivers/base/power/qos.c
+++ linux/drivers/base/power/qos.c
@@ -420,3 +420,28 @@ int dev_pm_qos_remove_global_notifier(st
 	return blocking_notifier_chain_unregister(&dev_pm_notifiers, notifier);
 }
 EXPORT_SYMBOL_GPL(dev_pm_qos_remove_global_notifier);
+
+/**
+ * dev_pm_qos_add_ancestor_request - Add PM QoS request for device's ancestor.
+ * @dev: Device whose ancestor to add the request for.
+ * @req: Pointer to the preallocated handle.
+ * @value: Constraint latency value.
+ */
+int dev_pm_qos_add_ancestor_request(struct device *dev,
+				    struct dev_pm_qos_request *req, s32 value)
+{
+	struct device *ancestor = dev->parent;
+	int error = -ENODEV;
+
+	while (ancestor && !ancestor->power.ignore_children)
+		ancestor = ancestor->parent;
+
+	if (ancestor)
+		error = dev_pm_qos_add_request(ancestor, req, value);
+
+	if (error)
+		req->dev = NULL;
+
+	return error;
+}
+EXPORT_SYMBOL_GPL(dev_pm_qos_add_ancestor_request);
Index: linux/include/linux/pm_qos.h
=================================--- linux.orig/include/linux/pm_qos.h
+++ linux/include/linux/pm_qos.h
@@ -92,6 +92,8 @@ int dev_pm_qos_add_global_notifier(struc
 int dev_pm_qos_remove_global_notifier(struct notifier_block *notifier);
 void dev_pm_qos_constraints_init(struct device *dev);
 void dev_pm_qos_constraints_destroy(struct device *dev);
+int dev_pm_qos_add_ancestor_request(struct device *dev,
+				    struct dev_pm_qos_request *req, s32 value);
 #else
 static inline int pm_qos_update_target(struct pm_qos_constraints *c,
 				       struct plist_node *node,
@@ -153,6 +155,9 @@ static inline void dev_pm_qos_constraint
 {
 	dev->power.power_state = PMSG_INVALID;
 }
+int dev_pm_qos_add_ancestor_request(struct device *dev,
+				    struct dev_pm_qos_request *req, s32 value)
+			{ return 0; }
 #endif
 
 #endif


  parent reply	other threads:[~2011-12-09 23:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 23:42 [RFC][PATCH 0/4] PM / shmobile: Use PM QoS latency constraints in touchscreen driver Rafael J. Wysocki
2011-12-09 23:43 ` [RFC][PATCH 1/4] PM / shmobile: Don't include SH7372's INTCS in syscore suspend/resume Rafael J. Wysocki
2011-12-09 23:44 ` [RFC][PATCH 2/4] PM / shmobile: Remove the stay_on flag from SH7372's PM domains Rafael J. Wysocki
2011-12-09 23:45 ` Rafael J. Wysocki [this message]
2011-12-09 23:46 ` [RFC][PATCH 4/4] PM / input / touchscreen: Make st1232 use device PM QoS constraints Rafael J. Wysocki
2011-12-12 14:34   ` [RFC][PATCH 4/4] PM / input / touchscreen: Make st1232 use device Guennadi Liakhovetski
2011-12-16  0:10 ` [Update][PATCH 0/5] PM / shmobile: Use PM QoS latency constraints in touchscreen driver on SH7372 Rafael J. Wysocki
2011-12-16  0:11   ` [Update][PATCH 1/5] PM / shmobile: Don't include SH7372's INTCS in syscore suspend/resume Rafael J. Wysocki
2011-12-16  0:12   ` [Update][PATCH 2/5] PM / shmobile: Remove the stay_on flag from SH7372's PM domains Rafael J. Wysocki
2011-12-16  0:12   ` [Update][PATCH 3/5] PM / QoS: Introduce dev_pm_qos_add_ancestor_request() Rafael J. Wysocki
2011-12-16  0:13   ` [Update][PATCH 4/5] PM / input / touchscreen: Make st1232 use device PM QoS constraints Rafael J. Wysocki
2011-12-16  0:16   ` [Update][PATCH 5/5] PM / shmobile: Allow the A4R domain to be turned off at run time 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=201112100045.31677.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).