Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: Call _REG when saving/restoring PCI state
@ 2023-06-02  3:11 Mario Limonciello
  2023-06-02 20:21 ` Bjorn Helgaas
  0 siblings, 1 reply; 7+ messages in thread
From: Mario Limonciello @ 2023-06-02  3:11 UTC (permalink / raw)
  To: bhelgaas; +Cc: linux-pci, linux-kernel, Mario Limonciello

ASMedia PCIe GPIO controllers connected to AMD SOC fail functional tests
after returning from s2idle. This is because the BIOS checks whether the
OSPM has called the _REG method to determine whether it can interact with
the OperationRegion assigned to the device.

To fix this issue, call acpi_evaluate_reg() when saving and restoring the
state of PCI devices.

Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/06_Device_Configuration/Device_Configuration.html#reg-region
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/pci/pci.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e38c2f6eebd4..071ecba548b0 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1068,6 +1068,12 @@ static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
 	return acpi_pci_bridge_d3(dev);
 }
 
+static inline int platform_toggle_reg(struct pci_dev *dev, int c)
+{
+	return acpi_evaluate_reg(ACPI_HANDLE(&dev->dev),
+				 ACPI_ADR_SPACE_PCI_CONFIG, c);
+}
+
 /**
  * pci_update_current_state - Read power state of given device and cache it
  * @dev: PCI device to handle.
@@ -1645,6 +1651,9 @@ static void pci_restore_ltr_state(struct pci_dev *dev)
 int pci_save_state(struct pci_dev *dev)
 {
 	int i;
+
+	platform_toggle_reg(dev, ACPI_REG_DISCONNECT);
+
 	/* XXX: 100% dword access ok here? */
 	for (i = 0; i < 16; i++) {
 		pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]);
@@ -1790,6 +1799,8 @@ void pci_restore_state(struct pci_dev *dev)
 	pci_enable_acs(dev);
 	pci_restore_iov_state(dev);
 
+	platform_toggle_reg(dev, ACPI_REG_CONNECT);
+
 	dev->state_saved = false;
 }
 EXPORT_SYMBOL(pci_restore_state);
@@ -3203,6 +3214,7 @@ void pci_pm_init(struct pci_dev *dev)
 	pci_read_config_word(dev, PCI_STATUS, &status);
 	if (status & PCI_STATUS_IMM_READY)
 		dev->imm_ready = 1;
+	platform_toggle_reg(dev, ACPI_REG_CONNECT);
 }
 
 static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-06-06 15:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02  3:11 [PATCH] PCI: Call _REG when saving/restoring PCI state Mario Limonciello
2023-06-02 20:21 ` Bjorn Helgaas
2023-06-02 21:57   ` Limonciello, Mario
2023-06-04 11:30     ` Rafael J. Wysocki
2023-06-05 18:33       ` Limonciello, Mario
2023-06-06 15:27         ` Limonciello, Mario
2023-06-04 11:06   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox