Message ID | 20250401153225.96379-3-anshuman.gupta@intel.com |
---|---|
State | New |
Headers | show |
Series | VRAM Self Refresh | expand |
> -----Original Message----- > From: Bjorn Helgaas <helgaas@kernel.org> > Sent: Wednesday, April 2, 2025 12:01 AM > To: Gupta, Anshuman <anshuman.gupta@intel.com> > Cc: intel-xe@lists.freedesktop.org; linux-acpi@vger.kernel.org; linux- > pci@vger.kernel.org; rafael@kernel.org; lenb@kernel.org; > bhelgaas@google.com; ilpo.jarvinen@linux.intel.com; De Marchi, Lucas > <lucas.demarchi@intel.com>; Vivi, Rodrigo <rodrigo.vivi@intel.com>; Nilawar, > Badal <badal.nilawar@intel.com>; Gupta, Varun <varun.gupta@intel.com>; > ville.syrjala@linux.intel.com; Shankar, Uma <uma.shankar@intel.com> > Subject: Re: [PATCH 02/12] PCI/ACPI: Add PERST# Assertion Delay _DSM > method > > On Tue, Apr 01, 2025 at 09:02:15PM +0530, Anshuman Gupta wrote: > > Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev > > 3.3. > > "PCI Firmware r3.3, sec 4.6.11" so the citation is major to minor. > > "0xb" or "0Bh" to match spec usage. Thanks for review, will fix it. > > > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com> > > --- > > drivers/pci/pci-acpi.c | 53 > ++++++++++++++++++++++++++++++++++++++++ > > include/linux/pci-acpi.h | 7 ++++++ > > 2 files changed, 60 insertions(+) > > > > diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index > > ebd49e43457e..04149f037664 100644 > > --- a/drivers/pci/pci-acpi.c > > +++ b/drivers/pci/pci-acpi.c > > @@ -1499,6 +1499,59 @@ int pci_acpi_request_d3cold_aux_power(struct > > pci_dev *dev, u32 requested_power) } > > EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power); > > > > +/** > > + * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI > > +DSM > > + * @dev: PCI device instance > > + * @delay_us: Requested delay_us > > + * > > + * This function sends a request to the host BIOS via ACPI _DSM to > > +grant the > > + * required PERST# delay for the specified PCI device. It evaluates > > +the _DSM > > + * to request the PERST# delay and handles the response accordingly. > > + * > > + * Return: returns 0 on success and errno on failure. > > + */ > > +int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 > > +delay_us) { > > + union acpi_object in_obj = { > > + .integer.type = ACPI_TYPE_INTEGER, > > + .integer.value = delay_us, > > + }; > > + > > + union acpi_object *out_obj; > > + acpi_handle handle; > > + int result, ret = -EINVAL; > > + > > + if (!dev || !ACPI_HANDLE(&dev->dev)) > > + return -EINVAL; > > + > > + handle = ACPI_HANDLE(&dev->dev); > > acpi_check_dsm(). Will fix it same as patch1 > > > + out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4, > > + DSM_PCI_PERST_ASSERTION_DELAY, > > + &in_obj, ACPI_TYPE_INTEGER); > > + if (!out_obj) > > + return -EINVAL; > > + > > + result = out_obj->integer.value; > > + > > + if (result == delay_us) { > > + dev_info(&dev->dev, "PERST# Assertion Delay set to" > > + "%u microseconds\n", delay_us); > > pci_info(). > > Join these into a single string, even though they won't fit in a line without > wrapping. This is to make them easier to grep for when a user reports seeing > the message. (Do this on the previous patch too, where I forgot to mention > it.) there was comment in RFC to warp the line with in 80. Will join the string. Thanks, Anshuman > > > + ret = 0; > > + } else if (result == 0) { > > + dev_warn(&dev->dev, "PERST# Assertion Delay request > failed," > > + "no previous valid request\n"); > > + } else { > > + dev_warn(&dev->dev, > > + "PERST# Assertion Delay request failed" > > + "Previous valid delay: %u microseconds\n", result); > > + } > > + > > + ACPI_FREE(out_obj); > > + return ret; > > +} > > +EXPORT_SYMBOL(pci_acpi_add_perst_assertion_delay);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index ebd49e43457e..04149f037664 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -1499,6 +1499,59 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) } EXPORT_SYMBOL(pci_acpi_request_d3cold_aux_power); +/** + * pci_acpi_add_perst_assertion_delay - Request PERST# delay via ACPI DSM + * @dev: PCI device instance + * @delay_us: Requested delay_us + * + * This function sends a request to the host BIOS via ACPI _DSM to grant the + * required PERST# delay for the specified PCI device. It evaluates the _DSM + * to request the PERST# delay and handles the response accordingly. + * + * Return: returns 0 on success and errno on failure. + */ +int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us) +{ + union acpi_object in_obj = { + .integer.type = ACPI_TYPE_INTEGER, + .integer.value = delay_us, + }; + + union acpi_object *out_obj; + acpi_handle handle; + int result, ret = -EINVAL; + + if (!dev || !ACPI_HANDLE(&dev->dev)) + return -EINVAL; + + handle = ACPI_HANDLE(&dev->dev); + + out_obj = acpi_evaluate_dsm_typed(handle, &pci_acpi_dsm_guid, 4, + DSM_PCI_PERST_ASSERTION_DELAY, + &in_obj, ACPI_TYPE_INTEGER); + if (!out_obj) + return -EINVAL; + + result = out_obj->integer.value; + + if (result == delay_us) { + dev_info(&dev->dev, "PERST# Assertion Delay set to" + "%u microseconds\n", delay_us); + ret = 0; + } else if (result == 0) { + dev_warn(&dev->dev, "PERST# Assertion Delay request failed," + "no previous valid request\n"); + } else { + dev_warn(&dev->dev, + "PERST# Assertion Delay request failed" + "Previous valid delay: %u microseconds\n", result); + } + + ACPI_FREE(out_obj); + return ret; +} +EXPORT_SYMBOL(pci_acpi_add_perst_assertion_delay); + static void pci_acpi_set_external_facing(struct pci_dev *dev) { u8 val; diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index dbc4b0ed433c..4b7373f91a9a 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h @@ -122,6 +122,7 @@ extern const guid_t pci_acpi_dsm_guid; #define DSM_PCI_POWER_ON_RESET_DELAY 0x08 #define DSM_PCI_DEVICE_READINESS_DURATIONS 0x09 #define DSM_PCI_D3COLD_AUX_POWER_LIMIT 0x0A +#define DSM_PCI_PERST_ASSERTION_DELAY 0x0B #ifdef CONFIG_PCIE_EDR void pci_acpi_add_edr_notifier(struct pci_dev *pdev); @@ -134,6 +135,7 @@ static inline void pci_acpi_remove_edr_notifier(struct pci_dev *pdev) { } int pci_acpi_set_companion_lookup_hook(struct acpi_device *(*func)(struct pci_dev *)); void pci_acpi_clear_companion_lookup_hook(void); int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power); +int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us); #else /* CONFIG_ACPI */ static inline void acpi_pci_add_bus(struct pci_bus *bus) { } @@ -142,6 +144,11 @@ int pci_acpi_request_d3cold_aux_power(struct pci_dev *dev, u32 requested_power) { return -EOPNOTSUPP; } + +int pci_acpi_add_perst_assertion_delay(struct pci_dev *dev, u32 delay_us) +{ + return -EOPNOTSUPP; +} #endif /* CONFIG_ACPI */ #endif /* _PCI_ACPI_H_ */
Implement _DSM Method 11 as per PCI firmware specs section 4.6.11 Rev 3.3. Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com> --- drivers/pci/pci-acpi.c | 53 ++++++++++++++++++++++++++++++++++++++++ include/linux/pci-acpi.h | 7 ++++++ 2 files changed, 60 insertions(+)