* [PATCH] fpga: dfl: release irq triggers when a feature device is removed
@ 2026-11-24 14:57 Ionut Nechita (Wind River)
2026-11-28 17:38 ` Xu Yilun
0 siblings, 1 reply; 2+ messages in thread
From: Ionut Nechita (Wind River) @ 2026-11-24 14:57 UTC (permalink / raw)
To: Xu Yilun, Moritz Fischer
Cc: Tom Rix, linux-fpga, linux-kernel, stable, Ionut Nechita
From: Ionut Nechita <ionut.nechita@windriver.com>
The eventfd triggers bound with the DFL_FPGA_*_SET_IRQ ioctls are only
released in the release() handler of the feature device file, when the
last user closes it. If the PCI device is removed while the file is
still open with a trigger bound, for example by an FPGA image reload
that removes and rescans the card, dfl-pci frees the MSI-X vectors
while the handler is still requested:
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
device_release_driver_internal
pci_stop_bus_device
pci_stop_and_remove_bus_device_locked
remove_store
The irqaction, its name and the eventfd reference are leaked, and the
later release() calls free_irq() on an irq number that is no longer
allocated to this device.
Release all triggers in dfl_fpga_dev_feature_uinit(), which runs on the
remove path of both the FME and the port device before the parent
frees the irq vectors. Do it after the sub-feature ops have been
cleared, so that the ioctls no longer reach the sub-features. The
release() handler then finds no triggers left to free.
Fixes: 322b598be4d9 ("fpga: dfl: introduce interrupt trigger setting API")
Cc: stable@vger.kernel.org
Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
---
The warning above was hit on an Intel FPGA PAC N3000 when the card was
removed for an image reload while /dev/dfl-fme.0 was held open with the
FME error irq bound. The fix is build-tested (W=1) on next-20261123; it
has not been runtime-tested on hardware yet.
drivers/fpga/dfl.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index 6f5fa7b2f..70abbdc7e 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -503,6 +503,16 @@ void dfl_fpga_dev_feature_uinit(struct platform_device *pdev)
feature->ops = NULL;
}
}
+
+ /*
+ * The device file may still be open with eventfd triggers bound.
+ * Release them now: the parent frees the irq vectors right after
+ * this device is removed, and release() may run much later.
+ */
+ 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);
}
EXPORT_SYMBOL_GPL(dfl_fpga_dev_feature_uinit);
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] fpga: dfl: release irq triggers when a feature device is removed
2026-11-24 14:57 [PATCH] fpga: dfl: release irq triggers when a feature device is removed Ionut Nechita (Wind River)
@ 2026-11-28 17:38 ` Xu Yilun
0 siblings, 0 replies; 2+ messages in thread
From: Xu Yilun @ 2026-11-28 17:38 UTC (permalink / raw)
To: Ionut Nechita (Wind River)
Cc: Xu Yilun, Moritz Fischer, Tom Rix, linux-fpga, linux-kernel, stable
On Tue, Nov 24, 2026 at 04:57:34PM +0200, Ionut Nechita (Wind River) wrote:
> From: Ionut Nechita <ionut.nechita@windriver.com>
>
> The eventfd triggers bound with the DFL_FPGA_*_SET_IRQ ioctls are only
> released in the release() handler of the feature device file, when the
> last user closes it. If the PCI device is removed while the file is
> still open with a trigger bound, for example by an FPGA image reload
> that removes and rescans the card, dfl-pci frees the MSI-X vectors
> while the handler is still requested:
>
> 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
> device_release_driver_internal
> pci_stop_bus_device
> pci_stop_and_remove_bus_device_locked
> remove_store
>
> The irqaction, its name and the eventfd reference are leaked, and the
> later release() calls free_irq() on an irq number that is no longer
> allocated to this device.
>
> Release all triggers in dfl_fpga_dev_feature_uinit(), which runs on the
> remove path of both the FME and the port device before the parent
> frees the irq vectors. Do it after the sub-feature ops have been
> cleared, so that the ioctls no longer reach the sub-features. The
Why? I don't see dfl_fpga_dev_feature_uinit() sync with any ioctl.
> release() handler then finds no triggers left to free.
I don't think this method makes things clear. Now the problem is that
cdev operations don't sync with pci driver remove, so make them synced?
>
> Fixes: 322b598be4d9 ("fpga: dfl: introduce interrupt trigger setting API")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ionut Nechita <ionut.nechita@windriver.com>
> ---
> The warning above was hit on an Intel FPGA PAC N3000 when the card was
> removed for an image reload while /dev/dfl-fme.0 was held open with the
> FME error irq bound. The fix is build-tested (W=1) on next-20261123; it
> has not been runtime-tested on hardware yet.
>
> drivers/fpga/dfl.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index 6f5fa7b2f..70abbdc7e 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -503,6 +503,16 @@ void dfl_fpga_dev_feature_uinit(struct platform_device *pdev)
> feature->ops = NULL;
> }
> }
> +
> + /*
> + * The device file may still be open with eventfd triggers bound.
> + * Release them now: the parent frees the irq vectors right after
> + * this device is removed, and release() may run much later.
> + */
> + 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);
> }
> EXPORT_SYMBOL_GPL(dfl_fpga_dev_feature_uinit);
>
> --
> 2.55.0
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 14:57 [PATCH] fpga: dfl: release irq triggers when a feature device is removed Ionut Nechita (Wind River)
2026-11-28 17:38 ` Xu Yilun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®