Skip to contentSkip to conversation

ath9k_htc: Support for AR9271 chipset.

ath9k-devel New Dan Carpenter 3 participants 5 messages Aug 11, 2015 – Aug 25, 2015 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

Hello Sujith,

The patch fb9987d0f748: "ath9k_htc: Support for AR9271 chipset." from Mar 17, 2010, leads to the following static checker warning:

	drivers/net/wireless/ath/ath9k/htc_drv_main.c:850 ath9k_htc_ani_work()
	warn: 'common->ani.caldone' can be either negative or positive

drivers/net/wireless/ath/ath9k/htc_drv_main.c
830 /* Perform calibration if necessary */
831 if (longcal || shortcal)
832 common->ani.caldone =
833 ath9k_hw_calibrate(ah, ah->curchan,
834 ah->rxchainmask, longcal);

ath9k_hw_calibrate() returns true/false/-ETIMEOUT.

835
836 ath9k_htc_ps_restore(priv);
837 }
838
839 set_timer:

   840          /*
   841          * Set timer interval based on previous results.
   842          * The interval must be the shortest necessary to satisfy ANI,
   843          * short calibration and long calibration.
   844          */
   845          cal_interval = ATH_LONG_CALINTERVAL;
   846          cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
   847          if (!common->ani.caldone)

But we don't test for negative here.

   848                  cal_interval = min(cal_interval, (u32)short_cal_interval);
   849  
   850          ieee80211_queue_delayed_work(common->hw, &priv->ani_work,
   851                                       msecs_to_jiffies(cal_interval));
   852  }

regards,
dan carpenter

#1 lore raw

PATCH 1/1 ath9k_htc: do ani shortcalibratio if we got -ETIMEDOUT

From: Oleksij Rempel <[email protected]>

current code will handle -ETIMEDOUT as success which is probalbly wrong.

According to this comment I assume it is safe to handle -ETIMEDOUT as false:
drivers/net/wireless/ath/ath9k/calib.c
290 /*

291          * We timed out waiting for the noisefloor to load, probably due to an
292          * in-progress rx. Simply return here and allow the load plenty of time
293          * to complete before the next calibration interval.  We need to avoid
294          * trying to load -50 (which happens below) while the previous load is
295          * still in progress as this can cause rx deafness. Instead by returning
296          * here, the baseband nf cal will just be capped by our present
297          * noisefloor until the next calibration timer.
298          */

Since no other error wariants are present, this patch is checking only for (ret <= 0).

---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +10 -3
index dab1323..172a9ff 100644
@@ -794,8 +794,11 @@ void ath9k_htc_ani_work(struct work_struct *work)
 		common->ani.longcal_timer = timestamp;
 	}
 
-	/* Short calibration applies only while caldone is false */
-	if (!common->ani.caldone) {
+	/*
+	 * Short calibration applies only while caldone
+	 * is false or -ETIMEDOUT
+	 */
+	if (common->ani.caldone <= 0) {
 		if ((timestamp - common->ani.shortcal_timer) >=
 		    short_cal_interval) {
 			shortcal = true;
@@ -844,7 +847,11 @@ set_timer:
 	*/
 	cal_interval = ATH_LONG_CALINTERVAL;
 	cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
-	if (!common->ani.caldone)
+	/*
+	 * Short calibration applies only while caldone
+	 * is false or -ETIMEDOUT
+	 */
+	if (common->ani.caldone <= 0)
 		cal_interval = min(cal_interval, (u32)short_cal_interval);
 
 	ieee80211_queue_delayed_work(common->hw, &priv->ani_work,
Signature · 1 line
2.1.4
#2 lore raw

PATCH 1/1 ath9k_htc: do ani shortcalibratio if we got -ETIMEDOUT

Opps wrong email address. I'll resend the patch

Am 13.08.2015 um 20:21 schrieb Oleksij Rempel:

Quoted 57 lines

From: Oleksij Rempel <[email protected]>

current code will handle -ETIMEDOUT as success which is probalbly wrong.

According to this comment I assume it is safe to handle -ETIMEDOUT as false:
drivers/net/wireless/ath/ath9k/calib.c
290 /*

291          * We timed out waiting for the noisefloor to load, probably due to an
292          * in-progress rx. Simply return here and allow the load plenty of time
293          * to complete before the next calibration interval.  We need to avoid
294          * trying to load -50 (which happens below) while the previous load is
295          * still in progress as this can cause rx deafness. Instead by returning
296          * here, the baseband nf cal will just be capped by our present
297          * noisefloor until the next calibration timer.
298          */

Since no other error wariants are present, this patch is checking only for (ret <= 0).

---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +10 -3
index dab1323..172a9ff 100644
@@ -794,8 +794,11 @@ void ath9k_htc_ani_work(struct work_struct *work)
 		common->ani.longcal_timer = timestamp;
 	}
 
-	/* Short calibration applies only while caldone is false */
-	if (!common->ani.caldone) {
+	/*
+	 * Short calibration applies only while caldone
+	 * is false or -ETIMEDOUT
+	 */
+	if (common->ani.caldone <= 0) {
 		if ((timestamp - common->ani.shortcal_timer) >=
 		    short_cal_interval) {
 			shortcal = true;
@@ -844,7 +847,11 @@ set_timer:
 	*/
 	cal_interval = ATH_LONG_CALINTERVAL;
 	cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
-	if (!common->ani.caldone)
+	/*
+	 * Short calibration applies only while caldone
+	 * is false or -ETIMEDOUT
+	 */
+	if (common->ani.caldone <= 0)
 		cal_interval = min(cal_interval, (u32)short_cal_interval);
 
 	ieee80211_queue_delayed_work(common->hw, &priv->ani_work,
Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20150814/44f71548/attachment.pgp 
#3 lore raw

PATCH v2 1/1 ath9k_htc: do ani shortcalibratio if we got -ETIMEDOUT

current code will handle -ETIMEDOUT as success which is probalbly wrong.

According to this comment I assume it is safe to handle -ETIMEDOUT as false:
drivers/net/wireless/ath/ath9k/calib.c
290 /*

291          * We timed out waiting for the noisefloor to load, probably due to an
292          * in-progress rx. Simply return here and allow the load plenty of time
293          * to complete before the next calibration interval.  We need to avoid
294          * trying to load -50 (which happens below) while the previous load is
295          * still in progress as this can cause rx deafness. Instead by returning
296          * here, the baseband nf cal will just be capped by our present
297          * noisefloor until the next calibration timer.
298          */

Since no other error wariants are present, this patch is checking only for (ret <= 0).

---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +10 -3
index dab1323..172a9ff 100644
@@ -794,8 +794,11 @@ void ath9k_htc_ani_work(struct work_struct *work)
 		common->ani.longcal_timer = timestamp;
 	}
 
-	/* Short calibration applies only while caldone is false */
-	if (!common->ani.caldone) {
+	/*
+	 * Short calibration applies only while caldone
+	 * is false or -ETIMEDOUT
+	 */
+	if (common->ani.caldone <= 0) {
 		if ((timestamp - common->ani.shortcal_timer) >=
 		    short_cal_interval) {
 			shortcal = true;
@@ -844,7 +847,11 @@ set_timer:
 	*/
 	cal_interval = ATH_LONG_CALINTERVAL;
 	cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL);
-	if (!common->ani.caldone)
+	/*
+	 * Short calibration applies only while caldone
+	 * is false or -ETIMEDOUT
+	 */
+	if (common->ani.caldone <= 0)
 		cal_interval = min(cal_interval, (u32)short_cal_interval);
 
 	ieee80211_queue_delayed_work(common->hw, &priv->ani_work,
Signature · 1 line
2.1.4
Applied
#4 lore raw

Re: [v2] ath9k_htc: do ani shortcalibratio if we got -ETIMEDOUT

Quoted 15 lines

current code will handle -ETIMEDOUT as success which is probalbly wrong.

According to this comment I assume it is safe to handle -ETIMEDOUT as false:
drivers/net/wireless/ath/ath9k/calib.c
290 /*

291          * We timed out waiting for the noisefloor to load, probably due to an
292          * in-progress rx. Simply return here and allow the load plenty of time
293          * to complete before the next calibration interval.  We need to avoid
294          * trying to load -50 (which happens below) while the previous load is
295          * still in progress as this can cause rx deafness. Instead by returning
296          * here, the baseband nf cal will just be capped by our present
297          * noisefloor until the next calibration timer.
298          */
Quoted 5 lines

Since no other error wariants are present, this patch is checking only for (ret <= 0).

Thanks, applied to wireless-drivers-next.git.

Kalle Valo