summaryrefslogtreecommitdiff
path: root/lib/igt_core.c
diff options
context:
space:
mode:
authorZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2020-10-23 09:30:11 +0200
committerZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2021-04-13 15:44:38 +0200
commite4d8b8b01d25d507cf850c69a3da3ec08ec6c88e (patch)
tree0c85e75f3f27d0352a31ae93af28d18ead9a1aa2 /lib/igt_core.c
parent86f1cf4d0c929aaf9b2ceec6de79c36fa44a0bdf (diff)
lib/intel_allocator: Add intel_allocator core
For discrete gens we have to cease of using relocations when batch buffers are submitted to GPU. On cards which have ppgtt we can use softpin establishing addresses on our own. We added simple allocator (taken from Mesa; works on lists) and random allocator to exercise batches with different addresses. All of that works for single VM (context) so we have to add additional layer (intel_allocator) to support multiprocessing / multithreading. For main IGT process (also for threads created in it) intel_allocator resolves addresses "locally", just by mutexing access to global allocator data (ctx/vm map). When fork() is in use children cannot establish addresses on they own and have to contact to the thread spawned within main IGT process. Currently SysV IPC message queue was chosen as a communication channel between children and allocator thread. Child calls same functions as main IGT process, only communication path will be chosen instead of acquiring addresses locally. v2: Add intel_allocator_open_full() to allow user pass vm range. Add strategy: NONE, LOW_TO_HIGH, HIGH_TO_LOW passed to allocator backend. v3: Child is now able to use allocator directly as standalone. It only need to call intel_allocator_init() to reinitialize appropriate structures. v4: Add pseudo allocator - INTEL_ALLOCATOR_RELOC which just increments offsets to avoid unnecessary conditional code. v5: Alter allocator core according to igt_map changes. v6: Add internal version __intel_allocator_alloc() to return ALLOC_INVALID_ADDRESS without assertion. v7: Add libatomic for linking libigt library. It is required on some archs, like mips. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Petri Latvala <petri.latvala@intel.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'lib/igt_core.c')
-rw-r--r--lib/igt_core.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 2b4182f1..6597acfa 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -58,6 +58,7 @@
#include <glib.h>
#include "drmtest.h"
+#include "intel_allocator.h"
#include "intel_chipset.h"
#include "intel_io.h"
#include "igt_debugfs.h"
@@ -1412,6 +1413,19 @@ __noreturn static void exit_subtest(const char *result)
}
num_test_children = 0;
+ /*
+ * When test completes - mostly in fail state it can leave allocated
+ * objects. An allocator is not an exception as it is global IGT
+ * entity and when test will allocate some ranges and then it will
+ * fail no free/close likely will be called (controling potential
+ * fails and clearing before assertions in IGT is not common).
+ *
+ * We call intel_allocator_init() then to prepare the allocator
+ * infrastructure from scratch for each test. Init also removes
+ * remnants from previous allocator run (if any).
+ */
+ intel_allocator_init();
+
if (!in_dynamic_subtest)
_igt_dynamic_tests_executed = -1;