b43-dev.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: b43-dev@lists.infradead.org
Subject: [PATCH] Fix alignment issues with DMA TX on BCM4331
Date: Fri, 12 Aug 2011 11:27:43 +0100	[thread overview]
Message-ID: <1313144864.27274.81.camel@i7.infradead.org> (raw)
In-Reply-To: <1313113295.27274.53.camel@i7.infradead.org>

When the TX descriptor ring is not aligned to 8KiB on BCM4331, we have
to write the full address to the TXINDEX register or the DMA engine gets
confused after the first time we wrap round to slot zero.

[ 7438.538945] Poked TX with address fe0 for slot 254
[ 7438.539077] Acking gen reason 20000000
[ 7438.539177] irq xmitstat 20fc1001 0000007f
[ 7438.607861] Poked TX with address 0 for slot 0
[ 7438.608567] Acking gen reason 20000000
[ 7438.608668] irq xmitstat 20fe1001 00000080
[ 7438.608709] irq xmitstat 20000011 00000080
[ 7438.608724] b43-phy2 debug: Out of order TX status report on DMA ring 1. Expected 256, but got 0
[ 7438.608739] irq xmitstat 20020011 00000080
[ 7438.608750] b43-phy2 debug: Out of order TX status report on DMA ring 1. Expected 256, but got 2
[ 7438.608765] irq xmitstat 20040011 00000080

We write 0xff0 to the TXADDRLO register to see if the DMA engine is
capable of unaligned operation. If it *is*, then it'll have this problem
and we have to write the full address to TXINDEX. Comments in brcmsmac
indicate that the low 13 bits are required.

If we're doing this, we *also* have to write to TXCTL to enable the DMA
engine *after* setting up the ring address.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
--
I've made that change to the initialisation order of TXCTL vs.
TXADDR{HI,LO} unconditional; is there a reason not to?

diff --git a/drivers/net/wireless/b43/dma.c b/drivers/net/wireless/b43/dma.c
index 82168f8..92dd6d9 100644
--- a/drivers/net/wireless/b43/dma.c
+++ b/drivers/net/wireless/b43/dma.c
@@ -225,8 +225,10 @@ static void op64_fill_descriptor(struct b43_dmaring *ring,
 
 static void op64_poke_tx(struct b43_dmaring *ring, int slot)
 {
-	b43_dma_write(ring, B43_DMA64_TXINDEX,
-		      (u32) (slot * sizeof(struct b43_dmadesc64)));
+	u32 indexval = slot * sizeof(struct b43_dmadesc64);
+	if (ring->unaligned)
+		indexval |= (u32)ring->dmabase;
+	b43_dma_write(ring, B43_DMA64_TXINDEX, indexval);
 }
 
 static void op64_tx_suspend(struct b43_dmaring *ring)
@@ -704,9 +710,14 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
 			    & B43_DMA64_TXADDREXT_MASK;
 			if (!parity)
 				value |= B43_DMA64_TXPARITYDISABLE;
-			b43_dma_write(ring, B43_DMA64_TXCTL, value);
+
+			b43_dma_write(ring, B43_DMA64_TXRINGLO, 0xff0);
+			if (b43_dma_read(ring, B43_DMA64_TXRINGLO))
+				ring->unaligned = 1;
+
 			b43_dma_write(ring, B43_DMA64_TXRINGLO, addrlo);
 			b43_dma_write(ring, B43_DMA64_TXRINGHI, addrhi);
+			b43_dma_write(ring, B43_DMA64_TXCTL, value);
 		} else {
 			u32 ringbase = (u32) (ring->dmabase);
 			addrext = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_EXT);
diff --git a/drivers/net/wireless/b43/dma.h b/drivers/net/wireless/b43/dma.h
index 7e20b04f..16dc565 100644
--- a/drivers/net/wireless/b43/dma.h
+++ b/drivers/net/wireless/b43/dma.h
@@ -251,6 +251,8 @@ struct b43_dmaring {
 	int index;
 	/* Boolean. Is this a TX ring? */
 	bool tx;
+	/* Boolean. Is this ring capable of 16-byte alignment? */
+	bool unaligned;
 	/* The type of DMA engine used. */
 	enum b43_dmatype type;
 	/* Boolean. Is this ring stopped at ieee80211 level? */

-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse at intel.com                              Intel Corporation

  parent reply	other threads:[~2011-08-12 10:27 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 20:14 No DMA RX on some BCM4321, on BCM43224 and BCM43225 Rafał Miłecki
2011-07-18 20:29 ` Larry Finger
2011-07-18 22:30   ` Rafał Miłecki
2011-07-18 23:32   ` Rafał Miłecki
2011-07-19  6:56     ` Rafał Miłecki
2011-07-19 14:46       ` Larry Finger
2011-07-19 15:12         ` Jonas Gorski
2011-07-18 20:41 ` Michael Büsch
2011-07-18 22:39   ` Rafał Miłecki
2011-07-18 22:59     ` Michael Büsch
2011-07-18 23:07       ` Rafał Miłecki
2011-07-18 23:08         ` Michael Büsch
2011-07-18 23:15           ` Rafał Miłecki
2011-07-18 23:24             ` Michael Büsch
2011-07-18 23:29               ` Rafał Miłecki
2011-07-18 23:12     ` Rafał Miłecki
2011-07-19 22:33 ` David Woodhouse
2011-08-12  1:41   ` David Woodhouse
2011-08-12 10:15     ` [PATCH] b43: Mask out unwanted bits of RX slot address David Woodhouse
2011-08-13 19:10       ` Rafał Miłecki
2011-08-13 19:38         ` Michael Büsch
2011-08-13 22:13       ` Rafał Miłecki
2011-08-13 22:56         ` David Woodhouse
2011-08-14  8:18           ` Rafał Miłecki
2011-08-14  8:19             ` David Woodhouse
2011-08-14  9:02         ` Rafał Miłecki
2011-08-14  9:07           ` Rafał Miłecki
2011-08-14  9:24             ` Rafał Miłecki
2011-08-14  9:31               ` Rafał Miłecki
2011-08-14 11:17               ` Rafał Miłecki
2011-08-14 11:22                 ` Rafał Miłecki
2011-08-14 11:35                 ` David Woodhouse
2011-08-14 15:02                   ` Rafał Miłecki
2011-08-14 15:10                     ` Michael Büsch
2011-08-14 11:38                 ` Rafał Miłecki
2011-08-14 11:52                   ` Michael Büsch
2011-08-14 12:06                   ` David Woodhouse
2011-08-14 13:43                     ` Rafał Miłecki
2011-08-12 10:27     ` David Woodhouse [this message]
2011-08-13 19:06       ` [PATCH] Fix alignment issues with DMA TX on BCM4331 Rafał Miłecki
2011-08-13 20:18         ` David Woodhouse
2011-08-13 20:22           ` Rafał Miłecki
2011-08-13 20:36             ` David Woodhouse
2011-08-14  8:09           ` Rafał Miłecki
2011-08-13 21:57       ` Larry Finger
2011-08-13 22:02         ` Rafał Miłecki
2011-08-13 22:07           ` David Woodhouse
2011-08-13 22:12             ` Rafał Miłecki
2011-08-13 22:17               ` David Woodhouse
2011-08-14  7:10                 ` Rafał Miłecki
2011-08-14  7:35                 ` Rafał Miłecki
2011-08-14  8:04                   ` David Woodhouse
2011-08-14  8:14                     ` Rafał Miłecki
2011-08-13 22:14           ` Larry Finger
2011-08-13 22:17             ` David Woodhouse
2011-08-13 22:29               ` Larry Finger

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=1313144864.27274.81.camel@i7.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=b43-dev@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).