Date: Mon, 05 Jan 2026 20:09:27 +0000 From: Jean-=?utf-8?Q?S=C3=A9bast?==?utf-8?Q?ien P=C3=A9?=dron <dumbbell@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 55bd09ae0fc4 - main - linuxkpi: Add support for statically-allocated kfifo Message-ID: <695c1a77.800f.5db6f26e@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=55bd09ae0fc437c9eb135952ac278540b7388add commit 55bd09ae0fc437c9eb135952ac278540b7388add Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2025-09-07 08:37:27 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2026-01-05 19:32:49 +0000 linuxkpi: Add support for statically-allocated kfifo The main difference with the dynamically allocated version is that the structure is initialized with `DECLARE_KFIFO()` which takes the number of items as an additional argument compared to `DECLARE_KFIFO_PTR()`. The declared structure is then initialized with `INIT_KFIFO()` which sets all fields to 0, except `total` which is computed from the size of the array passed to `DECLARE_KFIFO()`. The amdgpu DRM driver started to used this in Linux 6.10. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D54497 --- sys/compat/linuxkpi/common/include/linux/kfifo.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kfifo.h b/sys/compat/linuxkpi/common/include/linux/kfifo.h index d2f570781661..fbe16e22683e 100644 --- a/sys/compat/linuxkpi/common/include/linux/kfifo.h +++ b/sys/compat/linuxkpi/common/include/linux/kfifo.h @@ -33,8 +33,26 @@ #include <linux/slab.h> #include <linux/gfp.h> -#define INIT_KFIFO(x) 0 -#define DECLARE_KFIFO(x, y, z) +/* + * INIT_KFIFO() is used to initialize the structure declared with + * DECLARE_KFIFO(). It doesn't work with DECLARE_KFIFO_PTR(). + */ +#define INIT_KFIFO(_kf) \ + ({ \ + (_kf).total = nitems((_kf).head); \ + (_kf).count = 0; \ + (_kf).first = 0; \ + (_kf).last = 0; \ + }) + +#define DECLARE_KFIFO(_name, _type, _size) \ + struct kfifo_ ## _name { \ + size_t total; \ + size_t count; \ + size_t first; \ + size_t last; \ + _type head[_size]; \ + } _name #define DECLARE_KFIFO_PTR(_name, _type) \ struct kfifo_ ## _name { \home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?695c1a77.800f.5db6f26e>
