From: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org, rafael.j.wysocki@intel.com,
peterz@infradead.org, dave.hansen@linux.intel.com,
gautham.shenoy@amd.com, tglx@linutronix.de, len.brown@intel.com,
artem.bityutskiy@linux.intel.com
Subject: Re: [PATCH v8 3/4] intel_idle: Provide the default enter_dead() handler
Date: Tue, 17 Dec 2024 13:42:35 +0100 [thread overview]
Message-ID: <6bb2ba2e-bb51-4637-b254-2603c38a5537@linux.intel.com> (raw)
In-Reply-To: <CAJZ5v0hL0QOT17DnsUKONHVy1+Yy84soPWU74gHAxjsozerPgg@mail.gmail.com>
>> Recent Intel platforms require idle driver to provide information about
>> the MWAIT hint used to enter the deepest idle state in the play_dead
>> code.
>>
>> Provide the default enter_dead() handler for all of the platforms and
>> allow overwriting with a custom handler for each platform if needed.
>
> My changelog for this patch:
>
> "A subsequent change is going to make native_play_dead() rely on the
> idle driver to put CPUs going offline into appropriate idle states.
>
> For this reason, provide the default :enter_dead() handler for all of
> the idle states on all platforms supported by intel_idle with an
> option to override it with a custom handler if needed."
>
Ok. I'll apply that in the next version.
>> Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
>> ---
>> drivers/idle/intel_idle.c | 18 ++++++++++++++++--
>> 1 file changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
>> index ac4d8faa3886..c6874a6dbe95 100644
>> --- a/drivers/idle/intel_idle.c
>> +++ b/drivers/idle/intel_idle.c
>> @@ -56,6 +56,7 @@
>> #include <asm/mwait.h>
>> #include <asm/spec-ctrl.h>
>> #include <asm/fpu/api.h>
>> +#include <asm/smp.h>
>>
>> #define INTEL_IDLE_VERSION "0.5.1"
>>
>> @@ -227,6 +228,16 @@ static __cpuidle int intel_idle_s2idle(struct cpuidle_device *dev,
>> return 0;
>> }
>>
>> +static __cpuidle void intel_idle_enter_dead(struct cpuidle_device *dev,
>> + int index)
>> +{
>> + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
>> + struct cpuidle_state *state = &drv->states[index];
>> + unsigned long eax = flg2MWAIT(state->flags);
>> +
>> + mwait_play_dead(eax);
>> +}
>> +
>> /*
>> * States are indexed by the cstate number,
>> * which is also the index into the MWAIT hint array.
>> @@ -1798,6 +1809,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
>> state->flags |= CPUIDLE_FLAG_TIMER_STOP;
>>
>> state->enter = intel_idle;
>> + state->enter_dead = intel_idle_enter_dead;
>> state->enter_s2idle = intel_idle_s2idle;
>> }
>> }
>> @@ -2143,10 +2155,12 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
>> if (intel_idle_max_cstate_reached(cstate))
>> break;
>>
>> - if (!cpuidle_state_table[cstate].enter &&
>> - !cpuidle_state_table[cstate].enter_s2idle)
>> + if (!cpuidle_state_table[cstate].enter)
>
> I don't think that the above change belongs to this patch. If I'm
> mistaken, it should be mentioned in the changelog and the reason for
> making it should be explained.
Yeah, you are right, removing enter_s2idle check doesn't make much sense.
I think I was changing much more code, but eventually decided not to
change too much in one go and forgot to roll back that one.
With this:
if (!cpuidle_state_table[cstate].enter &&
!cpuidle_state_table[cstate].enter_s2idle)
we would not set enter_dead for states that only provide enter_dead handler, but I doesn't seem to happen in practice, so for the sake of simplicity I am just going to leave the check unchanged.
Unless you think it makes more sense to do:
if (!cpuidle_state_table[cstate].enter &&
+ !cpuidle_state_table[cstate].enter_dead &&
!cpuidle_state_table[cstate].enter_s2idle)
>
>> break;
>>
>> + if (!cpuidle_state_table[cstate].enter_dead)
>> + cpuidle_state_table[cstate].enter_dead = intel_idle_enter_dead;
>> +
>> /* If marked as unusable, skip this state. */
>> if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
>> pr_debug("state %s is disabled\n",
>> --
next prev parent reply other threads:[~2024-12-17 12:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 14:08 [PATCH v8 0/4] SRF: Fix offline CPU preventing pc6 entry Patryk Wlazlyn
2024-12-04 14:08 ` [PATCH v8 1/4] x86/smp: Allow calling mwait_play_dead with an arbitrary hint Patryk Wlazlyn
2024-12-04 14:08 ` [PATCH v8 2/4] ACPI: processor_idle: Add FFH state handling Patryk Wlazlyn
2024-12-04 14:08 ` [PATCH v8 3/4] intel_idle: Provide the default enter_dead() handler Patryk Wlazlyn
2024-12-10 20:26 ` Rafael J. Wysocki
2024-12-17 12:42 ` Patryk Wlazlyn [this message]
2024-12-16 1:31 ` kernel test robot
2024-12-04 14:08 ` [PATCH v8 4/4] x86/smp native_play_dead: Prefer cpuidle_play_dead() over mwait_play_dead() Patryk Wlazlyn
2024-12-10 20:50 ` Rafael J. Wysocki
2024-12-04 15:05 ` [PATCH v8 0/4] SRF: Fix offline CPU preventing pc6 entry Dave Hansen
2024-12-04 15:35 ` Patryk Wlazlyn
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=6bb2ba2e-bb51-4637-b254-2603c38a5537@linux.intel.com \
--to=patryk.wlazlyn@linux.intel.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=gautham.shenoy@amd.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rafael@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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