[Mesa-dev] [PATCH 11/53] i965/drm: Switch to util/list.h instead of libdrm_lists.h.
Kenneth Graunke
kenneth at whitecape.org
Wed Apr 5 00:10:01 UTC 2017
Both are kernel style lists, so this is trivial.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/Makefile.sources | 1 -
src/mesa/drivers/dri/i965/intel_bufmgr_gem.c | 91 ++++++++++-----------
src/mesa/drivers/dri/i965/libdrm_lists.h | 118 ---------------------------
3 files changed, 45 insertions(+), 165 deletions(-)
delete mode 100644 src/mesa/drivers/dri/i965/libdrm_lists.h
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources
index 9ae764fed58..1d2c6e06f8b 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -163,7 +163,6 @@ i965_FILES = \
intel_tiled_memcpy.c \
intel_tiled_memcpy.h \
intel_upload.c \
- libdrm_lists.h \
libdrm_macros.h \
uthash.h
diff --git a/src/mesa/drivers/dri/i965/intel_bufmgr_gem.c b/src/mesa/drivers/dri/i965/intel_bufmgr_gem.c
index c67f813bdf5..e116788e326 100644
--- a/src/mesa/drivers/dri/i965/intel_bufmgr_gem.c
+++ b/src/mesa/drivers/dri/i965/intel_bufmgr_gem.c
@@ -57,7 +57,7 @@
#define ETIME ETIMEDOUT
#endif
#include "libdrm_macros.h"
-#include "libdrm_lists.h"
+#include "util/list.h"
#include "brw_bufmgr.h"
#include "intel_bufmgr_priv.h"
#include "intel_chipset.h"
@@ -113,7 +113,7 @@ atomic_add_unless(int *v, int add, int unless)
typedef struct _drm_bacon_bo_gem drm_bacon_bo_gem;
struct drm_bacon_gem_bo_bucket {
- drmMMListHead head;
+ struct list_head head;
unsigned long size;
};
@@ -139,12 +139,12 @@ typedef struct _drm_bacon_bufmgr_gem {
int num_buckets;
time_t time;
- drmMMListHead managers;
+ struct list_head managers;
drm_bacon_bo_gem *name_table;
drm_bacon_bo_gem *handle_table;
- drmMMListHead vma_cache;
+ struct list_head vma_cache;
int vma_count, vma_open, vma_max;
uint64_t gtt_size;
@@ -237,10 +237,10 @@ struct _drm_bacon_bo_gem {
*/
void *user_virtual;
int map_count;
- drmMMListHead vma_list;
+ struct list_head vma_list;
/** BO cache list */
- drmMMListHead head;
+ struct list_head head;
/**
* Boolean of whether this BO and its children have been included in
@@ -701,16 +701,16 @@ static void
drm_bacon_gem_bo_cache_purge_bucket(drm_bacon_bufmgr_gem *bufmgr_gem,
struct drm_bacon_gem_bo_bucket *bucket)
{
- while (!DRMLISTEMPTY(&bucket->head)) {
+ while (!list_empty(&bucket->head)) {
drm_bacon_bo_gem *bo_gem;
- bo_gem = DRMLISTENTRY(drm_bacon_bo_gem,
- bucket->head.next, head);
+ bo_gem = LIST_ENTRY(drm_bacon_bo_gem,
+ bucket->head.next, head);
if (drm_bacon_gem_bo_madvise_internal
(bufmgr_gem, bo_gem, I915_MADV_DONTNEED))
break;
- DRMLISTDEL(&bo_gem->head);
+ list_del(&bo_gem->head);
drm_bacon_gem_bo_free(&bo_gem->bo);
}
}
@@ -754,15 +754,15 @@ drm_bacon_gem_bo_alloc_internal(drm_bacon_bufmgr *bufmgr,
/* Get a buffer out of the cache if available */
retry:
alloc_from_cache = false;
- if (bucket != NULL && !DRMLISTEMPTY(&bucket->head)) {
+ if (bucket != NULL && !list_empty(&bucket->head)) {
if (for_render) {
/* Allocate new render-target BOs from the tail (MRU)
* of the list, as it will likely be hot in the GPU
* cache and in the aperture for us.
*/
- bo_gem = DRMLISTENTRY(drm_bacon_bo_gem,
- bucket->head.prev, head);
- DRMLISTDEL(&bo_gem->head);
+ bo_gem = LIST_ENTRY(drm_bacon_bo_gem,
+ bucket->head.prev, head);
+ list_del(&bo_gem->head);
alloc_from_cache = true;
bo_gem->bo.align = alignment;
} else {
@@ -774,11 +774,11 @@ retry:
* allocating a new buffer is probably faster than
* waiting for the GPU to finish.
*/
- bo_gem = DRMLISTENTRY(drm_bacon_bo_gem,
- bucket->head.next, head);
+ bo_gem = LIST_ENTRY(drm_bacon_bo_gem,
+ bucket->head.next, head);
if (!drm_bacon_gem_bo_busy(&bo_gem->bo)) {
alloc_from_cache = true;
- DRMLISTDEL(&bo_gem->head);
+ list_del(&bo_gem->head);
}
}
@@ -807,9 +807,9 @@ retry:
if (!bo_gem)
goto err;
- /* drm_bacon_gem_bo_free calls DRMLISTDEL() for an uninitialized
+ /* drm_bacon_gem_bo_free calls list_del() for an uninitialized
list (vma_list), so better set the list head here */
- DRMINITLISTHEAD(&bo_gem->vma_list);
+ list_inithead(&bo_gem->vma_list);
bo_gem->bo.size = bo_size;
@@ -965,7 +965,7 @@ drm_bacon_gem_bo_alloc_userptr(drm_bacon_bufmgr *bufmgr,
return NULL;
p_atomic_set(&bo_gem->refcount, 1);
- DRMINITLISTHEAD(&bo_gem->vma_list);
+ list_inithead(&bo_gem->vma_list);
bo_gem->bo.size = size;
@@ -1142,7 +1142,7 @@ drm_bacon_bo_gem_create_from_name(drm_bacon_bufmgr *bufmgr,
goto out;
p_atomic_set(&bo_gem->refcount, 1);
- DRMINITLISTHEAD(&bo_gem->vma_list);
+ list_inithead(&bo_gem->vma_list);
bo_gem->bo.size = open_arg.size;
bo_gem->bo.offset = 0;
@@ -1193,7 +1193,7 @@ drm_bacon_gem_bo_free(drm_bacon_bo *bo)
struct drm_gem_close close;
int ret;
- DRMLISTDEL(&bo_gem->vma_list);
+ list_del(&bo_gem->vma_list);
if (bo_gem->mem_virtual) {
VG(VALGRIND_FREELIKE_BLOCK(bo_gem->mem_virtual, 0));
drm_munmap(bo_gem->mem_virtual, bo_gem->bo.size);
@@ -1254,15 +1254,15 @@ drm_bacon_gem_cleanup_bo_cache(drm_bacon_bufmgr_gem *bufmgr_gem, time_t time)
struct drm_bacon_gem_bo_bucket *bucket =
&bufmgr_gem->cache_bucket[i];
- while (!DRMLISTEMPTY(&bucket->head)) {
+ while (!list_empty(&bucket->head)) {
drm_bacon_bo_gem *bo_gem;
- bo_gem = DRMLISTENTRY(drm_bacon_bo_gem,
- bucket->head.next, head);
+ bo_gem = LIST_ENTRY(drm_bacon_bo_gem,
+ bucket->head.next, head);
if (time - bo_gem->free_time <= 1)
break;
- DRMLISTDEL(&bo_gem->head);
+ list_del(&bo_gem->head);
drm_bacon_gem_bo_free(&bo_gem->bo);
}
@@ -1289,11 +1289,11 @@ static void drm_bacon_gem_bo_purge_vma_cache(drm_bacon_bufmgr_gem *bufmgr_gem)
while (bufmgr_gem->vma_count > limit) {
drm_bacon_bo_gem *bo_gem;
- bo_gem = DRMLISTENTRY(drm_bacon_bo_gem,
- bufmgr_gem->vma_cache.next,
- vma_list);
+ bo_gem = LIST_ENTRY(drm_bacon_bo_gem,
+ bufmgr_gem->vma_cache.next,
+ vma_list);
assert(bo_gem->map_count == 0);
- DRMLISTDELINIT(&bo_gem->vma_list);
+ list_delinit(&bo_gem->vma_list);
if (bo_gem->mem_virtual) {
drm_munmap(bo_gem->mem_virtual, bo_gem->bo.size);
@@ -1317,7 +1317,7 @@ static void drm_bacon_gem_bo_close_vma(drm_bacon_bufmgr_gem *bufmgr_gem,
drm_bacon_bo_gem *bo_gem)
{
bufmgr_gem->vma_open--;
- DRMLISTADDTAIL(&bo_gem->vma_list, &bufmgr_gem->vma_cache);
+ list_addtail(&bo_gem->vma_list, &bufmgr_gem->vma_cache);
if (bo_gem->mem_virtual)
bufmgr_gem->vma_count++;
if (bo_gem->wc_virtual)
@@ -1331,7 +1331,7 @@ static void drm_bacon_gem_bo_open_vma(drm_bacon_bufmgr_gem *bufmgr_gem,
drm_bacon_bo_gem *bo_gem)
{
bufmgr_gem->vma_open++;
- DRMLISTDEL(&bo_gem->vma_list);
+ list_del(&bo_gem->vma_list);
if (bo_gem->mem_virtual)
bufmgr_gem->vma_count--;
if (bo_gem->wc_virtual)
@@ -1401,7 +1401,7 @@ drm_bacon_gem_bo_unreference_final(drm_bacon_bo *bo, time_t time)
bo_gem->name = NULL;
bo_gem->validate_index = -1;
- DRMLISTADDTAIL(&bo_gem->head, &bucket->head);
+ list_addtail(&bo_gem->head, &bucket->head);
} else {
drm_bacon_gem_bo_free(bo);
}
@@ -1928,10 +1928,10 @@ drm_bacon_bufmgr_gem_destroy(drm_bacon_bufmgr *bufmgr)
&bufmgr_gem->cache_bucket[i];
drm_bacon_bo_gem *bo_gem;
- while (!DRMLISTEMPTY(&bucket->head)) {
- bo_gem = DRMLISTENTRY(drm_bacon_bo_gem,
- bucket->head.next, head);
- DRMLISTDEL(&bo_gem->head);
+ while (!list_empty(&bucket->head)) {
+ bo_gem = LIST_ENTRY(drm_bacon_bo_gem,
+ bucket->head.next, head);
+ list_del(&bo_gem->head);
drm_bacon_gem_bo_free(&bo_gem->bo);
}
@@ -2668,7 +2668,7 @@ drm_bacon_bo_gem_create_from_prime(drm_bacon_bufmgr *bufmgr, int prime_fd, int s
goto out;
p_atomic_set(&bo_gem->refcount, 1);
- DRMINITLISTHEAD(&bo_gem->vma_list);
+ list_inithead(&bo_gem->vma_list);
/* Determine size of bo. The fd-to-handle ioctl really should
* return the size, but it doesn't. If we have kernel 3.12 or
@@ -3084,7 +3084,7 @@ add_bucket(drm_bacon_bufmgr_gem *bufmgr_gem, int size)
assert(i < ARRAY_SIZE(bufmgr_gem->cache_bucket));
- DRMINITLISTHEAD(&bufmgr_gem->cache_bucket[i].head);
+ list_inithead(&bufmgr_gem->cache_bucket[i].head);
bufmgr_gem->cache_bucket[i].size = size;
bufmgr_gem->num_buckets++;
}
@@ -3369,14 +3369,13 @@ drm_bacon_get_min_eu_in_pool(int fd)
}
static pthread_mutex_t bufmgr_list_mutex = PTHREAD_MUTEX_INITIALIZER;
-static drmMMListHead bufmgr_list = { &bufmgr_list, &bufmgr_list };
+static struct list_head bufmgr_list = { &bufmgr_list, &bufmgr_list };
static drm_bacon_bufmgr_gem *
drm_bacon_bufmgr_gem_find(int fd)
{
- drm_bacon_bufmgr_gem *bufmgr_gem;
-
- DRMLISTFOREACHENTRY(bufmgr_gem, &bufmgr_list, managers) {
+ list_for_each_entry(drm_bacon_bufmgr_gem,
+ bufmgr_gem, &bufmgr_list, managers) {
if (bufmgr_gem->fd == fd) {
p_atomic_inc(&bufmgr_gem->refcount);
return bufmgr_gem;
@@ -3395,7 +3394,7 @@ drm_bacon_bufmgr_gem_unref(drm_bacon_bufmgr *bufmgr)
pthread_mutex_lock(&bufmgr_list_mutex);
if (p_atomic_dec_zero(&bufmgr_gem->refcount)) {
- DRMLISTDEL(&bufmgr_gem->managers);
+ list_del(&bufmgr_gem->managers);
drm_bacon_bufmgr_gem_destroy(bufmgr);
}
@@ -3751,10 +3750,10 @@ drm_bacon_bufmgr_gem_init(int fd, int batch_size)
init_cache_buckets(bufmgr_gem);
- DRMINITLISTHEAD(&bufmgr_gem->vma_cache);
+ list_inithead(&bufmgr_gem->vma_cache);
bufmgr_gem->vma_max = -1; /* unlimited by default */
- DRMLISTADD(&bufmgr_gem->managers, &bufmgr_list);
+ list_add(&bufmgr_gem->managers, &bufmgr_list);
exit:
pthread_mutex_unlock(&bufmgr_list_mutex);
diff --git a/src/mesa/drivers/dri/i965/libdrm_lists.h b/src/mesa/drivers/dri/i965/libdrm_lists.h
deleted file mode 100644
index d0a2528847f..00000000000
--- a/src/mesa/drivers/dri/i965/libdrm_lists.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-
-/*
- * List macros heavily inspired by the Linux kernel
- * list handling. No list looping yet.
- */
-
-#include <stddef.h>
-
-typedef struct _drmMMListHead
-{
- struct _drmMMListHead *prev;
- struct _drmMMListHead *next;
-} drmMMListHead;
-
-#define DRMINITLISTHEAD(__item) \
- do{ \
- (__item)->prev = (__item); \
- (__item)->next = (__item); \
- } while (0)
-
-#define DRMLISTADD(__item, __list) \
- do { \
- (__item)->prev = (__list); \
- (__item)->next = (__list)->next; \
- (__list)->next->prev = (__item); \
- (__list)->next = (__item); \
- } while (0)
-
-#define DRMLISTADDTAIL(__item, __list) \
- do { \
- (__item)->next = (__list); \
- (__item)->prev = (__list)->prev; \
- (__list)->prev->next = (__item); \
- (__list)->prev = (__item); \
- } while(0)
-
-#define DRMLISTDEL(__item) \
- do { \
- (__item)->prev->next = (__item)->next; \
- (__item)->next->prev = (__item)->prev; \
- } while(0)
-
-#define DRMLISTDELINIT(__item) \
- do { \
- (__item)->prev->next = (__item)->next; \
- (__item)->next->prev = (__item)->prev; \
- (__item)->next = (__item); \
- (__item)->prev = (__item); \
- } while(0)
-
-#define DRMLISTENTRY(__type, __item, __field) \
- ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
-
-#define DRMLISTEMPTY(__item) ((__item)->next == (__item))
-
-#define DRMLISTSINGLE(__list) \
- (!DRMLISTEMPTY(__list) && ((__list)->next == (__list)->prev))
-
-#define DRMLISTFOREACH(__item, __list) \
- for ((__item) = (__list)->next; \
- (__item) != (__list); (__item) = (__item)->next)
-
-#define DRMLISTFOREACHSAFE(__item, __temp, __list) \
- for ((__item) = (__list)->next, (__temp) = (__item)->next; \
- (__item) != (__list); \
- (__item) = (__temp), (__temp) = (__item)->next)
-
-#define DRMLISTFOREACHSAFEREVERSE(__item, __temp, __list) \
- for ((__item) = (__list)->prev, (__temp) = (__item)->prev; \
- (__item) != (__list); \
- (__item) = (__temp), (__temp) = (__item)->prev)
-
-#define DRMLISTFOREACHENTRY(__item, __list, __head) \
- for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head); \
- &(__item)->__head != (__list); \
- (__item) = DRMLISTENTRY(__typeof__(*__item), \
- (__item)->__head.next, __head))
-
-#define DRMLISTFOREACHENTRYSAFE(__item, __temp, __list, __head) \
- for ((__item) = DRMLISTENTRY(__typeof__(*__item), (__list)->next, __head), \
- (__temp) = DRMLISTENTRY(__typeof__(*__item), \
- (__item)->__head.next, __head); \
- &(__item)->__head != (__list); \
- (__item) = (__temp), \
- (__temp) = DRMLISTENTRY(__typeof__(*__item), \
- (__temp)->__head.next, __head))
-
-#define DRMLISTJOIN(__list, __join) if (!DRMLISTEMPTY(__list)) { \
- (__list)->next->prev = (__join); \
- (__list)->prev->next = (__join)->next; \
- (__join)->next->prev = (__list)->prev; \
- (__join)->next = (__list)->next; \
-}
--
2.12.1
More information about the mesa-dev
mailing list