Skip to content

Commit 6744a03

Browse files
rchatrevinodkoul
authored andcommitted
dmaengine: idxd: Do not call DMX TX callbacks during workqueue disable
On driver unload any pending descriptors are flushed and pending DMA descriptors are explicitly completed: idxd_dmaengine_drv_remove() -> drv_disable_wq() -> idxd_wq_free_irq() -> idxd_flush_pending_descs() -> idxd_dma_complete_txd() With this done during driver unload any remaining descriptor is likely stuck and can be dropped. Even so, the descriptor may still have a callback set that could no longer be accessible. An example of such a problem is when the dmatest fails and the dmatest module is unloaded. The failure of dmatest leaves descriptors with dma_async_tx_descriptor::callback pointing to code that no longer exist. This causes a page fault as below at the time the IDXD driver is unloaded when it attempts to run the callback: BUG: unable to handle page fault for address: ffffffffc0665190 #PF: supervisor instruction fetch in kernel mode #PF: error_code(0x0010) - not-present page Fix this by clearing the callback pointers on the transmit descriptors only when workqueue is disabled. Fixes: 403a2e2 ("dmaengine: idxd: change MSIX allocation based on per wq activation") Signed-off-by: Reinette Chatre <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/37d06b772aa7f8863ca50f90930ea2fd80b38fc3.1670452419.git.reinette.chatre@intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 1beeec4 commit 6744a03

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/dma/idxd/device.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,19 @@ static void idxd_flush_pending_descs(struct idxd_irq_entry *ie)
11721172
spin_unlock(&ie->list_lock);
11731173

11741174
list_for_each_entry_safe(desc, itr, &flist, list) {
1175+
struct dma_async_tx_descriptor *tx;
1176+
11751177
list_del(&desc->list);
11761178
ctype = desc->completion->status ? IDXD_COMPLETE_NORMAL : IDXD_COMPLETE_ABORT;
1179+
/*
1180+
* wq is being disabled. Any remaining descriptors are
1181+
* likely to be stuck and can be dropped. callback could
1182+
* point to code that is no longer accessible, for example
1183+
* if dmatest module has been unloaded.
1184+
*/
1185+
tx = &desc->txd;
1186+
tx->callback = NULL;
1187+
tx->callback_result = NULL;
11771188
idxd_dma_complete_txd(desc, ctype, true);
11781189
}
11791190
}

0 commit comments

Comments
 (0)