linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath5k: disable ASPM
@ 2010-05-28 10:09 Jussi Kivilinna
  2010-05-28 16:19 ` [ath5k-devel] " Pavel Roskin
                   ` (3 more replies)
  0 siblings, 4 replies; 73+ messages in thread
From: Jussi Kivilinna @ 2010-05-28 10:09 UTC (permalink / raw)
  To: ath5k-devel; +Cc: linux-wireless

Atheros card on Acer Aspire One (AOA150, Atheros Communications Inc. AR5001
Wireless Network Adapter [168c:001c] (rev 01)) doesn't work well with ASPM
enabled. With ASPM ath5k will eventually stall on heavy traffic with often
'unsupported jumbo' warnings appearing. Disabling ASPM L0s/L1 in ath5k fixes
these problems.

Reproduced with pcie_aspm=force and by using 'nc < /dev/zero > /dev/null' at
both ends (usually stalls within seconds).

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
 drivers/net/wireless/ath/ath5k/base.c |   48 +++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index cc6d41d..ce9c983 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -48,6 +48,7 @@
 #include <linux/netdevice.h>
 #include <linux/cache.h>
 #include <linux/pci.h>
+#include <linux/pci-aspm.h>
 #include <linux/ethtool.h>
 #include <linux/uaccess.h>
 #include <linux/slab.h>
@@ -195,6 +196,8 @@ static const struct ieee80211_rate ath5k_rates[] = {
 static int __devinit	ath5k_pci_probe(struct pci_dev *pdev,
 				const struct pci_device_id *id);
 static void __devexit	ath5k_pci_remove(struct pci_dev *pdev);
+static void		__ath5k_disable_aspm(struct pci_dev *pdev, u16 state);
+static void		ath5k_disable_aspm(struct pci_dev *pdev, u16 state);
 #ifdef CONFIG_PM
 static int		ath5k_pci_suspend(struct device *dev);
 static int		ath5k_pci_resume(struct device *dev);
@@ -424,6 +427,47 @@ module_exit(exit_ath5k_pci);
 * PCI Initialization *
 \********************/
 
+#ifdef CONFIG_PCIEASPM
+static void __ath5k_disable_aspm(struct pci_dev *pdev, u16 state)
+{
+	pci_disable_link_state(pdev, state);
+}
+#else
+static void __ath5k_disable_aspm(struct pci_dev *pdev, u16 state)
+{
+	int pos;
+	u16 reg16;
+
+	/*
+	 * Both device and parent should have the same ASPM setting.
+	 * Disable ASPM in downstream component first and then upstream.
+	 */
+	pos = pci_pcie_cap(pdev);
+	pci_read_config_word(pdev, pos + PCI_EXP_LNKCTL, &reg16);
+	reg16 &= ~state;
+	pci_write_config_word(pdev, pos + PCI_EXP_LNKCTL, reg16);
+
+	if (!pdev->bus->self)
+		return;
+
+	pos = pci_pcie_cap(pdev->bus->self);
+	pci_read_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, &reg16);
+	reg16 &= ~state;
+	pci_write_config_word(pdev->bus->self, pos + PCI_EXP_LNKCTL, reg16);
+}
+#endif
+static void ath5k_disable_aspm(struct pci_dev *pdev, u16 state)
+{
+	if (!pdev->is_pcie)
+		return;
+
+	dev_info(&pdev->dev, "Disabling ASPM %s%s\n",
+		 (state & PCIE_LINK_STATE_L0S) ? "L0s " : "",
+		 (state & PCIE_LINK_STATE_L1) ? "L1" : "");
+
+	__ath5k_disable_aspm(pdev, state);
+}
+
 static const char *
 ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val)
 {
@@ -473,6 +517,8 @@ ath5k_pci_probe(struct pci_dev *pdev,
 	int ret;
 	u8 csz;
 
+	ath5k_disable_aspm(pdev, PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_L0S);
+
 	ret = pci_enable_device(pdev);
 	if (ret) {
 		dev_err(&pdev->dev, "can't enable device\n");
@@ -725,6 +771,8 @@ static int ath5k_pci_resume(struct device *dev)
 	struct ieee80211_hw *hw = pci_get_drvdata(pdev);
 	struct ath5k_softc *sc = hw->priv;
 
+	ath5k_disable_aspm(pdev, PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_L0S);
+
 	/*
 	 * Suspend/Resume resets the PCI configuration space, so we have to
 	 * re-disable the RETRY_TIMEOUT register (0x41) to keep


^ permalink raw reply related	[flat|nested] 73+ messages in thread

end of thread, other threads:[~2010-07-29  0:06 UTC | newest]

Thread overview: 73+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-28 10:09 [PATCH] ath5k: disable ASPM Jussi Kivilinna
2010-05-28 16:19 ` [ath5k-devel] " Pavel Roskin
2010-05-28 18:25   ` Jussi Kivilinna
2010-05-28 20:27     ` Pavel Roskin
2010-05-31  1:06       ` Bruno Randolf
2010-06-01 20:43         ` Luis R. Rodriguez
2010-05-28 17:40 ` Luis R. Rodriguez
2010-05-28 18:20   ` Jussi Kivilinna
2010-06-17 20:33 ` Maxim Levitsky
2010-06-18  8:20   ` Jussi Kivilinna
2010-06-18  9:09     ` [ath5k-devel] " RHS Linux User
2010-06-18 10:15     ` Maxim Levitsky
2010-06-18 10:49       ` Jussi Kivilinna
2010-06-18 11:05         ` Maxim Levitsky
2010-06-18 13:59           ` Bob Copeland
2010-06-18 14:11             ` Maxim Levitsky
2010-06-19  7:49               ` [PATCH v2] " Maxim Levitsky
2010-06-19 12:38                 ` Bob Copeland
2010-06-19 13:02                   ` Maxim Levitsky
2010-06-19 15:32                     ` [PATCH v3] " Maxim Levitsky
2010-07-26 20:13                       ` [ath5k-devel] " Luis R. Rodriguez
2010-07-26 20:49                         ` Maxim Levitsky
2010-07-26 21:06                           ` Luis R. Rodriguez
2010-07-26 21:14                             ` Matthew Garrett
2010-07-26 22:20                               ` Luis R. Rodriguez
2010-07-26 22:24                                 ` Matthew Garrett
2010-07-26 22:29                                   ` Luis R. Rodriguez
2010-07-26 21:17                             ` Maxim Levitsky
2010-07-26 21:25                               ` Matthew Garrett
2010-07-26 22:15                                 ` Luis R. Rodriguez
2010-07-26 22:21                                   ` Matthew Garrett
2010-07-26 22:26                                     ` Luis R. Rodriguez
2010-07-26 22:29                                       ` Matthew Garrett
2010-07-26 22:31                                         ` Luis R. Rodriguez
2010-07-26 22:33                                           ` Matthew Garrett
2010-07-26 22:43                                             ` Luis R. Rodriguez
2010-07-26 22:50                                               ` Matthew Garrett
2010-07-27  9:35                                                 ` Maxim Levitsky
2010-07-27 15:57                                                   ` Luis R. Rodriguez
2010-07-28 23:48                                                     ` Maxim Levitsky
2010-07-29  0:06                                                       ` Luis R. Rodriguez
2010-07-26 22:13                               ` Luis R. Rodriguez
2010-07-26 22:56                         ` Luis R. Rodriguez
2010-06-20  8:13                 ` [ath5k-devel] [PATCH v2] " Luis R. Rodriguez
2010-06-20 11:18                   ` Maxim Levitsky
2010-06-20 18:04                     ` Maxim Levitsky
2010-06-21  5:53                     ` Luis R. Rodriguez
2010-06-21 20:01                       ` Jussi Kivilinna
2010-06-21 20:16                       ` Maxim Levitsky
2010-06-21 20:33                         ` Jussi Kivilinna
2010-06-21 20:39                           ` Luis R. Rodriguez
2010-06-22 16:31                             ` Matthew Garrett
2010-06-22 16:48                               ` Luis R. Rodriguez
2010-06-22 16:52                                 ` Matthew Garrett
2010-06-22 17:17                                   ` Luis R. Rodriguez
2010-06-22 17:25                                     ` Matthew Garrett
2010-06-22 17:40                                       ` Luis R. Rodriguez
2010-06-22 17:50                                         ` Matthew Garrett
2010-06-22 18:28                                           ` Luis R. Rodriguez
2010-06-22 18:44                                             ` Matthew Garrett
2010-06-22 19:13                                               ` Luis R. Rodriguez
2010-06-22 19:31                                               ` Johannes Stezenbach
2010-06-22 19:37                                                 ` Luis R. Rodriguez
2010-06-22 19:38                                                   ` Luis R. Rodriguez
2010-06-23 14:39                                                     ` Johannes Stezenbach
2010-06-23 16:28                                                       ` Luis R. Rodriguez
2010-06-23 19:07                                                         ` Johannes Stezenbach
2010-06-23 19:23                                                   ` Johannes Stezenbach
2010-06-21 20:37                         ` Luis R. Rodriguez
2010-06-21 23:55                           ` Maxim Levitsky
2010-07-26 16:34 ` [PATCH] " Maxim Levitsky
2010-07-26 18:37   ` John W. Linville
2010-07-26 18:41   ` [ath5k-devel] " Luis R. Rodriguez

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).