ath9k: ASPM fixes
Subsystems (3)
v2 cover ath9k: ASPM fixes
This patch series try to fix ath9k ASPM. Some of patches are cleanup only or do merging common code (with e1000e driver).
With CONFIG_PCIEASPM it's possible to change ASPM settings on runtime via /sys/module/pcie_aspm/parameters/policy . However most drivers I looked at assume this setting is constant. I add a callback to pci driver to inform about the change, and allow driver to do needed hw related changes. Currently only ath9k implement the callback, but I think it will be useful for other drivers (i.e. iwlwifi, rtlwifi) that do some own ASPM handling.
These patches needs wide testing as they may work on some systems and not work on others, that can depend on PCIe bridges.
--- drivers/net/e1000e/netdev.c | 31 ---------- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 12 --- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 12 --- drivers/net/wireless/ath/ath9k/hw-ops.h | 9 +- drivers/net/wireless/ath/ath9k/hw.c | 17 +++-- drivers/net/wireless/ath/ath9k/hw.h | 12 +-- drivers/net/wireless/ath/ath9k/main.c | 8 -- drivers/net/wireless/ath/ath9k/pci.c | 88 ++++++++++++++++++++++------- drivers/pci/pcie/Makefile | 3 drivers/pci/pcie/aspm.c | 46 ++++++++++++++- include/linux/pci-aspm.h | 2 include/linux/pci.h | 3 12 files changed, 148 insertions(+), 95 deletions(-)
PATCH v2 1/12 ath9k: skip ->config_pci_powersave() if PCIe port has ASPM disabled
We receive many bug reports about system hang during suspend/resume when ath9k driver is in use. Adrian Chadd remarked that this problem happens on systems that have ASPM disabled.
To do not hit the bug, skip doing ->config_pci_powersave magic if PCIe downstream port device, which ath9k device is connected to, has ASPM disabled.
--- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 6 +----- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 6 +----- drivers/net/wireless/ath/ath9k/hw.c | 1 - drivers/net/wireless/ath/ath9k/hw.h | 2 +- drivers/net/wireless/ath/ath9k/pci.c | 23 +++++++++++++++++++++++ 5 files changed, 26 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_hw.c +1 -5
@@ -309,11 +309,7 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,u8 i;u32 val; -if (ah->is_pciexpress != true) -return ; - -/* Do not touch SerDes registers */ -if (ah->config.pcie_powersave_enable ==2 ) +if (ah->is_pciexpress != true || ah->aspm_enabled != true)return ;/* Nothing to do on restore for 11N */
drivers/net/wireless/ath/ath9k/ar9003_hw.c +1 -5
@@ -519,11 +519,7 @@ static void ar9003_hw_configpcipowersave(struct ath_hw *ah, int restore, int power_off) { -if (ah->is_pciexpress != true) -return ; - -/* Do not touch SerDes registers */ -if (ah->config.pcie_powersave_enable ==2 ) +if (ah->is_pciexpress != true || ah->aspm_enabled != true)return ;/* Nothing to do on restore for 11N */
drivers/net/wireless/ath/ath9k/hw.c +0 -1
@@ -378,7 +378,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah) ah->config.additional_swba_backoff =0 ; ah->config.ack_6mb =0x0 ; ah->config.cwm_ignore_extcca =0 ; - ah->config.pcie_powersave_enable =0 ; ah->config.pcie_clock_req =0 ; ah->config.pcie_waen =0 ; ah->config.analog_shiftreg =1 ;
drivers/net/wireless/ath/ath9k/hw.h +1 -1
@@ -219,7 +219,6 @@ struct ath9k_ops_config {int additional_swba_backoff;int ack_6mb;u32 cwm_ignore_extcca; -u8 pcie_powersave_enable;bool pcieSerDesWrite;u8 pcie_clock_req;u32 pcie_waen;
@@ -673,6 +672,7 @@ struct ath_hw {bool sw_mgmt_crypto;bool is_pciexpress; +bool aspm_enabled;bool is_monitoring;bool need_an_top2_fixup;u16 tx_trig_level;
drivers/net/wireless/ath/ath9k/pci.c +23 -0
@@ -123,6 +123,27 @@ static const struct ath_bus_ops ath_pci_bus_ops = { .extn_synch_en = ath_pci_extn_synch_enable, }; +static void ath_pci_check_aspm (struct ath_softc *sc) +{ +struct ath_hw *ah = sc->sc_ah; +struct pci_dev *pdev =to_pci_dev (sc->dev); +struct pci_dev *parent; +u8 aspm; + + ah->aspm_enabled = false; + +if (!pci_is_pcie (pdev)) +return ; + + parent = pdev->bus->self; +if (WARN_ON (!parent)) +return ; + +pci_read_config_byte (parent,ATH_PCIE_CAP_LINK_CTRL , &aspm); +if (aspm & (ATH_PCIE_CAP_LINK_L0S |ATH_PCIE_CAP_LINK_L1 )) + ah->aspm_enabled = true; +} +static int ath_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {void __iomem *mem;
@@ -230,6 +251,8 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_init; } +ath_pci_check_aspm (sc); +ath9k_hw_name (sc->sc_ah, hw_name,sizeof (hw_name));wiphy_info (hw->wiphy,"%s mem=0x%lx, irq=%d\n" , hw_name, (unsigned long )mem, pdev->irq);
Signature · 1 line
1.7.1
PATCH v2 2/12 ath9k: remove ->config_pci_powersave() redundant argument
In reply to Stanislaw GruszkaWe always call ->config_pci_powersave() with both restore and power_off arguments equal to 0 or both equal to 1, so merge them into one argument.
--- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 5 ++--- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 5 ++--- drivers/net/wireless/ath/ath9k/hw-ops.h | 5 ++--- drivers/net/wireless/ath/ath9k/hw.c | 2 +- drivers/net/wireless/ath/ath9k/hw.h | 3 +-- drivers/net/wireless/ath/ath9k/main.c | 6 +++--- 6 files changed, 11 insertions(+), 15 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_hw.c +2 -3
@@ -303,8 +303,7 @@ static void ar9002_hw_init_mode_gain_regs(struct ath_hw *ah)* register as the other analog registers. Hence the 9 writes. */ static void ar9002_hw_configpcipowersave (struct ath_hw *ah, -int restore, -int power_off) +bool power_off) {u8 i;u32 val;
@@ -313,7 +312,7 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,return ;/* Nothing to do on restore for 11N */ -if (!restore) { +if (!power_off/* !restore */ ) {if (AR_SREV_9280_20_OR_LATER (ah)) {/* * AR9280 2.0 or later chips use SerDes values from the
drivers/net/wireless/ath/ath9k/ar9003_hw.c +2 -3
@@ -516,14 +516,13 @@ static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)* register as the other analog registers. Hence the 9 writes. */ static void ar9003_hw_configpcipowersave (struct ath_hw *ah, -int restore, -int power_off) +bool power_off) {if (ah->is_pciexpress != true || ah->aspm_enabled != true)return ;/* Nothing to do on restore for 11N */ -if (!restore) { +if (!power_off/* !restore */ ) {/* set bit 19 to allow forcing of pcie core into L1 state */ REG_SET_BIT (ah,AR_PCIE_PM_CTRL ,AR_PCIE_PM_CTRL_ENA );
drivers/net/wireless/ath/ath9k/hw-ops.h +2 -3
@@ -22,10 +22,9 @@/* Hardware core and driver accessible callbacks */ static inline void ath9k_hw_configpcipowersave (struct ath_hw *ah, -int restore, -int power_off) +bool power_off) { -ath9k_hw_ops (ah)->config_pci_powersave (ah, restore, power_off); +ath9k_hw_ops (ah)->config_pci_powersave (ah, power_off); }static inline void ath9k_hw_rxena (struct ath_hw *ah)
drivers/net/wireless/ath/ath9k/hw.c +1 -1
@@ -597,7 +597,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)if (ah->is_pciexpress) -ath9k_hw_configpcipowersave (ah,0 ,0 ); +ath9k_hw_configpcipowersave (ah, false);else ath9k_hw_disablepcie (ah);
drivers/net/wireless/ath/ath9k/hw.h +1 -2
@@ -601,8 +601,7 @@ struct ath_hw_private_ops {*/ struct ath_hw_ops {void (*config_pci_powersave)(struct ath_hw *ah, -int restore, -int power_off); +bool power_off);void (*rx_enable)(struct ath_hw *ah);void (*set_desc_link)(void *ds,u32 link); bool (*calibrate)(struct ath_hw *ah,
drivers/net/wireless/ath/ath9k/main.c +3 -3
@@ -887,7 +887,7 @@ static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)ath9k_ps_wakeup (sc);spin_lock_bh (&sc->sc_pcu_lock); -ath9k_hw_configpcipowersave (ah,0 ,0 ); +ath9k_hw_configpcipowersave (ah, false);if (!ah->curchan) ah->curchan =ath9k_cmn_get_curchannel (sc->hw, ah);
@@ -967,7 +967,7 @@ void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)ath9k_hw_phy_disable (ah); -ath9k_hw_configpcipowersave (ah,1 ,1 ); +ath9k_hw_configpcipowersave (ah, true);spin_unlock_bh (&sc->sc_pcu_lock);ath9k_ps_restore (sc);
@@ -1066,7 +1066,7 @@ static int ath9k_start(struct ieee80211_hw *hw) init_channel =ath9k_cmn_get_curchannel (hw, ah);/* Reset SERDES registers */ -ath9k_hw_configpcipowersave (ah,0 ,0 ); +ath9k_hw_configpcipowersave (ah, false);/* * The basic interface to setting the hardware in a good
Signature · 1 line
1.7.1
PATCH v2 3/12 ath9k: merge common ->config_pci_powersave() checks
In reply to Stanislaw GruszkaMove common checks into wrapper function. Since ASPM can be only enabled on PCIe devices ->is_pciexpress check is unneeded.
--- drivers/net/wireless/ath/ath9k/ar9002_hw.c | 3 --- drivers/net/wireless/ath/ath9k/ar9003_hw.c | 3 --- drivers/net/wireless/ath/ath9k/hw-ops.h | 3 +++ 3 files changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/ath/ath9k/ar9002_hw.c +0 -3
@@ -308,9 +308,6 @@ static void ar9002_hw_configpcipowersave(struct ath_hw *ah,u8 i;u32 val; -if (ah->is_pciexpress != true || ah->aspm_enabled != true) -return ; -/* Nothing to do on restore for 11N */ if (!power_off/* !restore */ ) {if (AR_SREV_9280_20_OR_LATER (ah)) {
drivers/net/wireless/ath/ath9k/ar9003_hw.c +0 -3
@@ -518,9 +518,6 @@ static void ar9003_hw_init_mode_gain_regs(struct ath_hw *ah)static void ar9003_hw_configpcipowersave (struct ath_hw *ah,bool power_off) { -if (ah->is_pciexpress != true || ah->aspm_enabled != true) -return ; -/* Nothing to do on restore for 11N */ if (!power_off/* !restore */ ) {/* set bit 19 to allow forcing of pcie core into L1 state */
drivers/net/wireless/ath/ath9k/hw-ops.h +3 -0
@@ -24,6 +24,9 @@static inline void ath9k_hw_configpcipowersave (struct ath_hw *ah,bool power_off) { +if (ah->aspm_enabled != true) +return ; +ath9k_hw_ops (ah)->config_pci_powersave (ah, power_off); }
Signature · 1 line
1.7.1
PATCH v2 4/12 ath9k: use common PCIe ASPM definces instead of custom ones
In reply to Stanislaw Gruszka--- drivers/net/wireless/ath/ath9k/hw.h | 4 ---- drivers/net/wireless/ath/ath9k/pci.c | 17 +++++++++++------ 2 files changed, 11 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath9k/hw.h +0 -4
@@ -1028,10 +1028,6 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);void ath9k_hw_proc_mib_event (struct ath_hw *ah);void ath9k_hw_ani_monitor (struct ath_hw *ah,struct ath9k_channel *chan); -#define ATH_PCIE_CAP_LINK_CTRL 0x70 -#define ATH_PCIE_CAP_LINK_L0S 1 -#define ATH_PCIE_CAP_LINK_L1 2 -#define ATH9K_CLOCK_RATE_CCK 22#define ATH9K_CLOCK_RATE_5GHZ_OFDM 40#define ATH9K_CLOCK_RATE_2GHZ_OFDM 44
drivers/net/wireless/ath/ath9k/pci.c +11 -6
@@ -16,6 +16,7 @@#include <linux/nl80211.h> #include <linux/pci.h> +#include <linux/pci-aspm.h> #include <linux/ath9k_platform.h> #include "ath9k.h"
@@ -94,14 +95,16 @@ static void ath_pci_bt_coex_prep(struct ath_common *common) {struct ath_softc *sc = (struct ath_softc *) common->priv;struct pci_dev *pdev =to_pci_dev (sc->dev); +int pos;u8 aspm; -if (!pci_is_pcie (pdev)) + pos =pci_pcie_cap (pdev); +if (!pos)return ; -pci_read_config_byte (pdev,ATH_PCIE_CAP_LINK_CTRL , &aspm); - aspm &= ~(ATH_PCIE_CAP_LINK_L0S |ATH_PCIE_CAP_LINK_L1 ); -pci_write_config_byte (pdev,ATH_PCIE_CAP_LINK_CTRL , aspm); +pci_read_config_byte (pdev, pos +PCI_EXP_LNKCTL , &aspm); + aspm &= ~(PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 ); +pci_write_config_byte (pdev, pos +PCI_EXP_LNKCTL , aspm); }static void ath_pci_extn_synch_enable (struct ath_common *common)
@@ -128,6 +131,7 @@ static void ath_pci_check_aspm(struct ath_softc *sc)struct ath_hw *ah = sc->sc_ah;struct pci_dev *pdev =to_pci_dev (sc->dev);struct pci_dev *parent; +int ppos;u8 aspm; ah->aspm_enabled = false;
@@ -139,8 +143,9 @@ static void ath_pci_check_aspm(struct ath_softc *sc)if (WARN_ON (!parent))return ; -pci_read_config_byte (parent,ATH_PCIE_CAP_LINK_CTRL , &aspm); -if (aspm & (ATH_PCIE_CAP_LINK_L0S |ATH_PCIE_CAP_LINK_L1 )) + ppos =pci_pcie_cap (parent); +pci_read_config_byte (parent, ppos +PCI_EXP_LNKCTL , &aspm); +if (aspm & (PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 )) ah->aspm_enabled = true; }
Signature · 1 line
1.7.1
PATCH v2 5/12 ath9k: do btcoex ASPM disabling at initialization time
In reply to Stanislaw GruszkaDisable ASPM in pci .probe, to do not change settings when pci_bus_sem is not held.
Disable ASPM on upstream (device) and downstream (PCIe port) component. According to e1000e driver authors this is required. I did not find that requirement in PCIe spec, but it seems to be logical for me.
This need to be fixed for CONFIG_PCIEASPM, that will be done later ...
--- drivers/net/wireless/ath/ath9k/hw.h | 1 - drivers/net/wireless/ath/ath9k/main.c | 2 - drivers/net/wireless/ath/ath9k/pci.c | 52 +++++++++++++++++--------------- 3 files changed, 28 insertions(+), 27 deletions(-)
drivers/net/wireless/ath/ath9k/hw.h +0 -1
@@ -871,7 +871,6 @@ struct ath_bus_ops {enum ath_bus_type ath_bus_type;void (*read_cachesize)(struct ath_common *common,int *csz);bool (*eeprom_read)(struct ath_common *common,u32 off,u16 *data); -void (*bt_coex_prep)(struct ath_common *common);void (*extn_synch_en)(struct ath_common *common); };
drivers/net/wireless/ath/ath9k/main.c +0 -2
@@ -1141,8 +1141,6 @@ static int ath9k_start(struct ieee80211_hw *hw) AR_STOMP_LOW_WLAN_WGHT);ath9k_hw_btcoex_enable (ah); -if (common->bus_ops->bt_coex_prep) - common->bus_ops->bt_coex_prep (common);if (ah->btcoex_hw.scheme ==ATH_BTCOEX_CFG_3WIRE )ath9k_btcoex_timer_resume (sc); }
drivers/net/wireless/ath/ath9k/pci.c +28 -24
84 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 6/12 ath9k: init PCIe PM and SERDES registers if ASPM is enabled
In reply to Stanislaw GruszkaDuring init, we currently skip calling ->config_pci_powersave() because ah->aspm_enabled is not initialized. Fix that and initialize registers after we discover if ASPM is enabled.
--- drivers/net/wireless/ath/ath9k/hw.c | 5 +---- drivers/net/wireless/ath/ath9k/pci.c | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +1 -4
@@ -595,10 +595,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)ath9k_hw_init_mode_regs (ah); - -if (ah->is_pciexpress) -ath9k_hw_configpcipowersave (ah, false); -else +if (!ah->is_pciexpress)ath9k_hw_disablepcie (ah);if (!AR_SREV_9300_20_OR_LATER (ah))
drivers/net/wireless/ath/ath9k/pci.c +4 -1
@@ -148,8 +148,11 @@ static void ath_pci_aspm_init(struct ath_softc *sc) ppos =pci_pcie_cap (parent);pci_read_config_byte (parent, ppos +PCI_EXP_LNKCTL , &aspm); -if (aspm & (PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 )) +if (aspm & (PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 )) { ah->aspm_enabled = true; +/* Initialize PCIe PM and SERDES registers. */ +ath9k_hw_configpcipowersave (ah, false); + } }static int ath_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id)
Signature · 1 line
1.7.1
PATCH v2 7/12 pci: aspm: add function for disabling ASPM
In reply to Stanislaw GruszkaAdd support for disabling ASPM if !CONFIG_PCIEASPM. Patch is based on code from e1000e.
--- drivers/pci/pcie/Makefile | 3 +-- drivers/pci/pcie/aspm.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/linux/pci-aspm.h | 2 ++ 3 files changed, 44 insertions(+), 2 deletions(-)
drivers/pci/pcie/Makefile +1 -2
@@ -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
drivers/pci/pcie/aspm.c +41 -0
50 lines not on this page · raw message
include/linux/pci-aspm.h +2 -0
@@ -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);
Signature · 1 line
1.7.1
PATCH v2 8/12 ath9k: use common function for disabling ASPM
In reply to Stanislaw GruszkaDisable ASPM using common function, this works also with CONFIG_PCIEASPM=y.
--- drivers/net/wireless/ath/ath9k/pci.c | 29 ++++++----------------------- 1 files changed, 6 insertions(+), 23 deletions(-)
drivers/net/wireless/ath/ath9k/pci.c +6 -23
@@ -111,43 +111,26 @@ static void ath_pci_aspm_init(struct ath_softc *sc)struct ath_hw *ah = sc->sc_ah;struct pci_dev *pdev =to_pci_dev (sc->dev);struct pci_dev *parent; -int pos, ppos; +int pos;u8 aspm; ah->aspm_enabled = false; - pos =pci_pcie_cap (pdev); -if (!pos) +if (!pci_is_pcie (pdev))return ; - parent = pdev->bus->self; -if (ah->btcoex_hw.scheme !=ATH_BTCOEX_CFG_NONE ) {/* Bluetooth coexistance requires disabling ASPM. */ -pci_read_config_byte (pdev, pos +PCI_EXP_LNKCTL , &aspm); - aspm &= ~(PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 ); -pci_write_config_byte (pdev, pos +PCI_EXP_LNKCTL , aspm); - -/* -* Both upstream and downstream PCIe components should -* have the same ASPM settings. -*/ -if (WARN_ON (!parent)) -return ; - - ppos =pci_pcie_cap (parent); -pci_read_config_byte (parent, ppos +PCI_EXP_LNKCTL , &aspm); - aspm &= ~(PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 ); -pci_write_config_byte (parent, ppos +PCI_EXP_LNKCTL , aspm); - +pcie_disable_aspm (pdev,PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 );return ; } + parent = pdev->bus->self;if (WARN_ON (!parent))return ; - ppos =pci_pcie_cap (parent); -pci_read_config_byte (parent, ppos +PCI_EXP_LNKCTL , &aspm); + pos =pci_pcie_cap (parent); +pci_read_config_byte (parent, pos +PCI_EXP_LNKCTL , &aspm);if (aspm & (PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 )) { ah->aspm_enabled = true;/* Initialize PCIe PM and SERDES registers. */
Signature · 1 line
1.7.1
PATCH v2 9/12 e1000e: use common function for disabling ASPM
In reply to Stanislaw Gruszka--- drivers/net/e1000e/netdev.c | 31 +------------------------------ 1 files changed, 1 insertions(+), 30 deletions(-)
drivers/net/e1000e/netdev.c +1 -30
@@ -5358,42 +5358,13 @@ static void e1000_complete_shutdown(struct pci_dev *pdev, bool sleep, } } -#ifdef CONFIG_PCIEASPM -static void __e1000e_disable_aspm (struct pci_dev *pdev,u16 state) -{ -pci_disable_link_state_locked (pdev, state); -} -#else -static void __e1000e_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 , ®16); - 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 , ®16); - reg16 &= ~state; -pci_write_config_word (pdev->bus->self, pos +PCI_EXP_LNKCTL , reg16); -} -#endif static void e1000e_disable_aspm (struct pci_dev *pdev,u16 state) {dev_info (&pdev->dev,"Disabling ASPM %s %s\n" , (state &PCIE_LINK_STATE_L0S ) ?"L0s" :"" , (state &PCIE_LINK_STATE_L1 ) ?"L1" :"" ); -__e1000e_disable_aspm (pdev, state); +pcie_disable_aspm (pdev, state); }#ifdef CONFIG_PM
Signature · 1 line
1.7.1
PATCH v2 10/12 pci: aspm: add settings changed callback
In reply to Stanislaw GruszkaInform drivers that register pci_drviver->aspm_changed(), about new ASPM settings. Callback is only called for child (endpoint) devices.
--- drivers/pci/pcie/aspm.c | 5 ++++- include/linux/pci.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletions(-)
drivers/pci/pcie/aspm.c +4 -1
@@ -474,8 +474,11 @@ static void pcie_config_aspm_link(struct pcie_link_state *link, u32 state)*/ if (state &ASPM_STATE_L1 )pcie_config_aspm_dev (parent, upstream); -list_for_each_entry (child, &linkbus->devices, bus_list) +list_for_each_entry (child, &linkbus->devices, bus_list) {pcie_config_aspm_dev (child, dwstream); +if (child->driver && child->driver->aspm_changed) + child->driver->aspm_changed (child, dwstream); + }if (!(state &ASPM_STATE_L1 ))pcie_config_aspm_dev (parent, upstream);
include/linux/pci.h +3 -0
@@ -555,6 +555,9 @@ struct pci_driver {int (*resume_early) (struct pci_dev *dev);int (*resume) (struct pci_dev *dev);/* Device woken up */ void (*shutdown) (struct pci_dev *dev); +#ifdef CONFIG_PCIEASPM +void (*aspm_changed) (struct pci_dev *dev,u32 state); +#endif struct pci_error_handlers *err_handler;struct device_driver driver;struct pci_dynids dynids;
Signature · 1 line
1.7.1
PATCH v2 11/12 ath9k: be prepare for dynamic ASPM settings change
In reply to Stanislaw GruszkaKernel offer possibility to change ASPM settings using /sys/module/pcie_aspm/parameters/policy interface. As settings can be changed, we also need to change ath9k hw registers. Patch implement this by monitoring power_off state, and based on that state setup register when pci core inform us about ASPM change.
--- drivers/net/wireless/ath/ath9k/hw-ops.h | 1 + drivers/net/wireless/ath/ath9k/hw.h | 1 + drivers/net/wireless/ath/ath9k/pci.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 0 deletions(-)
drivers/net/wireless/ath/ath9k/hw-ops.h +1 -0
@@ -24,6 +24,7 @@static inline void ath9k_hw_configpcipowersave (struct ath_hw *ah,bool power_off) { + ah->power_off = power_off;if (ah->aspm_enabled != true)return ;
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -672,6 +672,7 @@ struct ath_hw {bool sw_mgmt_crypto;bool is_pciexpress;bool aspm_enabled; +bool power_off;bool is_monitoring;bool need_an_top2_fixup;u16 tx_trig_level;
drivers/net/wireless/ath/ath9k/pci.c +31 -0
@@ -286,6 +286,34 @@ static void ath_pci_remove(struct pci_dev *pdev)pci_release_region (pdev,0 ); } +#ifdef CONFIG_PCIEASPM + +static void ath_pci_aspm_changed (struct pci_dev *pdev,u32 state) +{ +struct ieee80211_hw *hw =pci_get_drvdata (pdev); +struct ath_softc *sc = hw->priv; +struct ath_hw *ah = sc->sc_ah; + +spin_lock_irq (&sc->sc_pcu_lock); + +/* +* ASPM settings were changed, we have to configure PCIe PM and SERDES +* registers based on current state of device and new ASPM settings. +*/ +if (state & (PCIE_LINK_STATE_L0S |PCIE_LINK_STATE_L1 )) { + ah->aspm_enabled = true; +ath9k_hw_configpcipowersave (ah, ah->power_off); + }else { +if (!ah->power_off) +ath9k_hw_configpcipowersave (ah, true); + ah->aspm_enabled = false; + } + +spin_unlock_irq (&sc->sc_pcu_lock); +} + +#endif +#ifdef CONFIG_PM static int ath_pci_suspend (struct device *device)
@@ -365,6 +393,9 @@ static struct pci_driver ath_pci_driver = { .id_table = ath_pci_id_table, .probe = ath_pci_probe, .remove = ath_pci_remove, +#ifdef CONFIG_PCIEASPM + .aspm_changed = ath_pci_aspm_changed, +#endif .driver.pm = ATH9K_PM_OPS, };
Signature · 1 line
1.7.1
PATCH v2 12/12 ath9k: fix initialization ordering issues
In reply to Stanislaw GruszkaWe should initialize registers before ieee80211_register_hw(). For non RFC posting, this patch will be merged with previous patch "ath9k: do btcoex ASPM disabling at initialization time"
--- drivers/net/wireless/ath/ath9k/hw.c | 11 +++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 1 + drivers/net/wireless/ath/ath9k/pci.c | 23 ++++++++++------------- 3 files changed, 22 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +11 -0
@@ -318,6 +318,14 @@ static void ath9k_hw_disablepcie(struct ath_hw *ah)REG_WRITE (ah,AR_PCIE_SERDES2 ,0x00000000 ); } +static void ath9k_hw_aspm_init (struct ath_hw *ah) +{ +struct ath_common *common =ath9k_hw_common (ah); + +if (common->bus_ops->aspm_init) + common->bus_ops->aspm_init (common); +} +/* This should work for all families including legacy */ static bool ath9k_hw_chip_test (struct ath_hw *ah) {
@@ -610,6 +618,9 @@ static int __ath9k_hw_init(struct ath_hw *ah)if (r)return r; +if (ah->is_pciexpress) +ath9k_hw_aspm_init (ah); + r =ath9k_hw_init_macaddr (ah);if (r) {ath_err (common,"Failed to initialize MAC address\n" );
drivers/net/wireless/ath/ath9k/hw.h +1 -0
@@ -873,6 +873,7 @@ struct ath_bus_ops {void (*read_cachesize)(struct ath_common *common,int *csz);bool (*eeprom_read)(struct ath_common *common,u32 off,u16 *data);void (*extn_synch_en)(struct ath_common *common); +void (*aspm_init)(struct ath_common *common); };static inline struct ath_common *ath9k_hw_common (struct ath_hw *ah)
drivers/net/wireless/ath/ath9k/pci.c +10 -13
@@ -99,23 +99,15 @@ static void ath_pci_extn_synch_enable(struct ath_common *common)pci_write_config_byte (pdev, sc->sc_ah->caps.pcie_lcr_offset, lnkctl); } -static const struct ath_bus_ops ath_pci_bus_ops = { - .ath_bus_type =ATH_PCI , - .read_cachesize = ath_pci_read_cachesize, - .eeprom_read = ath_pci_eeprom_read, - .extn_synch_en = ath_pci_extn_synch_enable, -}; - -static void ath_pci_aspm_init (struct ath_softc *sc) +static void ath_pci_aspm_init (struct ath_common *common) { +struct ath_softc *sc = (struct ath_softc *) common->priv;struct ath_hw *ah = sc->sc_ah;struct pci_dev *pdev =to_pci_dev (sc->dev);struct pci_dev *parent;int pos;u8 aspm; - ah->aspm_enabled = false; -if (!pci_is_pcie (pdev))return ;
@@ -138,6 +130,14 @@ static void ath_pci_aspm_init(struct ath_softc *sc) } } +static const struct ath_bus_ops ath_pci_bus_ops = { + .ath_bus_type =ATH_PCI , + .read_cachesize = ath_pci_read_cachesize, + .eeprom_read = ath_pci_eeprom_read, + .extn_synch_en = ath_pci_extn_synch_enable, + .aspm_init = ath_pci_aspm_init +}; +static int ath_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {void __iomem *mem;
@@ -245,9 +245,6 @@ static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_init; } -/* Need to be called after we discover hw capabilities */ -ath_pci_aspm_init (sc); -ath9k_hw_name (sc->sc_ah, hw_name,sizeof (hw_name));wiphy_info (hw->wiphy,"%s mem=0x%lx, irq=%d\n" , hw_name, (unsigned long )mem, pdev->irq);
Signature · 1 line
1.7.1
v2 cover ath9k: ASPM fixes
In reply to Stanislaw GruszkaQuoted 11 lines · On Wed, 27 Jul 2011 14:14:47 +0200 Stanislaw Gruszka <[email protected]>…
This patch series try to fix ath9k ASPM. Some of patches are cleanup only or do merging common code (with e1000e driver).
With
CONFIG_PCIEASPMit's possible to change ASPM settings on runtime via/sys/module/pcie_aspm/parameters/policy. However most drivers I looked at assume this setting is constant. I add a callback to pci driver to inform about the change, and allow driver to do needed hw related changes. Currently only ath9k implement the callback, but I think it will be useful for other drivers (i.e. iwlwifi, rtlwifi) that do some own ASPM handling.
Quoted 2 lines
These patches needs wide testing as they may work on some systems and not work on others, that can depend on PCIe bridges.
These look fine, I remember seeing a place where e1000e could use this just recently and it looks like you took care of it.
We may be able to sneak this in to 3.1 to make things easier on the dependent drivers, but it'll have to wait until I send my pull request for the first batch of PCI changes (probably today).
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
v2 cover ath9k: ASPM fixes
Quoted 14 lines · Jesse Barnes
Quoted 11 lines · On Wed, 27 Jul 2011 14:14:47 +0200 Stanislaw Gruszka <[email protected]>…
This patch series try to fix ath9k ASPM. Some of patches are cleanup only or do merging common code (with e1000e driver).
With
CONFIG_PCIEASPMit's possible to change ASPM settings on runtime via/sys/module/pcie_aspm/parameters/policy. However most drivers I looked at assume this setting is constant. I add a callback to pci driver to inform about the change, and allow driver to do needed hw related changes. Currently only ath9k implement the callback, but I think it will be useful for other drivers (i.e. iwlwifi, rtlwifi) that do some own ASPM handling.
Quoted 5 lines
Quoted 2 lines
These patches needs wide testing as they may work on some systems and not work on others, that can depend on PCIe bridges.
These look fine, I remember seeing a place where e1000e could use this just recently and it looks like you took care of it.
Yep, accually some pci changes I did was based on e1000e code.
Quoted 3 lines
We may be able to sneak this in to 3.1 to make things easier on the dependent drivers, but it'll have to wait until I send my pull request for the first batch of PCI changes (probably today).
This could go 3.2, except first patch (ath9k specific) which directly address system lockups. I'm going to a bit rework and post 1st patch today. Rest patches from the series I'll repost next week.
Thanks
Stanislaw