Re: [ath5k-devel] [AR2425] TX death on high load - are there hardware/software races?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bob Copeland
Date: Friday, March 19, 2010 - 5:19 am

On Thu, Mar 18, 2010 at 02:58:14PM -0400, Bob Copeland wrote:

Something like the following?  (only compile tested)

From: Bob Copeland <bob@hash.(none)>
Date: Fri, 19 Mar 2010 08:10:31 -0400
Subject: [PATCH] ath5k: fix race condition in tx desc processing

As pointed out by Benoit Papillault, there is a potential
race condition between the host and the hardware in reading
the next link in the transmit descriptor list:

cpu0              hw
                  tx for buf completed
                  raise tx_ok interrupt
process buf
buf->ds_link = 0
                  read buf->ds_link

This change checks txdp before processing a descriptor
(if there are any subsequent descriptors) to see if
hardware moved on.  We'll then process this descriptor on
the next tasklet.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
---
 drivers/net/wireless/ath/ath5k/base.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index b142a78..63dfb84 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -2059,6 +2059,11 @@ ath5k_tx_processq(struct ath5k_softc *sc, struct ath5k_txq *txq)
 	list_for_each_entry_safe(bf, bf0, &txq->q, list) {
 		ds = bf->desc;
 
+		/* make sure hardware can read the ds_link (if present) */
+		if (ath5k_hw_get_txdp(sc->ah, txq->qnum) == bf->daddr &&
+		    !list_is_last(&bf->list, &txq->q))
+			break;
+
 		ret = sc->ah->ah_proc_tx_desc(sc->ah, ds, &ts);
 		if (unlikely(ret == -EINPROGRESS))
 			break;
-- 
1.5.4.1


-- 
Bob Copeland %% www.bobcopeland.com

_______________________________________________
ath5k-devel mailing list
ath5k-devel@lists.ath5k.org
https://lists.ath5k.org/mailman/listinfo/ath5k-devel
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Sun Mar 14, 9:33 am)
Re: [ath5k-devel] [AR2425] TX death on high load - are the ..., Benoit PAPILLAULT, (Tue Mar 16, 3:45 pm)
Re: [ath5k-devel] [AR2425] TX death on high load - are the ..., Bob Copeland, (Fri Mar 19, 5:19 am)
Re: [ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Sat Mar 20, 10:41 am)
Re: [ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Tue Mar 30, 11:27 am)
Re: [ath5k-devel] [AR2425] TX death on high load, Bruno Randolf, (Wed Mar 31, 5:54 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Bob Copeland, (Thu Apr 1, 7:34 am)
Re: [ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Thu Apr 1, 12:14 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Thu Apr 1, 2:18 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Bob Copeland, (Thu Apr 1, 2:45 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Thu Apr 1, 3:51 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Bruno Randolf, (Thu Apr 1, 5:45 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Maxim Levitsky, (Thu Apr 1, 8:25 pm)
Re: [ath5k-devel] [AR2425] TX death on high load, Bruno Randolf, (Fri Apr 2, 2:34 am)
Re: [ath5k-devel] [AR2425] TX death on high load, Bruno Randolf, (Tue Apr 6, 7:17 pm)