mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/2] fpga: dfl: sync device file operations with feature device removal
@ 2026-11-30 18:21 Ionut Nechita (Wind River)
  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)
  0 siblings, 2 replies; 3+ messages in thread
From: Ionut Nechita (Wind River) @ 2026-11-30 18:21 UTC (permalink / raw)
  To: Xu Yilun, Moritz Fischer
  Cc: Xu Yilun, Tom Rix, Peter Colberg, linux-fpga, linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 18:21 [RFC PATCH v2 0/2] fpga: dfl: sync device file operations with feature device removal Ionut Nechita (Wind River)
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)

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®