Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 520fb7f

Browse files
matt-auldChristianKoenigAMD
authored andcommitted
drm/tests/buddy: stop using PAGE_SIZE
Gives the wrong impression that min page-size has to be tied to the CPU PAGE_SIZE. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Cc: Christian König <christian.koenig@amd.com> Cc: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240229105112.250077-4-matthew.auld@intel.com Signed-off-by: Christian König <christian.koenig@amd.com>
1 parent 117bbc0 commit 520fb7f

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

drivers/gpu/drm/tests/drm_buddy_test.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ static void drm_test_buddy_alloc_pathological(struct kunit *test)
329329
* Eventually we will have a fully 50% fragmented mm.
330330
*/
331331

332-
mm_size = PAGE_SIZE << max_order;
333-
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, PAGE_SIZE),
332+
mm_size = SZ_4K << max_order;
333+
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, SZ_4K),
334334
"buddy_init failed\n");
335335

336336
KUNIT_EXPECT_EQ(test, mm.max_order, max_order);
@@ -344,7 +344,7 @@ static void drm_test_buddy_alloc_pathological(struct kunit *test)
344344
}
345345

346346
for (order = top; order--;) {
347-
size = get_size(order, PAGE_SIZE);
347+
size = get_size(order, mm.chunk_size);
348348
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start,
349349
mm_size, size, size,
350350
&tmp, flags),
@@ -358,7 +358,7 @@ static void drm_test_buddy_alloc_pathological(struct kunit *test)
358358
}
359359

360360
/* There should be one final page for this sub-allocation */
361-
size = get_size(0, PAGE_SIZE);
361+
size = get_size(0, mm.chunk_size);
362362
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
363363
size, size, &tmp, flags),
364364
"buddy_alloc hit -ENOMEM for hole\n");
@@ -368,7 +368,7 @@ static void drm_test_buddy_alloc_pathological(struct kunit *test)
368368

369369
list_move_tail(&block->link, &holes);
370370

371-
size = get_size(top, PAGE_SIZE);
371+
size = get_size(top, mm.chunk_size);
372372
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
373373
size, size, &tmp, flags),
374374
"buddy_alloc unexpectedly succeeded at top-order %d/%d, it should be full!",
@@ -379,7 +379,7 @@ static void drm_test_buddy_alloc_pathological(struct kunit *test)
379379

380380
/* Nothing larger than blocks of chunk_size now available */
381381
for (order = 1; order <= max_order; order++) {
382-
size = get_size(order, PAGE_SIZE);
382+
size = get_size(order, mm.chunk_size);
383383
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
384384
size, size, &tmp, flags),
385385
"buddy_alloc unexpectedly succeeded at order %d, it should be full!",
@@ -408,14 +408,14 @@ static void drm_test_buddy_alloc_pessimistic(struct kunit *test)
408408
* page left.
409409
*/
410410

411-
mm_size = PAGE_SIZE << max_order;
412-
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, PAGE_SIZE),
411+
mm_size = SZ_4K << max_order;
412+
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, SZ_4K),
413413
"buddy_init failed\n");
414414

415415
KUNIT_EXPECT_EQ(test, mm.max_order, max_order);
416416

417417
for (order = 0; order < max_order; order++) {
418-
size = get_size(order, PAGE_SIZE);
418+
size = get_size(order, mm.chunk_size);
419419
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
420420
size, size, &tmp, flags),
421421
"buddy_alloc hit -ENOMEM with order=%d\n",
@@ -428,7 +428,7 @@ static void drm_test_buddy_alloc_pessimistic(struct kunit *test)
428428
}
429429

430430
/* And now the last remaining block available */
431-
size = get_size(0, PAGE_SIZE);
431+
size = get_size(0, mm.chunk_size);
432432
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
433433
size, size, &tmp, flags),
434434
"buddy_alloc hit -ENOMEM on final alloc\n");
@@ -440,7 +440,7 @@ static void drm_test_buddy_alloc_pessimistic(struct kunit *test)
440440

441441
/* Should be completely full! */
442442
for (order = max_order; order--;) {
443-
size = get_size(order, PAGE_SIZE);
443+
size = get_size(order, mm.chunk_size);
444444
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
445445
size, size, &tmp, flags),
446446
"buddy_alloc unexpectedly succeeded, it should be full!");
@@ -456,7 +456,7 @@ static void drm_test_buddy_alloc_pessimistic(struct kunit *test)
456456
list_del(&block->link);
457457
drm_buddy_free_block(&mm, block);
458458

459-
size = get_size(order, PAGE_SIZE);
459+
size = get_size(order, mm.chunk_size);
460460
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
461461
size, size, &tmp, flags),
462462
"buddy_alloc hit -ENOMEM with order=%d\n",
@@ -471,7 +471,7 @@ static void drm_test_buddy_alloc_pessimistic(struct kunit *test)
471471
}
472472

473473
/* To confirm, now the whole mm should be available */
474-
size = get_size(max_order, PAGE_SIZE);
474+
size = get_size(max_order, mm.chunk_size);
475475
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
476476
size, size, &tmp, flags),
477477
"buddy_alloc (realloc) hit -ENOMEM with order=%d\n",
@@ -502,15 +502,15 @@ static void drm_test_buddy_alloc_optimistic(struct kunit *test)
502502
* try to allocate them all.
503503
*/
504504

505-
mm_size = PAGE_SIZE * ((1 << (max_order + 1)) - 1);
505+
mm_size = SZ_4K * ((1 << (max_order + 1)) - 1);
506506

507-
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, PAGE_SIZE),
507+
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_init(&mm, mm_size, SZ_4K),
508508
"buddy_init failed\n");
509509

510510
KUNIT_EXPECT_EQ(test, mm.max_order, max_order);
511511

512512
for (order = 0; order <= max_order; order++) {
513-
size = get_size(order, PAGE_SIZE);
513+
size = get_size(order, mm.chunk_size);
514514
KUNIT_ASSERT_FALSE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
515515
size, size, &tmp, flags),
516516
"buddy_alloc hit -ENOMEM with order=%d\n",
@@ -523,7 +523,7 @@ static void drm_test_buddy_alloc_optimistic(struct kunit *test)
523523
}
524524

525525
/* Should be completely full! */
526-
size = get_size(0, PAGE_SIZE);
526+
size = get_size(0, mm.chunk_size);
527527
KUNIT_ASSERT_TRUE_MSG(test, drm_buddy_alloc_blocks(&mm, start, mm_size,
528528
size, size, &tmp, flags),
529529
"buddy_alloc unexpectedly succeeded, it should be full!");
@@ -540,15 +540,15 @@ static void drm_test_buddy_alloc_limit(struct kunit *test)
540540
LIST_HEAD(allocated);
541541
struct drm_buddy mm;
542542

543-
KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, size, PAGE_SIZE));
543+
KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, size, SZ_4K));
544544

545545
KUNIT_EXPECT_EQ_MSG(test, mm.max_order, DRM_BUDDY_MAX_ORDER,
546546
"mm.max_order(%d) != %d\n", mm.max_order,
547547
DRM_BUDDY_MAX_ORDER);
548548

549549
size = mm.chunk_size << mm.max_order;
550550
KUNIT_EXPECT_FALSE(test, drm_buddy_alloc_blocks(&mm, start, size, size,
551-
PAGE_SIZE, &allocated, flags));
551+
mm.chunk_size, &allocated, flags));
552552

553553
block = list_first_entry_or_null(&allocated, struct drm_buddy_block, link);
554554
KUNIT_EXPECT_TRUE(test, block);
@@ -558,10 +558,10 @@ static void drm_test_buddy_alloc_limit(struct kunit *test)
558558
drm_buddy_block_order(block), mm.max_order);
559559

560560
KUNIT_EXPECT_EQ_MSG(test, drm_buddy_block_size(&mm, block),
561-
BIT_ULL(mm.max_order) * PAGE_SIZE,
561+
BIT_ULL(mm.max_order) * mm.chunk_size,
562562
"block size(%llu) != %llu\n",
563563
drm_buddy_block_size(&mm, block),
564-
BIT_ULL(mm.max_order) * PAGE_SIZE);
564+
BIT_ULL(mm.max_order) * mm.chunk_size);
565565

566566
drm_buddy_free_list(&mm, &allocated);
567567
drm_buddy_fini(&mm);

0 commit comments

Comments
 (0)