Skip to contentSkip to conversation

ath9k: disable and kill interrupts methods review

PATCH New Viorel Suman 1 participant 2 messages Mar 1, 2015 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: disable and kill interrupts methods review

The patch guards ah->intr_ref_cnt from going into
a "negative" territory and synchronize the
enable_interrupts and disable_interrupts methods.

---
 drivers/net/wireless/ath/ath9k/mac.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/mac.c +19 -3
index bba85d1..81587d9 100644
@@ -782,6 +782,8 @@ void ath9k_hw_kill_interrupts(struct ath_hw *ah)
 	struct ath_common *common = ath9k_hw_common(ah);
 
 	ath_dbg(common, INTERRUPT, "disable IER\n");
+	atomic_set(&ah->intr_ref_cnt, -1);
+
 	REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
 	(void) REG_READ(ah, AR_IER);
 	if (!AR_SREV_9100(ah)) {
@@ -796,10 +798,24 @@ EXPORT_SYMBOL(ath9k_hw_kill_interrupts);
 
 void ath9k_hw_disable_interrupts(struct ath_hw *ah)
 {
+	struct ath_common *common = ath9k_hw_common(ah);
+	int rcount;
+
 	if (!(ah->imask & ATH9K_INT_GLOBAL))
-		atomic_set(&ah->intr_ref_cnt, -1);
-	else
-		atomic_dec(&ah->intr_ref_cnt);
+		return;
+
+	rcount = atomic_read(&ah->intr_ref_cnt);
+	if (rcount < 0) {
+		ath_dbg(common, INTERRUPT,
+			"IER already disabled ref count %d\n", rcount);
+		return;
+	}
+
+	if (rcount > 0 && !atomic_dec_and_test(&ah->intr_ref_cnt)) {
+		ath_dbg(common, INTERRUPT, "Do not disable IER ref count %d\n",
+			atomic_read(&ah->intr_ref_cnt));
+		return;
+	}
 
 	ath9k_hw_kill_interrupts(ah);
 }
Signature · 1 line
2.3.0
#1 lore raw

PATCH 1/1 ath9k: disable and kill interrupts methods review

Please drop this one.

Quoted 53 lines · Viorel Suman

The patch guards ah->intr_ref_cnt from going into
a "negative" territory and synchronize the
enable_interrupts and disable_interrupts methods.

---
 drivers/net/wireless/ath/ath9k/mac.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/net/wireless/ath/ath9k/mac.c +19 -4
index bba85d1..81587d9 100644
@@ -782,6 +782,8 @@ void ath9k_hw_kill_interrupts(struct ath_hw *ah)
        struct ath_common *common = ath9k_hw_common(ah);
 
        ath_dbg(common, INTERRUPT, "disable IER\n");
+       atomic_set(&ah->intr_ref_cnt, -1);
+
        REG_WRITE(ah, AR_IER, AR_IER_DISABLE);
        (void) REG_READ(ah, AR_IER);
        if (!AR_SREV_9100(ah)) {
@@ -796,10 +798,24 @@ EXPORT_SYMBOL(ath9k_hw_kill_interrupts);
 
 void ath9k_hw_disable_interrupts(struct ath_hw *ah)
 {
+       struct ath_common *common = ath9k_hw_common(ah);
+       int rcount;
+
        if (!(ah->imask & ATH9K_INT_GLOBAL))
-               atomic_set(&ah->intr_ref_cnt, -1);
-       else
-               atomic_dec(&ah->intr_ref_cnt);
+               return;
+
+       rcount = atomic_read(&ah->intr_ref_cnt);
+       if (rcount < 0) {
+               ath_dbg(common, INTERRUPT,
+                       "IER already disabled ref count %d\n", rcount);
+               return;
+       }
+
+       if (rcount > 0 && !atomic_dec_and_test(&ah->intr_ref_cnt)) {
+               ath_dbg(common, INTERRUPT, "Do not disable IER ref count %d\n",
+                       atomic_read(&ah->intr_ref_cnt));
+               return;
+       }
 
        ath9k_hw_kill_interrupts(ah);
 }
--

2.3.0