From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Santosh Shilimkar <santosh.shilimkar@ti.com>
Cc: rjw@sisk.pl, andrew@lunn.ch, kgene.kim@samsung.com,
jason@lakedaemon.net, horms@verge.net.au, patches@linaro.org,
khilman@deeprootsystems.com, magnus.damm@gmail.com,
linux-pm@vger.kernel.org, swarren@wwwdotorg.org, nsekhar@ti.com,
rob.herring@calxeda.com, deepthi@linux.vnet.ibm.com,
tony@atomide.com, lethal@linux-sh.org,
linaro-kernel@lists.linaro.org, kernel@pengutronix.de,
josephl@nvidia.com, jkosina@suse.cz, plagnioj@jcrosoft.com,
linux@maxim.org.za, linux-arm-kernel@lists.infradead.org
Subject: Re: [V4 patch 03/15] cpuidle: make a single register function for all
Date: Tue, 23 Apr 2013 14:51:41 +0200 [thread overview]
Message-ID: <517683DD.6060805@linaro.org> (raw)
In-Reply-To: <51767F57.7060809@ti.com>
On 04/23/2013 02:32 PM, Santosh Shilimkar wrote:
> On Tuesday 23 April 2013 02:24 PM, Daniel Lezcano wrote:
>> The usual scheme to initialize a cpuidle driver on a SMP is:
>>
>> cpuidle_register_driver(drv);
>> for_each_possible_cpu(cpu) {
>> device = &per_cpu(cpuidle_dev, cpu);
>> cpuidle_register_device(device);
>> }
>>
>> This code is duplicated in each cpuidle driver.
>>
>> On UP systems, it is done this way:
>>
>> cpuidle_register_driver(drv);
>> device = &per_cpu(cpuidle_dev, cpu);
>> cpuidle_register_device(device);
>>
>> On UP, the macro 'for_each_cpu' does one iteration:
>>
>> #define for_each_cpu(cpu, mask) \
>> for ((cpu) = 0; (cpu) < 1; (cpu)++, (void)mask)
>>
>> Hence, the initialization loop is the same for UP than SMP.
>>
>> Beside, we saw different bugs / mis-initialization / return code unchecked in
>> the different drivers, the code is duplicated including bugs. After fixing all
>> these ones, it appears the initialization pattern is the same for everyone.
>>
>> Please note, some drivers are doing dev->state_count = drv->state_count. This is
>> not necessary because it is done by the cpuidle_enable_device function in the
>> cpuidle framework. This is true, until you have the same states for all your
>> devices. Otherwise, the 'low level' API should be used instead with the specific
>> initialization for the driver.
>>
>> Let's add a wrapper function doing this initialization with a cpumask parameter
>> for the coupled idle states and use it for all the drivers.
>>
>> That will save a lot of LOC, consolidate the code, and the modifications in the
>> future could be done in a single place. Another benefit is the consolidation of
>> the cpuidle_device variable which is now in the cpuidle framework and no longer
>> spread accross the different arch specific drivers.
>>
>> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
>> ---
>
> I don't see you have addressed the comment on V3 [1] i gave for the subject patch
> Any reason ?
Yes, sorry for not answering.
This modification should be handled in the __cpuidle_register_device
function.
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 49e8d30..936d862 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -372,7 +372,7 @@ static int __cpuidle_register_device(struct
cpuidle_device *dev)
int ret;
struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
- if (!try_module_get(drv->owner))
+ if (!drv || !try_module_get(drv->owner))
return -EINVAL;
per_cpu(cpuidle_devices, dev->cpu) = dev;
Thus, the cpuidle_register function is not impacted by this as it will
always do cpuidle_register_driver, followed by cpuidle_register_device.
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2013-04-23 12:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-23 8:54 [V4 patch 00/15] cpuidle: code consolidation Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 01/15] cpuidle: remove en_core_tk_irqen flag Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 02/15] ARM: ux500: cpuidle: replace for_each_online_cpu by for_each_possible_cpu Daniel Lezcano
2013-04-30 9:16 ` Chander Kashyap
2013-04-23 8:54 ` [V4 patch 03/15] cpuidle: make a single register function for all Daniel Lezcano
2013-04-23 12:19 ` Rob Herring
2013-04-23 12:32 ` Santosh Shilimkar
2013-04-23 12:51 ` Daniel Lezcano [this message]
2013-04-23 13:04 ` Santosh Shilimkar
2013-04-23 8:54 ` [V4 patch 04/15] ARM: ux500: cpuidle: use init/exit common routine Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 05/15] ARM: at91: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 06/15] ARM: OMAP3: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 07/15] ARM: tegra: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 08/15] ARM: shmobile: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 09/15] ARM: OMAP4: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 10/15] ARM: tegra: cpuidle: use init/exit common routine for tegra2 Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 11/15] ARM: tegra: cpuidle: use init/exit common routine for tegra3 Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 12/15] ARM: calxeda: cpuidle: use init/exit common routine Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 13/15] ARM: kirkwood: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 14/15] ARM: davinci: " Daniel Lezcano
2013-04-23 8:54 ` [V4 patch 15/15] ARM: imx: " Daniel Lezcano
2013-04-23 12:00 ` [V4 patch 00/15] cpuidle: code consolidation Rafael J. Wysocki
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=517683DD.6060805@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=andrew@lunn.ch \
--cc=deepthi@linux.vnet.ibm.com \
--cc=horms@verge.net.au \
--cc=jason@lakedaemon.net \
--cc=jkosina@suse.cz \
--cc=josephl@nvidia.com \
--cc=kernel@pengutronix.de \
--cc=kgene.kim@samsung.com \
--cc=khilman@deeprootsystems.com \
--cc=lethal@linux-sh.org \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@maxim.org.za \
--cc=magnus.damm@gmail.com \
--cc=nsekhar@ti.com \
--cc=patches@linaro.org \
--cc=plagnioj@jcrosoft.com \
--cc=rjw@sisk.pl \
--cc=rob.herring@calxeda.com \
--cc=santosh.shilimkar@ti.com \
--cc=swarren@wwwdotorg.org \
--cc=tony@atomide.com \
/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).