Re: [PATCH v9 3/3] PCI/ACPI: Use device constraints to decide PCI target state fallback policy

From: Mika Westerberg
Date: Fri Aug 04 2023 - 09:20:52 EST


On Thu, Aug 03, 2023 at 08:02:29PM -0500, Mario Limonciello wrote:
> +/**
> + * acpi_pci_device_constraint - determine if the platform has a contraint for the device
> + * @dev: PCI device to check
> + * @result (out): the constraint specified by the platform
> + *
> + * If the platform has specified a constraint for a device, this function will
> + * return 0 and set @result to the constraint.
> + * Otherwise, it will return an error code.
> + */
> +int acpi_pci_device_constraint(struct pci_dev *dev, int *result)
> +{
> + int constraint;
> +
> + constraint = acpi_get_lps0_constraint(&dev->dev);
> + pci_dbg(dev, "ACPI device constraint: %d\n", constraint);
> + if (constraint < 0)
> + return constraint;
> + *result = constraint;

Is there something preventing to return the constraint directly instead
of storing it into "result"?

> +
> + return 0;
> +}
> +
> static void acpi_pci_config_space_access(struct pci_dev *dev, bool enable)
> {
> int val = enable ? ACPI_REG_CONNECT : ACPI_REG_DISCONNECT;
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 60230da957e0c..6c70f921467c6 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -1082,6 +1082,14 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
> return acpi_pci_bridge_d3(dev);
> }
>
> +static inline int platform_get_constraint(struct pci_dev *dev, int *result)

Ditto here.

> +{
> + if (pci_use_mid_pm())
> + return -ENODEV;
> +
> + return acpi_pci_device_constraint(dev, result);
> +}
> +