From: Xu Yilun <yilun.xu@linux.intel.com>
To: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
Cc: Xu Yilun <yilun.xu@intel.com>, Moritz Fischer <mdf@kernel.org>,
Tom Rix <trix@redhat.com>,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] fpga: dfl: release irq triggers when a feature device is removed
Date: Sun, 29 Nov 2026 01:38:29 +0800 [thread overview]
Message-ID: <awsRlTtDlPoQijA7@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20261124145734.38683-1-ionut.nechita@windriver.com>
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
>
>
prev parent reply other threads:[~2026-11-28 17:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:57 Ionut Nechita (Wind River)
2026-11-28 17:38 ` Xu Yilun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awsRlTtDlPoQijA7@yilunxu-OptiPlex-7050 \
--to=yilun.xu@linux.intel.com \
--cc=ionut.nechita@windriver.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=stable@vger.kernel.org \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®