From: "Limonciello, Mario" <mario.limonciello@amd.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-acpi@vger.kernel.org,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Iain Lane <iain@orangesquash.org.uk>,
Shyam-sundar S-k <Shyam-sundar.S-k@amd.com>
Subject: Re: [PATCH v12 9/9] ACPI: x86: s2idle: Enforce LPS0 constraints for PCI devices
Date: Thu, 17 Aug 2023 14:40:48 -0500 [thread overview]
Message-ID: <681613ab-a811-41c4-8abe-55780108ad26@amd.com> (raw)
In-Reply-To: <CAJZ5v0hTJzBkTD64bHmREGymjn2oWPt8y=6bb6WVJm39Jr+ouw@mail.gmail.com>
On 8/17/2023 2:37 PM, Rafael J. Wysocki wrote:
> On Thu, Aug 17, 2023 at 9:30 PM Limonciello, Mario
> <mario.limonciello@amd.com> wrote:
>>
>>
>>
>> On 8/17/2023 2:25 PM, Bjorn Helgaas wrote:
>>> On Wed, Aug 16, 2023 at 03:41:43PM -0500, Mario Limonciello wrote:
>>>> Since commit 9d26d3a8f1b0 ("PCI: Put PCIe ports into D3 during suspend")
>>>> PCIe ports from modern machines (>=2015) are allowed to be put into D3 by
>>>> storing a value to the `bridge_d3` variable in the `struct pci_dev`
>>>> structure.
>>>> ...
>>>
>>>> +static void lpi_check_pci_dev(struct lpi_constraints *entry, struct pci_dev *pdev)
>>>> +{
>>>> + pci_power_t target = entry->enabled ? entry->min_dstate : PCI_D0;
>>>> +
>>>> + if (pdev->current_state == target)
>>>> + return;
>>>> +
>>>> + /* constraint of ACPI D3hot means PCI D3hot _or_ D3cold */
>>>> + if (target == ACPI_STATE_D3_HOT &&
>>>
>>> ACPI_STATE_D3_HOT is not a valid pci_power_t value.
>>
>> Based on this, kernel robot sparse complaints and your comments on v11's
>> last patch I am going to split off to another function that returns the
>> pci_power_t state based upon the situation and better comment the reason
>> for the D0 when not enabled.
>>
>>>
>>>> + (pdev->current_state == PCI_D3hot ||
>>>> + pdev->current_state == PCI_D3cold))
>>>> + return;
>>>> +
>>>> + if (pm_debug_messages_on)
>>>> + acpi_handle_info(entry->handle,
>>>> + "LPI: PCI device in %s, not in %s\n",
>>>> + acpi_power_state_string(pdev->current_state),
>>>> + acpi_power_state_string(target));
>>>> +
>>>> + /* don't try with things that PCI core hasn't touched */
>>>> + if (pdev->current_state == PCI_UNKNOWN) {
>>>> + entry->handle = NULL;
>>>> + return;
>>>> + }
>>>> +
>>>> + pci_set_power_state(pdev, target);
>>>
>>> It doesn't seem logical for a "check_constraints()" function that
>>> takes no parameters and returns nothing to actively set the PCI power
>>> state.
>>>
>>> lpi_check_constraints() returns nothing, and from the fact that it was
>>> previously only called when "pm_debug_messages_on", I infer that it
>>> should have no side effects.
>>>
>>> IMHO "lpi_check_constraints" is not a great name because "check"
>>> doesn't suggest anything specific about what it does.
>>> "dump_constraints()" -- fine. "log_unmet_constraints()" -- fine
>>> (seems like the original intention of 726fb6b4f2a8 ("ACPI / PM: Check
>>> low power idle constraints for debug only"), which added it.
>>>
>>
>> Great feedback, thanks. I'm thinking to instead change it to:
>>
>> lpi_enforce_constraints()
>
> Don't even try to go this way, please.
>
> Originally, the LPI constraints are there to indicate to Windows
> whether or not it should attempt to enter Connected/Modern Standby.
>
> Because Linux doesn't do Modern Standby, it doesn't use the LPI
> constraints the way Windows does and it really shouldn't do that.
>
> I think that the exercise here is to use the information from the
> constraints list as an indication whether or not a given PCI Root Port
> is supposed to be put into D3hot/cold on suspend-to-idle and this has
> nothing to do with enforcement.
What do you think about me making the changes to pci_prepare_to_sleep()?
Something like this:
@@ -2733,11 +2742,17 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
{
bool wakeup = device_may_wakeup(&dev->dev);
pci_power_t target_state = pci_target_state(dev, wakeup);
+ pci_power_t constraint;
int error;
if (target_state == PCI_POWER_ERROR)
return -EIO;
+ /* if platform indicates device constraint for suspend, use it */
+ constraint = platform_check_constraint(dev, target_state);
+ if (constraint != PCI_POWER_ERROR)
+ target_state = constraint;
+
pci_enable_wake(dev, target_state, wakeup);
error = pci_set_power_state(dev, target_state);
next prev parent reply other threads:[~2023-08-17 19:41 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-16 20:41 [PATCH v12 0/9] Fix wakeup problems on some AMD platforms Mario Limonciello
2023-08-16 20:41 ` [PATCH v12 1/9] ACPI: Add comments to clarify some #ifdef statements Mario Limonciello
2023-08-16 22:36 ` Kuppuswamy Sathyanarayanan
2023-08-16 20:41 ` [PATCH v12 2/9] ACPI: Adjust #ifdef for *_lps0_dev use Mario Limonciello
2023-08-16 22:38 ` Kuppuswamy Sathyanarayanan
2023-08-16 20:41 ` [PATCH v12 3/9] ACPI: x86: s2idle: Post-increment variables when getting constraints Mario Limonciello
2023-08-17 2:42 ` Kuppuswamy Sathyanarayanan
2023-08-17 10:10 ` Andy Shevchenko
2023-08-17 15:28 ` Kuppuswamy Sathyanarayanan
2023-08-17 15:52 ` Andy Shevchenko
2023-08-16 20:41 ` [PATCH v12 4/9] ACPI: x86: s2idle: Catch multiple ACPI_TYPE_PACKAGE objects Mario Limonciello
2023-08-16 20:41 ` [PATCH v12 5/9] ACPI: x86: s2idle: Fix a logic error parsing AMD constraints table Mario Limonciello
2023-08-16 20:41 ` [PATCH v12 6/9] ACPI: x86: s2idle: Add more debugging for AMD constraints parsing Mario Limonciello
2023-08-16 20:41 ` [PATCH v12 7/9] ACPI: x86: s2idle: Store if constraint is enabled Mario Limonciello
2023-08-16 20:41 ` [PATCH v12 8/9] ACPI: x86: s2idle: Add for_each_lpi_constraint() helper Mario Limonciello
2023-08-16 20:41 ` [PATCH v12 9/9] ACPI: x86: s2idle: Enforce LPS0 constraints for PCI devices Mario Limonciello
2023-08-17 5:03 ` kernel test robot
2023-08-17 19:25 ` Bjorn Helgaas
2023-08-17 19:30 ` Limonciello, Mario
2023-08-17 19:37 ` Rafael J. Wysocki
2023-08-17 19:40 ` Limonciello, Mario [this message]
2023-08-17 19:53 ` Rafael J. Wysocki
2023-08-17 19:31 ` 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=681613ab-a811-41c4-8abe-55780108ad26@amd.com \
--to=mario.limonciello@amd.com \
--cc=Shyam-sundar.S-k@amd.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=helgaas@kernel.org \
--cc=iain@orangesquash.org.uk \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=rafael@kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
/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®