devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Jon Hunter <jonathanh@nvidia.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Kevin Hilman <khilman@kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	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
Subject: Re: [PATCH V6 03/10] PM / Domains: Add function to remove a pm-domain
Date: Mon, 29 Feb 2016 08:15:21 +0100	[thread overview]
Message-ID: <20160229071521.GG23745@ulmo> (raw)
In-Reply-To: <1456501724-28477-4-git-send-email-jonathanh@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]

On Fri, Feb 26, 2016 at 03:48:37PM +0000, Jon Hunter wrote:
> The genpd framework allows users to add power-domains via the
> pm_genpd_init() function, however, there is no corresponding function
> to remove a power-domain. For most devices this may be fine as the power
> domains are never removed, however, for devices that wish to populate
> the power-domains from within a driver, having the ability to remove a
> power domain if the probing of the device fails or the driver is unloaded
> is necessary. Therefore, add a function to remove a power-domain. Please
> note that the power domain can only be removed if there are no devices
> using the power-domain and it is not linked to another domain.

So I guess this introduces a problem not uncommon to other types of
resources. If you remove the driver, even if you fail ->remove() the
module may still go away along with any code associated with it. So
even if the PM domains can't be removed, you can't prevent the module
from going away. That could be somewhat mitigated if we were holding a
module reference count, because then the only way to unload the driver
would be via sysfs (we could prevent that too, which might be the best
way to do this today).

There is work underway to solve this generically, Rafael was working on
this, so I'm not sure we need to add additional infrastructure to the PM
domain code as part of this series. But we may want to mark the Tegra
PMC driver as .suppress_bind_attrs = true, to make sure it can't be
removed.

> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
>  drivers/base/power/domain.c | 31 +++++++++++++++++++++++++++++++
>  include/linux/pm_domain.h   |  5 +++++
>  2 files changed, 36 insertions(+)
> 
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 608bc00655ee..22f6e9d738bf 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1557,6 +1557,37 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
>  }
>  EXPORT_SYMBOL_GPL(pm_genpd_init);
>  
> +/**
> + * pm_genpd_remove - Remove a generic I/O PM domain object.
> + * @genpd: PM domain object to remove.
> + */

Would it be worth noting here that the object is only removed from the
list of domains, but that users are still responsible for freeing any
resources (such as memory) associated with it? It seems like this might
be obvious enough given the usage model of pm_genpd_init(), but it's
something that I noticed missing from the function.

Otherwise this looks fine:

Reviewed-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-02-29  7:15 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 ` [PATCH V6 02/10] PM / Domains: Add function to get the last domain added Jon Hunter
     [not found]   ` <1456501724-28477-3-git-send-email-jonathanh-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-02-29  7:04     ` 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
     [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 [this message]
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 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
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=20160229071521.GG23745@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gnurou@gmail.com \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jonathanh@nvidia.com \
    --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=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;
as well as URLs for NNTP newsgroup(s).