By temporarily storing the new_head by a uint32_t, we wipe out the
counter section of the head pointer.
Fixes: e4f01eca ("util: Add a free list structure for use with util_sparse_array")
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4612>
uint32_t head_idx = current_head; /* Index is the bottom 32 bits */
void *head_elem = util_sparse_array_get(fl->arr, head_idx);
uint32_t *head_next = (uint32_t *)((char *)head_elem + fl->next_offset);
uint32_t head_idx = current_head; /* Index is the bottom 32 bits */
void *head_elem = util_sparse_array_get(fl->arr, head_idx);
uint32_t *head_next = (uint32_t *)((char *)head_elem + fl->next_offset);
- uint32_t new_head = free_list_head(current_head, *head_next);
+ uint64_t new_head = free_list_head(current_head, *head_next);
uint64_t old_head = p_atomic_cmpxchg(&fl->head, current_head, new_head);
if (old_head == current_head)
return head_idx;
uint64_t old_head = p_atomic_cmpxchg(&fl->head, current_head, new_head);
if (old_head == current_head)
return head_idx;
uint32_t head_idx = current_head; /* Index is the bottom 32 bits */
void *head_elem = util_sparse_array_get(fl->arr, head_idx);
uint32_t *head_next = (uint32_t *)((char *)head_elem + fl->next_offset);
uint32_t head_idx = current_head; /* Index is the bottom 32 bits */
void *head_elem = util_sparse_array_get(fl->arr, head_idx);
uint32_t *head_next = (uint32_t *)((char *)head_elem + fl->next_offset);
- uint32_t new_head = free_list_head(current_head, *head_next);
+ uint64_t new_head = free_list_head(current_head, *head_next);
uint64_t old_head = p_atomic_cmpxchg(&fl->head, current_head, new_head);
if (old_head == current_head)
return head_elem;
uint64_t old_head = p_atomic_cmpxchg(&fl->head, current_head, new_head);
if (old_head == current_head)
return head_elem;