All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@kernel.org>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tomasz Figa <tomasz.figa@gmail.com>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>,
	Ben Dooks <ben-linux@fluff.org>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Philipp Zabel <philipp.zabel@gmail.com>,
	Mark Brown <broonie@kernel.org>, Wolfram Sang <wsa@the-dreams.de>,
	Russell King <linux@arm.linux.org.uk>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jack Dai <jack.dai@rock-chips.com>,
	Jinkun Hong <jinkun.hong@rock-chips.com>,
	Aaron Lu <aaron.lu@intel.com>,
	Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: Re: [PATCH 3/4] PM / Domains: Improve error handling while adding/removing devices
Date: Wed, 29 Oct 2014 16:57:48 -0700	[thread overview]
Message-ID: <7h38a65szn.fsf@deeprootsystems.com> (raw)
In-Reply-To: <1414507090-516-4-git-send-email-ulf.hansson@linaro.org> (Ulf Hansson's message of "Tue, 28 Oct 2014 15:38:09 +0100")

Ulf Hansson <ulf.hansson@linaro.org> writes:

> To improve error handling while adding/removing devices from their PM
> domains, we need to restructure the code a bit. Let's do this by moving
> the device specific parts into a separate function.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

[...]

> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 9d511c7..4e5fcd7 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1358,25 +1358,81 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
>  
>  #endif /* CONFIG_PM_SLEEP */
>  
> -static struct generic_pm_domain_data *__pm_genpd_alloc_dev_data(struct device *dev)
> +static int genpd_alloc_dev_data(struct generic_pm_domain *genpd,
> +				struct device *dev, struct gpd_timing_data *td)
>  {
>  	struct generic_pm_domain_data *gpd_data;
> +	int ret;
> +
> +	dev_dbg(dev, "%s()\n", __func__);
> +
> +	ret = dev_pm_get_subsys_data(dev);
> +	if (ret)
> +		return ret;
>  
>  	gpd_data = kzalloc(sizeof(*gpd_data), GFP_KERNEL);
> -	if (!gpd_data)
> -		return NULL;
> +	if (!gpd_data) {
> +		ret = -ENOMEM;
> +		goto err_alloc;
> +	}
>  
>  	mutex_init(&gpd_data->lock);
> +	gpd_data->base.dev = dev;
> +	gpd_data->td.constraint_changed = true;
> +	gpd_data->td.effective_constraint_ns = -1;
>  	gpd_data->nb.notifier_call = genpd_dev_pm_qos_notifier;
> +	if (td)
> +		gpd_data->td = *td;
> +
> +	spin_lock_irq(&dev->power.lock);
> +	if (!dev->power.subsys_data->domain_data)
> +		dev->power.subsys_data->domain_data = &gpd_data->base;
> +	else
> +		ret = -EINVAL;
> +	spin_unlock_irq(&dev->power.lock);
> +
> +	if (ret)
> +		goto err_data;
> +
> +	if (genpd->attach_dev)
> +		genpd->attach_dev(dev);

To me, it doesn't seem right that the attach is done in the 'alloc'
function.  IMO, the attach should stay in _add_device()

Kevin

WARNING: multiple messages have this Message-ID (diff)
From: khilman@kernel.org (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] PM / Domains: Improve error handling while adding/removing devices
Date: Wed, 29 Oct 2014 16:57:48 -0700	[thread overview]
Message-ID: <7h38a65szn.fsf@deeprootsystems.com> (raw)
In-Reply-To: <1414507090-516-4-git-send-email-ulf.hansson@linaro.org> (Ulf Hansson's message of "Tue, 28 Oct 2014 15:38:09 +0100")

Ulf Hansson <ulf.hansson@linaro.org> writes:

> To improve error handling while adding/removing devices from their PM
> domains, we need to restructure the code a bit. Let's do this by moving
> the device specific parts into a separate function.
>
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

[...]

> diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
> index 9d511c7..4e5fcd7 100644
> --- a/drivers/base/power/domain.c
> +++ b/drivers/base/power/domain.c
> @@ -1358,25 +1358,81 @@ EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
>  
>  #endif /* CONFIG_PM_SLEEP */
>  
> -static struct generic_pm_domain_data *__pm_genpd_alloc_dev_data(struct device *dev)
> +static int genpd_alloc_dev_data(struct generic_pm_domain *genpd,
> +				struct device *dev, struct gpd_timing_data *td)
>  {
>  	struct generic_pm_domain_data *gpd_data;
> +	int ret;
> +
> +	dev_dbg(dev, "%s()\n", __func__);
> +
> +	ret = dev_pm_get_subsys_data(dev);
> +	if (ret)
> +		return ret;
>  
>  	gpd_data = kzalloc(sizeof(*gpd_data), GFP_KERNEL);
> -	if (!gpd_data)
> -		return NULL;
> +	if (!gpd_data) {
> +		ret = -ENOMEM;
> +		goto err_alloc;
> +	}
>  
>  	mutex_init(&gpd_data->lock);
> +	gpd_data->base.dev = dev;
> +	gpd_data->td.constraint_changed = true;
> +	gpd_data->td.effective_constraint_ns = -1;
>  	gpd_data->nb.notifier_call = genpd_dev_pm_qos_notifier;
> +	if (td)
> +		gpd_data->td = *td;
> +
> +	spin_lock_irq(&dev->power.lock);
> +	if (!dev->power.subsys_data->domain_data)
> +		dev->power.subsys_data->domain_data = &gpd_data->base;
> +	else
> +		ret = -EINVAL;
> +	spin_unlock_irq(&dev->power.lock);
> +
> +	if (ret)
> +		goto err_data;
> +
> +	if (genpd->attach_dev)
> +		genpd->attach_dev(dev);

To me, it doesn't seem right that the attach is done in the 'alloc'
function.  IMO, the attach should stay in _add_device()

Kevin

  parent reply	other threads:[~2014-10-29 23:57 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 14:38 [PATCH 0/4] PM / Domains: Handle errors from ->attach_dev() callback Ulf Hansson
2014-10-28 14:38 ` Ulf Hansson
2014-10-28 14:38 ` [PATCH 1/4] PM / Domains: Remove reference counting for the generic_pm_domain_data Ulf Hansson
2014-10-28 14:38   ` Ulf Hansson
2014-10-29 20:44   ` Kevin Hilman
2014-10-29 20:44     ` Kevin Hilman
2014-10-28 14:38 ` [PATCH 2/4] PM / Domains: Don't allow an existing generic PM domain data Ulf Hansson
2014-10-28 14:38   ` Ulf Hansson
2014-10-29 22:28   ` Kevin Hilman
2014-10-29 22:28     ` Kevin Hilman
2014-10-28 14:38 ` [PATCH 3/4] PM / Domains: Improve error handling while adding/removing devices Ulf Hansson
2014-10-28 14:38   ` Ulf Hansson
2014-10-29 23:53   ` Kevin Hilman
2014-10-29 23:53     ` Kevin Hilman
2014-10-30 11:27     ` Ulf Hansson
2014-10-30 11:27       ` Ulf Hansson
2014-10-29 23:57   ` Kevin Hilman [this message]
2014-10-29 23:57     ` Kevin Hilman
2014-10-30 11:25     ` Ulf Hansson
2014-10-30 11:25       ` Ulf Hansson
2014-11-05  7:47   ` Geert Uytterhoeven
2014-11-05  7:47     ` Geert Uytterhoeven
2014-11-05  8:03     ` Ulf Hansson
2014-11-05  8:03       ` Ulf Hansson
2014-10-28 14:38 ` [PATCH 4/4] PM / Domains: Let the ->attach_dev() callback return an error code Ulf Hansson
2014-10-28 14:38   ` Ulf Hansson
2014-10-28 20:31   ` Geert Uytterhoeven
2014-10-28 20:31     ` Geert Uytterhoeven
2014-10-29  9:26     ` Ulf Hansson
2014-10-29  9:26       ` Ulf Hansson
2014-10-29  9:32       ` Geert Uytterhoeven
2014-10-29  9:32         ` Geert Uytterhoeven
2014-10-29 10:14         ` Ulf Hansson
2014-10-29 10:14           ` Ulf Hansson
2014-10-29 10:28           ` Geert Uytterhoeven
2014-10-29 10:28             ` Geert Uytterhoeven
2014-10-29 21:10     ` Kevin Hilman
2014-10-29 21:10       ` Kevin Hilman
2014-10-29 21:18       ` Geert Uytterhoeven
2014-10-29 21:18         ` Geert Uytterhoeven
2014-10-30 11:34       ` Ulf Hansson
2014-10-30 11:34         ` 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=7h38a65szn.fsf@deeprootsystems.com \
    --to=khilman@kernel.org \
    --cc=aaron.lu@intel.com \
    --cc=ben-linux@fluff.org \
    --cc=broonie@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=jack.dai@rock-chips.com \
    --cc=jinkun.hong@rock-chips.com \
    --cc=kgene.kim@samsung.com \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=magnus.damm@gmail.com \
    --cc=pavel@ucw.cz \
    --cc=philipp.zabel@gmail.com \
    --cc=rjw@rjwysocki.net \
    --cc=s.nawrocki@samsung.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tomasz.figa@gmail.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa@the-dreams.de \
    /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.