gpu: nvgpu: BVEC test for common.gr

Add BVEC test for nvgpu_gr_config_get_sm_info()

JIRA NVGPU-6951

Signed-off-by: tkudav <tkudav@nvidia.com>
Change-Id: I06182c68c041063556edd723f38fe1552ded7af0
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2554616
(cherry picked from commit f56884a5ea182695879a92412e8e5d94860ee606)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2560011
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
tkudav
2021-07-06 16:11:48 +05:30
committed by mobile promotions
parent fcf31d7063
commit c418946cb6
2 changed files with 68 additions and 2 deletions

View File

@@ -25,6 +25,7 @@
#include <unit/unit.h>
#include <unit/io.h>
#include <unit/utils.h>
#include <nvgpu/posix/io.h>
#include <nvgpu/posix/kmem.h>
@@ -302,7 +303,14 @@ int test_gr_config_set_get(struct unit_module *m,
u32 gindex = 0U;
u32 val = 0U;
struct nvgpu_sm_info *sm_info;
u32 num_sm = 0U;
u32 num_sm = nvgpu_gr_config_get_tpc_count(unit_gr_config) *
nvgpu_gr_config_get_sm_count_per_tpc(unit_gr_config);
u32 i, j, states, sm_id, sm_id_range, sm_range_difference;
u32 valid_sm_ids[][2] = {{0, num_sm-1}};
u32 invalid_sm_ids[][2] = {{num_sm, U32_MAX}};
u32 (*working_list)[2];
const char *string_cases[] = {"Valid", "Invalid"};
const char *string_states[] = {"Min", "Max", "Random Mid"};
srand(0);
@@ -313,6 +321,48 @@ int test_gr_config_set_get(struct unit_module *m,
unit_return_fail(m, "mismatch in no_of_sm\n");
}
/*
* i is to loop through valid and invalid cases
* j is to loop through different ranges within ith case
* states is for min, max and median
*/
/* loop through valid and invalid cases */
for (i = 0; i < 2; i++) {
/* select appropriate iteration size */
sm_id_range = (i == 0) ? ARRAY_SIZE(valid_sm_ids) : ARRAY_SIZE(invalid_sm_ids);
/* select correct working list */
working_list = (i == 0) ? valid_sm_ids : invalid_sm_ids;
for (j = 0; j < sm_id_range; j++) {
for (states = 0; states < 3; states++) {
/* check for min sm id */
if (states == 0)
sm_id = working_list[j][0];
else if (states == 1) {
/* check for max valid sm id */
sm_id = working_list[j][1];
} else {
sm_range_difference = working_list[j][1] - working_list[j][0];
/* Check for random sm id in range */
if (sm_range_difference > 1)
sm_id = get_random_u32(working_list[j][0] + 1, working_list[j][1] - 1);
else
continue;
}
unit_info(m, "BVEC testing for nvgpu_gr_config_get_sm_info with sm id = %u(%s range %s) done\n", sm_id, string_cases[i], string_states[states]);
sm_info = nvgpu_gr_config_get_sm_info(unit_gr_config, sm_id);
if (i == 0) {
if (sm_info == NULL)
unit_return_fail(m, "SM_id valid range check failed.\n");
} else {
if (sm_info != NULL)
unit_return_fail(m, "SM_id invalid range check failed.\n");
}
}
}
}
/*
* Set random value and read back
*/

View File

@@ -124,7 +124,13 @@ int test_gr_config_count(struct unit_module *m, struct gk20a *g, void *args);
* reflect the same value. This test helps to verify the
* configuration values can be changed as part of floorsweeping.
*
* Test Type: Feature, Error guessing
* Test Type: Feature, Error guessing, Boundary Value
*
* Equivalence classes:
* Variable : sm_id (nvgpu_gr_config_get_sm_info)
* - Valid : {0, (SM count - 1)}
* - Invalid : {SM count, U32_MAX}
* For GV11b, SM count = 8
*
* Targets: nvgpu_gr_config_set_no_of_sm,
* nvgpu_gr_config_get_no_of_sm,
@@ -146,6 +152,16 @@ int test_gr_config_count(struct unit_module *m, struct gk20a *g, void *args);
* Steps:
* - Random values are set for various configuration and read back to
* check those values.
* - For BVEC testing of nvgpu_gr_config_get_sm_info,
* - Get the 'SM count' based on TPC count and number of SMs per TPC.
* - Call nvgpu_gr_config_get_sm_info with input sm_id at boundary
* values - min boundary(0), max boundary(SM count - 1) and once
* with random value in valid range. nvgpu_gr_config_get_sm_info
* should return non NULL pointer with sm_info populated.
* - Call nvgpu_gr_config_get_sm_info with input sm_id at boundary
* values - min boundary(SM count), max boundary(U32_MAX) and once
* with random value in invalid range. nvgpu_gr_config_get_sm_info
* should return NULL pointer.
*
* Output: Returns PASS if the steps above were executed successfully. FAIL
* otherwise.