All of lore.kernel.org
 help / color / mirror / Atom feed
* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
@ 2013-04-18 12:47 Bartosz Markowski
  2013-04-22  8:46 ` Kalle Valo
  0 siblings, 1 reply; 6+ messages in thread
From: Bartosz Markowski @ 2013-04-18 12:47 UTC (permalink / raw)
  To: ath9k-devel

Divide the target_ps_control into 2 logical pieces:
- ath10k_pci_wake
- ath10k_pci_sleep

Signed-off-by: Bartosz Markowski <bartosz.markowski@tieto.com>
---
 drivers/net/wireless/ath/ath10k/pci.c |  117 ++++++++++++++++-----------------
 drivers/net/wireless/ath/ath10k/pci.h |   18 +----
 2 files changed, 60 insertions(+), 75 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index e4024ef..fedf321 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -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);
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index 9b497a7..2e988a2 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -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_ */
-- 
1.7.10

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

* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
  2013-04-18 12:47 [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control Bartosz Markowski
@ 2013-04-22  8:46 ` Kalle Valo
  2013-04-22  8:50   ` Bartosz.Markowski at tieto.com
  0 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2013-04-22  8:46 UTC (permalink / raw)
  To: ath9k-devel

Bartosz Markowski <bartosz.markowski@tieto.com> writes:

> Divide the target_ps_control into 2 logical pieces:
> - ath10k_pci_wake
> - ath10k_pci_sleep
>
> Signed-off-by: Bartosz Markowski <bartosz.markowski@tieto.com>

Thanks, applied with conflicts. Please check.

And I think we can change ath10k_target_ps to static now.

-- 
Kalle Valo

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

* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
  2013-04-22  8:46 ` Kalle Valo
@ 2013-04-22  8:50   ` Bartosz.Markowski at tieto.com
  2013-04-22  9:28     ` Markowski Bartosz
  0 siblings, 1 reply; 6+ messages in thread
From: Bartosz.Markowski at tieto.com @ 2013-04-22  8:50 UTC (permalink / raw)
  To: ath9k-devel

>-----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: split ath10k_pci_target_ps_control
>
>Bartosz Markowski <bartosz.markowski@tieto.com> writes:
>
>> Divide the target_ps_control into 2 logical pieces:
>> - ath10k_pci_wake
>> - ath10k_pci_sleep
>>
>> Signed-off-by: Bartosz Markowski <bartosz.markowski@tieto.com>
>
>Thanks, applied with conflicts. Please check.
>
>And I think we can change ath10k_target_ps to static now.

Yes. I will send a patch-set with this and remaining rebases after you iterate over the list.

-Bartosz

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

* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
  2013-04-22  8:50   ` Bartosz.Markowski at tieto.com
@ 2013-04-22  9:28     ` Markowski Bartosz
  2013-04-22  9:38       ` Kalle Valo
  0 siblings, 1 reply; 6+ messages in thread
From: Markowski Bartosz @ 2013-04-22  9:28 UTC (permalink / raw)
  To: ath9k-devel

On 22/04/13 10:50, Bartosz.Markowski at tieto.com wrote:
>> -----Original Message-----
>> From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
>>
>> And I think we can change ath10k_target_ps to 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

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

* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
  2013-04-22  9:28     ` Markowski Bartosz
@ 2013-04-22  9:38       ` Kalle Valo
  2013-04-22  9:44         ` Markowski Bartosz
  0 siblings, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2013-04-22  9:38 UTC (permalink / raw)
  To: ath9k-devel

Markowski Bartosz <bartosz.markowski@tieto.com> writes:

> On 22/04/13 10:50, Bartosz.Markowski at tieto.com wrote:
>>> -----Original Message-----
>>> From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
>>>
>>> And I think we can change ath10k_target_ps to 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:

diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 4bba532..9c650df 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -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");
 
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index a3b5e88..e0ed0b0 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -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);

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

* [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control
  2013-04-22  9:38       ` Kalle Valo
@ 2013-04-22  9:44         ` Markowski Bartosz
  0 siblings, 0 replies; 6+ messages in thread
From: Markowski Bartosz @ 2013-04-22  9:44 UTC (permalink / raw)
  To: ath9k-devel

On 22/04/13 11:38, Kalle Valo wrote:
> Markowski Bartosz <bartosz.markowski@tieto.com> writes:
>
>> On 22/04/13 10:50, Bartosz.Markowski at tieto.com wrote:
>>>> -----Original Message-----
>>>> From: Kalle Valo [mailto:kvalo at qca.qualcomm.com]
>>>>
>>>> And I think we can change ath10k_target_ps to 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

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

end of thread, other threads:[~2013-04-22  9:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-18 12:47 [ath9k-devel] [PATCH] ath10k: split ath10k_pci_target_ps_control Bartosz Markowski
2013-04-22  8:46 ` Kalle Valo
2013-04-22  8:50   ` Bartosz.Markowski at tieto.com
2013-04-22  9:28     ` Markowski Bartosz
2013-04-22  9:38       ` Kalle Valo
2013-04-22  9:44         ` Markowski Bartosz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.