ath10k: split ath10k_pci_target_ps_control
PATCH 1/1 ath10k: split ath10k_pci_target_ps_control
Divide the target_ps_control into 2 logical pieces:
- ath10k_pci_wake
- ath10k_pci_sleep
--- drivers/net/wireless/ath/ath10k/pci.c | 117 ++++++++++++++++----------------- drivers/net/wireless/ath/ath10k/pci.h | 18 +---- 2 files changed, 60 insertions(+), 75 deletions(-)
drivers/net/wireless/ath/ath10k/pci.c +58 -59
@@ -442,6 +442,63 @@ static void ath10k_pci_wait_for_target_to_awake(struct ath10k *ar)ath10k_warn ("Unable to wakeup target\n" ); } +void ath10k_pci_wake (struct ath10k *ar) +{ +struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); +void __iomem *pci_addr = ar_pci->mem; +static int max_delay; +int tot_delay =0 ; +int curr_delay =5 ; + +if (!ath10k_target_ps) +return ; + +if (atomic_read (&ar_pci->keep_awake_count) ==0 ) { +/* Force AWAKE */ +iowrite32 (PCIE_SOC_WAKE_V_MASK_T (ar), + pci_addr +PCIE_LOCAL_BASE_ADDRESS_T (ar) +PCIE_SOC_WAKE_ADDRESS_T (ar)); + } +atomic_inc (&ar_pci->keep_awake_count); + +if (ar_pci->verified_awake) +return ; + +for (;;) { +if (ath10k_pci_target_is_awake (ar)) { + ar_pci->verified_awake = true; +break ; + } + +if (tot_delay >PCIE_WAKE_TIMEOUT ) +ath10k_warn ("keep_awake_count %d\n" ,atomic_read (&ar_pci->keep_awake_count)); + +udelay (curr_delay); + tot_delay += curr_delay; + +if (curr_delay <50 ) + curr_delay +=5 ; + } + +if (tot_delay > max_delay) + max_delay = tot_delay; +} + +void ath10k_pci_sleep (struct ath10k *ar) +{ +struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); +void __iomem *pci_addr = ar_pci->mem; + +if (!ath10k_target_ps) +return ; + +if (atomic_dec_and_test (&ar_pci->keep_awake_count)) { +/* Allow sleep */ + ar_pci->verified_awake = false; +iowrite32 (PCIE_SOC_WAKE_RESET_T (ar), + pci_addr +PCIE_LOCAL_BASE_ADDRESS_T (ar) +PCIE_SOC_WAKE_ADDRESS_T (ar)); + } +} +/* * FIXME: Handle OOM properly. */
@@ -1631,7 +1688,7 @@ static int ath10k_pci_probe_device(struct ath10k *ar)else {/* Force AWAKE forever */ ath10k_dbg (ATH10K_DBG_PCI ,"on-chip power save disabled\n" ); -ath10k_pci_target_ps_control (ar, false, true); +ath10k_pci_wake (ar); }ath10k_pci_ce_init (ar);
@@ -1655,64 +1712,6 @@ ce_deinit:return ret; } -void ath10k_pci_target_ps_control (struct ath10k *ar,bool sleep_ok, -bool wait_for_it) -{ -struct ath10k_pci *ar_pci =ath10k_pci_priv (ar); -void __iomem *pci_addr = ar_pci->mem; -static int max_delay; - -if (sleep_ok) { -if (atomic_dec_and_test (&ar_pci->keep_awake_count)) { -/* Allow sleep */ - ar_pci->verified_awake = false; -iowrite32 (PCIE_SOC_WAKE_RESET_T (ar), - pci_addr +PCIE_LOCAL_BASE_ADDRESS_T (ar) + -PCIE_SOC_WAKE_ADDRESS_T (ar)); - } - }else { -if (atomic_read (&ar_pci->keep_awake_count) ==0 ) { -/* Force AWAKE */ -iowrite32 (PCIE_SOC_WAKE_V_MASK_T (ar), - pci_addr +PCIE_LOCAL_BASE_ADDRESS_T (ar) + -PCIE_SOC_WAKE_ADDRESS_T (ar)); - } -atomic_inc (&ar_pci->keep_awake_count); - -if (wait_for_it && !ar_pci->verified_awake) { -int tot_delay =0 ; -int curr_delay =5 ; - -for (;;) { -if (ath10k_pci_target_is_awake (ar)) { - ar_pci->verified_awake = true; -break ; - } - -if (tot_delay >PCIE_WAKE_TIMEOUT ) { -ath10k_warn - ("keep_awake_count %d " -"PCIE_SOC_WAKE_ADDRESS = %x\n" , -atomic_read (&ar_pci-> - keep_awake_count), -ioread32 (pci_addr + -PCIE_LOCAL_BASE_ADDRESS_T (ar) + -PCIE_SOC_WAKE_ADDRESS_T (ar))); - } - -udelay (curr_delay); - tot_delay += curr_delay; - -if (curr_delay <50 ) - curr_delay +=5 ; - } - -if (tot_delay > max_delay) - max_delay = tot_delay; - } - } -} -static void ath10k_pci_fw_interrupt_handler (struct ath10k *ar) {struct ath10k_pci *ar_pci =ath10k_pci_priv (ar);
drivers/net/wireless/ath/ath10k/pci.h +2 -16
@@ -347,21 +347,7 @@ static inline void WAR_CE_SRC_RING_WRITE_IDX_SET(struct ath10k *ar, } } -void ath10k_pci_target_ps_control (struct ath10k *ar, -bool sleep_ok, -bool wait_for_it); - -static inline void ath10k_pci_wake (struct ath10k *ar) -{ -if (ath10k_target_ps) -ath10k_pci_target_ps_control (ar, false, true); -} - -static inline void ath10k_pci_sleep (struct ath10k *ar) -{ -if (ath10k_target_ps) -ath10k_pci_target_ps_control (ar, true, false); -} - +void ath10k_pci_wake (struct ath10k *ar); +void ath10k_pci_sleep (struct ath10k *ar);#endif /* _PCI_H_ */
Signature · 1 line
1.7.10
Kalle Valo
AppliedPATCH 1/1 ath10k: split ath10k_pci_target_ps_control
Quoted 5 lines · Bartosz Markowski
Divide the
target_ps_controlinto 2 logical pieces:
-ath10k_pci_wake
-ath10k_pci_sleepSigned-off-by Bartosz Markowski <[email protected]>
Thanks, applied with conflicts. Please check.
And I think we can change ath10k_target_ps to static now.
Signature · 1 line
Kalle Valo
PATCH 1/1 ath10k: split ath10k_pci_target_ps_control
Quoted 13 lines
-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Sent: 22 kwietnia 2013 10:47
To: Markowski Bartosz
Cc: ath9k-devel at lists.ath9k.org
Subject: Re: [ath9k-devel] [PATCH] ath10k: splitath10k_pci_target_ps_controlQuoted 4 lines · Bartosz Markowski
Divide the
target_ps_controlinto 2 logical pieces:
-ath10k_pci_wake
-ath10k_pci_sleep
Quoted 5 lines
Quoted 1 line
Signed-off-by Bartosz Markowski <[email protected]>Thanks, applied with conflicts. Please check.
And I think we can change
ath10k_target_psto static now.
Yes. I will send a patch-set with this and remaining rebases after you iterate over the list.
-Bartosz
PATCH 1/1 ath10k: split ath10k_pci_target_ps_control
Quoted 6 lines · Bartosz.Markowski at tieto.com
Quoted 4 lines
-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]And I think we can change
ath10k_target_psto static now.Yes. I will send a patch-set with this and remaining rebases after you iterate over the list.
hmm, seems like we actually can't make it static yet. The ath10k_pci_sleep/wake() are called from ce and pci code.
-Bartosz
PATCH 1/1 ath10k: split ath10k_pci_target_ps_control
Quoted 9 lines · Markowski Bartosz
Quoted 6 lines · Bartosz.Markowski at tieto.com
Quoted 4 lines
-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]And I think we can change
ath10k_target_psto static now.Yes. I will send a patch-set with this and remaining rebases after you iterate over the list.
hmm, seems like we actually can't make it static yet. The ath10k_pci_sleep/wake() are called from ce and pci code.
Sorry, I don't understand how that prevents making the variable static.
Just to be clear, I was thinking doing something like this:
drivers/net/wireless/ath/ath10k/pci.c +1 -1
@@ -33,7 +33,7 @@#include "ce.h" #include "pci.h" -unsigned int ath10k_target_ps; +static unsigned int ath10k_target_ps;module_param (ath10k_target_ps, uint,0644 );MODULE_PARM_DESC (ath10k_target_ps,"Enable ath10k Target (SoC) PS option" );
drivers/net/wireless/ath/ath10k/pci.h +0 -2
@@ -353,8 +353,6 @@ static inline void WAR_CE_SRC_RING_WRITE_IDX_SET(struct ath10k *ar, } } -extern unsigned int ath10k_target_ps; -void ath10k_pci_wake (struct ath10k *ar);void ath10k_pci_sleep (struct ath10k *ar);
PATCH 1/1 ath10k: split ath10k_pci_target_ps_control
Quoted 6 lines · Kalle Valo
Quoted 4 lines · Markowski Bartosz
Quoted 3 lines · Bartosz.Markowski at tieto.com
Quoted 3 lines
-----Original Message-----
From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
And I think we can change
ath10k_target_psto static now.Yes. I will send a patch-set with this and remaining rebases after you iterate over the list.
hmm, seems like we actually can't make it static yet. The ath10k_pci_sleep/wake() are called from ce and pci code.
Sorry, I don't understand how that prevents making the variable static.
Sorry, seems like I need a coffee break. Sure, you're right here.
Bartosz