Skip to content

Commit

Permalink
drm/xe/tests: Fix the shrinker test compiler warnings.
Browse files Browse the repository at this point in the history
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 <nathan@kernel.org>
Closes: https://lore.kernel.org/20240913195649.GA61514@thelio-3990X/
Fixes: 5a90b60 ("drm/xe: Add a xe_bo subtest for shrinking / swapping")
Cc: dri-devel@lists.freedesktop.org
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com> #v1
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241004141121.186177-1-thomas.hellstrom@linux.intel.com
  • Loading branch information
Thomas Hellström committed Oct 9, 2024
1 parent 67ec9f8 commit 7a7593e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/gpu/drm/xe/tests/xe_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <kunit/visibility.h>

#include <linux/iosys-map.h>
#include <linux/math64.h>
#include <linux/random.h>
#include <linux/swap.h>

Expand Down Expand Up @@ -440,7 +441,7 @@ static int shrink_test_run_device(struct xe_device *xe)
LIST_HEAD(bos);
struct xe_bo_link *link, *next;
struct sysinfo si;
size_t ram, ram_and_swap, purgeable, alloced, to_alloc, limit;
u64 ram, ram_and_swap, purgeable = 0, alloced, to_alloc, limit;
unsigned int interrupted = 0, successful = 0, count = 0;
struct rnd_state prng;
u64 rand_seed;
Expand Down Expand Up @@ -469,7 +470,7 @@ static int shrink_test_run_device(struct xe_device *xe)
ram_and_swap = ram + get_nr_swap_pages() * PAGE_SIZE;
if (to_alloc > ram_and_swap)
purgeable = to_alloc - ram_and_swap;
purgeable += purgeable / 5;
purgeable += div64_u64(purgeable, 5);

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

0 comments on commit 7a7593e

Please sign in to comment.