summaryrefslogtreecommitdiff
path: root/tests/vc4_purgeable_bo.c
diff options
context:
space:
mode:
authorArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-11-11 10:30:54 +0200
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2019-11-12 17:45:47 +0200
commit602003c3d751c72fc309a0e64d4193f6da720f6b (patch)
tree5e29d9b685f8268a9ad56f52ad788f4300ddc289 /tests/vc4_purgeable_bo.c
parent5997df31db10f190fe8b70d920b6a6b8d3b24126 (diff)
lib/igt_list: Update, clean-up and document igt_list
Our list was something between Wayland and Linux Kernel list implementations, right in the uncanny valley. On top of that it falsely claimed that it's a straight copy from the Wayland project. Let's make our impl more akin to the kernel one to ease the cognitive dissonance for the developers working on all those projects. This patch: * mimics the current kernel list interface * separates IGT helpers in the source files * adds brief explanation and code example for igt-doc * introduces igt_list.c as static inlines are not visible in the docs v2: mimic the kernel instead of wayland (Chris) - _head suffix for the sentinel/link struct - _entry_ in iterator names that go over the elements v3: I forgot to merge this in time and there was another call site that had to be converted in gem_spin_batch.c Cc: Petri Latvala <petri.latvala@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com> Acked-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'tests/vc4_purgeable_bo.c')
-rw-r--r--tests/vc4_purgeable_bo.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/vc4_purgeable_bo.c b/tests/vc4_purgeable_bo.c
index cfe14e70..ee89e153 100644
--- a/tests/vc4_purgeable_bo.c
+++ b/tests/vc4_purgeable_bo.c
@@ -36,7 +36,7 @@
#include "vc4_drm.h"
struct igt_vc4_bo {
- struct igt_list node;
+ struct igt_list_head node;
int handle;
void *map;
size_t size;
@@ -49,7 +49,7 @@ static void __attribute__((noreturn)) sigtrap(int sig)
longjmp(jmp, sig);
}
-static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
+static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list_head *list,
size_t size)
{
struct igt_vc4_bo *bo;
@@ -71,7 +71,7 @@ static void igt_vc4_alloc_mmap_max_bo(int fd, struct igt_list *list,
}
}
-static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
+static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list_head *list)
{
struct igt_vc4_bo *bo;
@@ -87,9 +87,9 @@ static void igt_vc4_unmap_free_bo_pool(int fd, struct igt_list *list)
static void igt_vc4_trigger_purge(int fd)
{
- struct igt_list list;
+ struct igt_list_head list;
- igt_list_init(&list);
+ IGT_INIT_LIST_HEAD(&list);
/* Try to allocate as much as we can to trigger a purge. */
igt_vc4_alloc_mmap_max_bo(fd, &list, 64 * 1024);
@@ -97,7 +97,7 @@ static void igt_vc4_trigger_purge(int fd)
igt_vc4_unmap_free_bo_pool(fd, &list);
}
-static void igt_vc4_purgeable_subtest_prepare(int fd, struct igt_list *list)
+static void igt_vc4_purgeable_subtest_prepare(int fd, struct igt_list_head *list)
{
igt_vc4_unmap_free_bo_pool(fd, list);
igt_vc4_alloc_mmap_max_bo(fd, list, 64 * 1024);
@@ -107,7 +107,7 @@ static void igt_vc4_purgeable_subtest_prepare(int fd, struct igt_list *list)
igt_main
{
struct igt_vc4_bo *bo;
- struct igt_list list;
+ struct igt_list_head list;
uint32_t *map;
int fd, ret;
@@ -117,22 +117,22 @@ igt_main
fd = drm_open_driver(DRIVER_VC4);
igt_vc4_get_param(fd, DRM_VC4_PARAM_SUPPORTS_MADVISE, &val);
igt_require(val);
- igt_list_init(&list);
+ IGT_INIT_LIST_HEAD(&list);
}
igt_subtest("mark-willneed") {
igt_vc4_purgeable_subtest_prepare(fd, &list);
- igt_list_for_each(bo, &list, node)
+ igt_list_for_each_entry(bo, &list, node)
igt_assert(igt_vc4_purgeable_bo(fd, bo->handle,
false));
}
igt_subtest("mark-purgeable") {
igt_vc4_purgeable_subtest_prepare(fd, &list);
- igt_list_for_each(bo, &list, node)
+ igt_list_for_each_entry(bo, &list, node)
igt_vc4_purgeable_bo(fd, bo->handle, true);
- igt_list_for_each(bo, &list, node)
+ igt_list_for_each_entry(bo, &list, node)
igt_vc4_purgeable_bo(fd, bo->handle, false);
}
@@ -205,13 +205,13 @@ igt_main
igt_subtest("mark-unpurgeable-check-retained") {
igt_vc4_purgeable_subtest_prepare(fd, &list);
- igt_list_for_each(bo, &list, node) {
+ igt_list_for_each_entry(bo, &list, node) {
map = (uint32_t *)bo->map;
*map = 0xdeadbeef;
igt_vc4_purgeable_bo(fd, bo->handle, true);
}
- igt_list_for_each(bo, &list, node) {
+ igt_list_for_each_entry(bo, &list, node) {
map = (uint32_t *)bo->map;
if (igt_vc4_purgeable_bo(fd, bo->handle, false))
igt_assert(*map == 0xdeadbeef);
@@ -221,7 +221,7 @@ igt_main
igt_subtest("mark-unpurgeable-purged") {
igt_vc4_purgeable_subtest_prepare(fd, &list);
- igt_list_for_each(bo, &list, node)
+ igt_list_for_each_entry(bo, &list, node)
igt_vc4_purgeable_bo(fd, bo->handle, true);
/* Trigger a purge. */