From: "Ionut Nechita (Wind River)" <ionut.nechita@windriver.com>
To: Xu Yilun <yilun.xu@linux.intel.com>, Moritz Fischer <mdf@kernel.org>
Cc: Xu Yilun <yilun.xu@intel.com>, Tom Rix <trix@redhat.com>,
Peter Colberg <peter.colberg@intel.com>,
linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 0/2] fpga: dfl: sync device file operations with feature device removal
Date: Mon, 30 Nov 2026 20:21:30 +0200 [thread overview]
Message-ID: <20261130182132.56809-1-ionut.nechita@windriver.com> (raw)
The eventfd triggers bound through the FME and port device files are
only released when the last user closes the file. If the card is
removed while a file is held open with a trigger bound, for example for
an FPGA image reload on an Intel FPGA PAC N3000, dfl-pci frees the
MSI-X vectors with the handlers still requested.
v1 released the triggers from dfl_fpga_dev_feature_uinit(). As Yilun
pointed out, nothing there synchronizes with the ioctls: they read
feature->ops without a lock, so a SET_IRQ ioctl in flight could bind a
trigger again right after the cleanup. Looking closer, the file
operations are not synchronized with the removal at all, and since the
feature device data was moved to devm on the PCI device, a release(),
ioctl or mmap after dfl-pci is unbound uses freed memory.
Patch 1 synchronizes the file operations with the unregistration of the
cdev ops, through a rw_semaphore in the feature platform data, which an
open file keeps alive. Patch 2 releases the irq triggers there, which
is the v1 fix on top of that.
This is an RFC because it has not been tested on hardware yet. It is
built with W=1 (allmodconfig, PROVE_LOCKING=y) on next-20261127, and
applies to and builds on a 6.18-based tree. I plan to test it on an
N3000 later this week, removing the card with the FME and port files
held open and irqs bound, and with SET_IRQ racing the removal, and to
send a non-RFC version with the results. Comments on the approach are
welcome meanwhile.
Not covered here:
- MMIO mappings set up through mmap before the removal are not revoked.
- Unbinding and rebinding only the dfl-fme or dfl-port platform driver
with the file open still reuses a cdev that is in use, as before.
v1: https://lore.kernel.org/all/20261124145734.38683-1-ionut.nechita@windriver.com/
Changes in v2:
- Synchronize the file operations with the removal (new patch 1).
- Release the triggers when the cdev ops are unregistered, under the
new lock, instead of in dfl_fpga_dev_feature_uinit().
Ionut Nechita (2):
fpga: dfl: sync device file operations with feature device removal
fpga: dfl: release irq triggers when the device file ops are
unregistered
drivers/fpga/dfl-afu-main.c | 75 +++++++++++++++++++++-------
drivers/fpga/dfl-fme-main.c | 48 ++++++++++++++----
drivers/fpga/dfl.c | 98 ++++++++++++++++++++++++++++++++++++-
drivers/fpga/dfl.h | 26 +++++++---
4 files changed, 213 insertions(+), 34 deletions(-)
base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d
--
2.56.1
next reply other threads:[~2026-11-30 18:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 18:21 Ionut Nechita (Wind River) [this message]
2026-11-30 18:21 ` [RFC PATCH v2 1/2] " Ionut Nechita (Wind River)
2026-11-30 18:21 ` [RFC PATCH v2 2/2] fpga: dfl: release irq triggers when the device file ops are unregistered Ionut Nechita (Wind River)
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=20261130182132.56809-1-ionut.nechita@windriver.com \
--to=ionut.nechita@windriver.com \
--cc=linux-fpga@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdf@kernel.org \
--cc=peter.colberg@intel.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
--cc=yilun.xu@linux.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®