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 <[email protected]>
AuthorDate: 2025-09-07 08:37:27 +0000
Commit:     Jean-Sébastien Pédron <[email protected]>
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 {                                        \

Reply via email to