summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-07-13 12:34:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-07-19 11:32:36 +0100
commit86f7b724ef18986bc58d35558d22e1ed3f8df4f9 (patch)
treed4f81c752eac621ab22cba23f9b1303732b12fb0
parent7f85adc4050182f490c7a5c48db3d57cdb00af4e (diff)
lib: Move trash_bos to their only user
Only pm_rpm still uses the igt_trash_aperture() and so we can remove it from the lib and in the process convert it over from the legacy libdrm_intel. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Michał Winiarski <michal.winiarski@intel.com> Reviewed-by: Michał Winiarski <michal.winiarski@intel.com>
-rw-r--r--lib/igt_aux.c57
-rw-r--r--lib/igt_aux.h10
-rw-r--r--tests/pm_rpm.c31
3 files changed, 22 insertions, 76 deletions
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index d9dbf7ce..1250d5c5 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -682,63 +682,6 @@ void igt_print_activity(void)
igt_interactive_info(".");
}
-/* mappable aperture trasher helper */
-drm_intel_bo **trash_bos;
-int num_trash_bos;
-
-/**
- * igt_init_aperture_trashers:
- * @bufmgr: libdrm buffer manager
- *
- * Initialize the aperture trasher using @bufmgr, which can then be run with
- * igt_trash_aperture().
- */
-void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr)
-{
- int i;
-
- num_trash_bos = gem_mappable_aperture_size() / (1024*1024);
-
- trash_bos = malloc(num_trash_bos * sizeof(drm_intel_bo *));
- igt_assert(trash_bos);
-
- for (i = 0; i < num_trash_bos; i++)
- trash_bos[i] = drm_intel_bo_alloc(bufmgr, "trash bo", 1024*1024, 4096);
-}
-
-/**
- * igt_trash_aperture:
- *
- * Trash the aperture by walking a set of GTT memory mapped objects.
- */
-void igt_trash_aperture(void)
-{
- int i;
- uint8_t *gtt_ptr;
-
- for (i = 0; i < num_trash_bos; i++) {
- drm_intel_gem_bo_map_gtt(trash_bos[i]);
- gtt_ptr = trash_bos[i]->virtual;
- *gtt_ptr = 0;
- drm_intel_gem_bo_unmap_gtt(trash_bos[i]);
- }
-}
-
-/**
- * igt_cleanup_aperture_trashers:
- *
- * Clean up all aperture trasher state set up with igt_init_aperture_trashers().
- */
-void igt_cleanup_aperture_trashers(void)
-{
- int i;
-
- for (i = 0; i < num_trash_bos; i++)
- drm_intel_bo_unreference(trash_bos[i]);
-
- free(trash_bos);
-}
-
static int autoresume_delay;
static const char *suspend_state_name[] = {
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 639a9077..ef89faa9 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -28,16 +28,13 @@
#ifndef IGT_AUX_H
#define IGT_AUX_H
-#include <intel_bufmgr.h>
#include <inttypes.h>
#include <stdbool.h>
+#include <stddef.h>
#include <sys/time.h>
#include <i915/gem_submission.h>
-extern drm_intel_bo **trash_bos;
-extern int num_trash_bos;
-
/* signal interrupt helpers */
#define gettid() syscall(__NR_gettid)
#define sigev_notify_thread_id _sigev_un._tid
@@ -122,11 +119,6 @@ bool igt_check_boolean_env_var(const char *env_var, bool default_value);
bool igt_aub_dump_enabled(void);
-/* helpers based upon the libdrm buffer manager */
-void igt_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
-void igt_trash_aperture(void);
-void igt_cleanup_aperture_trashers(void);
-
/* suspend/hibernate and auto-resume system */
/**
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 1f2647be..4268bb19 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -1295,25 +1295,36 @@ static void gem_idle_subtest(void)
static void gem_evict_pwrite_subtest(void)
{
- static drm_intel_bufmgr *bufmgr;
+ struct {
+ uint32_t handle;
+ uint32_t *ptr;
+ } *trash_bos;
+ unsigned int num_trash_bos, n;
uint32_t buf;
- int i;
- bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
- igt_assert(bufmgr);
- igt_init_aperture_trashers(bufmgr);
+ num_trash_bos = gem_mappable_aperture_size() / (1024*1024) + 1;
+ trash_bos = malloc(num_trash_bos * sizeof(*trash_bos));
+ igt_assert(trash_bos);
- igt_trash_aperture();
+ for (n = 0; n < num_trash_bos; n++) {
+ trash_bos[n].handle = gem_create(drm_fd, 1024*1024);
+ trash_bos[n].ptr = gem_mmap__gtt(drm_fd, trash_bos[n].handle,
+ 1024*1024, PROT_WRITE);
+ *trash_bos[n].ptr = 0;
+ }
disable_or_dpms_all_screens_and_wait(&ms_data, true);
igt_assert(wait_for_suspended());
buf = 0;
- for (i = 0; i < num_trash_bos; i++)
- gem_write(drm_fd, trash_bos[i]->handle, 0, &buf, sizeof(buf));
+ for (n = 0; n < num_trash_bos; n++)
+ gem_write(drm_fd, trash_bos[n].handle, 0, &buf, sizeof(buf));
- igt_cleanup_aperture_trashers();
- drm_intel_bufmgr_destroy(bufmgr);
+ for (n = 0; n < num_trash_bos; n++) {
+ munmap(trash_bos[n].ptr, 1024*1024);
+ gem_close(drm_fd, trash_bos[n].handle);
+ }
+ free(trash_bos);
}
/* This also triggered WARNs on dmesg at some point. */