[PATCH 6.1.y] dmaengine: idxd: Fix not releasing workqueue on .release()

Wenshan Lan posted 1 patch 2 days ago
drivers/dma/idxd/init.c  | 1 -
drivers/dma/idxd/sysfs.c | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
[PATCH 6.1.y] dmaengine: idxd: Fix not releasing workqueue on .release()
Posted by Wenshan Lan 2 days ago
From: Vinicius Costa Gomes <vinicius.gomes@intel.com>

[ Upstream commit 3d33de353b1ff9023d5ec73b9becf80ea87af695 ]

The workqueue associated with an DSA/IAA device is not released when
the object is freed.

Fixes: 47c16ac27d4c ("dmaengine: idxd: fix idxd conf_dev 'struct device' lifetime")
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Link: https://patch.msgid.link/20260121-idxd-fix-flr-on-kernel-queues-v3-v3-7-7ed70658a9d1@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
[ Remove destroy_workqueue(idxd->wq) from the function idxd_remove() to
avoid the workqueue is released twice. ]
Signed-off-by: Wenshan Lan <jetlan9@163.com>
---
On 6.1.x, destroy_workqueue(idxd->wq) is still called directly in
idxd_remove(). Applying the upstream patch as-is would cause a double
destroy:
once in idxd_remove() and again in idxd_conf_device_release() when
put_device() triggers the release callback.

Resolution: In addition to adding destroy_workqueue(idxd->wq) to
idxd_conf_device_release(), the call was removed from idxd_remove().
This is safe because idxd_remove() ends with
put_device(idxd_confdev(idxd)) which drops the last reference and
triggers idxd_conf_device_release(), where the workqueue is now destroyed.

---
 drivers/dma/idxd/init.c  | 1 -
 drivers/dma/idxd/sysfs.c | 1 +
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 6059ffc08eac..2880a0b0f5e6 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -813,7 +813,6 @@ static void idxd_remove(struct pci_dev *pdev)
 	if (device_user_pasid_enabled(idxd))
 		iommu_dev_disable_feature(&pdev->dev, IOMMU_DEV_FEAT_SVA);
 	pci_disable_device(pdev);
-	destroy_workqueue(idxd->wq);
 	perfmon_pmu_remove(idxd);
 	put_device(idxd_confdev(idxd));
 }
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 0689464c4816..ea222e1654ab 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -1663,6 +1663,7 @@ static void idxd_conf_device_release(struct device *dev)
 {
 	struct idxd_device *idxd = confdev_to_idxd(dev);
 
+	destroy_workqueue(idxd->wq);
 	kfree(idxd->groups);
 	bitmap_free(idxd->wq_enable_map);
 	kfree(idxd->wqs);
-- 
2.43.0
Re: [PATCH 6.1.y] dmaengine: idxd: Fix not releasing workqueue on .release()
Posted by Sasha Levin 1 day, 10 hours ago
> [PATCH 6.1.y] dmaengine: idxd: Fix not releasing workqueue on .release()

Queued for 6.1, thanks.

--
Thanks,
Sasha