dmaengine: idxd: force wq context cleanup on device disable path
authorDave Jiang <dave.jiang@intel.com>
Tue, 28 Jun 2022 23:00:56 +0000 (16:00 -0700)
committerVinod Koul <vkoul@kernel.org>
Fri, 1 Jul 2022 11:42:40 +0000 (17:12 +0530)
commit44c4237cf3436bda2b185ff728123651ad133f69
tree37adad967fa02621446dd75b046eb128f502ad1e
parent0ac9c3dd0d6fe293cd5044cfad10bec27d171e4e
dmaengine: idxd: force wq context cleanup on device disable path

Testing shown that when a wq mode is setup to be dedicated and then torn
down and reconfigured to shared, the wq configured end up being dedicated
anyays. The root cause is when idxd_device_wqs_clear_state() gets called
during idxd_driver removal, idxd_wq_disable_cleanup() does not get called
vs when the wq driver is removed first. The check of wq state being
"enabled" causes the cleanup to be bypassed. However, idxd_driver->remove()
releases all wq drivers. So the wqs goes to "disabled" state and will never
be "enabled". By that point, the driver has no idea if the wq was
previously configured or clean. So force call idxd_wq_disable_cleanup() on
all wqs always to make sure everything gets cleaned up.

Reported-by: Tony Zhu <tony.zhu@intel.com>
Tested-by: Tony Zhu <tony.zhu@intel.com>
Fixes: 0dcfe41e9a4c ("dmanegine: idxd: cleanup all device related bits after disabling device")
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Co-developed-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20220628230056.2527816-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/idxd/device.c