Skip to content

Commit 7e229f0

Browse files
committed
Merge branch 'pci/pm'
- Reduce wait time for secondary bus to be ready to speed up resume (Mika Westerberg) - Avoid putting EloPOS E2/S2/H2 (as well as Elo i2) PCIe Ports in D3cold (Ondrej Zary) - Call _REG when transitioning D-states so AML that uses the PCI config space OpRegion works, which fixes some ASMedia GPIO controllers (Mario Limonciello) * pci/pm: PCI/ACPI: Call _REG when transitioning D-states PCI/ACPI: Validate acpi_pci_set_power_state() parameter PCI/PM: Avoid putting EloPOS E2/S2/H2 PCIe Ports in D3cold PCI/PM: Shorten pci_bridge_wait_for_secondary_bus() wait time for slow links
2 parents db5ccb2 + 112a7f9 commit 7e229f0

File tree

3 files changed

+82
-37
lines changed

3 files changed

+82
-37
lines changed

drivers/pci/pci-acpi.c

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,16 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev)
10431043
return false;
10441044
}
10451045

1046+
static void acpi_pci_config_space_access(struct pci_dev *dev, bool enable)
1047+
{
1048+
int val = enable ? ACPI_REG_CONNECT : ACPI_REG_DISCONNECT;
1049+
int ret = acpi_evaluate_reg(ACPI_HANDLE(&dev->dev),
1050+
ACPI_ADR_SPACE_PCI_CONFIG, val);
1051+
if (ret)
1052+
pci_dbg(dev, "ACPI _REG %s evaluation failed (%d)\n",
1053+
enable ? "connect" : "disconnect", ret);
1054+
}
1055+
10461056
int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
10471057
{
10481058
struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
@@ -1053,32 +1063,49 @@ int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
10531063
[PCI_D3hot] = ACPI_STATE_D3_HOT,
10541064
[PCI_D3cold] = ACPI_STATE_D3_COLD,
10551065
};
1056-
int error = -EINVAL;
1066+
int error;
10571067

10581068
/* If the ACPI device has _EJ0, ignore the device */
10591069
if (!adev || acpi_has_method(adev->handle, "_EJ0"))
10601070
return -ENODEV;
10611071

10621072
switch (state) {
1063-
case PCI_D3cold:
1064-
if (dev_pm_qos_flags(&dev->dev, PM_QOS_FLAG_NO_POWER_OFF) ==
1065-
PM_QOS_FLAGS_ALL) {
1066-
error = -EBUSY;
1067-
break;
1068-
}
1069-
fallthrough;
10701073
case PCI_D0:
10711074
case PCI_D1:
10721075
case PCI_D2:
10731076
case PCI_D3hot:
1074-
error = acpi_device_set_power(adev, state_conv[state]);
1077+
case PCI_D3cold:
1078+
break;
1079+
default:
1080+
return -EINVAL;
1081+
}
1082+
1083+
if (state == PCI_D3cold) {
1084+
if (dev_pm_qos_flags(&dev->dev, PM_QOS_FLAG_NO_POWER_OFF) ==
1085+
PM_QOS_FLAGS_ALL)
1086+
return -EBUSY;
1087+
1088+
/* Notify AML lack of PCI config space availability */
1089+
acpi_pci_config_space_access(dev, false);
10751090
}
10761091

1077-
if (!error)
1078-
pci_dbg(dev, "power state changed by ACPI to %s\n",
1079-
acpi_power_state_string(adev->power.state));
1092+
error = acpi_device_set_power(adev, state_conv[state]);
1093+
if (error)
1094+
return error;
10801095

1081-
return error;
1096+
pci_dbg(dev, "power state changed by ACPI to %s\n",
1097+
acpi_power_state_string(adev->power.state));
1098+
1099+
/*
1100+
* Notify AML of PCI config space availability. Config space is
1101+
* accessible in all states except D3cold; the only transitions
1102+
* that change availability are transitions to D3cold and from
1103+
* D3cold to D0.
1104+
*/
1105+
if (state == PCI_D0)
1106+
acpi_pci_config_space_access(dev, true);
1107+
1108+
return 0;
10821109
}
10831110

10841111
pci_power_t acpi_pci_get_power_state(struct pci_dev *dev)

drivers/pci/pci.c

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ struct pci_pme_device {
6464

6565
#define PME_TIMEOUT 1000 /* How long between PME checks */
6666

67+
/*
68+
* Following exit from Conventional Reset, devices must be ready within 1 sec
69+
* (PCIe r6.0 sec 6.6.1). A D3cold to D0 transition implies a Conventional
70+
* Reset (PCIe r6.0 sec 5.8).
71+
*/
72+
#define PCI_RESET_WAIT 1000 /* msec */
73+
6774
/*
6875
* Devices may extend the 1 sec period through Request Retry Status
6976
* completions (PCIe r6.0 sec 2.3.1). The spec does not provide an upper
@@ -2968,13 +2975,13 @@ static const struct dmi_system_id bridge_d3_blacklist[] = {
29682975
{
29692976
/*
29702977
* Downstream device is not accessible after putting a root port
2971-
* into D3cold and back into D0 on Elo i2.
2978+
* into D3cold and back into D0 on Elo Continental Z2 board
29722979
*/
2973-
.ident = "Elo i2",
2980+
.ident = "Elo Continental Z2",
29742981
.matches = {
2975-
DMI_MATCH(DMI_SYS_VENDOR, "Elo Touch Solutions"),
2976-
DMI_MATCH(DMI_PRODUCT_NAME, "Elo i2"),
2977-
DMI_MATCH(DMI_PRODUCT_VERSION, "RevB"),
2982+
DMI_MATCH(DMI_BOARD_VENDOR, "Elo Touch Solutions"),
2983+
DMI_MATCH(DMI_BOARD_NAME, "Geminilake"),
2984+
DMI_MATCH(DMI_BOARD_VERSION, "Continental Z2"),
29782985
},
29792986
},
29802987
#endif
@@ -5102,11 +5109,9 @@ int pci_bridge_wait_for_secondary_bus(struct pci_dev *dev, char *reset_type)
51025109
*
51035110
* However, 100 ms is the minimum and the PCIe spec says the
51045111
* software must allow at least 1s before it can determine that the
5105-
* device that did not respond is a broken device. There is
5106-
* evidence that 100 ms is not always enough, for example certain
5107-
* Titan Ridge xHCI controller does not always respond to
5108-
* configuration requests if we only wait for 100 ms (see
5109-
* https://bugzilla.kernel.org/show_bug.cgi?id=203885).
5112+
* device that did not respond is a broken device. Also device can
5113+
* take longer than that to respond if it indicates so through Request
5114+
* Retry Status completions.
51105115
*
51115116
* Therefore we wait for 100 ms and check for the device presence
51125117
* until the timeout expires.
@@ -5115,16 +5120,36 @@ int pci_bridge_wait_for_secondary_bus(struct pci_dev *dev, char *reset_type)
51155120
return 0;
51165121

51175122
if (pcie_get_speed_cap(dev) <= PCIE_SPEED_5_0GT) {
5123+
u16 status;
5124+
51185125
pci_dbg(dev, "waiting %d ms for downstream link\n", delay);
51195126
msleep(delay);
5120-
} else {
5121-
pci_dbg(dev, "waiting %d ms for downstream link, after activation\n",
5122-
delay);
5123-
if (!pcie_wait_for_link_delay(dev, true, delay)) {
5124-
/* Did not train, no need to wait any further */
5125-
pci_info(dev, "Data Link Layer Link Active not set in 1000 msec\n");
5127+
5128+
if (!pci_dev_wait(child, reset_type, PCI_RESET_WAIT - delay))
5129+
return 0;
5130+
5131+
/*
5132+
* If the port supports active link reporting we now check
5133+
* whether the link is active and if not bail out early with
5134+
* the assumption that the device is not present anymore.
5135+
*/
5136+
if (!dev->link_active_reporting)
51265137
return -ENOTTY;
5127-
}
5138+
5139+
pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &status);
5140+
if (!(status & PCI_EXP_LNKSTA_DLLLA))
5141+
return -ENOTTY;
5142+
5143+
return pci_dev_wait(child, reset_type,
5144+
PCIE_RESET_READY_POLL_MS - PCI_RESET_WAIT);
5145+
}
5146+
5147+
pci_dbg(dev, "waiting %d ms for downstream link, after activation\n",
5148+
delay);
5149+
if (!pcie_wait_for_link_delay(dev, true, delay)) {
5150+
/* Did not train, no need to wait any further */
5151+
pci_info(dev, "Data Link Layer Link Active not set in 1000 msec\n");
5152+
return -ENOTTY;
51285153
}
51295154

51305155
return pci_dev_wait(child, reset_type,

drivers/pci/pci.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ struct pci_cap_saved_state *pci_find_saved_ext_cap(struct pci_dev *dev,
6666
#define PCI_PM_D3HOT_WAIT 10 /* msec */
6767
#define PCI_PM_D3COLD_WAIT 100 /* msec */
6868

69-
/*
70-
* Following exit from Conventional Reset, devices must be ready within 1 sec
71-
* (PCIe r6.0 sec 6.6.1). A D3cold to D0 transition implies a Conventional
72-
* Reset (PCIe r6.0 sec 5.8).
73-
*/
74-
#define PCI_RESET_WAIT 1000 /* msec */
75-
7669
void pci_update_current_state(struct pci_dev *dev, pci_power_t state);
7770
void pci_refresh_power_state(struct pci_dev *dev);
7871
int pci_power_up(struct pci_dev *dev);

0 commit comments

Comments
 (0)