1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 28 Oct 2019 15:20:40 +0100
3 Subject: [PATCH] backport: add pci_disable_link_state wrapper with return code
5 The signature of pci_disable_link_state was changed to indicate if the state
6 was successfully disabled. Since the old version did not have this, add a
7 wrapper which checks the pcie register to determine the return code
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 --- a/backport-include/linux/pci.h
13 +++ b/backport-include/linux/pci.h
14 @@ -236,4 +236,29 @@ static inline struct pci_dev *pcie_find_
15 (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
18 +#if defined(CONFIG_PCI) && LINUX_VERSION_IS_LESS(5,3,0)
21 +LINUX_BACKPORT(pci_disable_link_state)(struct pci_dev *pdev, int state)
25 + pci_disable_link_state(pdev, state);
27 + pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspmc);
28 + if ((state & PCIE_LINK_STATE_L0S) &&
29 + (aspmc & PCI_EXP_LNKCTL_ASPM_L0S))
32 + if ((state & PCIE_LINK_STATE_L1) &&
33 + (aspmc & PCI_EXP_LNKCTL_ASPM_L1))
39 +#define pci_disable_link_state LINUX_BACKPORT(pci_disable_link_state)
43 #endif /* _BACKPORT_LINUX_PCI_H */