Skip to content

Commit 7a7593e

Browse files
author
Thomas Hellström
committed
drm/xe/tests: Fix the shrinker test compiler warnings.
The xe_bo_shrink_kunit test has an uninitialized value and illegal integer size conversions on 32-bit. Fix. v2: - Use div64_u64 to ensure the u64 division compiles everywhere. (Matt Auld) Reported-by: Nathan Chancellor <[email protected]> Closes: https://lore.kernel.org/20240913195649.GA61514@thelio-3990X/ Fixes: 5a90b60 ("drm/xe: Add a xe_bo subtest for shrinking / swapping") Cc: [email protected] Cc: Matthew Auld <[email protected]> Reviewed-by: Matthew Auld <[email protected]> #v1 Signed-off-by: Thomas Hellström <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 67ec9f8 commit 7a7593e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpu/drm/xe/tests/xe_bo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <kunit/visibility.h>
88

99
#include <linux/iosys-map.h>
10+
#include <linux/math64.h>
1011
#include <linux/random.h>
1112
#include <linux/swap.h>
1213

@@ -440,7 +441,7 @@ static int shrink_test_run_device(struct xe_device *xe)
440441
LIST_HEAD(bos);
441442
struct xe_bo_link *link, *next;
442443
struct sysinfo si;
443-
size_t ram, ram_and_swap, purgeable, alloced, to_alloc, limit;
444+
u64 ram, ram_and_swap, purgeable = 0, alloced, to_alloc, limit;
444445
unsigned int interrupted = 0, successful = 0, count = 0;
445446
struct rnd_state prng;
446447
u64 rand_seed;
@@ -469,7 +470,7 @@ static int shrink_test_run_device(struct xe_device *xe)
469470
ram_and_swap = ram + get_nr_swap_pages() * PAGE_SIZE;
470471
if (to_alloc > ram_and_swap)
471472
purgeable = to_alloc - ram_and_swap;
472-
purgeable += purgeable / 5;
473+
purgeable += div64_u64(purgeable, 5);
473474

474475
kunit_info(test, "Free ram is %lu bytes. Will allocate twice of that.\n",
475476
(unsigned long)ram);

0 commit comments

Comments
 (0)