dmaengine: idxd: Move dma_free_coherent() out of spinlocked context
Subsystems (2)
PATCH 1/1 dmaengine: idxd: Move dma_free_coherent() out of spinlocked context
Task may be rescheduled within dma_free_coherent(). So dma_free_coherent() can't be called between spin_lock() and spin_unlock() to avoid Call Trace:
Call Trace:
<TASK>
dump_stack_lvl+0x37/0x50
__might_resched+0x16a/0x1c0
vunmap+0x2c/0x70
__iommu_dma_free+0x96/0x100
idxd_device_evl_free+0xd5/0x100 [idxd]
device_release_driver_internal+0x197/0x200
unbind_store+0xa1/0xb0
kernfs_fop_write_iter+0x120/0x1c0
vfs_write+0x2d3/0x400
ksys_write+0x63/0xe0
do_syscall_64+0x44/0xa0
entry_SYSCALL_64_after_hwframe+0x6e/0xd8Move it out of the context.
--- drivers/dma/idxd/device.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/dma/idxd/device.c +8 -1
@@ -802,6 +802,9 @@ static int idxd_device_evl_setup(struct idxd_device *idxd)static void idxd_device_evl_free (struct idxd_device *idxd) { +void *evl_log; +unsigned int evl_log_size; +dma_addr_t evl_dma;union gencfg_reg gencfg;union genctrl_reg genctrl;struct device *dev = &idxd->pdev->dev;
@@ -822,11 +825,15 @@ static void idxd_device_evl_free(struct idxd_device *idxd)iowrite64 (0 , idxd->reg_base +IDXD_EVLCFG_OFFSET );iowrite64 (0 , idxd->reg_base +IDXD_EVLCFG_OFFSET +8 ); -dma_free_coherent (dev, evl->log_size, evl->log, evl->dma);bitmap_free (evl->bmap); + evl_log = evl->log; + evl_log_size = evl->log_size; + evl_dma = evl->dma; evl->log =NULL ; evl->size =IDXD_EVL_SIZE_MIN ;spin_unlock (&evl->lock); + +dma_free_coherent (dev, evl_log_size, evl_log, evl_dma); }static void idxd_group_config_write (struct idxd_group *group)
Signature · 1 line
2.25.1
PATCH 1/1 dmaengine: idxd: Move dma_free_coherent() out of spinlocked context
Task may be rescheduled within dma_free_coherent(). So dma_free_coherent() can't be called between spin_lock() and spin_unlock() to avoid Call Trace:
Call Trace:
<TASK>
dump_stack_lvl+0x37/0x50
__might_resched+0x16a/0x1c0
vunmap+0x2c/0x70
__iommu_dma_free+0x96/0x100
idxd_device_evl_free+0xd5/0x100 [idxd]
device_release_driver_internal+0x197/0x200
unbind_store+0xa1/0xb0
kernfs_fop_write_iter+0x120/0x1c0
vfs_write+0x2d3/0x400
ksys_write+0x63/0xe0
do_syscall_64+0x44/0xa0
entry_SYSCALL_64_after_hwframe+0x6e/0xd8Move it out of the context.
--- drivers/dma/idxd/device.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/dma/idxd/device.c +8 -1
@@ -802,6 +802,9 @@ static int idxd_device_evl_setup(struct idxd_device *idxd)static void idxd_device_evl_free (struct idxd_device *idxd) { +void *evl_log; +unsigned int evl_log_size; +dma_addr_t evl_dma;union gencfg_reg gencfg;union genctrl_reg genctrl;struct device *dev = &idxd->pdev->dev;
@@ -822,11 +825,15 @@ static void idxd_device_evl_free(struct idxd_device *idxd)iowrite64 (0 , idxd->reg_base +IDXD_EVLCFG_OFFSET );iowrite64 (0 , idxd->reg_base +IDXD_EVLCFG_OFFSET +8 ); -dma_free_coherent (dev, evl->log_size, evl->log, evl->dma);bitmap_free (evl->bmap); + evl_log = evl->log; + evl_log_size = evl->log_size; + evl_dma = evl->dma; evl->log =NULL ; evl->size =IDXD_EVL_SIZE_MIN ;spin_unlock (&evl->lock); + +dma_free_coherent (dev, evl_log_size, evl_log, evl_dma); }static void idxd_group_config_write (struct idxd_group *group)
Signature · 1 line
2.25.1
Quoted 16 lines · Rex Zhang
Task may be rescheduled within
dma_free_coherent(). Sodma_free_coherent()can't be called betweenspin_lock()andspin_unlock()to avoid Call Trace:Call Trace: <TASK> dump_stack_lvl+0x37/0x50 __might_resched+0x16a/0x1c0 vunmap+0x2c/0x70 __iommu_dma_free+0x96/0x100 idxd_device_evl_free+0xd5/0x100 [idxd] device_release_driver_internal+0x197/0x200 unbind_store+0xa1/0xb0 kernfs_fop_write_iter+0x120/0x1c0 vfs_write+0x2d3/0x400 ksys_write+0x63/0xe0 do_syscall_64+0x44/0xa0 entry_SYSCALL_64_after_hwframe+0x6e/0xd8
Quoted 3 lines
Move it out of the context.
[...]
Applied, thanks!
[1/1] dmaengine: idxd: Move dma_free_coherent() out of spinlocked context
commit: e271c0ba3f919c48e90c64b703538fbb7865cb63
Best regards,
Signature · 1 line
~Vinod
Quoted 16 lines · Rex Zhang
Task may be rescheduled within
dma_free_coherent(). Sodma_free_coherent()can't be called betweenspin_lock()andspin_unlock()to avoid Call Trace:Call Trace: <TASK> dump_stack_lvl+0x37/0x50 __might_resched+0x16a/0x1c0 vunmap+0x2c/0x70 __iommu_dma_free+0x96/0x100 idxd_device_evl_free+0xd5/0x100 [idxd] device_release_driver_internal+0x197/0x200 unbind_store+0xa1/0xb0 kernfs_fop_write_iter+0x120/0x1c0 vfs_write+0x2d3/0x400 ksys_write+0x63/0xe0 do_syscall_64+0x44/0xa0 entry_SYSCALL_64_after_hwframe+0x6e/0xd8
Quoted 7 lines
Move it out of the context.
Fixes 244da66cda35 ("dmaengine: idxd: setup event log configuration")Signed-off-by Rex Zhang <[email protected]>Reviewed-by Dave Jiang <[email protected]>Reviewed-by Fenghua Yu <[email protected]>---
Quoted 34 lines
drivers/dma/idxd/device.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/dma/idxd/device.c +8
-1@@ -802,6 +802,9 @@ static int idxd_device_evl_setup(struct idxd_device *idxd)static void idxd_device_evl_free (struct idxd_device *idxd) { +void *evl_log; +unsigned int evl_log_size; +dma_addr_t evl_dma;union gencfg_reg gencfg;union genctrl_reg genctrl;struct device *dev = &idxd->pdev->dev;@@ -822,11 +825,15 @@ static void idxd_device_evl_free(struct idxd_device *idxd)iowrite64 (0 , idxd->reg_base +IDXD_EVLCFG_OFFSET );iowrite64 (0 , idxd->reg_base +IDXD_EVLCFG_OFFSET +8 ); -dma_free_coherent (dev, evl->log_size, evl->log, evl->dma);bitmap_free (evl->bmap); + evl_log = evl->log; + evl_log_size = evl->log_size; + evl_dma = evl->dma; evl->log =NULL ; evl->size =IDXD_EVL_SIZE_MIN ;spin_unlock (&evl->lock); + +dma_free_coherent (dev, evl_log_size, evl_log, evl_dma); }static void idxd_group_config_write (struct idxd_group *group)