mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>,
	linux-pm@vger.kernel.org,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	linux-kernel@vger.kernel.org,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Andy Gross <andy.gross@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>
Subject: Re: [PATCH] drivers: cpuidle: assign enter_freeze to same as enter callback function
Date: Wed, 9 Nov 2016 18:48:52 +0000	[thread overview]
Message-ID: <c6f986a7-5a00-7a4f-bdb3-db783f585b3e@arm.com> (raw)
In-Reply-To: <20161109183925.GA19565@red-moon>



On 09/11/16 18:39, Lorenzo Pieralisi wrote:
> On Wed, Nov 09, 2016 at 05:43:30PM +0000, Sudeep Holla wrote:
>> enter_freeze() callback is expected atleast to do the same as enter()
>> but it has to guarantee that interrupts aren't enabled at any point
>> in its execution, as the tick is frozen.
>>
>> CPUs execute ->enter_freeze with the local tick or entire timekeeping
>> suspended, so it must not re-enable interrupts at any point (even
>> temporarily) or attempt to change states of clock event devices.
>>
>> It will be called when the system goes to suspend-to-idle and will
>> reduce power usage because CPUs won't be awaken for unnecessary IRQs
>> (i.e. woken up only on IRQs from "wakeup sources")
>>
>> Since for all the states that have CPUIDLE_FLAG_TIMER_STOP flag set,
>> local tick is stopped, we can reuse the same code for both the enter()
>> and enter_freeze() callbacks. Only "coupled" cpuidle mechanism enables
>> interrupts and doing that with timekeeping suspended is generally not
>> safe. Since this generic DT based idle driver doesn't support "coupled"
>> states, it is safe to assume that the interrupts are not re-enabled.
>>
>> This patch assign enter_freeze to same as enter callback function which
>> helps to save power without any intermittent spurious wakeups from
>> suspend-to-idle.
>>
>> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
>> ---
>>  drivers/cpuidle/dt_idle_states.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpuidle/dt_idle_states.c b/drivers/cpuidle/dt_idle_states.c
>> index a5c111b67f37..5a087d108475 100644
>> --- a/drivers/cpuidle/dt_idle_states.c
>> +++ b/drivers/cpuidle/dt_idle_states.c
>> @@ -79,8 +79,17 @@ static int init_state_node(struct cpuidle_state *idle_state,
>>  		desc = state_node->name;
>>
>>  	idle_state->flags = 0;
>> -	if (of_property_read_bool(state_node, "local-timer-stop"))
>> +	if (of_property_read_bool(state_node, "local-timer-stop")) {
>>  		idle_state->flags |= CPUIDLE_FLAG_TIMER_STOP;
>> +		/*
>> +		 * CPUIDLE_FLAG_TIMER_STOP guarantees that the local tick is
>> +		 * stopped and since this is not a "coupled" state interrupts
>> +		 * won't be enabled when it exits allowing the tick to be
>> +		 * frozen safely. So enter() can be also enter_freeze()
>> +		 * callback.
>> +		 */
>
> I do not think that represents a guarantee for enter_freeze() to be
> functional, we can initialize enter_freeze() with a function that
> does _not_ enable IRQs while executing, it has not much to do with
> the local timer losing HW state.
>

I agree, and I didn't mean that with the above comment. But reading
again, I see your point.

> I would just init the enter_freeze() pointer and be done with that,
> adding code to check whether the idle back-end enables IRQs when it
> enters idle is a major PITA that really is not worth the hassle and
> apart from coupled C-states (which we do not support in DT as you said)
> I can't find another example (and on top of that it is not even
> something we can solve through DT since it is not a property of the idle
> state but more related to its kernel implementation).
>

Makes sense, I was just trying to avoid setting for a state like
CPU/Cluster retention but I agree, we need not do that.

> If we wanted to do it _properly_ we have to add an arch hook to check
> if the given idle state enter function back-end, ie cpu_ops on ARM64 or
> or cpuidle_ops on ARM, enables IRQs while executing, I would honestly
> avoid it but comments are nonetheless welcome.
>

Yes, that's may be unnecessary addition of some code when we can do it
in simple ways, but I am open to suggestions.

-- 
Regards,
Sudeep

  reply	other threads:[~2016-11-09 18:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-09 17:43 Sudeep Holla
2016-11-09 18:39 ` Lorenzo Pieralisi
2016-11-09 18:48   ` Sudeep Holla [this message]
2016-11-10 10:28     ` Vincent Guittot
2016-11-10 10:34       ` Sudeep Holla
2016-11-10 14:24 ` [PATCH v2] " Sudeep Holla
2016-11-10 18:18   ` Andy Gross
2016-11-15 14:20   ` Sudeep Holla
2016-11-24  1:15     ` 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=c6f986a7-5a00-7a4f-bdb3-db783f585b3e@arm.com \
    --to=sudeep.holla@arm.com \
    --cc=andy.gross@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=vincent.guittot@linaro.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

all inboxes | Powered by JetHome®