Lines Matching full:shmem
3 * KUnit test suite for GEM objects backed by shmem buffers
38 * Test creating a shmem GEM object backed by shmem buffer. The test
40 * shmem file node and object functions attributes set, and the size
46 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_obj_create() local
48 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_obj_create()
49 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_obj_create()
50 KUNIT_EXPECT_EQ(test, shmem->base.size, TEST_SIZE); in drm_gem_shmem_test_obj_create()
51 KUNIT_EXPECT_NOT_NULL(test, shmem->base.filp); in drm_gem_shmem_test_obj_create()
52 KUNIT_EXPECT_NOT_NULL(test, shmem->base.funcs); in drm_gem_shmem_test_obj_create()
54 drm_gem_shmem_free(shmem); in drm_gem_shmem_test_obj_create()
58 * Test creating a shmem GEM object from a scatter/gather table exported
60 * created with the shmem file node attribute equal to NULL and the sgt
66 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_obj_create_private() local
117 shmem = to_drm_gem_shmem_obj(gem_obj); in drm_gem_shmem_test_obj_create_private()
118 KUNIT_EXPECT_PTR_EQ(test, shmem->sgt, sgt); in drm_gem_shmem_test_obj_create_private()
120 drm_gem_shmem_free(shmem); in drm_gem_shmem_test_obj_create_private()
124 * Test pinning backing pages for a shmem GEM object. The test case
131 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_pin_pages() local
134 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_pin_pages()
135 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_pin_pages()
136 KUNIT_EXPECT_NULL(test, shmem->pages); in drm_gem_shmem_test_pin_pages()
137 KUNIT_EXPECT_EQ(test, shmem->pages_use_count, 0); in drm_gem_shmem_test_pin_pages()
139 ret = kunit_add_action_or_reset(test, drm_gem_shmem_free_wrapper, shmem); in drm_gem_shmem_test_pin_pages()
142 ret = drm_gem_shmem_pin(shmem); in drm_gem_shmem_test_pin_pages()
144 KUNIT_ASSERT_NOT_NULL(test, shmem->pages); in drm_gem_shmem_test_pin_pages()
145 KUNIT_EXPECT_EQ(test, shmem->pages_use_count, 1); in drm_gem_shmem_test_pin_pages()
147 for (i = 0; i < (shmem->base.size >> PAGE_SHIFT); i++) in drm_gem_shmem_test_pin_pages()
148 KUNIT_ASSERT_NOT_NULL(test, shmem->pages[i]); in drm_gem_shmem_test_pin_pages()
150 drm_gem_shmem_unpin(shmem); in drm_gem_shmem_test_pin_pages()
151 KUNIT_EXPECT_NULL(test, shmem->pages); in drm_gem_shmem_test_pin_pages()
152 KUNIT_EXPECT_EQ(test, shmem->pages_use_count, 0); in drm_gem_shmem_test_pin_pages()
156 * Test creating a virtual mapping for a shmem GEM object. The test
164 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_vmap() local
168 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_vmap()
169 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_vmap()
170 KUNIT_EXPECT_NULL(test, shmem->vaddr); in drm_gem_shmem_test_vmap()
171 KUNIT_EXPECT_EQ(test, shmem->vmap_use_count, 0); in drm_gem_shmem_test_vmap()
173 ret = kunit_add_action_or_reset(test, drm_gem_shmem_free_wrapper, shmem); in drm_gem_shmem_test_vmap()
176 ret = drm_gem_shmem_vmap(shmem, &map); in drm_gem_shmem_test_vmap()
178 KUNIT_ASSERT_NOT_NULL(test, shmem->vaddr); in drm_gem_shmem_test_vmap()
180 KUNIT_EXPECT_EQ(test, shmem->vmap_use_count, 1); in drm_gem_shmem_test_vmap()
186 drm_gem_shmem_vunmap(shmem, &map); in drm_gem_shmem_test_vmap()
187 KUNIT_EXPECT_NULL(test, shmem->vaddr); in drm_gem_shmem_test_vmap()
188 KUNIT_EXPECT_EQ(test, shmem->vmap_use_count, 0); in drm_gem_shmem_test_vmap()
193 * PRIME usage from a shmem GEM object. The test case succeeds if a
200 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_get_pages_sgt() local
206 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_get_pages_sgt()
207 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_get_pages_sgt()
209 ret = kunit_add_action_or_reset(test, drm_gem_shmem_free_wrapper, shmem); in drm_gem_shmem_test_get_pages_sgt()
212 ret = drm_gem_shmem_pin(shmem); in drm_gem_shmem_test_get_pages_sgt()
215 sgt = drm_gem_shmem_get_sg_table(shmem); in drm_gem_shmem_test_get_pages_sgt()
217 KUNIT_EXPECT_NULL(test, shmem->sgt); in drm_gem_shmem_test_get_pages_sgt()
232 * driver usage from a shmem GEM object. The test case succeeds if the
239 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_get_sg_table() local
244 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_get_sg_table()
245 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_get_sg_table()
247 ret = kunit_add_action_or_reset(test, drm_gem_shmem_free_wrapper, shmem); in drm_gem_shmem_test_get_sg_table()
251 sgt = drm_gem_shmem_get_pages_sgt(shmem); in drm_gem_shmem_test_get_sg_table()
253 KUNIT_ASSERT_NOT_NULL(test, shmem->pages); in drm_gem_shmem_test_get_sg_table()
254 KUNIT_EXPECT_EQ(test, shmem->pages_use_count, 1); in drm_gem_shmem_test_get_sg_table()
255 KUNIT_EXPECT_PTR_EQ(test, sgt, shmem->sgt); in drm_gem_shmem_test_get_sg_table()
266 * Test updating the madvise state of a shmem GEM object. The test
274 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_madvise() local
277 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_madvise()
278 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_madvise()
279 KUNIT_ASSERT_EQ(test, shmem->madv, 0); in drm_gem_shmem_test_madvise()
281 ret = kunit_add_action_or_reset(test, drm_gem_shmem_free_wrapper, shmem); in drm_gem_shmem_test_madvise()
284 ret = drm_gem_shmem_madvise(shmem, 1); in drm_gem_shmem_test_madvise()
286 KUNIT_ASSERT_EQ(test, shmem->madv, 1); in drm_gem_shmem_test_madvise()
289 ret = drm_gem_shmem_madvise(shmem, -1); in drm_gem_shmem_test_madvise()
291 KUNIT_ASSERT_EQ(test, shmem->madv, -1); in drm_gem_shmem_test_madvise()
294 ret = drm_gem_shmem_madvise(shmem, 0); in drm_gem_shmem_test_madvise()
296 KUNIT_ASSERT_EQ(test, shmem->madv, -1); in drm_gem_shmem_test_madvise()
300 * Test purging a shmem GEM object. First, assert that a newly created
301 * shmem GEM object is not purgeable. Then, set madvise to a positive
303 * backing pages. Finally, assert that the shmem GEM object is now
309 struct drm_gem_shmem_object *shmem; in drm_gem_shmem_test_purge() local
313 shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE); in drm_gem_shmem_test_purge()
314 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem); in drm_gem_shmem_test_purge()
316 ret = kunit_add_action_or_reset(test, drm_gem_shmem_free_wrapper, shmem); in drm_gem_shmem_test_purge()
319 ret = drm_gem_shmem_is_purgeable(shmem); in drm_gem_shmem_test_purge()
322 ret = drm_gem_shmem_madvise(shmem, 1); in drm_gem_shmem_test_purge()
326 sgt = drm_gem_shmem_get_pages_sgt(shmem); in drm_gem_shmem_test_purge()
329 ret = drm_gem_shmem_is_purgeable(shmem); in drm_gem_shmem_test_purge()
332 drm_gem_shmem_purge(shmem); in drm_gem_shmem_test_purge()
333 KUNIT_EXPECT_NULL(test, shmem->pages); in drm_gem_shmem_test_purge()
334 KUNIT_EXPECT_NULL(test, shmem->sgt); in drm_gem_shmem_test_purge()
335 KUNIT_EXPECT_EQ(test, shmem->madv, -1); in drm_gem_shmem_test_purge()
381 MODULE_DESCRIPTION("KUnit test suite for GEM objects backed by shmem buffers");