From: Kevin Hilman <khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
To: Finlye Xiao <finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Cc: mark.rutland-5wv7dgnIgG8@public.gmane.org,
nm-l0cyMroinI0@public.gmane.org,
heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org,
viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tony.xie-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
tim.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
ulysses.huang-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
jay.xu-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org,
wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lin.huang-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org,
sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
rocky.hao-TNX95d0MmH7DzftRWevZcw@public.gmane.org,
dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org
Subject: Re: [PATCH v2 4/4] PM / AVS: rockchip-cpu-avs: add driver handling Rockchip cpu avs
Date: Thu, 18 Aug 2016 14:02:51 -0500 [thread overview]
Message-ID: <m260qxrjc4.fsf@baylibre.com> (raw)
In-Reply-To: <1471510341-63926-5-git-send-email-finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org> (Finlye Xiao's message of "Thu, 18 Aug 2016 16:52:21 +0800")
Hi Finlye,
Finlye Xiao <finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org> writes:
> From: Finley Xiao <finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
>
> This patch supports adjusting opp's voltage according to leakage
>
> Signed-off-by: Finley Xiao <finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
[...]
> +static void rockchip_adjust_volt_by_leakage(struct device *cpu_dev,
> + struct cpufreq_policy *policy,
> + struct rockchip_cpu_avs *avs,
> + int id)
> +{
> + struct cluster_info *cluster = &avs->cluster[id];
> + int ret;
> +
> + if (cluster->leakage)
> + goto next;
>
> + ret = rockchip_get_leakage(cpu_dev, &cluster->leakage);
> + if (ret) {
> + dev_err(avs->dev, "cpu%d leakage invalid\n", policy->cpu);
> + return;
> + }
> +
> + ret = rockchip_get_offset_volt(cluster->leakage, cluster->table,
> + &cluster->adjust_volt);
> + if (ret) {
> + dev_err(avs->dev, "cpu%d leakage volt table err\n",
> + policy->cpu);
> + return;
> + }
Rather than do this for each notifier, since the table is static, why
not fill out struct cluster_info during probe?
I see there is a check above to skip this if it's already filled out,
but since the data is static, why not fill it out once at probe.
> +next:
> + ret = rockchip_adjust_opp_table(cpu_dev, policy->freq_table,
> + cluster->adjust_volt);
> + if (ret)
> + dev_err(avs->dev, "cpu%d failed to adjust volt\n", policy->cpu);
> +
> + dev_dbg(avs->dev, "cpu%d, leakage=%d, adjust_volt=%d\n", policy->cpu,
> + cluster->leakage, cluster->adjust_volt);
> +}
[...]
> +static int rockchip_cpu_avs_probe(struct platform_device *pdev)
> +{
> + struct rockchip_cpu_avs *avs;
> + char name[MAX_NAME_LEN];
> + int i, ret, cpu, id;
> + int last_id = -1;
> + int cluster_num = 0;
> +
> + for_each_online_cpu(cpu) {
> + id = topology_physical_package_id(cpu);
> + if (id < 0)
> + return -EINVAL;
> + if (id != last_id) {
> + last_id = id;
> + cluster_num++;
> + }
> + }
I don't think this counting is quite correct since physical and logial
CPU numbering is not guaranteed.
For example, I've seen big.LITTLE systems where the first little CPU is
the boot CPU, but the big CPUs are the next ones booted, you end up with
something like:
little cluster: CPU0,5-7
big cluster: CPU1-4
So your counting mechansim above would count 3 clusters in that case.
> + avs = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_cpu_avs),
> + GFP_KERNEL);
> + if (!avs)
> + return -ENOMEM;
> +
> + avs->dev = &pdev->dev;
> + avs->cpufreq_notify.notifier_call = rockchip_cpu_avs_notifier;
> + avs->cluster = devm_kzalloc(&pdev->dev,
> + sizeof(struct cluster_info) * cluster_num, GFP_KERNEL);
> + if (!avs->cluster)
> + return -ENOMEM;
> +
> + for (i = 0; i < cluster_num; i++) {
> + snprintf(name, MAX_NAME_LEN, "leakage-volt-cluster%d", i);
> + ret = rockchip_get_leakage_volt_table(&pdev->dev,
> + &avs->cluster[i].table,
> + name);
> + if (ret)
> + continue;
> + }
> +
> + return cpufreq_register_notifier(&avs->cpufreq_notify,
> + CPUFREQ_POLICY_NOTIFIER);
> +}
Other than those minor comments, I think the driver looks good to me.
After those changes. We'll also need to see acks from the DT folks on
the DT changes and bindings before merging.
Kevin
next prev parent reply other threads:[~2016-08-18 19:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 8:52 [PATCH v2 0/4] PM / AVS: add Rockchip cpu avs Finlye Xiao
2016-08-18 8:52 ` [PATCH v2 3/4] dt-bindings: add binding document for " Finlye Xiao
[not found] ` <1471510341-63926-1-git-send-email-finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-08-18 8:52 ` [PATCH v2 1/4] nvmem: rockchip-efuse: Change initcall to subsys Finlye Xiao
[not found] ` <1471510341-63926-2-git-send-email-finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-08-18 18:28 ` Kevin Hilman
[not found] ` <m2mvkaq6c5.fsf-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2016-08-18 22:29 ` Heiko Stuebner
2016-08-19 16:19 ` Kevin Hilman
2016-08-18 8:52 ` [PATCH v2 2/4] of: introduce of_property_read_s32_index Finlye Xiao
2016-08-18 8:52 ` [PATCH v2 4/4] PM / AVS: rockchip-cpu-avs: add driver handling Rockchip cpu avs Finlye Xiao
[not found] ` <1471510341-63926-5-git-send-email-finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-08-18 19:02 ` Kevin Hilman [this message]
2016-08-29 6:08 ` Viresh Kumar
2016-09-12 21:55 ` Stephen Boyd
[not found] ` <20160912215515.GF7243-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>
2016-09-26 3:55 ` Viresh Kumar
2016-09-26 8:05 ` Heiko Stuebner
2016-09-27 8:40 ` Finley Xiao
2016-09-27 22:14 ` Stephen Boyd
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=m260qxrjc4.fsf@baylibre.com \
--to=khilman-rdvid1duhrbwk0htik3j/w@public.gmane.org \
--cc=dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
--cc=jay.xu-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=lin.huang-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=nm-l0cyMroinI0@public.gmane.org \
--cc=rjw-LthD3rsA81gm4RdzfppkhA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=rocky.hao-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=sboyd-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=sre-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=tim.chen-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=tony.xie-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=ulysses.huang-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.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).