All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Kevin Hilman <khilman@kernel.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Kukjin Kim <kgene@kernel.org>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Alexander Aring <alex.aring@gmail.com>,
	Eric Anholt <eric@anholt.net>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH V2 08/10] PM / Domains: Store the provider in the PM domain structure
Date: Mon, 12 Sep 2016 14:56:18 +0200	[thread overview]
Message-ID: <CAPDyKFr-Y6024XK8EzXox6L0EkHXg6tsa0bAmCe-QA1OFfwo+w@mail.gmail.com> (raw)
In-Reply-To: <1473678074-15126-9-git-send-email-jonathanh@nvidia.com>

On 12 September 2016 at 13:01, Jon Hunter <jonathanh@nvidia.com> wrote:
> It is possible that a device has more than one provider of PM domains
> and to support the removal of a PM domain by provider, it is necessary
> to store a reference to the provider in the PM domain structure.
> Therefore, store a reference to the firmware node handle in the PM
> domain structure and populate it when providers (only device-tree based
> providers are currently supported by PM domains) are registered.
>
> Please note that when removing PM domains, it is necessary to verify
> that the PM domain provider has been removed from the list of providers
> before the PM domain can be removed. To do this add another member to
> the PM domain structure that indicates if the provider is present and
> set this member accordingly when providers are added and removed.
>
> Initialise the 'provider' and 'has_provider' members of the
> generic_pm_domain structure when a PM domains is added by calling
> pm_genpd_init().
>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/base/power/domain.c | 42 +++++++++++++++++++++++++++++++++++++-----
>  include/linux/pm_domain.h   |  2 ++
>  2 files changed, 39 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 1bd8d412db06..d5135caa84db 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1306,6 +1306,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
>         genpd->device_count = 0;
>         genpd->max_off_time_ns = -1;
>         genpd->max_off_time_changed = true;
> +       genpd->provider = NULL;
> +       genpd->has_provider = false;
>         genpd->domain.ops.runtime_suspend = genpd_runtime_suspend;
>         genpd->domain.ops.runtime_resume = genpd_runtime_resume;
>         genpd->domain.ops.prepare = pm_genpd_prepare;
> @@ -1491,6 +1493,11 @@ int of_genpd_add_provider_simple(struct device_node *np,
>         if (pm_genpd_present(genpd))
>                 ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
>
> +       if (!ret) {
> +               genpd->provider = &np->fwnode;
> +               genpd->has_provider = true;
> +       }
> +
>         mutex_unlock(&gpd_list_lock);
>
>         return ret;
> @@ -1506,7 +1513,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>                                   struct genpd_onecell_data *data)
>  {
>         unsigned int i;
> -       int ret;
> +       int ret = -EINVAL;
>
>         if (!np || !data)
>                 return -EINVAL;
> @@ -1514,13 +1521,26 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>         mutex_lock(&gpd_list_lock);
>
>         for (i = 0; i < data->num_domains; i++) {
> -               if (!pm_genpd_present(data->domains[i])) {
> -                       mutex_unlock(&gpd_list_lock);
> -                       return -EINVAL;
> -               }
> +               if (!pm_genpd_present(data->domains[i]))
> +                       goto error;
> +
> +               data->domains[i]->provider = &np->fwnode;
> +               data->domains[i]->has_provider = true;
>         }
>
>         ret = genpd_add_provider(np, genpd_xlate_onecell, data);
> +       if (ret < 0)
> +               goto error;
> +
> +       mutex_unlock(&gpd_list_lock);
> +
> +       return 0;
> +
> +error:
> +       while (i--) {
> +               data->domains[i]->provider = NULL;
> +               data->domains[i]->has_provider = false;
> +       }
>
>         mutex_unlock(&gpd_list_lock);
>
> @@ -1535,10 +1555,21 @@ EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell);
>  void of_genpd_del_provider(struct device_node *np)
>  {
>         struct of_genpd_provider *cp;
> +       struct generic_pm_domain *gpd;
>
> +       mutex_lock(&gpd_list_lock);
>         mutex_lock(&of_genpd_mutex);
>         list_for_each_entry(cp, &of_genpd_providers, link) {
>                 if (cp->node == np) {
> +                       /*
> +                        * For each PM domain associated with the
> +                        * provider, set the 'has_provider' to false
> +                        * so that the PM domain can be safely removed.
> +                        */
> +                       list_for_each_entry(gpd, &gpd_list, gpd_list_node)
> +                               if (gpd->provider == &np->fwnode)
> +                                       gpd->has_provider = false;
> +
>                         list_del(&cp->link);
>                         of_node_put(cp->node);
>                         kfree(cp);
> @@ -1546,6 +1577,7 @@ void of_genpd_del_provider(struct device_node *np)
>                 }
>         }
>         mutex_unlock(&of_genpd_mutex);
> +       mutex_unlock(&gpd_list_lock);
>  }
>  EXPORT_SYMBOL_GPL(of_genpd_del_provider);
>
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index f103869db443..554f8915c691 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -51,6 +51,8 @@ struct generic_pm_domain {
>         struct mutex lock;
>         struct dev_power_governor *gov;
>         struct work_struct power_off_work;
> +       struct fwnode_handle *provider; /* Identity of the domain provider */
> +       bool has_provider;
>         const char *name;
>         atomic_t sd_count;      /* Number of subdomains with power "on" */
>         enum gpd_status status; /* Current state of the domain */
> --
> 2.1.4
>

WARNING: multiple messages have this Message-ID (diff)
From: ulf.hansson@linaro.org (Ulf Hansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 08/10] PM / Domains: Store the provider in the PM domain structure
Date: Mon, 12 Sep 2016 14:56:18 +0200	[thread overview]
Message-ID: <CAPDyKFr-Y6024XK8EzXox6L0EkHXg6tsa0bAmCe-QA1OFfwo+w@mail.gmail.com> (raw)
In-Reply-To: <1473678074-15126-9-git-send-email-jonathanh@nvidia.com>

On 12 September 2016 at 13:01, Jon Hunter <jonathanh@nvidia.com> wrote:
> It is possible that a device has more than one provider of PM domains
> and to support the removal of a PM domain by provider, it is necessary
> to store a reference to the provider in the PM domain structure.
> Therefore, store a reference to the firmware node handle in the PM
> domain structure and populate it when providers (only device-tree based
> providers are currently supported by PM domains) are registered.
>
> Please note that when removing PM domains, it is necessary to verify
> that the PM domain provider has been removed from the list of providers
> before the PM domain can be removed. To do this add another member to
> the PM domain structure that indicates if the provider is present and
> set this member accordingly when providers are added and removed.
>
> Initialise the 'provider' and 'has_provider' members of the
> generic_pm_domain structure when a PM domains is added by calling
> pm_genpd_init().
>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
>  drivers/base/power/domain.c | 42 +++++++++++++++++++++++++++++++++++++-----
>  include/linux/pm_domain.h   |  2 ++
>  2 files changed, 39 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 1bd8d412db06..d5135caa84db 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1306,6 +1306,8 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
>         genpd->device_count = 0;
>         genpd->max_off_time_ns = -1;
>         genpd->max_off_time_changed = true;
> +       genpd->provider = NULL;
> +       genpd->has_provider = false;
>         genpd->domain.ops.runtime_suspend = genpd_runtime_suspend;
>         genpd->domain.ops.runtime_resume = genpd_runtime_resume;
>         genpd->domain.ops.prepare = pm_genpd_prepare;
> @@ -1491,6 +1493,11 @@ int of_genpd_add_provider_simple(struct device_node *np,
>         if (pm_genpd_present(genpd))
>                 ret = genpd_add_provider(np, genpd_xlate_simple, genpd);
>
> +       if (!ret) {
> +               genpd->provider = &np->fwnode;
> +               genpd->has_provider = true;
> +       }
> +
>         mutex_unlock(&gpd_list_lock);
>
>         return ret;
> @@ -1506,7 +1513,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>                                   struct genpd_onecell_data *data)
>  {
>         unsigned int i;
> -       int ret;
> +       int ret = -EINVAL;
>
>         if (!np || !data)
>                 return -EINVAL;
> @@ -1514,13 +1521,26 @@ int of_genpd_add_provider_onecell(struct device_node *np,
>         mutex_lock(&gpd_list_lock);
>
>         for (i = 0; i < data->num_domains; i++) {
> -               if (!pm_genpd_present(data->domains[i])) {
> -                       mutex_unlock(&gpd_list_lock);
> -                       return -EINVAL;
> -               }
> +               if (!pm_genpd_present(data->domains[i]))
> +                       goto error;
> +
> +               data->domains[i]->provider = &np->fwnode;
> +               data->domains[i]->has_provider = true;
>         }
>
>         ret = genpd_add_provider(np, genpd_xlate_onecell, data);
> +       if (ret < 0)
> +               goto error;
> +
> +       mutex_unlock(&gpd_list_lock);
> +
> +       return 0;
> +
> +error:
> +       while (i--) {
> +               data->domains[i]->provider = NULL;
> +               data->domains[i]->has_provider = false;
> +       }
>
>         mutex_unlock(&gpd_list_lock);
>
> @@ -1535,10 +1555,21 @@ EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell);
>  void of_genpd_del_provider(struct device_node *np)
>  {
>         struct of_genpd_provider *cp;
> +       struct generic_pm_domain *gpd;
>
> +       mutex_lock(&gpd_list_lock);
>         mutex_lock(&of_genpd_mutex);
>         list_for_each_entry(cp, &of_genpd_providers, link) {
>                 if (cp->node == np) {
> +                       /*
> +                        * For each PM domain associated with the
> +                        * provider, set the 'has_provider' to false
> +                        * so that the PM domain can be safely removed.
> +                        */
> +                       list_for_each_entry(gpd, &gpd_list, gpd_list_node)
> +                               if (gpd->provider == &np->fwnode)
> +                                       gpd->has_provider = false;
> +
>                         list_del(&cp->link);
>                         of_node_put(cp->node);
>                         kfree(cp);
> @@ -1546,6 +1577,7 @@ void of_genpd_del_provider(struct device_node *np)
>                 }
>         }
>         mutex_unlock(&of_genpd_mutex);
> +       mutex_unlock(&gpd_list_lock);
>  }
>  EXPORT_SYMBOL_GPL(of_genpd_del_provider);
>
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index f103869db443..554f8915c691 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -51,6 +51,8 @@ struct generic_pm_domain {
>         struct mutex lock;
>         struct dev_power_governor *gov;
>         struct work_struct power_off_work;
> +       struct fwnode_handle *provider; /* Identity of the domain provider */
> +       bool has_provider;
>         const char *name;
>         atomic_t sd_count;      /* Number of subdomains with power "on" */
>         enum gpd_status status; /* Current state of the domain */
> --
> 2.1.4
>

  reply	other threads:[~2016-09-12 12:56 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 11:01 [PATCH V2 00/10] PM / Domains: Add support for removing PM domains Jon Hunter
2016-09-12 11:01 ` Jon Hunter
2016-09-12 11:01 ` [PATCH V2 03/10] staging: board: Remove calls to of_genpd_get_from_provider() Jon Hunter
2016-09-12 11:01   ` Jon Hunter
     [not found] ` <1473678074-15126-1-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-09-12 11:01   ` [PATCH V2 01/10] PM / Domains: Add new helper functions for device-tree Jon Hunter
2016-09-12 11:01     ` Jon Hunter
2016-09-12 11:01   ` [PATCH V2 02/10] ARM: EXYNOS: Remove calls to of_genpd_get_from_provider() Jon Hunter
2016-09-12 11:01     ` Jon Hunter
2016-09-12 11:01   ` [PATCH V2 04/10] PM / Domains: Don't expose generic_pm_domain structure to clients Jon Hunter
2016-09-12 11:01     ` Jon Hunter
2016-09-12 11:01   ` [PATCH V2 06/10] PM / Domains: Verify the PM domain is present when adding a provider Jon Hunter
2016-09-12 11:01     ` Jon Hunter
2016-09-12 11:01   ` [PATCH V2 07/10] PM / Domains: Prepare for adding support to remove PM domains Jon Hunter
2016-09-12 11:01     ` Jon Hunter
2016-09-12 11:01   ` [PATCH V2 08/10] PM / Domains: Store the provider in the PM domain structure Jon Hunter
2016-09-12 11:01     ` Jon Hunter
2016-09-12 12:56     ` Ulf Hansson [this message]
2016-09-12 12:56       ` Ulf Hansson
2016-09-12 11:01   ` [PATCH V2 09/10] PM / Domains: Add support for removing PM domains Jon Hunter
2016-09-12 11:01     ` Jon Hunter
     [not found]     ` <1473678074-15126-10-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-09-12 12:56       ` Ulf Hansson
2016-09-12 12:56         ` Ulf Hansson
2016-09-12 11:01   ` [PATCH V2 10/10] PM / Domains: Add support for removing nested PM domains by provider Jon Hunter
2016-09-12 11:01     ` Jon Hunter
     [not found]     ` <1473678074-15126-11-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-09-12 12:56       ` Ulf Hansson
2016-09-12 12:56         ` Ulf Hansson
2016-09-12 13:02   ` [PATCH V2 00/10] PM / Domains: Add support for removing PM domains Ulf Hansson
2016-09-12 13:02     ` Ulf Hansson
     [not found]     ` <CAPDyKFqd6vH=eCKBSQg0Q5w9x8sd0SiZ42E7yJn6ZDWP1OMuZg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-09-12 13:45       ` Rafael J. Wysocki
2016-09-12 13:45         ` Rafael J. Wysocki
2016-09-12 11:01 ` [PATCH V2 05/10] PM / Domains: Don't expose xlate and provider helper functions Jon Hunter
2016-09-12 11:01   ` Jon Hunter
2016-09-14  0:58 ` [PATCH V2 00/10] PM / Domains: Add support for removing PM domains Rafael J. Wysocki
2016-09-14  0:58   ` 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=CAPDyKFr-Y6024XK8EzXox6L0EkHXg6tsa0bAmCe-QA1OFfwo+w@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=alex.aring@gmail.com \
    --cc=eric@anholt.net \
    --cc=jonathanh@nvidia.com \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene@kernel.org \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=thierry.reding@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 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.