tests/amdgpu: Fix various warnings

This patch fixes the following warnings:
-Wformat=
-Wmaybe-uninitialized
-Wmisleading-indentation
-Wstringop-truncation
-Wunused-function
-Wunused-variable

It also removes forward declarations and moves
global functions to the bottom, keeping locals
at the top, in ras_tests.c.

Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
main
Luben Tuikov 2019-12-05 21:05:13 -05:00 committed by Marek Olšák
parent ed96524001
commit fb1634583f
4 changed files with 117 additions and 129 deletions

View File

@ -3306,7 +3306,7 @@ static void amdgpu_memcpy_draw(amdgpu_device_handle device_handle,
int bo_cmd_size = 4096;
struct amdgpu_cs_request ibs_request = {0};
struct amdgpu_cs_ib_info ib_info= {0};
uint32_t hang_state, hangs, expired;
uint32_t expired;
amdgpu_bo_list_handle bo_list;
struct amdgpu_cs_fence fence_status = {0};

View File

@ -358,6 +358,7 @@ static void amdgpu_cs_uvd_decode(void)
bs_addr = fb_addr + 4*1024;
dpb_addr = ALIGN(bs_addr + sizeof(uvd_bitstream), 4*1024);
ctx_addr = 0;
if (family_id >= AMDGPU_FAMILY_VI) {
if ((family_id == AMDGPU_FAMILY_AI) ||
(chip_id == chip_rev+0x50 || chip_id == chip_rev+0x5A ||

View File

@ -522,124 +522,6 @@ static int amdgpu_ras_lookup_id(drmDevicePtr device)
return -1;
}
CU_BOOL suite_ras_tests_enable(void)
{
amdgpu_device_handle device_handle;
uint32_t major_version;
uint32_t minor_version;
int i;
drmDevicePtr device;
for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
if (amdgpu_device_initialize(drm_amdgpu[i], &major_version,
&minor_version, &device_handle))
continue;
if (drmGetDevice2(drm_amdgpu[i],
DRM_DEVICE_GET_PCI_REVISION,
&device))
continue;
if (device->bustype == DRM_BUS_PCI &&
amdgpu_ras_lookup_capability(device_handle)) {
amdgpu_device_deinitialize(device_handle);
return CU_TRUE;
}
if (amdgpu_device_deinitialize(device_handle))
continue;
}
return CU_FALSE;
}
int suite_ras_tests_init(void)
{
drmDevicePtr device;
amdgpu_device_handle device_handle;
uint32_t major_version;
uint32_t minor_version;
uint32_t capability;
struct ras_test_mask test_mask;
int id;
int i;
int r;
for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
r = amdgpu_device_initialize(drm_amdgpu[i], &major_version,
&minor_version, &device_handle);
if (r)
continue;
if (drmGetDevice2(drm_amdgpu[i],
DRM_DEVICE_GET_PCI_REVISION,
&device)) {
amdgpu_device_deinitialize(device_handle);
continue;
}
if (device->bustype != DRM_BUS_PCI) {
amdgpu_device_deinitialize(device_handle);
continue;
}
capability = amdgpu_ras_lookup_capability(device_handle);
if (capability == 0) {
amdgpu_device_deinitialize(device_handle);
continue;
}
id = amdgpu_ras_lookup_id(device);
if (id == -1) {
amdgpu_device_deinitialize(device_handle);
continue;
}
test_mask = amdgpu_ras_get_test_mask(device);
devices[devices_count++] = (struct amdgpu_ras_data) {
device_handle, id, capability, test_mask,
};
}
if (devices_count == 0)
return CUE_SINIT_FAILED;
return CUE_SUCCESS;
}
int suite_ras_tests_clean(void)
{
int r;
int i;
int ret = CUE_SUCCESS;
for (i = 0; i < devices_count; i++) {
r = amdgpu_device_deinitialize(devices[i].device_handle);
if (r)
ret = CUE_SCLEAN_FAILED;
}
return ret;
}
static void amdgpu_ras_disable_test(void);
static void amdgpu_ras_enable_test(void);
static void amdgpu_ras_inject_test(void);
static void amdgpu_ras_query_test(void);
static void amdgpu_ras_basic_test(void);
CU_TestInfo ras_tests[] = {
{ "ras basic test", amdgpu_ras_basic_test },
{ "ras query test", amdgpu_ras_query_test },
{ "ras inject test", amdgpu_ras_inject_test },
{ "ras disable test", amdgpu_ras_disable_test },
#if 0
{ "ras enable test", amdgpu_ras_enable_test },
#endif
CU_TEST_INFO_NULL,
};
//helpers
static int test_card;
@ -648,10 +530,8 @@ static char debugfs_path[1024];
static uint32_t ras_mask;
static amdgpu_device_handle device_handle;
static int set_test_card(int card)
static void set_test_card(int card)
{
int i;
test_card = card;
sprintf(sysfs_path, "/sys/class/drm/card%d/device/ras/", devices[card].id);
sprintf(debugfs_path, "/sys/kernel/debug/dri/%d/ras/", devices[card].id);
@ -660,8 +540,6 @@ static int set_test_card(int card)
ras_block_mask_inject = devices[card].test_mask.inject_mask;
ras_block_mask_query = devices[card].test_mask.query_mask;
ras_block_mask_basic = devices[card].test_mask.basic_mask;
return 0;
}
static const char *get_ras_sysfs_root(void)
@ -742,7 +620,6 @@ static int amdgpu_ras_query_err_count(enum amdgpu_ras_block block,
{
char buf[64];
char name[1024];
int ret;
*ue = *ce = 0;
@ -779,7 +656,7 @@ static int amdgpu_ras_inject(enum amdgpu_ras_block block,
inject->head.block = block;
inject->head.type = type;
inject->head.sub_block_index = sub_block;
strncpy(inject->head.name, ras_block_str(block), 32);
strncpy(inject->head.name, ras_block_str(block), sizeof(inject->head.name)-1);
inject->address = address;
inject->value = value;
@ -956,8 +833,6 @@ static void amdgpu_ras_query_test(void)
static void amdgpu_ras_basic_test(void)
{
unsigned long ue, ce;
char name[1024];
int ret;
int i;
int j;
@ -1000,3 +875,115 @@ static void amdgpu_ras_basic_test(void)
}
}
}
CU_TestInfo ras_tests[] = {
{ "ras basic test", amdgpu_ras_basic_test },
{ "ras query test", amdgpu_ras_query_test },
{ "ras inject test", amdgpu_ras_inject_test },
{ "ras disable test", amdgpu_ras_disable_test },
#if 0
{ "ras enable test", amdgpu_ras_enable_test },
#endif
CU_TEST_INFO_NULL,
};
CU_BOOL suite_ras_tests_enable(void)
{
amdgpu_device_handle device_handle;
uint32_t major_version;
uint32_t minor_version;
int i;
drmDevicePtr device;
for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
if (amdgpu_device_initialize(drm_amdgpu[i], &major_version,
&minor_version, &device_handle))
continue;
if (drmGetDevice2(drm_amdgpu[i],
DRM_DEVICE_GET_PCI_REVISION,
&device))
continue;
if (device->bustype == DRM_BUS_PCI &&
amdgpu_ras_lookup_capability(device_handle)) {
amdgpu_device_deinitialize(device_handle);
return CU_TRUE;
}
if (amdgpu_device_deinitialize(device_handle))
continue;
}
return CU_FALSE;
}
int suite_ras_tests_init(void)
{
drmDevicePtr device;
amdgpu_device_handle device_handle;
uint32_t major_version;
uint32_t minor_version;
uint32_t capability;
struct ras_test_mask test_mask;
int id;
int i;
int r;
for (i = 0; i < MAX_CARDS_SUPPORTED && drm_amdgpu[i] >= 0; i++) {
r = amdgpu_device_initialize(drm_amdgpu[i], &major_version,
&minor_version, &device_handle);
if (r)
continue;
if (drmGetDevice2(drm_amdgpu[i],
DRM_DEVICE_GET_PCI_REVISION,
&device)) {
amdgpu_device_deinitialize(device_handle);
continue;
}
if (device->bustype != DRM_BUS_PCI) {
amdgpu_device_deinitialize(device_handle);
continue;
}
capability = amdgpu_ras_lookup_capability(device_handle);
if (capability == 0) {
amdgpu_device_deinitialize(device_handle);
continue;
}
id = amdgpu_ras_lookup_id(device);
if (id == -1) {
amdgpu_device_deinitialize(device_handle);
continue;
}
test_mask = amdgpu_ras_get_test_mask(device);
devices[devices_count++] = (struct amdgpu_ras_data) {
device_handle, id, capability, test_mask,
};
}
if (devices_count == 0)
return CUE_SINIT_FAILED;
return CUE_SUCCESS;
}
int suite_ras_tests_clean(void)
{
int r;
int i;
int ret = CUE_SUCCESS;
for (i = 0; i < devices_count; i++) {
r = amdgpu_device_deinitialize(devices[i].device_handle);
if (r)
ret = CUE_SCLEAN_FAILED;
}
return ret;
}

View File

@ -96,7 +96,7 @@ static int syncobj_command_submission_helper(uint32_t syncobj_handle, bool
struct amdgpu_cs_fence fence_status;
amdgpu_bo_list_handle bo_list;
amdgpu_va_handle va_handle;
uint32_t expired, flags;
uint32_t expired;
int i, r;
uint64_t seq_no;
static uint32_t *ptr;