History

PCI: let pci_disable_link_state propagate errors

Drivers may rely on pci_disable_link_state() having disabled certain ASPM link states. If OS can't control ASPM then pci_disable_link_state() turns into a no-op w/o informing the caller. The driver therefore may falsely assume the respective ASPM link states are disabled. Let pci_disable_link_state() propagate errors to the caller, enabling the caller to react accordingly.

Heiner Kallweit committed 7 years ago

Commit 4cfd2181 parent dca73a62 files · +15 −12Browse files

Unified · Split

2 files
  1. drivers/pci/pcie/aspm.c +11 −9
  2. include/linux/pci-aspm.h +4 −3
drivers/pci/pcie/aspm.c+11−9
@@ -1062,18 +1062,18 @@ void pcie_aspm_powersave_config_link(struct pci_dev *pdev) · 1061 unmodified lines
10621062 up_read(&pci_bus_sem);
10631063 }
10641064
1065−static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
1065+static int __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem)
10661066 {
10671067 struct pci_dev *parent = pdev->bus->self;
10681068 struct pcie_link_state *link;
10691069
10701070 if (!pci_is_pcie(pdev))
1071− return;
1071+ return 0;
10721072
10731073 if (pdev->has_secondary_link)
10741074 parent = pdev;
10751075 if (!parent || !parent->link_state)
1076− return;
1076+ return -EINVAL;
10771077
10781078 /*
10791079 * A driver requested that ASPM be disabled on this device, but
@@ -1085,7 +1085,7 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) · 5 unmodified lines
10851085 */
10861086 if (aspm_disabled) {
10871087 pci_warn(pdev, "can't disable ASPM; OS doesn't have ASPM control\n");
1088− return;
1088+ return -EPERM;
10891089 }
10901090
10911091 if (sem)
@@ -1105,11 +1105,13 @@ static void __pci_disable_link_state(struct pci_dev *pdev, int state, bool sem) · 13 unmodified lines
11051105 mutex_unlock(&aspm_lock);
11061106 if (sem)
11071107 up_read(&pci_bus_sem);
1108+
1109+ return 0;
11081110 }
11091111
1110−void pci_disable_link_state_locked(struct pci_dev *pdev, int state)
1112+int pci_disable_link_state_locked(struct pci_dev *pdev, int state)
11111113 {
1112− __pci_disable_link_state(pdev, state, false);
1114+ return __pci_disable_link_state(pdev, state, false);
11131115 }
11141116 EXPORT_SYMBOL(pci_disable_link_state_locked);
11151117
@@ -1117,14 +1119,14 @@ EXPORT_SYMBOL(pci_disable_link_state_locked); · 1 unmodified line
11171119 * pci_disable_link_state - Disable device's link state, so the link will
11181120 * never enter specific states. Note that if the BIOS didn't grant ASPM
11191121 * control to the OS, this does nothing because we can't touch the LNKCTL
1120− * register.
1122+ * register. Returns 0 or a negative errno.
11211123 *
11221124 * @pdev: PCI device
11231125 * @state: ASPM link state to disable
11241126 */
1125−void pci_disable_link_state(struct pci_dev *pdev, int state)
1127+int pci_disable_link_state(struct pci_dev *pdev, int state)
11261128 {
1127− __pci_disable_link_state(pdev, state, true);
1129+ return __pci_disable_link_state(pdev, state, true);
11281130 }
11291131 EXPORT_SYMBOL(pci_disable_link_state);
11301132
include/linux/pci-aspm.h+4−3
@@ -24,11 +24,12 @@ · 23 unmodified lines
2424 #define PCIE_LINK_STATE_CLKPM 4
2525
2626 #ifdef CONFIG_PCIEASPM
27−void pci_disable_link_state(struct pci_dev *pdev, int state);
28−void pci_disable_link_state_locked(struct pci_dev *pdev, int state);
27+int pci_disable_link_state(struct pci_dev *pdev, int state);
28+int pci_disable_link_state_locked(struct pci_dev *pdev, int state);
2929 void pcie_no_aspm(void);
3030 #else
31−static inline void pci_disable_link_state(struct pci_dev *pdev, int state) { }
31+static inline int pci_disable_link_state(struct pci_dev *pdev, int state)
32+{ return 0; }
3233 static inline void pcie_no_aspm(void) { }
3334 #endif
3435

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t