drm/xe/tests: avoid build warning on 32-bit targets
Subsystems (2)
PATCH 1/1 drm/xe/tests: avoid build warning on 32-bit targets
From: Arnd Bergmann <[email protected]>
Building the test case on 32-bit targets produces an integer overflow warning, as a constant value is assigned to a 32-bit resource_size_t variable:
In file included from drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c:3329:drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c: In function 'pf_gt_config_test_init':drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c:14:25: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '14940110848' to '2055208960' [-Werror=overflow]
14 | #define TEST_VRAM 0x37a800000ull
| ^~~~~~~~~~~~~~
drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c:71:29: note: in expansion of macro 'TEST_VRAM'
71 | vram->usable_size = TEST_VRAM;
| ^~~~~~~~~Shut up the warning with an extra cast that marks this truncation as intentional. This is probably not the right fix here, but I could not figure out where the constant value actually comes from, or if a smaller number would be appropriate on a 32-bit system. It's possible that the test case or the driver is just not useful on 32-bit machines because of other parts of the logic here.
---
If there is a better way to fix this, please treat this as a bug report and just add a Reported-by tag in the commit.
--- drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c +1 -1
@@ -11,7 +11,7 @@#include "xe_pci_test.h" #define TEST_MAX_VFS 63 -#define TEST_VRAM 0x37a800000ull +#define TEST_VRAM (resource_size_t)0x37a800000ullstatic void pf_set_admin_mode (struct xe_device *xe,bool enable) {
Signature · 1 line
2.39.5
Hi Arnd,
Quoted 20 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
Building the test case on 32-bit targets produces an integer overflow warning, as a constant value is assigned to a 32-bit
resource_size_tvariable:In file included from
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c:3329:drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c: In function 'pf_gt_config_test_init':drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c:14:25: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '14940110848' to '2055208960' [-Werror=overflow]14 | #define TEST_VRAM 0x37a800000ull | ^~~~~~~~~~~~~~ drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c:71:29: note: in expansion of macro 'TEST_VRAM' 71 | vram->usable_size = TEST_VRAM; | ^~~~~~~~~Shut up the warning with an extra cast that marks this truncation as intentional. This is probably not the right fix here, but I could not figure out where the constant value actually comes from, or if a smaller number would be appropriate on a 32-bit system. It's possible that the test case or the driver is just not useful on 32-bit machines because of other parts of the logic here.
Quoted 5 lines
Fixes cbe29da6f7c0 ("drm/xe/tests: Add KUnit tests for new VRAM fair provisioning")Signed-off-by Arnd Bergmann <[email protected]>---
If there is a better way to fix this, please treat this as a bug report and just add a Reported-by tag in the commit.
this was already fixed and pushed [1]
[1] https://gitlab.freedesktop.org/drm/xe/kernel/-/commit/4f18a79b3585a28c9f73f859fe83f12d0eccc736
Quoted 17 lines
--- drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_config_kunit.c +1
-1@@ -11,7 +11,7 @@#include "xe_pci_test.h" #define TEST_MAX_VFS 63 -#define TEST_VRAM 0x37a800000ull +#define TEST_VRAM (resource_size_t)0x37a800000ullstatic void pf_set_admin_mode (struct xe_device *xe,bool enable) {
Quoted 11 lines · Michal Wajdeczko
Quoted 4 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
---
If there is a better way to fix this, please treat this as a bug report and just add a Reported-by tag in the commit.this was already fixed and pushed [1]
[1]
https://gitlab.freedesktop.org/drm/xe/kernel/-/commit/4f18a79b3585a28c9f73f859fe83f12d0eccc736
Right, that looks better than my version. Apparently it just missed the current linux-next that I was testing on.
Arnd
Hi,
Quoted 5 lines · Arnd Bergmann
Shut up the warning with an extra cast that marks this truncation as intentional. This is probably not the right fix here, but I could not figure out where the constant value actually comes from, or if a smaller number would be appropriate on a 32-bit system. It's possible that the test case or the driver is just not useful on 32-bit machines because of other parts of the logic here.
vram->usable_size should be the same thing that gets reported during boot:
[ 6.538254] xe 0030:03:00.0: [drm] VRAM[0]: Actual physical size 0x0000000300000000, usable size exclude stolen 0x00000002fb800000, CPU accessible size 0x00000002fb800000
I think this should always be 64 bit wide, even on 32 bit architectures, because the VRAM exists and can be distributed to VFs, even if it cannot be accessed from the CPU.
Simon