Linux wireless drivers development
 help / color / mirror / Atom feed
From: "Björn Smedman" <bjorn.smedman@venatech.se>
To: linux-wireless <linux-wireless@vger.kernel.org>,
	ath9k-devel@lists.ath9k.org
Subject: [RFC] ath9k: Insert wmb before linking dma descriptors
Date: Mon, 4 Oct 2010 22:55:08 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.00.1010042059130.29449@vtdt3> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2485 bytes --]

Hi all,

I've been looking at how ath9k does DMA and comparing with the
recommendations in the Linux kernel documentation for the DMA API[1]. To
me it looks like we risk setting up incorrect DMA descriptors on
platforms that can reorder writes because all data in the descriptor may
not be written to memory before the descriptor is linked into the DMA
chain.

The patch below attempts to remove this risk by inserting a write memory
barrier between where we set up a descriptor and where we add it to the 
DMA chain. My hope is that this may solve some of the harder chip lockups 
on MIPS but more testing is required to determine if it has this effect.

Any thoughts?

/Björn

1. http://www.mjmwired.net/kernel/Documentation/DMA-API.txt

---
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 081192e..8e43443 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -450,6 +450,8 @@ void ath_beacon_tasklet(unsigned long data)
 				"beacon queue %u did not stop?\n", sc->beacon.beaconq);
 		}
 
+		wmb();
+
 		/* NB: cabq traffic should already be queued and primed */
 		ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bfaddr);
 		ath9k_hw_txstart(ah, sc->beacon.beaconq);
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index 9c166f3..2cc0271 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -90,6 +90,8 @@ static void ath_rx_buf_link(struct ath_softc *sc, struct ath_buf *bf)
 			     common->rx_bufsize,
 			     0);
 
+	wmb();
+
 	if (sc->rx.rxlink == NULL)
 		ath9k_hw_putrxbuf(ah, bf->bf_daddr);
 	else
@@ -500,6 +502,9 @@ int ath_startrecv(struct ath_softc *sc)
 		goto start_recv;
 
 	bf = list_first_entry(&sc->rx.rxbuf, struct ath_buf, list);
+
+	wmb();
+
 	ath9k_hw_putrxbuf(ah, bf->bf_daddr);
 	ath9k_hw_rxena(ah);
 
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index f7da6b2..4b8c428 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1250,6 +1250,8 @@ static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq,
 	ath_print(common, ATH_DBG_QUEUE,
 		  "qnum: %d, txq depth: %d\n", txq->axq_qnum, txq->axq_depth);
 
+	wmb();
+
 	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
 		if (txq->axq_depth >= ATH_TXFIFO_DEPTH) {
 			list_splice_tail_init(head, &txq->txq_fifo_pending);

             reply	other threads:[~2010-10-04 20:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-04 20:55 Björn Smedman [this message]
2010-10-05 13:17 ` [RFC] ath9k: Insert wmb before linking dma descriptors John W. Linville
2010-10-05 19:50   ` [ath9k-devel] " Luis R. Rodriguez
2010-10-09 15:19     ` Björn Smedman
2010-10-09 15:23       ` Felix Fietkau
2010-10-28 23:36         ` Ben Greear
2010-10-28 23:45           ` Felix Fietkau
2010-10-29  0:57             ` Luis R. Rodriguez
2010-11-01 15:44               ` Björn Smedman
2010-11-01 17:17                 ` Bob Copeland
2010-11-01 18:49                   ` Björn Smedman
2010-11-01 18:56                     ` Bob Copeland
2010-11-01 22:45                     ` Peter Stuge
2010-11-01 22:51                       ` Ben Greear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.1010042059130.29449@vtdt3 \
    --to=bjorn.smedman@venatech.se \
    --cc=ath9k-devel@lists.ath9k.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox