From nobody Wed Apr 22 21:08:24 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g1Bf10Dt9z6bKvW for ; Wed, 22 Apr 2026 21:08:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g1Bf04QW5z3knQ for ; Wed, 22 Apr 2026 21:08:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8tiCiHnUTG5AMJDcj8v7vkyJx7aqEgrTkgz4uZo/hzc=; b=boGXCyy/LzW05c8u7BBPq0MtBx9AleFUwQrqJxNKDNNbkAm/giVaadyur055XGQYYcRqqq a7Xk3qC4D9OwtLvTuBwHv5r+knn2AttSNXdU9ld4XUmOQQJKDhnrYNoRBAb8HYkLUGblUe zzxxArHag7+FkBCpcwXoGKwgWop7ps+CtknmACBjqAe5tD2ySLCHHYNtqvfVqKfk66Ezm7 K/S25nT132RMPa/eVMNLoNsF/xOwFYe8x7dJUyLLEDxYVYk+/CIA/9ld7JMef1DFncunXA NnLoOHcZp9UqqnTMKYl1x5PzBuxnStYzOsDAIxQ0+TceUCbqOC5M/4wpmzAHcw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1776892104; a=rsa-sha256; cv=none; b=o5TkXVjuz2sJSn2yi/2K22NVLAlZDawVUByOFtEQjGQcjkdjc8QpM6J8TmR5qhCsCL4RQF 84C0FgJAsJPWbbqmaxz/mwORSrcTHMCNPAcXqf1qVtKl1KoiKiLIr8L+U+pZ26Mxh3zFa6 dAtZ7Bc+hT2kLigzAsge8JcYxdHwmwWVajUngE4EgtdL80bkLaQUQfiGWmUey7n3/tUVf1 JnIMp0hZJfnYIH2F35gCNAfZONQ9SFdQpOFrtUYCDTWcX4Y/0I3uxMGOtjRaZ+I7Uqlbwf mFQd9XA7/qjuxkcXQYjj64f+UMiezYP3ppg1YFFSC9SAfyC4iFRL464snp7KwQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1776892104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8tiCiHnUTG5AMJDcj8v7vkyJx7aqEgrTkgz4uZo/hzc=; b=sMZ+tk37zbcotZtJnVyeeHfBG90RWYccsL6ttf1HAACnXnYT6YJqMcZNpD18d9YkS4zO6E 3cWTsZRBCOSqNw62I6eRr7XUlsp3UG8JUCMZQcZ1dozw0ajueAb/fTy2a3PLA23LPGXbDz l7fFhkjXaq+UUv2m6+x26FZtGfw497fk6LQpDM9Pv0JgiYi1q5qmzeQjtFVNuUGEBsfe3i MrZAz7/anpbXB2Dd554SlXf0TxPUL4eHtPuthPu/IHEwOYSXP2DwQJzBj9n/Uv3XIYBcEF jtQGBZmB+EvR7plhpxdTdCh+2LXw3pqKTI22xsheK6bYc0a62lUl9aI0bFHTog== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g1Bf03lD7zn9Z for ; Wed, 22 Apr 2026 21:08:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27ca9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 22 Apr 2026 21:08:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron From: Bjoern A. Zeeb Subject: git: 6425b7399b34 - stable/15 - linuxkpi: Add eventfd_*() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 6425b7399b3425222260a4497ac98e4a5e811330 Auto-Submitted: auto-generated Date: Wed, 22 Apr 2026 21:08:24 +0000 Message-Id: <69e938c8.27ca9.6e4c2fed@gitrepo.freebsd.org> The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=6425b7399b3425222260a4497ac98e4a5e811330 commit 6425b7399b3425222260a4497ac98e4a5e811330 Author: Jean-Sébastien Pédron AuthorDate: 2025-05-26 18:12:40 +0000 Commit: Bjoern A. Zeeb CommitDate: 2026-04-22 20:56:59 +0000 linuxkpi: Add eventfd_*() Add and expose the `eventfd_*()` API. This is used by DRM drivers for some time, but the code was commented out so far. Note that Linux uses `struct eventfd_ctx`, but FreeBSD defines `struct eventfd`. We define `eventfd_ctx` as a synonym to `eventfd`. Reviewed by: christos, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50853 (cherry picked from commit a200c8e51cdb4586ad2eb20d2b45ba367f00beaf) --- sys/compat/linuxkpi/common/include/linux/eventfd.h | 54 +++++++++++++++++++ sys/compat/linuxkpi/common/src/linux_eventfd.c | 63 ++++++++++++++++++++++ sys/compat/linuxkpi/dummy/include/linux/eventfd.h | 0 sys/conf/files | 2 + sys/modules/linuxkpi/Makefile | 1 + 5 files changed, 120 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/eventfd.h b/sys/compat/linuxkpi/common/include/linux/eventfd.h new file mode 100644 index 000000000000..d167d4b7d189 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/eventfd.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2025 The FreeBSD Foundation + * Copyright (c) 2025 Jean-Sébastien Pédron + * + * This software was developed by Jean-Sébastien Pédron under sponsorship + * from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LINUXKPI_LINUX_EVENTFD_H_ +#define _LINUXKPI_LINUX_EVENTFD_H_ + +#include + +#include +#include +#include +#include +#include + +/* + * Linux uses `struct eventfd_ctx`, but FreeBSD defines `struct eventfd`. Here, + * we define a synonym to the FreeBSD structure. This allows to keep Linux code + * unmodified. + */ +#define eventfd_ctx eventfd + +#define eventfd_ctx_fdget lkpi_eventfd_ctx_fdget +struct eventfd_ctx *lkpi_eventfd_ctx_fdget(int fd); + +#define eventfd_ctx_put lkpi_eventfd_ctx_put +void lkpi_eventfd_ctx_put(struct eventfd_ctx *ctx); + +#endif /* _LINUXKPI_LINUX_EVENTFD_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_eventfd.c b/sys/compat/linuxkpi/common/src/linux_eventfd.c new file mode 100644 index 000000000000..126c6c54b9a5 --- /dev/null +++ b/sys/compat/linuxkpi/common/src/linux_eventfd.c @@ -0,0 +1,63 @@ +/*- + * Copyright (c) 2025 The FreeBSD Foundation + * Copyright (c) 2025 Jean-Sébastien Pédron + * + * This software was developed by Jean-Sébastien Pédron under sponsorship + * from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include + +struct eventfd_ctx * +lkpi_eventfd_ctx_fdget(int fd) +{ + struct file *fp; + struct eventfd_ctx *ctx; + + /* Lookup file pointer by file descriptor index. */ + if (fget_unlocked(curthread, fd, &cap_no_rights, &fp) != 0) + return (ERR_PTR(-EBADF)); + + /* + * eventfd_get() bumps the refcount, so we can safely release the + * reference on the file itself afterwards. + */ + ctx = eventfd_get(fp); + fdrop(fp, curthread); + + if (ctx == NULL) + return (ERR_PTR(-EBADF)); + + return (ctx); +} + +void +lkpi_eventfd_ctx_put(struct eventfd_ctx *ctx) +{ + eventfd_put(ctx); +} diff --git a/sys/compat/linuxkpi/dummy/include/linux/eventfd.h b/sys/compat/linuxkpi/dummy/include/linux/eventfd.h deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/sys/conf/files b/sys/conf/files index ddac2f0cea93..9d6488a415cb 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4649,6 +4649,8 @@ compat/linuxkpi/common/src/linux_dmi.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_domain.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" +compat/linuxkpi/common/src/linux_eventfd.c optional compat_linuxkpi \ + compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_firmware.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_folio.c optional compat_linuxkpi \ diff --git a/sys/modules/linuxkpi/Makefile b/sys/modules/linuxkpi/Makefile index 77d73f19075a..2090fe76d857 100644 --- a/sys/modules/linuxkpi/Makefile +++ b/sys/modules/linuxkpi/Makefile @@ -6,6 +6,7 @@ SRCS= linux_compat.c \ linux_devres.c \ linux_dmi.c \ linux_domain.c \ + linux_eventfd.c \ linux_firmware.c \ linux_folio.c \ linux_fpu.c \