From: Jon Hunter <jonathanh@nvidia.com>
To: Rafael Wysocki <rjw@rjwysocki.net>,
Ulf Hansson <ulf.hansson@linaro.org>,
Kevin Hilman <khilman@kernel.org>
Cc: linux-pm@vger.kernel.org
Subject: Re: [PATCH] PM / Domains: Return -EPROBE_DEFER if we fail to init or turn-on domain
Date: Fri, 31 Jul 2015 10:19:06 +0100 [thread overview]
Message-ID: <55BB3D8A.2010101@nvidia.com> (raw)
In-Reply-To: <1438334216-26308-1-git-send-email-jonathanh@nvidia.com>
Ugh ... forgot to mark this as a V2! Will resend for clarity ...
On 31/07/15 10:16, Jon Hunter wrote:
> When a device is probed, the function dev_pm_domain_attach() is called
> to see if there is a power-domain that is associated with the device and
> needs to be turned on. If dev_pm_domain_attach() does not return
> -EPROBE_DEFER then the device will be probed.
>
> For devices using genpd, dev_pm_domain_attach() will call
> genpd_dev_pm_attach(). If genpd_dev_pm_attach() does not find a power
> domain associated with the device then it returns an error code not
> equal to -EPROBE_DEFER to allow the device to be probed. However, if
> genpd_dev_pm_attach() does find a power-domain that is associated with
> the device, then it does not return -EPROBE_DEFER on failure and hence
> the device will still be probed. Furthermore, genpd_dev_pm_attach() does
> not check the error code returned by pm_genpd_poweron() to see if the
> power-domain was turned on successfully.
>
> Fix this by checking the return code from pm_genpd_poweron() and
> returning -EPROBE_DEFER from genpd_dev_pm_attach on failure, if there
> is a power-domain associated with the device.
>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
> Acked-by: Kevin Hilman <khilman@linaro.org>
> ---
> drivers/base/power/domain.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index a1abe16dfe16..7666a1cbaf95 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1947,7 +1947,10 @@ static void genpd_dev_pm_sync(struct device *dev)
> * Both generic and legacy Samsung-specific DT bindings are supported to keep
> * backwards compatibility with existing DTBs.
> *
> - * Returns 0 on successfully attached PM domain or negative error code.
> + * Returns 0 on successfully attached PM domain or negative error code. Note
> + * that if a power-domain exists for the device, but it cannot be found or
> + * turned on, then return -EPROBE_DEFER to ensure that the device is not
> + * probed and to re-try again later.
> */
> int genpd_dev_pm_attach(struct device *dev)
> {
> @@ -1984,7 +1987,7 @@ int genpd_dev_pm_attach(struct device *dev)
> dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
> __func__, PTR_ERR(pd));
> of_node_put(dev->of_node);
> - return PTR_ERR(pd);
> + return -EPROBE_DEFER;
> }
>
> dev_dbg(dev, "adding to PM domain %s\n", pd->name);
> @@ -2002,14 +2005,15 @@ int genpd_dev_pm_attach(struct device *dev)
> dev_err(dev, "failed to add to PM domain %s: %d",
> pd->name, ret);
> of_node_put(dev->of_node);
> - return ret;
> + goto out;
> }
>
> dev->pm_domain->detach = genpd_dev_pm_detach;
> dev->pm_domain->sync = genpd_dev_pm_sync;
> - pm_genpd_poweron(pd);
> + ret = pm_genpd_poweron(pd);
>
> - return 0;
> +out:
> + return ret ? -EPROBE_DEFER : 0;
> }
> EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
> #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
>
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
next prev parent reply other threads:[~2015-07-31 9:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-31 9:16 [PATCH] PM / Domains: Return -EPROBE_DEFER if we fail to init or turn-on domain Jon Hunter
2015-07-31 9:19 ` Jon Hunter [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-07-28 8:04 Jon Hunter
2015-07-30 23:28 ` Kevin Hilman
2015-07-31 9:20 ` 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=55BB3D8A.2010101@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=khilman@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--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).