Skip to contentSkip to conversation

igb: Use dma_wmb() instead of wmb() before doorbell writes

PATCH New Venkatesh Srinivas 3 participants 3 messages May 25, 2018 – Jun 5, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 igb: Use dma_wmb() instead of wmb() before doorbell writes

igb writes to doorbells to post transmit and receive descriptors; after writing descriptors to memory but before writing to doorbells, use dma_wmb() rather than wmb(). wmb() is more heavyweight than necessary before doorbell writes.

On x86, this avoids SFENCEs before doorbell writes in both the tx and rx refill paths.

---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +2 -2
index cce7ada89255..8aea50867a5d 100644
@@ -5674,7 +5674,7 @@ static int igb_tx_map(struct igb_ring *tx_ring,
 	 * We also need this memory barrier to make certain all of the
 	 * status bits have been updated before next_to_watch is written.
 	 */
-	wmb();
+	dma_wmb();
 
 	/* set next_to_watch value indicating a packet is present */
 	first->next_to_watch = tx_desc;
@@ -8093,7 +8093,7 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count)
 		 * applicable for weak-ordered memory model archs,
 		 * such as IA-64).
 		 */
-		wmb();
+		dma_wmb();
 		writel(i, rx_ring->tail);
 	}
 }
Signature · 1 line
2.17.0.921.gf22659ad46-goog
#1 lore raw

PATCH 1/1 igb: Use dma_wmb() instead of wmb() before doorbell writes

Quoted 18 lines · Venkatesh Srinivas

igb writes to doorbells to post transmit and receive descriptors; after writing descriptors to memory but before writing to doorbells, use dma_wmb() rather than wmb(). wmb() is more heavyweight than necessary before doorbell writes.

On x86, this avoids SFENCEs before doorbell writes in both the tx and rx refill paths.

---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +0 -0
index cce7ada89255..8aea50867a5d 100644

drivers/net/ethernet/intel/igb/igb_main.c static int igb_tx_map(struct igb_ring *tx_ring, · line 5680

Quoted 8 lines
drivers/net/ethernet/intel/igb/igb_main.c +1 -1
@@ -5674,7 +5674,7 @@ static int igb_tx_map(struct igb_ring *tx_ring,
         * We also need this memory barrier to make certain all of the
         * status bits have been updated before next_to_watch is written.
         */
-       wmb();
+       dma_wmb();
 
        /* set next_to_watch value indicating a packet is present */
        first->next_to_watch = tx_desc;

This change I am good with. My first instinct would be to replace this with just an smp_wmb(), however we are better off probably just using the dma_wmb() so that it doesn't get compiled out in the non-smp kernel case.

drivers/net/ethernet/intel/igb/igb_main.c void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count) · line 8099

Quoted 9 lines
drivers/net/ethernet/intel/igb/igb_main.c +1 -1
@@ -8093,7 +8093,7 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count)
                 * applicable for weak-ordered memory model archs,
                 * such as IA-64).
                 */
-               wmb();
+               dma_wmb();
                writel(i, rx_ring->tail);
        }
 }

I'm not sure if this is even really needed. My understanding is that the writel should be providing a barrier if needed already. Odds are we can probably just drop the wmb() and update the comment that goes with it.

Thanks.

- Alex

#2 lore raw

PATCH 1/1 igb: Use dma_wmb() instead of wmb() before doorbell writes

Quoted 8 lines

From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Alexander Duyck
Sent: Friday, May 25, 2018 8:56 AM
To: Venkatesh Srinivas <[email protected]>
Cc: vsrinivas at ops101.org; intel-wired-lan <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH] igb: Use dma_wmb() instead of wmb() before doorbell writes

Quoted 14 lines
Quoted 12 lines · Venkatesh Srinivas

igb writes to doorbells to post transmit and receive descriptors; after writing descriptors to memory but before writing to doorbells, use dma_wmb() rather than wmb(). wmb() is more heavyweight than necessary before doorbell writes.

On x86, this avoids SFENCEs before doorbell writes in both the tx and rx refill paths.

---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)