backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: backports@vger.kernel.org
Cc: johannes@sipsolutions.net, nbd@nbd.name,
	Hauke Mehrtens <hauke@hauke-m.de>
Subject: [PATCH v2] backports: Add return value to backport_pci_disable_link_state()
Date: Tue, 19 Nov 2019 00:45:09 +0100	[thread overview]
Message-ID: <20191118234509.13044-1-hauke@hauke-m.de> (raw)

Since Linux upstream commit 4cfd21885592 ("PCI: let
pci_disable_link_state propagate errors") The
backport_pci_disable_link_state() function can return an error. This
return code is now used by the mt76 driver.

In case it is not possible to disable ASPM, for example on some ACPI
systems, we should return an error and mt76 handles this. Do this by
checking the PCI registers if the operation was successfully.

The checking of the PCI register was added by Felix Fietkau.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/pci.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/backport/backport-include/linux/pci.h b/backport/backport-include/linux/pci.h
index 84c4e8f6..1cc5f281 100644
--- a/backport/backport-include/linux/pci.h
+++ b/backport/backport-include/linux/pci.h
@@ -236,4 +236,29 @@ static inline struct pci_dev *pcie_find_root_port(struct pci_dev *dev)
 	(PCI_IRQ_LEGACY | PCI_IRQ_MSI | PCI_IRQ_MSIX)
 #endif
 
+#if defined(CONFIG_PCI)
+#if LINUX_VERSION_IS_LESS(5,3,0)
+static inline int
+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 /* < 5.3 */
+#endif /* defined(CONFIG_PCI) */
+
 #endif /* _BACKPORT_LINUX_PCI_H */
-- 
2.20.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

                 reply	other threads:[~2019-11-18 23:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191118234509.13044-1-hauke@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=20191116183623.8858-1-hauke@hauke-m.de \
    --cc=backports@vger.kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).