All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Limonciello, Mario" <mario.limonciello@amd.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>, Len Brown <len.brown@intel.com>,
	Linux PM <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 01/10] PM: suspend: Introduce `pm_suspend_preferred_s2idle`
Date: Tue, 12 Jul 2022 15:16:53 -0500	[thread overview]
Message-ID: <fd572ac1-9447-b148-8ad5-c6ecca5c6477@amd.com> (raw)
In-Reply-To: <CAJZ5v0g5Zsbddid+w2qxa_bqwmeP-FSk_42SZ3doMoFs0r8S8g@mail.gmail.com>

On 7/12/2022 14:06, Rafael J. Wysocki wrote:
> On Fri, Jul 1, 2022 at 4:33 AM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
>>
>> Many drivers in the kernel will check the FADT to determine if low
>> power idle is supported and use this information to set up a policy
>> decision in the driver.  To abstract this information from drivers
>> introduce a new helper symbol that can indicate this information.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   include/linux/suspend.h |  1 +
>>   kernel/power/suspend.c  | 17 +++++++++++++++++
>>   2 files changed, 18 insertions(+)
>>
>> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
>> index 70f2921e2e70..9d911e026720 100644
>> --- a/include/linux/suspend.h
>> +++ b/include/linux/suspend.h
>> @@ -305,6 +305,7 @@ static inline bool idle_should_enter_s2idle(void)
>>          return unlikely(s2idle_state == S2IDLE_STATE_ENTER);
>>   }
>>
>> +extern bool pm_suspend_preferred_s2idle(void);
>>   extern bool pm_suspend_default_s2idle(void);
>>   extern void __init pm_states_init(void);
>>   extern void s2idle_set_ops(const struct platform_s2idle_ops *ops);
>> diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
>> index 827075944d28..0030e7dfe6cf 100644
>> --- a/kernel/power/suspend.c
>> +++ b/kernel/power/suspend.c
>> @@ -9,6 +9,7 @@
>>
>>   #define pr_fmt(fmt) "PM: " fmt
>>
>> +#include <linux/acpi.h>
>>   #include <linux/string.h>
>>   #include <linux/delay.h>
>>   #include <linux/errno.h>
>> @@ -61,6 +62,22 @@ static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head);
>>   enum s2idle_states __read_mostly s2idle_state;
>>   static DEFINE_RAW_SPINLOCK(s2idle_lock);
>>
>> +/**
>> + * pm_suspend_preferred_s2idle - Check if suspend-to-idle is the preferred suspend method.
>> + *
>> + * Return 'true' if suspend-to-idle is preferred by the system designer for the default
>> + * suspend method.
>> + */
>> +bool pm_suspend_preferred_s2idle(void)
>> +{
>> +#ifdef CONFIG_ACPI
>> +       return acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0;
>> +#else
>> +       return false;
>> +#endif
>> +}
>> +EXPORT_SYMBOL_GPL(pm_suspend_preferred_s2idle);
> 
> First, this is ACPI-specific, so please don't try to generalize it
> artificially.  This confuses things and doesn't really help.
> 
> Second, ACPI_FADT_LOW_POWER_S0 means that "low power S0 idle" is
> supported, not that suspend-to-idle is the preferred suspend method in
> Linux.
> 
> System designers who set that bit in FADT may not even know what
> suspend-to-idle is.

In "practice" it means that the system has been enabled for Modern 
Standby in Windows.

> 
> But it is good that you have identified the code checking that bit,
> because it should not be checked without a valid reason.  I need to
> review that code and see what's going on in there.

Within this series the intent is to see that the vendor meant the system 
to be using Modern Standby on Windows (and implicitly Suspend To Idle on 
Linux).

With this I was trying to distinguish intent of the OEM between intent 
of the user for helping to declare policy.  Maybe the distinction of OEM 
and user decision don't really matter though and "mem_sleep_current" is 
better to use?  I think in a lot of the cases that I outlined I think 
that mem_sleep_current can drop right in instead of acpi_gbl_FADT.flags.

If you would like I'm happy to do that and send a new series.

> 
>> +
>>   /**
>>    * pm_suspend_default_s2idle - Check if suspend-to-idle is the default suspend.
>>    *
>> --
>> 2.34.1
>>


  reply	other threads:[~2022-07-12 20:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01  2:33 [PATCH v3 01/10] PM: suspend: Introduce `pm_suspend_preferred_s2idle` Mario Limonciello
2022-07-01  2:33 ` [PATCH v3 02/10] ACPI / x86: Use new `pm_suspend_preferred_s2idle` Mario Limonciello
2022-07-13 18:33   ` Rafael J. Wysocki
2022-07-01  2:33 ` [PATCH v3 03/10] ACPI: LPIT: " Mario Limonciello
2022-07-01 13:01   ` kernel test robot
2022-07-01  2:33 ` [PATCH v3 04/10] ata: ahci: Use `pm_suspend_preferred_s2idle` Mario Limonciello
2022-07-01  5:06   ` Damien Le Moal
2022-07-01 18:01     ` Mario Limonciello
2022-07-02  9:34   ` kernel test robot
2022-07-01  2:33 ` [PATCH v3 05/10] rtc: cmos: " Mario Limonciello
2022-07-01 11:50   ` kernel test robot
2022-07-01  2:33 ` [PATCH v3 06/10] thermal: intel: pch: " Mario Limonciello
2022-07-01  2:33 ` [PATCH v3 07/10] drm/amd: " Mario Limonciello
2022-07-01  2:33   ` Mario Limonciello
2022-07-01  2:33   ` Mario Limonciello
2022-07-01  2:33 ` [PATCH v3 08/10] drm/amd: Use `pm_suspend_default_s2idle` Mario Limonciello
2022-07-01  2:33   ` Mario Limonciello
2022-07-01  2:33   ` Mario Limonciello
2022-07-01  2:33 ` [PATCH v3 09/10] HID: I2C-HID: Use `pm_suspend_preferred_s2idle` Mario Limonciello
2022-07-01  2:33 ` [PATCH v3 10/10] HID: usbhid: Set USB mice as s2idle wakeup resources Mario Limonciello
2022-07-01  6:57   ` Greg KH
2022-07-01  6:58   ` Greg KH
2022-07-01 18:00     ` Mario Limonciello
2022-07-01 11:30   ` kernel test robot
2022-07-12 19:06 ` [PATCH v3 01/10] PM: suspend: Introduce `pm_suspend_preferred_s2idle` Rafael J. Wysocki
2022-07-12 20:16   ` Limonciello, Mario [this message]
2022-07-13 18:27     ` 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=fd572ac1-9447-b148-8ad5-c6ecca5c6477@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@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 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.