2 * SPDX-License-Identifier: MIT
4 * Copyright © 2016 Intel Corporation
7 #include "i915_selftest.h"
9 #include "huge_gem_object.h"
10 #include "selftests/igt_flush_test.h"
11 #include "selftests/mock_gem_device.h"
13 static int igt_gem_object(void *arg
)
15 struct drm_i915_private
*i915
= arg
;
16 struct drm_i915_gem_object
*obj
;
19 /* Basic test to ensure we can create an object */
21 obj
= i915_gem_object_create_shmem(i915
, PAGE_SIZE
);
24 pr_err("i915_gem_object_create failed, err=%d\n", err
);
29 i915_gem_object_put(obj
);
34 static int igt_gem_huge(void *arg
)
36 const unsigned int nreal
= 509; /* just to be awkward */
37 struct drm_i915_private
*i915
= arg
;
38 struct drm_i915_gem_object
*obj
;
42 /* Basic sanitycheck of our huge fake object allocation */
44 obj
= huge_gem_object(i915
,
46 i915
->ggtt
.vm
.total
+ PAGE_SIZE
);
50 err
= i915_gem_object_pin_pages(obj
);
52 pr_err("Failed to allocate %u pages (%lu total), err=%d\n",
53 nreal
, obj
->base
.size
/ PAGE_SIZE
, err
);
57 for (n
= 0; n
< obj
->base
.size
/ PAGE_SIZE
; n
++) {
58 if (i915_gem_object_get_page(obj
, n
) !=
59 i915_gem_object_get_page(obj
, n
% nreal
)) {
60 pr_err("Page lookup mismatch at index %u [%u]\n",
68 i915_gem_object_unpin_pages(obj
);
70 i915_gem_object_put(obj
);
74 int i915_gem_object_mock_selftests(void)
76 static const struct i915_subtest tests
[] = {
77 SUBTEST(igt_gem_object
),
79 struct drm_i915_private
*i915
;
82 i915
= mock_gem_device();
86 err
= i915_subtests(tests
, i915
);
88 mock_destroy_device(i915
);
92 int i915_gem_object_live_selftests(struct drm_i915_private
*i915
)
94 static const struct i915_subtest tests
[] = {
95 SUBTEST(igt_gem_huge
),
98 return i915_subtests(tests
, i915
);