From: Stanislaw Gruszka <sgruszka@redhat.com>
To: "John W. Linville" <linville@tuxdriver.com>,
linux-wireless <linux-wireless@vger.kernel.org>
Cc: ath9k-devel@venema.h4ckr.net, camilo@mesias.co.uk,
Jonathan Nieder <jrnieder@gmail.com>,
Tony Houghton <h@realh.co.uk>,
Rajkumar Manoharan <rmanoharan@atheros.com>,
ath9k-devel@venema.h4ckr.net, Adrian Chadd <adrian@freebsd.org>,
<lrodriguez@atheros.com>
Subject: [PATCH -next 4/8] pci: aspm: add function for disabling ASPM
Date: Fri, 5 Aug 2011 13:10:35 +0200 [thread overview]
Message-ID: <1312542639-4274-5-git-send-email-sgruszka@redhat.com> (raw)
In-Reply-To: <1312542639-4274-1-git-send-email-sgruszka@redhat.com>
Add support for disabling ASPM if !CONFIG_PCIEASPM. Patch is based
on code from e1000e.
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: linux-pci@vger.kernel.org
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: e1000-devel@lists.sourceforge.net
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
drivers/pci/pcie/Makefile | 3 +--
drivers/pci/pcie/aspm.c | 41 +++++++++++++++++++++++++++++++++++++++++
include/linux/pci-aspm.h | 2 ++
3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile
index 00c62df..6e20c59 100644
--- a/drivers/pci/pcie/Makefile
+++ b/drivers/pci/pcie/Makefile
@@ -2,8 +2,7 @@
# Makefile for PCI-Express PORT Driver
#
-# Build PCI Express ASPM if needed
-obj-$(CONFIG_PCIEASPM) += aspm.o
+obj-y += aspm.o
pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o
pcieportdrv-$(CONFIG_ACPI) += portdrv_acpi.o
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
index 6892601..2883fc3 100644
--- a/drivers/pci/pcie/aspm.c
+++ b/drivers/pci/pcie/aspm.c
@@ -21,6 +21,8 @@
#include <linux/pci-aspm.h>
#include "../pci.h"
+#ifdef CONFIG_PCIEASPM
+
#ifdef MODULE_PARAM_PREFIX
#undef MODULE_PARAM_PREFIX
#endif
@@ -976,3 +978,42 @@ bool pcie_aspm_support_enabled(void)
return aspm_support_enabled;
}
EXPORT_SYMBOL(pcie_aspm_support_enabled);
+
+void pcie_disable_aspm(struct pci_dev *pdev, u16 state)
+{
+ pci_disable_link_state_locked(pdev, state);
+}
+EXPORT_SYMBOL(pcie_disable_aspm);
+
+#else /* CONFIG_PCIEASPM */
+
+void pcie_disable_aspm(struct pci_dev *pdev, u16 state)
+{
+ int pos;
+ u16 reg16;
+ struct pci_dev *parent;
+
+ pos = pci_pcie_cap(pdev);
+ if (!pos)
+ return;
+ /*
+ * Both device and parent should have the same ASPM setting.
+ * Disable ASPM in downstream component first and then upstream.
+ */
+
+ pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, ®16);
+ reg16 &= ~state;
+ pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
+
+ parent = pdev->bus->self;
+ if (WARN_ON(!parent))
+ return;
+
+ pos = pci_pcie_cap(parent);
+ pci_read_config_word(parent, pos + PCI_EXP_LNKCTL, ®16);
+ reg16 &= ~state;
+ pci_write_config_word(parent, pos + PCI_EXP_LNKCTL, reg16);
+}
+EXPORT_SYMBOL(pcie_disable_aspm);
+
+#endif
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h
index 7cea7b6..f9722e6 100644
--- a/include/linux/pci-aspm.h
+++ b/include/linux/pci-aspm.h
@@ -55,6 +55,8 @@ static inline void pcie_no_aspm(void)
}
#endif
+extern void pcie_disable_aspm(struct pci_dev *pdev, u16 state);
+
#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
extern void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev);
extern void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev);
--
1.7.1
next prev parent reply other threads:[~2011-08-05 11:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-05 11:10 [PATCH -next 0/8] ath9k: ASPM fixes Stanislaw Gruszka
2011-08-05 11:10 ` [PATCH -next 1/8] ath9k: remove ->config_pci_powersave() redundant argument Stanislaw Gruszka
2011-08-05 11:10 ` [PATCH -next 2/8] ath9k: merge common ->config_pci_powersave() checks Stanislaw Gruszka
2011-08-05 11:10 ` [PATCH -next 3/8] ath9k: do btcoex ASPM disabling at initialization time Stanislaw Gruszka
2011-08-05 11:10 ` Stanislaw Gruszka [this message]
2011-08-05 11:10 ` [PATCH -next 5/8] ath9k: use common function for disabling ASPM Stanislaw Gruszka
2011-08-05 11:10 ` [PATCH -next 6/8] e1000e: " Stanislaw Gruszka
2011-08-05 11:10 ` [PATCH -next 7/8] pci: aspm: add settings changed callback Stanislaw Gruszka
2011-08-05 11:10 ` [PATCH -next 8/8] ath9k: be prepare for dynamic ASPM settings change Stanislaw Gruszka
2011-08-11 16:08 ` [PATCH -next 0/8] ath9k: ASPM fixes John W. Linville
2011-08-12 12:35 ` Stanislaw Gruszka
2011-08-12 18:49 ` Jeff Kirsher
2011-08-17 15:41 ` Stanislaw Gruszka
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=1312542639-4274-5-git-send-email-sgruszka@redhat.com \
--to=sgruszka@redhat.com \
--cc=adrian@freebsd.org \
--cc=ath9k-devel@venema.h4ckr.net \
--cc=camilo@mesias.co.uk \
--cc=h@realh.co.uk \
--cc=jrnieder@gmail.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=lrodriguez@atheros.com \
--cc=rmanoharan@atheros.com \
/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).