mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
drm/tests/gpu_buddy: add a new test case for buffer clearance during resume
Add a new unit test case for buffer clearance issue during resume. Using a non-power-of-two mm size, allocate alternating blocks of 4KiB in an even sequence and free them as cleared. All alternate blocks should be marked as dirty and the split blocks should be merged back to their original size when the blocks clear reset function is called. Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patch.msgid.link/20260721114236.507578-1-Arunpravin.PaneerSelvam@amd.com
This commit is contained in:
@@ -1002,6 +1002,47 @@ static void gpu_test_buddy_alloc_clear(struct kunit *test)
|
||||
"buddy_alloc hit an error size=%lu\n", ps);
|
||||
gpu_buddy_free_list(&mm, &allocated, GPU_BUDDY_CLEARED);
|
||||
gpu_buddy_fini(&mm);
|
||||
|
||||
/*
|
||||
* Using a non-power-of-two mm size, allocate alternating blocks of 4KiB in an
|
||||
* even sequence and free them as cleared. All blocks should be marked as
|
||||
* dirty and the split blocks should be merged back to their original
|
||||
* size when the blocks clear reset function is called.
|
||||
*/
|
||||
KUNIT_EXPECT_FALSE(test, gpu_buddy_init(&mm, mm_size, ps));
|
||||
KUNIT_EXPECT_EQ(test, mm.max_order, max_order);
|
||||
|
||||
i = 0;
|
||||
n_pages = mm_size / ps;
|
||||
do {
|
||||
if (i % 2 == 0)
|
||||
KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_alloc_blocks(&mm, 0, mm_size,
|
||||
ps, ps, &allocated, 0),
|
||||
"buddy_alloc hit an error size=%lu\n", ps);
|
||||
} while (++i < n_pages);
|
||||
|
||||
gpu_buddy_free_list(&mm, &allocated, GPU_BUDDY_CLEARED);
|
||||
gpu_buddy_reset_clear(&mm, false);
|
||||
KUNIT_EXPECT_EQ(test, mm.clear_avail, 0);
|
||||
|
||||
/*
|
||||
* Using a non-power-of-two mm size, allocate alternating blocks of 4KiB in an
|
||||
* odd sequence and free them as cleared. All blocks should be marked as
|
||||
* cleared and the split blocks should be merged back to their original
|
||||
* size when the blocks clear reset function is called.
|
||||
*/
|
||||
i = 0;
|
||||
do {
|
||||
if (i % 2 != 0)
|
||||
KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_alloc_blocks(&mm, 0, mm_size,
|
||||
ps, ps, &allocated, 0),
|
||||
"buddy_alloc hit an error size=%lu\n", ps);
|
||||
} while (++i < n_pages);
|
||||
|
||||
gpu_buddy_free_list(&mm, &allocated, GPU_BUDDY_CLEARED);
|
||||
gpu_buddy_reset_clear(&mm, true);
|
||||
KUNIT_EXPECT_EQ(test, mm.clear_avail, mm_size);
|
||||
gpu_buddy_fini(&mm);
|
||||
}
|
||||
|
||||
static void gpu_test_buddy_alloc_contiguous(struct kunit *test)
|
||||
|
||||
Reference in New Issue
Block a user