Re: [PATCH V6 03/10] PM / Domains: Add function to remove a pm-domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux