All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jon Hunter <jonathanh@nvidia.com>
To: Stephen Warren <swarren@wwwdotorg.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Alexandre Courbot <gnurou@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Kevin Hilman <khilman@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, Jon Hunter <jonathanh@nvidia.com>
Subject: [PATCH V6 02/10] PM / Domains: Add function to get the last domain added
Date: Fri, 26 Feb 2016 15:48:36 +0000	[thread overview]
Message-ID: <1456501724-28477-3-git-send-email-jonathanh@nvidia.com> (raw)
In-Reply-To: <1456501724-28477-1-git-send-email-jonathanh@nvidia.com>

To remove generic PM domains in a sane way, we need to remove them by
starting from the last PM domain added. The reason for this is that a PM
domain may be a subdomain of another and so we need to remove the child
PM domains for a given domain first. By removing PM domains in reverse
order we can ensure that the children are removed first.

Add a new function to get the last PM domain that was added. In case PM
domains are added by more than one device in the system (for example,
on-chip domains and off-chip domains) add a 'owner' device structure
to the generic PM domain structure so that the ownership of a PM domain
can be identified by the device structure of the device that added it
Use this 'owner' device structure to return the last PM domain added by
this device.

Note that because pm_genpd_init() simply adds each PM domain to the
head of the gpd_list object, list_for_each_entry() will start from the
last PM domain added.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
This is the outcome from a discussion I had with Ulf on how best to
handle the removal of power-domains [0]. I opted to call the device
structure 'owner' because 'parent' could be misleading if a power
domain is a child of another power domain. However, open to suggestions!

[0] http://marc.info/?l=linux-pm&m=145460070816340&w=2

 drivers/base/power/domain.c | 25 +++++++++++++++++++++++++
 include/linux/pm_domain.h   |  7 +++++++
 2 files changed, 32 insertions(+)

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index ea9f2aa3fc33..608bc00655ee 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -65,6 +65,31 @@ struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev)
 }
 
 /*
+ * Get the last generic PM domain added whose 'owner' device structure
+ * matches the device structure provided. The 'owner' device structure
+ * for a given PM domain should be initialised by the device that is
+ * creating the PM domains and hence, calling pm_genpd_init().
+ */
+struct generic_pm_domain *pm_genpd_list_get_tail(struct device *dev)
+{
+	struct generic_pm_domain *genpd = NULL, *gpd;
+
+	if (IS_ERR_OR_NULL(dev))
+		return NULL;
+
+	mutex_lock(&gpd_list_lock);
+	list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
+		if (gpd->owner == dev) {
+			genpd = gpd;
+			break;
+		}
+	}
+	mutex_unlock(&gpd_list_lock);
+
+	return genpd;
+}
+
+/*
  * This should only be used where we are certain that the pm_domain
  * attached to the device is a genpd domain.
  */
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 49cd8890b873..b38dd74dea9b 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -46,6 +46,7 @@ struct genpd_power_state {
 
 struct generic_pm_domain {
 	struct dev_pm_domain domain;	/* PM domain operations */
+	struct device *owner;		/* Identity of the domain owner */
 	struct list_head gpd_list_node;	/* Node in the global PM domains list */
 	struct list_head master_links;	/* Links with PM domain as a master */
 	struct list_head slave_links;	/* Links with PM domain as a slave */
@@ -120,6 +121,7 @@ static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
 }
 
 extern struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev);
+extern struct generic_pm_domain *pm_genpd_list_get_tail(struct device *dev);
 extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
 				 struct device *dev,
 				 struct gpd_timing_data *td);
@@ -145,6 +147,11 @@ static inline struct generic_pm_domain *pm_genpd_lookup_dev(struct device *dev)
 {
 	return NULL;
 }
+static inline
+struct generic_pm_domain *pm_genpd_list_get_tail(struct device *dev)
+{
+	return NULL;
+}
 static inline int __pm_genpd_add_device(struct generic_pm_domain *genpd,
 					struct device *dev,
 					struct gpd_timing_data *td)
-- 
2.1.4


  reply	other threads:[~2016-02-26 15:48 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 15:48 [PATCH V6 00/10] Add generic PM domain support for Tegra Jon Hunter
2016-02-26 15:48 ` Jon Hunter [this message]
     [not found]   ` <1456501724-28477-3-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29  7:04     ` [PATCH V6 02/10] PM / Domains: Add function to get the last domain added Thierry Reding
2016-02-29 13:32   ` Ulf Hansson
2016-02-26 15:48 ` [PATCH V6 05/10] Documentation: DT: bindings: Add power domain info for NVIDIA PMC Jon Hunter
     [not found]   ` <1456501724-28477-6-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29  7:22     ` Thierry Reding
2016-02-29 10:37       ` Jon Hunter
     [not found]         ` <56D41F60.6010504-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29 11:01           ` Thierry Reding
2016-03-01 11:36             ` Jon Hunter
2016-02-26 15:48 ` [PATCH V6 07/10] soc: tegra: pmc: Add generic PM domain support Jon Hunter
     [not found]   ` <1456501724-28477-8-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-03-02  0:18     ` Kevin Hilman
     [not found] ` <1456501724-28477-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-26 15:48   ` [PATCH V6 01/10] PM / Domains: Fix removal of a subdomain Jon Hunter
     [not found]     ` <1456501724-28477-2-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29  6:58       ` Thierry Reding
2016-02-29 12:13       ` Ulf Hansson
2016-02-26 15:48   ` [PATCH V6 03/10] PM / Domains: Add function to remove a pm-domain Jon Hunter
2016-02-29  7:15     ` Thierry Reding
2016-02-29 10:14       ` Jon Hunter
     [not found]         ` <56D41A17.20008-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29 13:10           ` Jon Hunter
2016-02-29 13:45     ` Ulf Hansson
2016-02-26 15:48   ` [PATCH V6 04/10] Documentation: DT: bindings: Update NVIDIA PMC for Tegra Jon Hunter
2016-03-02 17:02     ` Thierry Reding
2016-02-26 15:48   ` [PATCH V6 06/10] soc: tegra: pmc: Wait for powergate state to change Jon Hunter
     [not found]     ` <1456501724-28477-7-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29  7:24       ` Thierry Reding
2016-02-29 10:38         ` Jon Hunter
2016-02-29 12:14       ` Thierry Reding
2016-02-26 15:48   ` [PATCH V6 08/10] soc: tegra: pmc: Move powergate definitions to dt-bindings Jon Hunter
2016-02-26 15:48   ` [PATCH V6 09/10] ARM64: tegra: select PM_GENERIC_DOMAINS Jon Hunter
     [not found]     ` <1456501724-28477-10-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29 13:48       ` Ulf Hansson
2016-02-26 15:48 ` [PATCH V6 10/10] ARM64: tegra: Add audio PM domain device node for Tegra210 Jon Hunter
2016-02-29  7:30   ` Thierry Reding
2016-02-29 10:41     ` Jon Hunter
2016-02-29 10:54       ` Thierry Reding
2016-03-02 15:35 ` [PATCH V6 00/10] Add generic PM domain support for Tegra Thierry Reding
     [not found]   ` <20160302153556.GB21035-AwZRO8vwLAwmlAP/+Wk3EA@public.gmane.org>
2016-03-02 19:36     ` Kevin Hilman
     [not found]       ` <7h7fhk3c4o.fsf-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2016-03-02 23:07         ` Rafael J. Wysocki
2016-03-03  3:22           ` Kevin Hilman
     [not found]             ` <7h7fhkxn1r.fsf-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2016-03-03 11:47               ` Jon Hunter
2016-03-07 13:32                 ` Jon Hunter

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=1456501724-28477-3-git-send-email-jonathanh@nvidia.com \
    --to=jonathanh@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gnurou@gmail.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=khilman@kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.