Skip to contentSkip to conversation

ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

PATCH New Mohammed Shafi Shajakhan 2 participants 3 messages Jun 18, 2012 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

From: Mohammed Shafi Shajakhan <[email protected]>

"ath9k: Fix softlockup in AR9485" with commit id 64bc1239c790e051ff677e023435d770d2ffa174 fixed the reported issue, yet its better to avoid the possible infinite loop in ar9003_get_pll_sqsum_dvc by having a timeout as suggested by ath9k maintainers.
http://www.spinics.net/lists/linux-wireless/msg92126.html.
Based on my testing PLL's locking measurement is done in ~200us (2 iterations).

Cc stable at vger.kernel.org
Cc Rolf Offermanns <[email protected]>
Cc Sujith Manoharan <[email protected]>
Cc Senthil Balasubramanian <[email protected]>
---
 drivers/net/wireless/ath/ath9k/hw.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +13 -1
index 784baee..a42c26f 100644
@@ -773,13 +773,25 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)
 
 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah)
 {
+	struct ath_common *common = ath9k_hw_common(ah);
+	int i = 0;
+
 	REG_CLR_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
 	udelay(100);
 	REG_SET_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
 
-	while ((REG_READ(ah, PLL4) & PLL4_MEAS_DONE) == 0)
+	while ((REG_READ(ah, PLL4) & PLL4_MEAS_DONE) == 0) {
+
 		udelay(100);
 
+		if (WARN_ON_ONCE(i >= 100)) {
+			ath_err(common, "PLL4 meaurement not done\n");
+			break;
+		}
+
+		i++;
+	}
+
 	return (REG_READ(ah, PLL3) & SQSUM_DVC_MASK) >> 3;
 }
 EXPORT_SYMBOL(ar9003_get_pll_sqsum_dvc);
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

Quoted 36 lines · Mohammed Shafi Shajakhan

From: Mohammed Shafi Shajakhan <[email protected]>

"ath9k: Fix softlockup in AR9485" with commit id 64bc1239c790e051ff677e023435d770d2ffa174 fixed the reported issue, yet its better to avoid the possible infinite loop in ar9003_get_pll_sqsum_dvc by having a timeout as suggested by ath9k maintainers.
http://www.spinics.net/lists/linux-wireless/msg92126.html.
Based on my testing PLL's locking measurement is done in ~200us (2 iterations).

Cc Rolf Offermanns <[email protected]>
Cc Sujith Manoharan <[email protected]>
Cc Senthil Balasubramanian <[email protected]>
---
 drivers/net/wireless/ath/ath9k/hw.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +3 -1
index 784baee..a42c26f 100644
@@ -773,13 +773,25 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)
 
 u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah)
 {
+	struct ath_common *common = ath9k_hw_common(ah);
+	int i = 0;
+
 	REG_CLR_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
 	udelay(100);
 	REG_SET_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
 
-	while ((REG_READ(ah, PLL4) & PLL4_MEAS_DONE) == 0)

drivers/net/wireless/ath/ath9k/hw.c static void ath9k_hw_init_qos(struct ath_hw *ah) · line 792

Quoted 10 lines
drivers/net/wireless/ath/ath9k/hw.c +8 -0
+	while ((REG_READ(ah, PLL4) & PLL4_MEAS_DONE) == 0) {
+
 		udelay(100);
 
+		if (WARN_ON_ONCE(i >= 100)) {
+			ath_err(common, "PLL4 meaurement not done\n");
+			break;
+		}
+
+		i++;

How did you come up with 100 as max limit to break the loop?

-Rajkumar

#2 lore raw

PATCH 1/1 ath9k_hw: avoid possible infinite loop in ar9003_get_pll_sqsum_dvc

Hi Raj,

Quoted 41 lines · Rajkumar Manoharan
Quoted 40 lines · Mohammed Shafi Shajakhan

From: Mohammed Shafi Shajakhan<[email protected]>

"ath9k: Fix softlockup in AR9485" with commit id 64bc1239c790e051ff677e023435d770d2ffa174 fixed the reported issue, yet its better to avoid the possible infinite loop in ar9003_get_pll_sqsum_dvc by having a timeout as suggested by ath9k maintainers.
http://www.spinics.net/lists/linux-wireless/msg92126.html.
Based on my testing PLL's locking measurement is done in ~200us (2 iterations).

Cc stable at vger.kernel.org
Cc Rolf Offermanns<[email protected]>
Cc Sujith Manoharan<[email protected]>
Cc Senthil Balasubramanian<[email protected]>
---
  drivers/net/wireless/ath/ath9k/hw.c |   14 +++++++++++++-
  1 files changed, 13 insertions(+), 1 deletions(-)
drivers/net/wireless/ath/ath9k/hw.c +5 -1
index 784baee..a42c26f 100644
@@ -773,13 +773,25 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)
 
  u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah)
  {
+	struct ath_common *common = ath9k_hw_common(ah);
+	int i = 0;
+
  	REG_CLR_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
  	udelay(100);
  	REG_SET_BIT(ah, PLL3, PLL3_DO_MEAS_MASK);
 
-	while ((REG_READ(ah, PLL4)&  PLL4_MEAS_DONE) == 0)
+	while ((REG_READ(ah, PLL4)&  PLL4_MEAS_DONE) == 0) {
+
  		udelay(100);
 
Quoted 8 lines

drivers/net/wireless/ath/ath9k/hw.c static void ath9k_hw_init_qos(struct ath_hw *ah) · line 792

Quoted 6 lines
drivers/net/wireless/ath/ath9k/hw.c +6 -0
+		if (WARN_ON_ONCE(i>= 100)) {
+			ath_err(common, "PLL4 meaurement not done\n");
+			break;
+		}
+
+		i++;

How did you come up with 100 as max limit to break the loop?

i assumed its a sufficient arbitrary max value to confirm that the PLL locking measurement does not happens. Based on my quite a few of tests(idle associated, with traffic)PLL immediately locksup in 200us (2 iterations). As per your suggestion i will quickly check with the System's team if we can give a proper value, rather than 100 * 100 us as timeout. thanks for reviewing it!

Signature · 2 lines
thanks,
shafi