From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM list <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Russell King - ARM Linux <linux@arm.linux.org.uk>
Subject: Re: [PATCH 2/2] cpufreq: Separate CPU device removal from CPU online
Date: Thu, 23 Jul 2015 12:09:42 +0530 [thread overview]
Message-ID: <20150723063942.GF5322@linux> (raw)
In-Reply-To: <15986005.VczafT3nkj@vostro.rjw.lan>
On 23-07-15, 02:04, Rafael J. Wysocki wrote:
> +static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
> +{
> + unsigned int cpu = dev->id;
> + struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
> +
> + pr_debug("%s: adding CPU %u\n", __func__, cpu);
> +
> + if (policy && policy->kobj_cpu != cpu) {
Why are you comparing cpu against kobj_cpu ? I don't think it can ever
be false.
> + int ret;
> +
> + pr_debug("%s: Adding symlink for CPU: %u\n", __func__, cpu);
dev_dbg
> + ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq");
> + if (ret) {
> + dev_dbg(dev, "%s: Failed to create link (%d)\n",
dev_err
> + __func__, ret);
> + return ret;
> + }
> +
> + /* Track CPUs for which sysfs links are created */
> + cpumask_set_cpu(cpu, policy->linked_cpus);
> + }
> +
> + return cpu_online(cpu) ? cpufreq_dev_online(dev, false) : 0;
> +}
Looks fine otherwise. Thanks for getting your hands dirty :)
> static void cpufreq_offline_prepare(unsigned int cpu)
> {
> struct cpufreq_policy *policy;
> @@ -2344,31 +2343,35 @@ unlock:
> }
> EXPORT_SYMBOL(cpufreq_update_policy);
>
> +static void cpufreq_cpu_online(unsigned int cpu)
> +{
> + struct device *dev = get_cpu_device(cpu);
> +
> + if (dev)
> + cpufreq_dev_online(dev, true);
> +}
What about dropping this wrapper function and ...
> static int cpufreq_cpu_callback(struct notifier_block *nfb,
> unsigned long action, void *hcpu)
> {
> unsigned int cpu = (unsigned long)hcpu;
> - struct device *dev;
>
> - dev = get_cpu_device(cpu);
... keeping this as is? And then we can do
s/cpufreq_dev_online/cpufreq_cpu_online which suits better.
> - if (dev) {
> - switch (action & ~CPU_TASKS_FROZEN) {
> - case CPU_ONLINE:
> - cpufreq_add_dev(dev, NULL);
> - break;
> -
> - case CPU_DOWN_PREPARE:
> - cpufreq_offline_prepare(cpu);
> - break;
> -
> - case CPU_POST_DEAD:
> - cpufreq_offline_finish(cpu);
> - break;
> -
> - case CPU_DOWN_FAILED:
> - cpufreq_add_dev(dev, NULL);
> - break;
> - }
> + switch (action & ~CPU_TASKS_FROZEN) {
> + case CPU_ONLINE:
> + cpufreq_cpu_online(cpu);
> + break;
> +
> + case CPU_DOWN_PREPARE:
> + cpufreq_offline_prepare(cpu);
> + break;
> +
> + case CPU_POST_DEAD:
> + cpufreq_offline_finish(cpu);
> + break;
> +
> + case CPU_DOWN_FAILED:
> + cpufreq_cpu_online(cpu);
> + break;
> }
> return NOTIFY_OK;
> }
--
viresh
next prev parent reply other threads:[~2015-07-23 6:39 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 0:00 [PATCH 0/2] cpufreq: Better separation of device addition/removal and online/offline paths Rafael J. Wysocki
2015-07-23 0:01 ` [PATCH 1/2] cpufreq: Rename two functions related to CPU offline Rafael J. Wysocki
2015-07-23 6:40 ` Viresh Kumar
2015-07-23 0:04 ` [PATCH 2/2] cpufreq: Separate CPU device removal from CPU online Rafael J. Wysocki
2015-07-23 6:39 ` Viresh Kumar [this message]
2015-07-23 20:56 ` Rafael J. Wysocki
2015-07-24 2:19 ` Viresh Kumar
2015-07-24 19:54 ` Rafael J. Wysocki
2015-07-27 14:01 ` [PATCH 0/7] cpufreq: Better separation of device addition/removal and online/offline paths Rafael J. Wysocki
2015-07-27 14:03 ` [PATCH 1/7] cpufreq: Rework two functions related to CPU offline Rafael J. Wysocki
2015-07-27 14:42 ` Viresh Kumar
2015-07-27 14:03 ` [PATCH 2/7] cpufreq: Drop cpufreq_policy_restore() Rafael J. Wysocki
2015-07-27 14:48 ` Viresh Kumar
2015-07-27 14:04 ` [PATCH 3/7] cpufreq: Drop unnecessary label from cpufreq_add_dev() Rafael J. Wysocki
2015-07-27 14:52 ` Viresh Kumar
2015-07-27 14:05 ` [PATCH 4/7] cpufreq: Drop unused dev argument from two functions Rafael J. Wysocki
2015-07-27 14:53 ` Viresh Kumar
2015-07-27 14:06 ` [PATCH 5/7] cpufreq: Do not update related_cpus on every policy activation Rafael J. Wysocki
2015-07-27 14:56 ` Viresh Kumar
2015-07-27 14:07 ` [PATCH 6/7] cpufreq: Pass CPU number to cpufreq_policy_alloc() Rafael J. Wysocki
2015-07-27 14:58 ` Viresh Kumar
2015-07-27 14:09 ` [PATCH 7/7] cpufreq: Separate CPU device removal from CPU online Rafael J. Wysocki
2015-07-27 15:06 ` Viresh Kumar
2015-07-27 20:56 ` Rafael J. Wysocki
2015-07-27 21:56 ` Rafael J. Wysocki
2015-07-28 2:06 ` Viresh Kumar
2015-07-28 14:22 ` Rafael J. Wysocki
2015-07-27 21:55 ` [Update][PATCH 7/7] cpufreq: Separate CPU device registration " Rafael J. Wysocki
2015-07-28 2:20 ` Viresh Kumar
2015-07-28 14:13 ` Rafael J. Wysocki
2015-07-29 1:03 ` [Update 2x][PATCH " Rafael J. Wysocki
2015-07-29 1:08 ` [PATCH] cpufreq: Replace recover_policy with new_policy in cpufreq_online() Rafael J. Wysocki
2015-07-29 5:38 ` Viresh Kumar
2015-07-29 5:32 ` [Update 2x][PATCH 7/7] cpufreq: Separate CPU device registration from CPU online Viresh Kumar
2015-07-29 14:02 ` Rafael J. Wysocki
2015-07-29 14:07 ` Viresh Kumar
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=20150723063942.GF5322@linux \
--to=viresh.kumar@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=rjw@rjwysocki.net \
/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).