svn commit: r319201 - head/sys/dev/ena

Zbigniew Bodek zbb at FreeBSD.org
Tue May 30 12:00:58 UTC 2017


Author: zbb
Date: Tue May 30 12:00:56 2017
New Revision: 319201
URL: https://svnweb.freebsd.org/changeset/base/319201

Log:
  Introduce additional locks when releasing TX resources and buffers in ENA
  
  There could be race condition with TX cleaning routine when cleaning mbufs,
  when it was called directly from main sending thread (ena_mq_start).
  
  Submitted by:   Michal Krawczyk <mk at semihalf.com>
  Obtained from:  Semihalf
  Sponsored by:   Amazon.com Inc.
  Differential revision: https://reviews.freebsd.org/D10927

Modified:
  head/sys/dev/ena/ena.c

Modified: head/sys/dev/ena/ena.c
==============================================================================
--- head/sys/dev/ena/ena.c	Tue May 30 11:58:51 2017	(r319200)
+++ head/sys/dev/ena/ena.c	Tue May 30 12:00:56 2017	(r319201)
@@ -713,6 +713,7 @@ ena_free_tx_resources(struct ena_adapter *adapter, int
 	drbr_flush(adapter->ifp, tx_ring->br);
 
 	/* Free buffer DMA maps, */
+	ENA_RING_MTX_LOCK(tx_ring);
 	for (int i = 0; i < tx_ring->ring_size; i++) {
 		m_freem(tx_ring->tx_buffer_info[i].mbuf);
 		tx_ring->tx_buffer_info[i].mbuf = NULL;
@@ -721,6 +722,7 @@ ena_free_tx_resources(struct ena_adapter *adapter, int
 		bus_dmamap_destroy(adapter->tx_buf_tag,
 		    tx_ring->tx_buffer_info[i].map);
 	}
+	ENA_RING_MTX_UNLOCK(tx_ring);
 
 	/* And free allocated memory. */
 	ENA_MEM_FREE(adapter->ena_dev->dmadev, tx_ring->tx_buffer_info);
@@ -1121,6 +1123,7 @@ ena_free_tx_bufs(struct ena_adapter *adapter, unsigned
 {
 	struct ena_ring *tx_ring = &adapter->tx_ring[qid];
 
+	ENA_RING_MTX_LOCK(tx_ring);
 	for (int i = 0; i < tx_ring->ring_size; i++) {
 		struct ena_tx_buffer *tx_info = &tx_ring->tx_buffer_info[i];
 
@@ -1134,6 +1137,7 @@ ena_free_tx_bufs(struct ena_adapter *adapter, unsigned
 		m_free(tx_info->mbuf);
 		tx_info->mbuf = NULL;
 	}
+	ENA_RING_MTX_UNLOCK(tx_ring);
 
 	return;
 }


More information about the svn-src-all mailing list