All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lina Iyer <lina.iyer@linaro.org>
To: Brendan Jackman <brendan.jackman@arm.com>
Cc: ulf.hansson@linaro.org, khilman@kernel.org, rjw@rjwysocki.net,
	linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	andy.gross@linaro.org, sboyd@codeaurora.org,
	linux-arm-msm@vger.kernel.org,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Subject: Re: [PATCH v2 06/14] PM / cpu_domains: Setup PM domains for CPUs/clusters
Date: Thu, 4 Aug 2016 10:32:16 -0600	[thread overview]
Message-ID: <20160804163216.GD1207@linaro.org> (raw)
In-Reply-To: <20160804155947.GD1732@brendan-thinkstation>

On Thu, Aug 04 2016 at 09:59 -0600, Brendan Jackman wrote:
>Hi Lina,
>
>I spotted a couple more nits..
>
>> +static struct generic_pm_domain *of_init_cpu_pm_domain(struct device_node *dn,
>> +				const struct cpu_pd_ops *ops)
>> +{
>> +	struct cpu_pm_domain *pd = NULL;
>> +	struct generic_pm_domain *genpd = NULL;
>> +	int ret = -ENOMEM;
>> +
>> +	if (!of_device_is_available(dn))
>> +		return ERR_PTR(-ENODEV);
>> +
>> +	genpd = kzalloc(sizeof(*genpd), GFP_KERNEL);
>> +	if (!genpd)
>> +		goto fail;
>> +
>> +	genpd->name = kstrndup(dn->full_name, CPU_PD_NAME_MAX, GFP_KERNEL);
>> +	if (!genpd->name)
>> +		goto fail;
>> +
>> +	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>> +	if (!pd)
>> +		goto fail;
>> +
>> +	if (!zalloc_cpumask_var(&pd->cpus, GFP_KERNEL))
>> +		goto fail;
>> +
>> +	genpd->power_off = cpu_pd_power_off;
>> +	genpd->power_on = cpu_pd_power_on;
>> +	genpd->flags |= GENPD_FLAG_IRQ_SAFE;
>> +	genpd->of_node = dn;
>> +	pd->genpd = genpd;
>> +	pd->ops.power_on = ops->power_on;
>> +	pd->ops.power_off = ops->power_off;
>> +
>> +	INIT_LIST_HEAD_RCU(&pd->link);
>> +	mutex_lock(&cpu_pd_list_lock);
>> +	list_add_rcu(&pd->link, &of_cpu_pd_list);
>> +	mutex_unlock(&cpu_pd_list_lock);
>> +
>> +	/* Populate platform specific states from DT */
>> +	if (ops->populate_state_data) {
>> +		struct device_node *np;
>> +		int i;
>> +
>> +		/* Initialize the arm,idle-state properties */
>> +		ret = pm_genpd_of_parse_power_states(genpd);
>> +		if (ret) {
>> +			pr_warn("%s domain states not initialized (%d)\n",
>> +					dn->full_name, ret);
>> +			goto fail;
>> +		}
>> +		for (i = 0; i < genpd->state_count; i++) {
>> +			np = of_parse_phandle(dn, "domain-idle-states", i);
>> +			ret = ops->populate_state_data(np,
>> +					&genpd->states[i].param);
>> +			of_node_put(np);
>> +			if (ret)
>> +				goto fail;
>> +		}
>> +	}
>
>It seems a bit unfortunate to do of_parse_phandle for "domain-idle-states"
>again, when pm_genpd_of_parse_power_states has just done that. Maybe we could
>could add an `of_node` member to `struct genpd_power_state` and have
>pm_genpd_of_parse_power_states populate that?
>
Hmm.. that could be done.

>> +
>> +	/* Register the CPU genpd */
>> +	pr_debug("adding %s as CPU PM domain\n", pd->genpd->name);
>> +	ret = pm_genpd_init(pd->genpd, &simple_qos_governor, false);
>> +	if (ret) {
>> +		pr_err("Unable to initialize domain %s\n", dn->full_name);
>> +		goto fail;
>> +	}
>> +
>> +	ret = of_genpd_add_provider_simple(dn, pd->genpd);
>> +	if (ret)
>> +		pr_warn("Unable to add genpd %s as provider\n",
>> +				pd->genpd->name);
>> +
>> +	return pd->genpd;
>> +fail:
>> +
>> +	kfree(genpd->name);
>> +	kfree(genpd);
>> +	if (pd)
>> +		kfree(pd->cpus);
>> +	kfree(pd);
>> +	return ERR_PTR(ret);
>> +}
>> +
>
>
>> +int of_setup_cpu_pd_single(int cpu, const struct cpu_pd_ops *ops)
>> +{
>> +
>> +	struct device_node *dn;
>> +	struct generic_pm_domain *genpd;
>> +	struct cpu_pm_domain *cpu_pd;
>> +
>> +	dn = of_get_cpu_node(cpu, NULL);
>> +	if (!dn)
>> +		return -ENODEV;
>
>of_get_cpu_node increments the refcount so we need an of_node_put at some point.
>
>There are loads of instances around the kernel of of_get_cpu_node without
>corresponding of_node_put, though, I could be misunderstanding...
>
It should be done. An easily missed statementr, I suppose.

Thanks for all the nits. This is the best time for that.

Thanks,
Lina

>> +
>> +	dn = of_parse_phandle(dn, "power-domains", 0);
>> +	if (!dn)
>> +		return -ENODEV;
>> +
>> +	/* Find the genpd for this CPU, create if not found */
>> +	genpd = of_get_cpu_domain(dn, ops, cpu);
>> +	if (IS_ERR(genpd))
>> +		return PTR_ERR(genpd);
>> +
>> +	of_node_put(dn);
>> +	cpu_pd = to_cpu_pd(genpd);
>> +	if (!cpu_pd) {
>> +		pr_err("%s: Genpd was created outside CPU PM domains\n",
>> +				__func__);
>> +		return -ENOENT;
>> +	}
>> +
>> +	return cpu_pd_attach_cpu(cpu_pd, cpu);
>> +}
>
>Cheers,
>Brendan

WARNING: multiple messages have this Message-ID (diff)
From: lina.iyer@linaro.org (Lina Iyer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 06/14] PM / cpu_domains: Setup PM domains for CPUs/clusters
Date: Thu, 4 Aug 2016 10:32:16 -0600	[thread overview]
Message-ID: <20160804163216.GD1207@linaro.org> (raw)
In-Reply-To: <20160804155947.GD1732@brendan-thinkstation>

On Thu, Aug 04 2016 at 09:59 -0600, Brendan Jackman wrote:
>Hi Lina,
>
>I spotted a couple more nits..
>
>> +static struct generic_pm_domain *of_init_cpu_pm_domain(struct device_node *dn,
>> +				const struct cpu_pd_ops *ops)
>> +{
>> +	struct cpu_pm_domain *pd = NULL;
>> +	struct generic_pm_domain *genpd = NULL;
>> +	int ret = -ENOMEM;
>> +
>> +	if (!of_device_is_available(dn))
>> +		return ERR_PTR(-ENODEV);
>> +
>> +	genpd = kzalloc(sizeof(*genpd), GFP_KERNEL);
>> +	if (!genpd)
>> +		goto fail;
>> +
>> +	genpd->name = kstrndup(dn->full_name, CPU_PD_NAME_MAX, GFP_KERNEL);
>> +	if (!genpd->name)
>> +		goto fail;
>> +
>> +	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
>> +	if (!pd)
>> +		goto fail;
>> +
>> +	if (!zalloc_cpumask_var(&pd->cpus, GFP_KERNEL))
>> +		goto fail;
>> +
>> +	genpd->power_off = cpu_pd_power_off;
>> +	genpd->power_on = cpu_pd_power_on;
>> +	genpd->flags |= GENPD_FLAG_IRQ_SAFE;
>> +	genpd->of_node = dn;
>> +	pd->genpd = genpd;
>> +	pd->ops.power_on = ops->power_on;
>> +	pd->ops.power_off = ops->power_off;
>> +
>> +	INIT_LIST_HEAD_RCU(&pd->link);
>> +	mutex_lock(&cpu_pd_list_lock);
>> +	list_add_rcu(&pd->link, &of_cpu_pd_list);
>> +	mutex_unlock(&cpu_pd_list_lock);
>> +
>> +	/* Populate platform specific states from DT */
>> +	if (ops->populate_state_data) {
>> +		struct device_node *np;
>> +		int i;
>> +
>> +		/* Initialize the arm,idle-state properties */
>> +		ret = pm_genpd_of_parse_power_states(genpd);
>> +		if (ret) {
>> +			pr_warn("%s domain states not initialized (%d)\n",
>> +					dn->full_name, ret);
>> +			goto fail;
>> +		}
>> +		for (i = 0; i < genpd->state_count; i++) {
>> +			np = of_parse_phandle(dn, "domain-idle-states", i);
>> +			ret = ops->populate_state_data(np,
>> +					&genpd->states[i].param);
>> +			of_node_put(np);
>> +			if (ret)
>> +				goto fail;
>> +		}
>> +	}
>
>It seems a bit unfortunate to do of_parse_phandle for "domain-idle-states"
>again, when pm_genpd_of_parse_power_states has just done that. Maybe we could
>could add an `of_node` member to `struct genpd_power_state` and have
>pm_genpd_of_parse_power_states populate that?
>
Hmm.. that could be done.

>> +
>> +	/* Register the CPU genpd */
>> +	pr_debug("adding %s as CPU PM domain\n", pd->genpd->name);
>> +	ret = pm_genpd_init(pd->genpd, &simple_qos_governor, false);
>> +	if (ret) {
>> +		pr_err("Unable to initialize domain %s\n", dn->full_name);
>> +		goto fail;
>> +	}
>> +
>> +	ret = of_genpd_add_provider_simple(dn, pd->genpd);
>> +	if (ret)
>> +		pr_warn("Unable to add genpd %s as provider\n",
>> +				pd->genpd->name);
>> +
>> +	return pd->genpd;
>> +fail:
>> +
>> +	kfree(genpd->name);
>> +	kfree(genpd);
>> +	if (pd)
>> +		kfree(pd->cpus);
>> +	kfree(pd);
>> +	return ERR_PTR(ret);
>> +}
>> +
>
>
>> +int of_setup_cpu_pd_single(int cpu, const struct cpu_pd_ops *ops)
>> +{
>> +
>> +	struct device_node *dn;
>> +	struct generic_pm_domain *genpd;
>> +	struct cpu_pm_domain *cpu_pd;
>> +
>> +	dn = of_get_cpu_node(cpu, NULL);
>> +	if (!dn)
>> +		return -ENODEV;
>
>of_get_cpu_node increments the refcount so we need an of_node_put at some point.
>
>There are loads of instances around the kernel of of_get_cpu_node without
>corresponding of_node_put, though, I could be misunderstanding...
>
It should be done. An easily missed statementr, I suppose.

Thanks for all the nits. This is the best time for that.

Thanks,
Lina

>> +
>> +	dn = of_parse_phandle(dn, "power-domains", 0);
>> +	if (!dn)
>> +		return -ENODEV;
>> +
>> +	/* Find the genpd for this CPU, create if not found */
>> +	genpd = of_get_cpu_domain(dn, ops, cpu);
>> +	if (IS_ERR(genpd))
>> +		return PTR_ERR(genpd);
>> +
>> +	of_node_put(dn);
>> +	cpu_pd = to_cpu_pd(genpd);
>> +	if (!cpu_pd) {
>> +		pr_err("%s: Genpd was created outside CPU PM domains\n",
>> +				__func__);
>> +		return -ENOENT;
>> +	}
>> +
>> +	return cpu_pd_attach_cpu(cpu_pd, cpu);
>> +}
>
>Cheers,
>Brendan

  reply	other threads:[~2016-08-04 16:32 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-29 21:56 [PATCH v2 00/14] PM: SoC idle support using PM domains Lina Iyer
2016-07-29 21:56 ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 01/14] PM / Domains: Allow domain power states to be read from DT Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-08-04 13:24   ` Brendan Jackman
2016-08-04 13:24     ` Brendan Jackman
2016-08-04 15:08     ` Lina Iyer
2016-08-04 15:08       ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 02/14] dt/bindings: update binding for PM domain idle states Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-08-01 16:30   ` Rob Herring
2016-08-01 16:30     ` Rob Herring
2016-08-01 21:00     ` Lina Iyer
2016-08-01 21:00       ` Lina Iyer
2016-08-04 15:24   ` Brendan Jackman
2016-08-04 15:24     ` Brendan Jackman
2016-08-04 16:28     ` Lina Iyer
2016-08-04 16:28       ` Lina Iyer
2016-08-04 18:15       ` Brendan Jackman
2016-08-04 18:15         ` Brendan Jackman
2016-08-04 19:02         ` Lina Iyer
2016-08-04 19:02           ` Lina Iyer
2016-08-04 21:23       ` Lina Iyer
2016-08-04 21:23         ` Lina Iyer
2016-08-04 15:29   ` Brendan Jackman
2016-08-04 15:29     ` Brendan Jackman
2016-07-29 21:56 ` [PATCH v2 03/14] PM / Domains: Abstract genpd locking Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 04/14] PM / Domains: Support IRQ safe PM domains Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 05/14] PM / doc: update device documentation for devices in " Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 06/14] PM / cpu_domains: Setup PM domains for CPUs/clusters Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-08-04 10:15   ` Brendan Jackman
2016-08-04 10:15     ` Brendan Jackman
2016-08-04 15:06     ` Lina Iyer
2016-08-04 15:06       ` Lina Iyer
2016-08-04 15:59   ` Brendan Jackman
2016-08-04 15:59     ` Brendan Jackman
2016-08-04 16:32     ` Lina Iyer [this message]
2016-08-04 16:32       ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 07/14] ARM: cpuidle: Add runtime PM support for CPUs Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 08/14] timer: Export next wake up of a CPU Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 09/14] PM / cpu_domains: Add PM Domain governor for CPUs Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 10/14] doc / cpu_domains: Describe CPU PM domains setup and governor Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 11/14] drivers: firmware: psci: Allow OS Initiated suspend mode Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 12/14] drivers: firmware: psci: Support cluster idle states for OS-Initiated Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 13/14] ARM64: dts: Add PSCI cpuidle support for MSM8916 Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-07-29 21:56 ` [PATCH v2 14/14] ARM64: dts: Define CPU power domain " Lina Iyer
2016-07-29 21:56   ` Lina Iyer
2016-08-01 14:53   ` Lina Iyer
2016-08-01 14:53     ` Lina Iyer

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=20160804163216.GD1207@linaro.org \
    --to=lina.iyer@linaro.org \
    --cc=andy.gross@linaro.org \
    --cc=brendan.jackman@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=khilman@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=sboyd@codeaurora.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 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.