From: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: lenb@kernel.org, linux-acpi@vger.kernel.org,
linux-pm@lists.linux-foundation.org, linaro-dev@lists.linaro.org,
linux-kernel@vger.kernel.org
Subject: Re: [linux-pm] [RFC 1/4] cpuidle: define the enter function in the driver structure
Date: Fri, 08 Jun 2012 23:03:06 +0530 [thread overview]
Message-ID: <4FD23752.6090101@linux.vnet.ibm.com> (raw)
In-Reply-To: <1339171365-4098-1-git-send-email-daniel.lezcano@linaro.org>
Hi Daniel,
On 06/08/2012 09:32 PM, Daniel Lezcano wrote:
> We have the state index passed as parameter to the 'enter' function.
> Most of the drivers assign their 'enter' functions several times in
> the cpuidle_state structure, as we have the index, we can delegate
> to the driver to handle their own callback array.
>
> That will have the benefit of removing multiple lines of code in the
> different drivers.
>
> In order to smoothly modify the driver, the 'enter' function are in
> the driver structure and in the cpuidle state structure. That will
> let the time to modify the different drivers one by one.
> So the 'cpuidle_enter' function checks if the 'enter' callback is
> assigned in the driver structure and use it, otherwise it invokes
> the 'enter' assigned to the cpuidle_state.
Currently, the backend driver initializes
all the cpuidle states supported on the platform,
and each state can have its own enter routine
which can be unique This is a clean approach.
By moving the enter routine into the driver,
we are enforcing in having only one enter state.
There is unnecessary overhead involved
in calling a wrapper routine just to
index into the right idle state routine
for many platforms at runtime.
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> drivers/cpuidle/cpuidle.c | 4 +++-
> include/linux/cpuidle.h | 1 +
> 2 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index d90519c..155dee7 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -46,7 +46,9 @@ static inline int cpuidle_enter(struct cpuidle_device *dev,
> struct cpuidle_driver *drv, int index)
> {
> struct cpuidle_state *target_state = &drv->states[index];
> - return target_state->enter(dev, drv, index);
> +
> + return drv->enter(dev, drv, index) ? drv->enter(dev, drv, index) :
> + target_state->enter(dev, drv, index);
> }
>
> static inline int cpuidle_enter_tk(struct cpuidle_device *dev,
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index 6c26a3d..d82e169 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -130,6 +130,7 @@ struct cpuidle_driver {
> struct cpuidle_state states[CPUIDLE_STATE_MAX];
> int state_count;
> int safe_state_index;
> + int (*enter)(struct cpuidle_device *, struct cpuidle_driver *, int);
> };
>
> #ifdef CONFIG_CPU_IDLE
Cheers,
Deepthi
next prev parent reply other threads:[~2012-06-08 17:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 16:02 [RFC 1/4] cpuidle: define the enter function in the driver structure Daniel Lezcano
2012-06-08 16:02 ` [RFC 2/4] cpuidle: move enter_dead to " Daniel Lezcano
2012-06-08 16:02 ` Daniel Lezcano
2012-06-08 16:02 ` [RFC 3/4] cpuidle : move tlb flag to the cpuidle header Daniel Lezcano
[not found] ` <1339171365-4098-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-06-08 16:02 ` [RFC 4/4] cpuidle: replace the 'disable' field by a flag Daniel Lezcano
2012-06-08 16:02 ` Daniel Lezcano
2012-06-08 17:33 ` Deepthi Dharwar [this message]
2012-06-08 21:34 ` [RFC 1/4] cpuidle: define the enter function in the driver structure Daniel Lezcano
2012-06-08 21:34 ` [linux-pm] " Daniel Lezcano
[not found] ` <4FD27000.7000208-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-06-13 12:44 ` Jean Pihet
2012-06-13 12:44 ` Jean Pihet
2012-06-13 13:10 ` Daniel Lezcano
2012-06-13 13:10 ` [linux-pm] " Daniel Lezcano
2012-06-14 7:49 ` Namhyung Kim
2012-06-14 8:16 ` Daniel Lezcano
2012-06-14 8:16 ` 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=4FD23752.6090101@linux.vnet.ibm.com \
--to=deepthi@linux.vnet.ibm.com \
--cc=daniel.lezcano@linaro.org \
--cc=lenb@kernel.org \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.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.