From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Stephen Boyd <sboyd@codeaurora.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: "rjw@rjwysocki.net" <rjw@rjwysocki.net>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Catalin Marinas <Catalin.Marinas@arm.com>,
"robherring2@gmail.com" <robherring2@gmail.com>,
"arnd@arndb.de" <arnd@arndb.de>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"lina.iyer@linaro.org" <lina.iyer@linaro.org>
Subject: Re: [PATCH 2/6] ARM: cpuidle: Add a cpuidle ops structure to be used for DT
Date: Wed, 18 Mar 2015 09:13:27 +0100 [thread overview]
Message-ID: <550933A7.9030401@linaro.org> (raw)
In-Reply-To: <5508D160.6090205@codeaurora.org>
On 03/18/2015 02:14 AM, Stephen Boyd wrote:
> On 03/17/15 04:29, Lorenzo Pieralisi wrote:
>> On Mon, Mar 16, 2015 at 10:08:19PM +0000, Stephen Boyd wrote:
>>> On 03/03/15 04:29, Daniel Lezcano wrote:
>>>> The code is optimized to use the __init section intensively in order to reduce
>>>> the memory footprint after the driver is initialized and unify the function
>>>> names with ARM64.
>>>>
>>>> In order to prevent multiple declarations and the specific cpuidle ops to be
>>>> spread across the different headers, a mechanism, similar to the cgroup subsys,
>>>> has been introduced.
>>>>
>>>> A new platform willing to add its cpuidle ops must add an entry in the file
>>>> cpuidle_ops.h in the current form:
>>>>
>>>> #if IS_ENABLED(CONFIG_ARM_FOO_CPUIDLE)
>>>> CPUIDLE_OPS(foo)
>>>> #endif
>>>>
>>>> ... and use the variable name in the specific low level code:
>>>>
>>>> struct cpuidle_ops foo_cpuidle_ops;
>>>>
>>>> The CPUIDLE_OPS macro will be processed in different way in the cpuidle.c file,
>>>> thus allowing to keep untouched the arm cpuidle core code in the future when
>>>> a new platform is added.
>>> [...]
>>>> diff --git a/arch/arm/include/asm/cpuidle_ops.h b/arch/arm/include/asm/cpuidle_ops.h
>>>> new file mode 100644
>>>> index 0000000..be0a612
>>>> --- /dev/null
>>>> +++ b/arch/arm/include/asm/cpuidle_ops.h
>>>> @@ -0,0 +1,3 @@
>>>> +/*
>>>> + * List of cpuidle operations
>>>> + */
>>>> diff --git a/arch/arm/kernel/cpuidle.c b/arch/arm/kernel/cpuidle.c
>>>> index 45969f8..25e9789c 100644
>>>> --- a/arch/arm/kernel/cpuidle.c
>>>> +++ b/arch/arm/kernel/cpuidle.c
>>>> @@ -10,8 +10,29 @@
>>>> */
>>>>
>>>> #include <linux/cpuidle.h>
>>>> +#include <linux/of.h>
>>>> +#include <linux/of_device.h>
>>>> #include <asm/cpuidle.h>
>>>>
>>>> +#define CPUIDLE_OPS(__x) extern struct cpuidle_ops __x ## _cpuidle_ops;
>>>> +#include <asm/cpuidle_ops.h>
>>>> +#undef CPUIDLE_OPS
>>>> +
>>>> +#define CPUIDLE_OPS(__x) __x ## _cpuidle_ops_id,
>>>> +enum cpuidle_ops_id {
>>>> +#include <asm/cpuidle_ops.h>
>>>> + CPUIDLE_OPS_COUNT,
>>>> +};
>>>> +#undef CPUIDLE_OPS
>>>> +
>>>> +#define CPUIDLE_OPS(__x) [__x ## _cpuidle_ops_id ] = &__x ## _cpuidle_ops,
>>>> +static struct cpuidle_ops *supported_cpuidle_ops[] __initconst = {
>>>> +#include <asm/cpuidle_ops.h>
>>>> +};
>>>> +#undef CPUIDLE_OPS
>>>> +
>>>> +static struct cpuidle_ops cpuidle_ops[NR_CPUS];
>>> Is there any reason why we aren't putting these structures into a linker
>>> section like we do for the smp operations structures?
>> I think it can be done with an OF_TABLE, it is a bit of shame cpuidle_ops
>> should work on UP too otherwise they could have been merged in
>> smp_ops to create cpu_ops, like arm64 does.
>
> We should merge the two and remove the SMP dependency on arm32.
I will be happy to do that but right now it would be nice to keep
focused on bringing the cpuidle ops first, even if we have a bit of code
duplicated, in order to unblock the cpuidle drivers awaiting for this
code to be merged.
>>> The nice thing about using the linker is it makes it clearer at the
>>> location where we define the structure that it's actually used by
>>> something. Right now the structures are defined non-static in a file and
>>> then we have to know that a CPUIDLE_OPS() define has been made in
>>> another architecture specific asm header file so that this macro magic
>>> works. The commit text says something about multiple declarations and
>>> ops spread across header files, which shouldn't apply if we're using the
>>> linker to find these ops and merge them into an array we can iterate over.
>> It makes sense, see above for UP vs SMP. I wonder if we can't find
>> something to overcome the UP limitation nicely, the init code in
>> arch/arm/kernel/devtree.c is identical for smp_ops and cpuidle_ops,
>> apart from the CONFIG_SMP ifdeffery.
>
> It should be possible to replace the arm32 smp_operations structure with
> something like the arm64 cpu_operations structure. Yes we would have to
> drop the SMP dependency, but that will be ok. It would require some work
> to make arm32 and arm64 the same, but for these purposes that isn't
> really required as long as we can put the cpu idle hook there.
>
--
<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:[~2015-03-18 8:13 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 12:29 [PATCH 0/6] ARM: cpuidle: Unify the ARM64/ARM DT approach Daniel Lezcano
2015-03-03 12:29 ` [PATCH 1/6] ARM: cpuidle: Remove duplicate header inclusion Daniel Lezcano
2015-03-13 17:54 ` Lorenzo Pieralisi
2015-03-03 12:29 ` [PATCH 2/6] ARM: cpuidle: Add a cpuidle ops structure to be used for DT Daniel Lezcano
2015-03-16 18:16 ` Lorenzo Pieralisi
2015-03-17 11:01 ` Daniel Lezcano
2015-03-16 22:08 ` Stephen Boyd
2015-03-17 11:29 ` Lorenzo Pieralisi
2015-03-18 1:14 ` Stephen Boyd
2015-03-18 8:13 ` Daniel Lezcano [this message]
2015-03-20 17:23 ` Catalin Marinas
2015-03-03 12:29 ` [PATCH 3/6] ARM64: cpuidle: Replace cpu_suspend by the common ARM/ARM64 function Daniel Lezcano
2015-03-13 18:21 ` Catalin Marinas
2015-03-13 21:22 ` Daniel Lezcano
2015-03-03 12:29 ` [PATCH 5/6] ARM64: cpuidle: Remove arm64 reference Daniel Lezcano
[not found] ` <1425385777-14766-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-03 12:29 ` [PATCH 4/6] ARM64: cpuidle: Rename cpu_init_idle to a common function name Daniel Lezcano
[not found] ` <1425385777-14766-5-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-03-13 18:22 ` Catalin Marinas
2015-03-14 11:41 ` Catalin Marinas
2015-03-15 16:26 ` Lorenzo Pieralisi
2015-03-20 16:01 ` Daniel Lezcano
2015-03-20 17:26 ` Catalin Marinas
2015-03-03 12:29 ` [PATCH 6/6] ARM: cpuidle: Enable the ARM64 driver for both ARM32/ARM64 Daniel Lezcano
2015-03-12 14:25 ` [PATCH 0/6] ARM: cpuidle: Unify the ARM64/ARM DT approach Daniel Lezcano
2015-03-13 18:29 ` Catalin Marinas
2015-03-13 21:26 ` Daniel Lezcano
2015-03-13 20:51 ` Rob Herring
2015-03-13 21:31 ` Daniel Lezcano
2015-03-15 16:48 ` Lorenzo Pieralisi
2015-03-13 17:03 ` Kevin Hilman
2015-03-13 17:08 ` Daniel Lezcano
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=550933A7.9030401@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=Catalin.Marinas@arm.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=lina.iyer@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=rjw@rjwysocki.net \
--cc=robherring2@gmail.com \
--cc=sboyd@codeaurora.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).