[RFC PATCH v1 2/2] PCI/ASPM: Never enable CLKPM for insane devices

From: Saheed O. Bolarinwa
Date: Sat Nov 06 2021 - 13:56:43 EST


clkpm_store() makes it possible to turn off link->clkpm_disable
for devices that fails pcie_aspm_sanity_check().

- Ceck the result of pcie_aspm_sanity_check() when setting
link->clpm_disable within clkpm_store().

Signed-off-by: Saheed O. Bolarinwa <refactormyself@xxxxxxxxx>
---
drivers/pci/pcie/aspm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 72cb17489e88..c81b0ef32229 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -1282,7 +1282,7 @@ static ssize_t clkpm_store(struct device *dev,
down_read(&pci_bus_sem);
mutex_lock(&aspm_lock);

- link->clkpm_disable = !state_enable;
+ link->clkpm_disable = !(state_enable && !pcie_aspm_sanity_check(pdev));
pcie_set_clkpm(link, policy_to_clkpm_state(link));

mutex_unlock(&aspm_lock);
--
2.20.1