dmaengine: idxd: Fix not releasing workqueue on .release()
PATCH 1/1 dmaengine: idxd: Fix not releasing workqueue on .release()
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 3d33de353b1ff9023d5ec73b9becf80ea87af695 ]
The workqueue associated with an DSA/IAA device is not released when the object is freed.
[ Remove destroy_workqueue(idxd->wq) from the function idxd_remove() to avoid the workqueue is released twice. ]
---
On 5.15.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(-)
drivers/dma/idxd/init.c +0 -1
@@ -829,7 +829,6 @@ static void idxd_remove(struct pci_dev *pdev)pci_iounmap (pdev, idxd->reg_base);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)); }
drivers/dma/idxd/sysfs.c +1 -0
@@ -1271,6 +1271,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);kfree (idxd->wqs);kfree (idxd->engines);
Signature · 1 line
2.43.0
Sasha Levin
maintainerQuoted 1 line · Wenshan Lan
[PATCH 5.15.y] dmaengine: idxd: Fix not releasing workqueue on .release()
Now applied to 5.15.y as dd377066acf6a4 (backport of upstream 3d33de353b1f).
Thanks,
Sasha