Lines Matching +full:scatter +full:- +full:gather
1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/dma-buf.h>
11 #include <linux/iosys-map.h>
45 struct drm_device *drm_dev = test->priv; 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()
58 * Test creating a shmem GEM object from a scatter/gather table exported
59 * via a DMA-BUF. The test case succeed if the GEM object is successfully
61 * attribute pointing to the scatter/gather table that has been imported.
65 struct drm_device *drm_dev = test->priv; in drm_gem_shmem_test_obj_create_private()
74 /* Create a mock scatter/gather table */ in drm_gem_shmem_test_obj_create_private()
90 sg_init_one(sgt->sgl, buf, TEST_SIZE); in drm_gem_shmem_test_obj_create_private()
93 * Set the DMA mask to 64-bits and map the sgtables in drm_gem_shmem_test_obj_create_private()
97 ret = dma_set_mask(drm_dev->dev, DMA_BIT_MASK(64)); in drm_gem_shmem_test_obj_create_private()
100 ret = dma_map_sgtable(drm_dev->dev, sgt, DMA_BIDIRECTIONAL, 0); in drm_gem_shmem_test_obj_create_private()
103 /* Init a mock DMA-BUF */ in drm_gem_shmem_test_obj_create_private()
109 KUNIT_EXPECT_EQ(test, gem_obj->size, TEST_SIZE); in drm_gem_shmem_test_obj_create_private()
110 KUNIT_EXPECT_NULL(test, gem_obj->filp); in drm_gem_shmem_test_obj_create_private()
111 KUNIT_EXPECT_NOT_NULL(test, gem_obj->funcs); in drm_gem_shmem_test_obj_create_private()
113 /* The scatter/gather table will be freed by drm_gem_shmem_free */ 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()
130 struct drm_device *drm_dev = test->priv; 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()
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()
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()
163 struct drm_device *drm_dev = test->priv; 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()
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()
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()
192 * Test exporting a scatter/gather table of pinned pages suitable for
194 * scatter/gather table large enough to accommodate the backing memory
199 struct drm_device *drm_dev = test->priv; in drm_gem_shmem_test_get_pages_sgt()
217 KUNIT_EXPECT_NULL(test, shmem->sgt); in drm_gem_shmem_test_get_pages_sgt()
224 len += sg->length; in drm_gem_shmem_test_get_pages_sgt()
231 * Test pinning pages and exporting a scatter/gather table suitable for
233 * backing pages are pinned and a scatter/gather table large enough to
238 struct drm_device *drm_dev = test->priv; in drm_gem_shmem_test_get_sg_table()
250 /* The scatter/gather table will be freed by drm_gem_shmem_free */ 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()
259 len += sg->length; in drm_gem_shmem_test_get_sg_table()
273 struct drm_device *drm_dev = test->priv; in drm_gem_shmem_test_madvise()
279 KUNIT_ASSERT_EQ(test, shmem->madv, 0); 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()
296 KUNIT_ASSERT_EQ(test, shmem->madv, -1); in drm_gem_shmem_test_madvise()
302 * value and call drm_gem_shmem_get_pages_sgt() to pin and dma-map the
308 struct drm_device *drm_dev = test->priv; in drm_gem_shmem_test_purge()
325 /* The scatter/gather table will be freed by drm_gem_shmem_free */ 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()
356 test->priv = drm_dev; in drm_gem_shmem_test_init()