2 * SPDX-License-Identifier: MIT
4 * Copyright © 2016 Intel Corporation
7 #include "i915_selftest.h"
9 #include "selftests/mock_gem_device.h"
11 static int mock_phys_object(void *arg
)
13 struct drm_i915_private
*i915
= arg
;
14 struct drm_i915_gem_object
*obj
;
17 /* Create an object and bind it to a contiguous set of physical pages,
18 * i.e. exercise the i915_gem_object_phys API.
21 obj
= i915_gem_object_create_shmem(i915
, PAGE_SIZE
);
24 pr_err("i915_gem_object_create failed, err=%d\n", err
);
28 err
= i915_gem_object_attach_phys(obj
, PAGE_SIZE
);
30 pr_err("i915_gem_object_attach_phys failed, err=%d\n", err
);
34 if (obj
->ops
!= &i915_gem_phys_ops
) {
35 pr_err("i915_gem_object_attach_phys did not create a phys object\n");
40 if (!atomic_read(&obj
->mm
.pages_pin_count
)) {
41 pr_err("i915_gem_object_attach_phys did not pin its phys pages\n");
46 /* Make the object dirty so that put_pages must do copy back the data */
47 i915_gem_object_lock(obj
, NULL
);
48 err
= i915_gem_object_set_to_gtt_domain(obj
, true);
49 i915_gem_object_unlock(obj
);
51 pr_err("i915_gem_object_set_to_gtt_domain failed with err=%d\n",
57 i915_gem_object_put(obj
);
62 int i915_gem_phys_mock_selftests(void)
64 static const struct i915_subtest tests
[] = {
65 SUBTEST(mock_phys_object
),
67 struct drm_i915_private
*i915
;
70 i915
= mock_gem_device();
74 err
= i915_subtests(tests
, i915
);
76 mock_destroy_device(i915
);