Skip to content

Commit 1fded07

Browse files
ahunter6Vinod Koul
authored andcommitted
dmaengine: intel_mid_dma: locking and freeing fixes
Two issues are fixed: 1. DMA descriptors are reused so when freeing lli structures that are linked to them, the pointer must be nulled. 2. midc_scan_descriptors() must be called with the channel lock held. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
1 parent 0ef7e20 commit 1fded07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/dma/intel_mid_dma.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ static void midc_dostart(struct intel_mid_dma_chan *midc,
280280
* callbacks but must be called with the lock held.
281281
*/
282282
static void midc_descriptor_complete(struct intel_mid_dma_chan *midc,
283-
struct intel_mid_dma_desc *desc)
283+
struct intel_mid_dma_desc *desc)
284+
__releases(&midc->lock) __acquires(&midc->lock)
284285
{
285286
struct dma_async_tx_descriptor*txd = &desc->txd;
286287
dma_async_tx_callback callback_txd = NULL;
@@ -311,6 +312,7 @@ static void midc_descriptor_complete(struct intel_mid_dma_chan *midc,
311312
pci_pool_free(desc->lli_pool, desc->lli,
312313
desc->lli_phys);
313314
pci_pool_destroy(desc->lli_pool);
315+
desc->lli = NULL;
314316
}
315317
list_move(&desc->desc_node, &midc->free_list);
316318
midc->busy = false;
@@ -490,7 +492,9 @@ static enum dma_status intel_mid_dma_tx_status(struct dma_chan *chan,
490492

491493
ret = dma_async_is_complete(cookie, last_complete, last_used);
492494
if (ret != DMA_SUCCESS) {
495+
spin_lock_bh(&midc->lock);
493496
midc_scan_descriptors(to_middma_device(chan->device), midc);
497+
spin_unlock_bh(&midc->lock);
494498

495499
last_complete = midc->completed;
496500
last_used = chan->cookie;
@@ -566,6 +570,7 @@ static int intel_mid_dma_device_control(struct dma_chan *chan,
566570
pci_pool_free(desc->lli_pool, desc->lli,
567571
desc->lli_phys);
568572
pci_pool_destroy(desc->lli_pool);
573+
desc->lli = NULL;
569574
}
570575
list_move(&desc->desc_node, &midc->free_list);
571576
}

0 commit comments

Comments
 (0)