From: Nicolas Ferre <nicolas.ferre@atmel.com>
To: <netdev@vger.kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>, <davem@davemloft.net>,
<havard@skinnemoen.net>, <nicolas.ferre@atmel.com>,
<plagnioj@jcrosoft.com>, <jamie@jamieiles.com>,
<linux-kernel@vger.kernel.org>, <patrice.vilchez@atmel.com>
Subject: [PATCH 02/10] net/macb: memory barriers cleanup
Date: Wed, 5 Sep 2012 10:19:09 +0200 [thread overview]
Message-ID: <8f4d7383d051ed4e3617944141c7746505e35638.1346775479.git.nicolas.ferre@atmel.com> (raw)
In-Reply-To: <cover.1346775479.git.nicolas.ferre@atmel.com>
From: Havard Skinnemoen <havard@skinnemoen.net>
Remove a couple of unneeded barriers and document the remaining ones.
Signed-off-by: Havard Skinnemoen <havard@skinnemoen.net>
[nicolas.ferre@atmel.com: split patch in topics]
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
drivers/net/ethernet/cadence/macb.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 9a10f69..26ca01e 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -372,7 +372,9 @@ static void macb_tx(struct macb *bp)
BUG_ON(skb == NULL);
+ /* Make hw descriptor updates visible to CPU */
rmb();
+
bufstat = bp->tx_ring[tail].ctrl;
if (!(bufstat & MACB_BIT(TX_USED)))
@@ -415,7 +417,10 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
if (frag == last_frag)
break;
}
+
+ /* Make descriptor updates visible to hardware */
wmb();
+
return 1;
}
@@ -436,12 +441,14 @@ static int macb_rx_frame(struct macb *bp, unsigned int first_frag,
frag_len);
offset += RX_BUFFER_SIZE;
bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
- wmb();
if (frag == last_frag)
break;
}
+ /* Make descriptor updates visible to hardware */
+ wmb();
+
skb->protocol = eth_type_trans(skb, bp->dev);
bp->stats.rx_packets++;
@@ -461,6 +468,8 @@ static void discard_partial_frame(struct macb *bp, unsigned int begin,
for (frag = begin; frag != end; frag = NEXT_RX(frag))
bp->rx_ring[frag].addr &= ~MACB_BIT(RX_USED);
+
+ /* Make descriptor updates visible to hardware */
wmb();
/*
@@ -479,7 +488,9 @@ static int macb_rx(struct macb *bp, int budget)
for (; budget > 0; tail = NEXT_RX(tail)) {
u32 addr, ctrl;
+ /* Make hw descriptor updates visible to CPU */
rmb();
+
addr = bp->rx_ring[tail].addr;
ctrl = bp->rx_ring[tail].ctrl;
@@ -674,6 +685,8 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
bp->tx_ring[entry].addr = mapping;
bp->tx_ring[entry].ctrl = ctrl;
+
+ /* Make newly initialized descriptor visible to hardware */
wmb();
entry = NEXT_TX(entry);
@@ -782,9 +795,6 @@ static void macb_init_rings(struct macb *bp)
static void macb_reset_hw(struct macb *bp)
{
- /* Make sure we have the write buffer for ourselves */
- wmb();
-
/*
* Disable RX and TX (XXX: Should we halt the transmission
* more gracefully?)
--
1.7.10
next prev parent reply other threads:[~2012-09-05 8:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 8:19 [PATCH 00/10] net/macb: driver enhancement concerning GEM support, ring logic and cleanup Nicolas Ferre
2012-09-05 8:19 ` [PATCH 01/10] net/macb: Add support for Gigabit Ethernet mode Nicolas Ferre
2012-09-05 8:19 ` Nicolas Ferre [this message]
2012-09-05 8:19 ` [PATCH 03/10] net/macb: change debugging messages Nicolas Ferre
2012-09-05 8:19 ` [PATCH 04/10] net/macb: Fix a race in macb_start_xmit() Nicolas Ferre
2012-09-05 21:30 ` David Miller
2012-09-06 14:52 ` Nicolas Ferre
2012-09-06 15:49 ` Havard Skinnemoen
2012-09-07 16:34 ` Nicolas Ferre
2012-09-05 9:00 ` [PATCH 05/10] net/macb: clean up ring buffer logic Nicolas Ferre
2012-09-05 9:00 ` [PATCH 06/10] net/macb: better manage tx errors Nicolas Ferre
2012-09-05 9:00 ` [PATCH 07/10] net/macb: tx status is more than 8 bits now Nicolas Ferre
2012-09-05 9:00 ` [PATCH 08/10] net/macb: macb_get_drvinfo: add GEM/MACB suffix to differentiate revision Nicolas Ferre
2012-09-05 21:31 ` David Miller
2012-09-05 23:27 ` Ben Hutchings
2012-09-06 14:01 ` Nicolas Ferre
2012-09-06 17:42 ` David Miller
2012-09-05 9:00 ` [PATCH 09/10] net/macb: ethtool interface: add register dump feature Nicolas Ferre
2012-09-05 21:32 ` David Miller
2012-09-05 23:36 ` Ben Hutchings
2012-09-06 14:20 ` [PATCH v2 " Nicolas Ferre
2012-09-06 14:34 ` Ben Hutchings
2012-09-05 9:04 ` [PATCH 10/10] net/macb: Offset first RX buffer by two bytes Nicolas Ferre
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=8f4d7383d051ed4e3617944141c7746505e35638.1346775479.git.nicolas.ferre@atmel.com \
--to=nicolas.ferre@atmel.com \
--cc=davem@davemloft.net \
--cc=havard@skinnemoen.net \
--cc=jamie@jamieiles.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=patrice.vilchez@atmel.com \
--cc=plagnioj@jcrosoft.com \
/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).