aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2019-10-28 16:02:32 +0100
committerFelix Fietkau <nbd@nbd.name>2019-12-28 20:40:58 +0100
commitda7dde8993169bfe4b91d590913b8d05debd7a89 (patch)
treeea7965c5f5e7252a38dfeceb5c4685407741cd7e
parent62d5ece70bf6cbbdd1add3a16475a1cea1cb260d (diff)
downloadupstream-da7dde8993169bfe4b91d590913b8d05debd7a89.tar.gz
upstream-da7dde8993169bfe4b91d590913b8d05debd7a89.tar.bz2
upstream-da7dde8993169bfe4b91d590913b8d05debd7a89.zip
mac80211: add pcie apsm backport changes
Required for newer versions of mt76 Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry-picked from commit d64daf7026ce47788f12130462a3107bdab8718f)
-rw-r--r--package/kernel/mac80211/patches/build/100-backports-pci-Include-linux-pci-aspm.h.patch24
-rw-r--r--package/kernel/mac80211/patches/build/101-backport-add-pci_disable_link_state-wrapper-with-ret.patch43
2 files changed, 67 insertions, 0 deletions
diff --git a/package/kernel/mac80211/patches/build/100-backports-pci-Include-linux-pci-aspm.h.patch b/package/kernel/mac80211/patches/build/100-backports-pci-Include-linux-pci-aspm.h.patch
new file mode 100644
index 0000000000..5faeb96748
--- /dev/null
+++ b/package/kernel/mac80211/patches/build/100-backports-pci-Include-linux-pci-aspm.h.patch
@@ -0,0 +1,24 @@
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Fri, 27 Sep 2019 23:12:08 +0200
+Subject: [PATCH] backports: pci: Include linux/pci-aspm.h
+
+In upstream commit 7ce2e76a0420 linux/pci-aspm.h was removed and the
+content included into pci.h. Add an include to have the functions
+defined in linux/pci-aspm.h available when linux/pci.h is included.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+
+--- a/backport-include/linux/pci.h
++++ b/backport-include/linux/pci.h
+@@ -3,6 +3,10 @@
+ #include_next <linux/pci.h>
+ #include <linux/version.h>
+
++#if LINUX_VERSION_IS_LESS(5,4,0)
++#include <linux/pci-aspm.h>
++#endif
++
+ #ifndef module_pci_driver
+ /**
+ * module_pci_driver() - Helper macro for registering a PCI driver
diff --git a/package/kernel/mac80211/patches/build/101-backport-add-pci_disable_link_state-wrapper-with-ret.patch b/package/kernel/mac80211/patches/build/101-backport-add-pci_disable_link_state-wrapper-with-ret.patch
new file mode 100644
index 0000000000..cae20f5dc3
--- /dev/null
+++ b/package/kernel/mac80211/patches/build/101-backport-add-pci_disable_link_state-wrapper-with-ret.patch
@@ -0,0 +1,43 @@
+From: Felix Fietkau <nbd@nbd.name>
+Date: Mon, 28 Oct 2019 15:20:40 +0100
+Subject: [PATCH] backport: add pci_disable_link_state wrapper with return code
+
+The signature of pci_disable_link_state was changed to indicate if the state
+was successfully disabled. Since the old version did not have this, add a
+wrapper which checks the pcie register to determine the return code
+
+Signed-off-by: Felix Fietkau <nbd@nbd.name>
+---
+
+--- a/backport-include/linux/pci.h
++++ b/backport-include/linux/pci.h
+@@ -236,4 +236,29 @@ static inline struct pci_dev *pcie_find_
+ (PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
+ #endif
+
++#if LINUX_VERSION_IS_LESS(5,3,0)
++
++static inline int
++LINUX_BACKPORT(pci_disable_link_state)(struct pci_dev *pdev, int state)
++{
++ u16 aspmc;
++
++ pci_disable_link_state(pdev, state);
++
++ pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &aspmc);
++ if ((state & PCIE_LINK_STATE_L0S) &&
++ (aspmc & PCI_EXP_LNKCTL_ASPM_L0S))
++ return -EPERM;
++
++ if ((state & PCIE_LINK_STATE_L1) &&
++ (aspmc & PCI_EXP_LNKCTL_ASPM_L1))
++ return -EPERM;
++
++ return 0;
++}
++
++#define pci_disable_link_state LINUX_BACKPORT(pci_disable_link_state)
++
++#endif
++
+ #endif /* _BACKPORT_LINUX_PCI_H */