From 60e3aee389929d3da39a1a9c3decc913a32b43b1 Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Fri, 18 Jun 2021 13:16:06 +0530 Subject: [PATCH] gpu: nvgpu: units: BVEC test for common.ptimer Update common.ptimer boundary value test to use BVEC test values. Update test documentation accordingly. Jira NVGPU-6394 Change-Id: Ib215d8a3eeac73f2dbc2a558d0e4df50c9f12157 Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2546971 (cherry picked from commit e34aff6524822ff0f0ec74bc8202e2748b027099) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2551338 Reviewed-by: svcacv Reviewed-by: svc_kernel_abi Reviewed-by: Shashank Singh Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- userspace/units/ptimer/nvgpu-ptimer.c | 64 +++++++++------------------ userspace/units/ptimer/nvgpu-ptimer.h | 19 +++++--- 2 files changed, 34 insertions(+), 49 deletions(-) diff --git a/userspace/units/ptimer/nvgpu-ptimer.c b/userspace/units/ptimer/nvgpu-ptimer.c index cbe892025..c7722a6f5 100644 --- a/userspace/units/ptimer/nvgpu-ptimer.c +++ b/userspace/units/ptimer/nvgpu-ptimer.c @@ -262,65 +262,45 @@ int test_ptimer_scaling(struct unit_module *m, struct gk20a *g, void *args) { int ret = UNIT_SUCCESS; + int err; u32 val; - val = scale_ptimer(100, 20); - if (val != 50) { - unit_err(m, "ptimer scale calculation incorrect\n"); + /* Initialize ptimer source freq as per gv11b platform freq */ + g->ptimer_src_freq = 31250000U; + + err = nvgpu_ptimer_scale(g, 0U, &val); + if ((err != 0) || (val != 0U)) { + unit_err(m, "ptimer scale calculation incorrect, line %u\n", __LINE__); ret = UNIT_FAIL; } - val = scale_ptimer(111, 20); - if (val != 56) { - unit_err(m, "ptimer scale calculation incorrect\n"); + err = nvgpu_ptimer_scale(g, 1000U, &val); + if ((err != 0) || (val != 1000U)) { + unit_err(m, "ptimer scale calculation incorrect, line %u\n", __LINE__); ret = UNIT_FAIL; } - val = scale_ptimer(U32_MAX/10, 20); - if (val != (U32_MAX/20)+1) { - unit_err(m, "ptimer scale calculation incorrect\n"); + err = nvgpu_ptimer_scale(g, U32_MAX / 10, &val); + if ((err != 0) || (val != (U32_MAX / 10))) { + unit_err(m, "ptimer scale calculation incorrect, line %u\n", __LINE__); ret = UNIT_FAIL; } - val = scale_ptimer(0, U32_MAX); - if (val != 0) { - unit_err(m, "ptimer scale calculation incorrect\n"); + err = nvgpu_ptimer_scale(g, (U32_MAX / 10U) + 1, &val); + if (err == 0) { + unit_err(m, "unexpected success returned, line %u\n", __LINE__); ret = UNIT_FAIL; } - val = scale_ptimer(100, 1); - if (val != 1001) { - unit_err(m, "ptimer scale calculation incorrect\n"); + err = nvgpu_ptimer_scale(g, U32_MAX / 5U, &val); + if (err == 0) { + unit_err(m, "unexpected success returned, line %u\n", __LINE__); ret = UNIT_FAIL; } - val = scale_ptimer(10, 6); - if (val != 17) { - unit_err(m, "ptimer scale calculation incorrect\n"); - ret = UNIT_FAIL; - } - - val = ptimer_scalingfactor10x(100); - if (val != (PTIMER_REF_FREQ_HZ*10/100)) { - unit_err(m, "ptimer scale calculation incorrect\n"); - ret = UNIT_FAIL; - } - - val = ptimer_scalingfactor10x(97); - if (val != (PTIMER_REF_FREQ_HZ*10/97)) { - unit_err(m, "ptimer scale calculation incorrect\n"); - ret = UNIT_FAIL; - } - - val = ptimer_scalingfactor10x(100); - if (val != (PTIMER_REF_FREQ_HZ*10/100)) { - unit_err(m, "ptimer scale calculation incorrect\n"); - ret = UNIT_FAIL; - } - - val = ptimer_scalingfactor10x(PTIMER_REF_FREQ_HZ); - if (val != 10) { - unit_err(m, "ptimer scale calculation incorrect\n"); + err = nvgpu_ptimer_scale(g, U32_MAX, &val); + if (err == 0) { + unit_err(m, "unexpected success returned, line %u\n", __LINE__); ret = UNIT_FAIL; } diff --git a/userspace/units/ptimer/nvgpu-ptimer.h b/userspace/units/ptimer/nvgpu-ptimer.h index a71a6010d..0610f940e 100644 --- a/userspace/units/ptimer/nvgpu-ptimer.h +++ b/userspace/units/ptimer/nvgpu-ptimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -156,19 +156,24 @@ int test_ptimer_isr(struct unit_module *m, /** * Test specification for: test_ptimer_scaling * - * Description: Verify the scale_ptimer() and ptimer_scalingfactor10x() APIs. + * Description: Verify the nvgpu_ptimer_scale() API. * * Test Type: Feature Based, Boundary Values * - * Targets: scale_ptimer, ptimer_scalingfactor10x + * Targets: nvgpu_ptimer_scale + * + * Equivalence classes: + * Variable: timeout + * - Valid : 0 to U32_MAX/10 * * Input: None * * Steps: - * - Call the scale_ptimer() API with various input values and verify the - * returned value. - * - Call the ptimer_scalingfactor10x() API with various input values and verify - * the returned value. + * - Initialize ptimer source freq as per gv11b platform freq (i.e. 31250000U). + * - Call the nvgpu_ptimer_scale() API with below BVEC test values and verify the + * returned value and error code. + * Valid test values : 0, 1000, U32_MAX/10 + * Invalid test values : U32_MAX/10 + 1, U32_MAX/5, U32_MAX * * Output: * - UNIT_FAIL if encounters an error creating reg space