diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2011-10-10 10:27:02 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-10-14 14:48:11 -0400 |
commit | 984ecb9293b77901947f3ade5f7e1a70bfc7d940 (patch) | |
tree | 478b235d7c457350049ddf6ee91425e37f050696 /drivers | |
parent | b319d3eb964a602dd1f77bd04b033c40f896e06f (diff) |
iwlagn: fix a race in the unmapping of the TFDs
While inspecting the code, I saw that iwl_tx_queue_unmap modifies
the read pointer of the Tx queue without taking any locks. This means
that it can race with the reclaim flow. This can possibly lead to
a DMA warning complaining that we unmap the same buffer twice.
This is more a W/A than a fix since it is really weird to take
sta_lock inside iwl_tx_queue_unmap, but it can help until we revamp
the locking model in the transport layer.
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 60067c7f0de0..f69aecb554e9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | |||
@@ -406,6 +406,7 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id) | |||
406 | struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id]; | 406 | struct iwl_tx_queue *txq = &trans_pcie->txq[txq_id]; |
407 | struct iwl_queue *q = &txq->q; | 407 | struct iwl_queue *q = &txq->q; |
408 | enum dma_data_direction dma_dir; | 408 | enum dma_data_direction dma_dir; |
409 | unsigned long flags; | ||
409 | 410 | ||
410 | if (!q->n_bd) | 411 | if (!q->n_bd) |
411 | return; | 412 | return; |
@@ -418,12 +419,14 @@ static void iwl_tx_queue_unmap(struct iwl_trans *trans, int txq_id) | |||
418 | else | 419 | else |
419 | dma_dir = DMA_TO_DEVICE; | 420 | dma_dir = DMA_TO_DEVICE; |
420 | 421 | ||
422 | spin_lock_irqsave(&trans->shrd->sta_lock, flags); | ||
421 | while (q->write_ptr != q->read_ptr) { | 423 | while (q->write_ptr != q->read_ptr) { |
422 | /* The read_ptr needs to bound by q->n_window */ | 424 | /* The read_ptr needs to bound by q->n_window */ |
423 | iwlagn_txq_free_tfd(trans, txq, get_cmd_index(q, q->read_ptr), | 425 | iwlagn_txq_free_tfd(trans, txq, get_cmd_index(q, q->read_ptr), |
424 | dma_dir); | 426 | dma_dir); |
425 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd); | 427 | q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd); |
426 | } | 428 | } |
429 | spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); | ||
427 | } | 430 | } |
428 | 431 | ||
429 | /** | 432 | /** |