[RFC PATCH v2 2/2] fpga: dfl: release irq triggers when the device file ops are unregistered
From: Ionut Nechita (Wind River)
Date: Mon Nov 30 2026 - 13:22:22 EST
From: Ionut Nechita <ionut.nechita@xxxxxxxxxxxxx>
The eventfd triggers bound with the DFL_FPGA_*_SET_IRQ ioctls are only
released in release(), when the last user closes the device file. If
the feature device is removed while the file is open, dfl-pci frees the
MSI-X vectors with the handlers still requested, and the irqaction, its
name and the eventfd reference are leaked:
remove_proc_entry: removing non-empty directory 'irq/62', leaking at least 'fpga-irq[0](dfl-fme.0-4)'
WARNING: CPU: 24 PID: 19313 at fs/proc/generic.c:742 remove_proc_entry+0x199/0x1c0
Call Trace:
unregister_irq_proc
free_desc
irq_free_descs
msi_domain_free_irqs_all_locked
pci_free_irq_vectors
pci_device_remove
Release them when the cdev ops are unregistered on the remove path of
the FME and the port, once no file operation can bind them again.
Fixes: 322b598be4d9 ("fpga: dfl: introduce interrupt trigger setting API")
Signed-off-by: Ionut Nechita <ionut.nechita@xxxxxxxxxxxxx>
---
drivers/fpga/dfl.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index f1b7e22954c6c..2a374b9df7701 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -681,16 +681,26 @@ EXPORT_SYMBOL_GPL(dfl_fpga_dev_ops_register);
*
* The device file may still be open. Wait for the file operations in
* progress and make the later ones fail, so that none of them reaches
- * the feature device once it is gone.
+ * the feature device once it is gone. Release the irq triggers bound
+ * through the file, as release() will not: the parent frees the irq
+ * vectors once the feature device is removed.
*/
void dfl_fpga_dev_ops_unregister(struct platform_device *pdev)
{
struct dfl_feature_platform_data *pdata = dev_get_platdata(&pdev->dev);
+ struct dfl_feature_dev_data *fdata = pdata->fdata;
+ struct dfl_feature *feature;
cdev_del(&pdata->cdev);
down_write(&pdata->ops_rwsem);
pdata->ops_unregistered = true;
+
+ mutex_lock(&fdata->lock);
+ dfl_fpga_dev_for_each_feature(fdata, feature)
+ dfl_fpga_set_irq_triggers(feature, 0, feature->nr_irqs, NULL);
+ mutex_unlock(&fdata->lock);
+
up_write(&pdata->ops_rwsem);
}
EXPORT_SYMBOL_GPL(dfl_fpga_dev_ops_unregister);
--
2.56.1