Re: [PATCH v12 9/9] ACPI: x86: s2idle: Enforce LPS0 constraints for PCI devices
From: Rafael J. Wysocki
Date: Thu Aug 17 2023 - 15:33:12 EST
On Thu, Aug 17, 2023 at 9:25 PM Bjorn Helgaas <helgaas@xxxxxxxxxx> 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.
>
> > + (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.
That's correct, it is not expected to have 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.
It seems that we are entering bikeshedding territory here ...