From: jonathanh@nvidia.com (Jon Hunter)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 8/9] PM / Domains: Add support for multi PM domains per device to genpd
Date: Wed, 30 May 2018 17:04:37 +0100 [thread overview]
Message-ID: <a53f0970-22c4-444f-10e6-c115a21d05ea@nvidia.com> (raw)
In-Reply-To: <20180529100421.31022-9-ulf.hansson@linaro.org>
On 29/05/18 11:04, Ulf Hansson wrote:
> To support devices being partitioned across multiple PM domains, let's
> begin with extending genpd to cope with these kind of configurations.
>
> Therefore, add a new exported function genpd_dev_pm_attach_by_id(), which
> is similar to the existing genpd_dev_pm_attach(), but with the difference
> that it allows its callers to provide an index to the PM domain that it
> wants to attach.
>
> Note that, genpd_dev_pm_attach_by_id() shall only be called by the driver
> core / PM core, similar to how the existing dev_pm_domain_attach() makes
> use of genpd_dev_pm_attach(). However, this is implemented by following
> changes on top.
>
> Because, only one PM domain can be attached per device, genpd needs to
> create a virtual device that it can attach/detach instead. More precisely,
> let the new function genpd_dev_pm_attach_by_id() register a virtual struct
> device via calling device_register(). Then let it attach this device to the
> corresponding PM domain, rather than the one that is provided by the
> caller. The actual attaching is done via re-using the existing genpd OF
> functions.
>
> At successful attachment, genpd_dev_pm_attach_by_id() returns the created
> virtual device, which allows the caller to operate on it to deal with power
> management. Following changes on top, provides more details in this
> regards.
>
> To deal with detaching of a PM domain for the multiple PM domains case,
> let's also extend the existing genpd_dev_pm_detach() function, to cover the
> cleanup of the created virtual device, via make it call device_unregister()
> on it. In this way, there is no need to introduce a new function to deal
> with detach for the multiple PM domain case, but instead the existing one
> is re-used.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>
> Changes in v2:
> - Fixed comments from Jon. Clarified function descriptions
> and changelog.
>
> ---
> drivers/base/power/domain.c | 80 +++++++++++++++++++++++++++++++++++++
> include/linux/pm_domain.h | 8 ++++
> 2 files changed, 88 insertions(+)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 2af99bfcbe3c..2b496d79159d 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -2171,6 +2171,15 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
> }
> EXPORT_SYMBOL_GPL(of_genpd_remove_last);
>
> +static void genpd_release_dev(struct device *dev)
> +{
> + kfree(dev);
> +}
> +
> +static struct bus_type genpd_bus_type = {
> + .name = "genpd",
> +};
> +
> /**
> * genpd_dev_pm_detach - Detach a device from its PM domain.
> * @dev: Device to detach.
> @@ -2208,6 +2217,10 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
>
> /* Check if PM domain can be powered off after removing this device. */
> genpd_queue_power_off_work(pd);
> +
> + /* Unregister the device if it was created by genpd. */
> + if (dev->bus == &genpd_bus_type)
> + device_unregister(dev);
> }
>
> static void genpd_dev_pm_sync(struct device *dev)
> @@ -2298,6 +2311,67 @@ int genpd_dev_pm_attach(struct device *dev)
> }
> EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
>
> +/**
> + * genpd_dev_pm_attach_by_id() - Attach a device to one of its PM domain.
> + * @dev: Device to attach.
Can you update the description of the above as well?
Thanks
Jon
--
nvpublic
next prev parent reply other threads:[~2018-05-30 16:04 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 10:04 [PATCH v2 0/9] PM / Domains: Add support for multi PM domains per device Ulf Hansson
2018-05-29 10:04 ` [PATCH v2 1/9] PM / Domains: Drop extern declarations of functions in pm_domain.h Ulf Hansson
2018-05-31 6:12 ` Viresh Kumar
2018-05-29 10:04 ` [PATCH v2 2/9] PM / Domains: Drop __pm_genpd_add_device() Ulf Hansson
2018-05-31 6:13 ` Viresh Kumar
2018-05-29 10:04 ` [PATCH v2 3/9] PM / Domains: Drop genpd as in-param for pm_genpd_remove_device() Ulf Hansson
2018-05-31 6:15 ` Viresh Kumar
2018-05-29 10:04 ` [PATCH v2 4/9] PM / Domains: Drop unused parameter in genpd_allocate_dev_data() Ulf Hansson
2018-05-31 6:16 ` Viresh Kumar
2018-05-29 10:04 ` [PATCH v2 5/9] PM / Domains: dt: Allow power-domain property to be a list of specifiers Ulf Hansson
2018-05-31 3:53 ` Rob Herring
2018-05-31 6:18 ` Viresh Kumar
2018-05-29 10:04 ` [PATCH v2 6/9] PM / Domains: Don't attach devices in genpd with multi PM domains Ulf Hansson
2018-05-30 16:06 ` Jon Hunter
2018-05-29 10:04 ` [PATCH v2 7/9] PM / Domains: Split genpd_dev_pm_attach() Ulf Hansson
2018-05-30 16:08 ` Jon Hunter
2018-05-31 7:04 ` Viresh Kumar
2018-05-29 10:04 ` [PATCH v2 8/9] PM / Domains: Add support for multi PM domains per device to genpd Ulf Hansson
2018-05-30 16:04 ` Jon Hunter [this message]
2018-05-31 6:17 ` Ulf Hansson
2018-05-31 8:03 ` Jon Hunter
2018-05-31 10:44 ` Ulf Hansson
2018-05-31 10:48 ` Jon Hunter
2018-05-29 10:04 ` [PATCH v2 9/9] PM / Domains: Add dev_pm_domain_attach_by_id() to manage multi PM domains Ulf Hansson
2018-05-30 9:19 ` Jon Hunter
2018-05-30 11:31 ` Ulf Hansson
2018-05-30 14:30 ` Jon Hunter
2018-06-27 8:55 ` Rajendra Nayak
2018-06-27 9:05 ` Ulf Hansson
2018-06-27 9:29 ` Rajendra Nayak
2018-05-30 9:30 ` [PATCH v2 0/9] PM / Domains: Add support for multi PM domains per device Rafael J. Wysocki
2018-05-30 11:34 ` Ulf Hansson
2018-05-31 9:14 ` Viresh Kumar
2018-05-31 10:47 ` Ulf Hansson
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=a53f0970-22c4-444f-10e6-c115a21d05ea@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.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).