The branch main has been updated by dumbbell:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=be818f265e8cd448f5bf442198c495ba554b45c9

commit be818f265e8cd448f5bf442198c495ba554b45c9
Author:     Jean-Sébastien Pédron <dumbb...@freebsd.org>
AuthorDate: 2024-12-27 21:16:36 +0000
Commit:     Jean-Sébastien Pédron <dumbb...@freebsd.org>
CommitDate: 2025-01-31 16:00:48 +0000

    linuxkpi: Use same field names in `struct xarray` as Linux
    
    [Why]
    The i915 DRM driver started to access the `xa_lock` field in Linux 6.7.
    
    Reviewed by:    manu
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D48754
---
 sys/compat/linuxkpi/common/include/linux/xarray.h | 12 +++----
 sys/compat/linuxkpi/common/src/linux_xarray.c     | 38 +++++++++++------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/xarray.h 
b/sys/compat/linuxkpi/common/include/linux/xarray.h
index ab98c8d66805..fba36eea0ab5 100644
--- a/sys/compat/linuxkpi/common/include/linux/xarray.h
+++ b/sys/compat/linuxkpi/common/include/linux/xarray.h
@@ -49,14 +49,14 @@
 
 #define        xa_limit_32b XA_LIMIT(0, 0xFFFFFFFF)
 
-#define        XA_ASSERT_LOCKED(xa) mtx_assert(&(xa)->mtx, MA_OWNED)
-#define        xa_lock(xa) mtx_lock(&(xa)->mtx)
-#define        xa_unlock(xa) mtx_unlock(&(xa)->mtx)
+#define        XA_ASSERT_LOCKED(xa) mtx_assert(&(xa)->xa_lock, MA_OWNED)
+#define        xa_lock(xa) mtx_lock(&(xa)->xa_lock)
+#define        xa_unlock(xa) mtx_unlock(&(xa)->xa_lock)
 
 struct xarray {
-       struct radix_tree_root root;
-       struct mtx mtx;         /* internal mutex */
-       uint32_t flags;         /* see XA_FLAGS_XXX */
+       struct radix_tree_root xa_head;
+       struct mtx xa_lock;     /* internal mutex */
+       uint32_t xa_flags;      /* see XA_FLAGS_XXX */
 };
 
 /*
diff --git a/sys/compat/linuxkpi/common/src/linux_xarray.c 
b/sys/compat/linuxkpi/common/src/linux_xarray.c
index 746cd6029544..54c536042392 100644
--- a/sys/compat/linuxkpi/common/src/linux_xarray.c
+++ b/sys/compat/linuxkpi/common/src/linux_xarray.c
@@ -52,7 +52,7 @@ __xa_erase(struct xarray *xa, uint32_t index)
 
        XA_ASSERT_LOCKED(xa);
 
-       retval = radix_tree_delete(&xa->root, index);
+       retval = radix_tree_delete(&xa->xa_head, index);
        if (retval == NULL_VALUE)
                retval = NULL;
 
@@ -81,7 +81,7 @@ xa_load(struct xarray *xa, uint32_t index)
        void *retval;
 
        xa_lock(xa);
-       retval = radix_tree_lookup(&xa->root, index);
+       retval = radix_tree_lookup(&xa->xa_head, index);
        xa_unlock(xa);
 
        if (retval == NULL_VALUE)
@@ -122,16 +122,16 @@ __xa_alloc(struct xarray *xa, uint32_t *pindex, void 
*ptr, uint32_t mask, gfp_t
        XA_ASSERT_LOCKED(xa);
 
        /* mask should allow to allocate at least one item */
-       MPASS(mask > ((xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0));
+       MPASS(mask > ((xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0));
 
        /* mask can be any power of two value minus one */
        MPASS((mask & (mask + 1)) == 0);
 
-       *pindex = (xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0;
+       *pindex = (xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0;
        if (ptr == NULL)
                ptr = NULL_VALUE;
 retry:
-       retval = radix_tree_insert(&xa->root, *pindex, ptr);
+       retval = radix_tree_insert(&xa->xa_head, *pindex, ptr);
 
        switch (retval) {
        case -EEXIST:
@@ -184,16 +184,16 @@ __xa_alloc_cyclic(struct xarray *xa, uint32_t *pindex, 
void *ptr, uint32_t mask,
        XA_ASSERT_LOCKED(xa);
 
        /* mask should allow to allocate at least one item */
-       MPASS(mask > ((xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0));
+       MPASS(mask > ((xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0));
 
        /* mask can be any power of two value minus one */
        MPASS((mask & (mask + 1)) == 0);
 
-       *pnext_index = (xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0;
+       *pnext_index = (xa->xa_flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0;
        if (ptr == NULL)
                ptr = NULL_VALUE;
 retry:
-       retval = radix_tree_insert(&xa->root, *pnext_index, ptr);
+       retval = radix_tree_insert(&xa->xa_head, *pnext_index, ptr);
 
        switch (retval) {
        case -EEXIST:
@@ -203,7 +203,7 @@ retry:
                }
                (*pnext_index)++;
                (*pnext_index) &= mask;
-               if (*pnext_index == 0 && (xa->flags & XA_FLAGS_ALLOC1) != 0)
+               if (*pnext_index == 0 && (xa->xa_flags & XA_FLAGS_ALLOC1) != 0)
                        (*pnext_index)++;
                goto retry;
        case -ENOMEM:
@@ -262,7 +262,7 @@ __xa_insert(struct xarray *xa, uint32_t index, void *ptr, 
gfp_t gfp)
        if (ptr == NULL)
                ptr = NULL_VALUE;
 retry:
-       retval = radix_tree_insert(&xa->root, index, ptr);
+       retval = radix_tree_insert(&xa->xa_head, index, ptr);
 
        switch (retval) {
        case -ENOMEM:
@@ -306,7 +306,7 @@ __xa_store(struct xarray *xa, uint32_t index, void *ptr, 
gfp_t gfp)
        if (ptr == NULL)
                ptr = NULL_VALUE;
 retry:
-       retval = radix_tree_store(&xa->root, index, &ptr);
+       retval = radix_tree_store(&xa->xa_head, index, &ptr);
 
        switch (retval) {
        case 0:
@@ -347,9 +347,9 @@ xa_init_flags(struct xarray *xa, uint32_t flags)
 {
        memset(xa, 0, sizeof(*xa));
 
-       mtx_init(&xa->mtx, "lkpi-xarray", NULL, MTX_DEF | MTX_RECURSE);
-       xa->root.gfp_mask = GFP_NOWAIT;
-       xa->flags = flags;
+       mtx_init(&xa->xa_lock, "lkpi-xarray", NULL, MTX_DEF | MTX_RECURSE);
+       xa->xa_head.gfp_mask = GFP_NOWAIT;
+       xa->xa_flags = flags;
 }
 
 /*
@@ -362,9 +362,9 @@ xa_destroy(struct xarray *xa)
        struct radix_tree_iter iter;
        void **ppslot;
 
-       radix_tree_for_each_slot(ppslot, &xa->root, &iter, 0)
-               radix_tree_iter_delete(&xa->root, &iter, ppslot);
-       mtx_destroy(&xa->mtx);
+       radix_tree_for_each_slot(ppslot, &xa->xa_head, &iter, 0)
+               radix_tree_iter_delete(&xa->xa_head, &iter, ppslot);
+       mtx_destroy(&xa->xa_lock);
 }
 
 /*
@@ -379,7 +379,7 @@ __xa_empty(struct xarray *xa)
 
        XA_ASSERT_LOCKED(xa);
 
-       return (!radix_tree_iter_find(&xa->root, &iter, &temp));
+       return (!radix_tree_iter_find(&xa->xa_head, &iter, &temp));
 }
 
 bool
@@ -416,7 +416,7 @@ __xa_next(struct xarray *xa, unsigned long *pindex, bool 
not_first)
                        return (NULL);
        }
 
-       found = radix_tree_iter_find(&xa->root, &iter, &ppslot);
+       found = radix_tree_iter_find(&xa->xa_head, &iter, &ppslot);
        if (likely(found)) {
                retval = *ppslot;
                if (retval == NULL_VALUE)

Reply via email to