Re: [PATCH v3 7/8] drm/amd/display: Introduce KUnit tests to dc_dmub_srv library

2022-09-14 Thread kernel test robot
Hi Maíra,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm/drm-next]
[also build test ERROR on drm-intel/for-linux-next drm-tip/drm-tip linus/master 
v6.0-rc5 next-20220914]
[cannot apply to drm-misc/drm-misc-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Ma-ra-Canal/drm-amd-display-Introduce-KUnit-to-Display-Mode-Library/20220913-000256
base:   git://anongit.freedesktop.org/drm/drm drm-next
config: loongarch-randconfig-r026-20220914 
(https://download.01.org/0day-ci/archive/20220915/202209150834.m0besply-...@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/50e2391775a6552a521c783a6fcd36942b906e3f
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Ma-ra-Canal/drm-amd-display-Introduce-KUnit-to-Display-Mode-Library/20220913-000256
git checkout 50e2391775a6552a521c783a6fcd36942b906e3f
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 
O=build_dir ARCH=loongarch SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All errors (new ones prefixed by >>):

   In file included from 
drivers/gpu/drm/amd/amdgpu/../display/dc/dc_dmub_srv.c:863:
   drivers/gpu/drm/amd/amdgpu/../display/dc/../tests/dc/dc_dmub_srv_test.c: In 
function 'populate_subvp_cmd_drr_info_test':
>> drivers/gpu/drm/amd/amdgpu/../display/dc/../tests/dc/dc_dmub_srv_test.c:260:9:
>>  error: implicit declaration of function 'populate_subvp_cmd_drr_info'; did 
>> you mean 'populate_subvp_cmd_drr_info_test'? 
>> [-Werror=implicit-function-declaration]
 260 | populate_subvp_cmd_drr_info(test_param->dc, 
test_param->subvp_pipe,
 | ^~~
 | populate_subvp_cmd_drr_info_test
   In file included from 
drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:32,
from 
drivers/gpu/drm/amd/amdgpu/../display/dc/dc_dmub_srv.c:31:
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h: At top 
level:
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:137:22: 
warning: 'SYNAPTICS_DEVICE_ID' defined but not used [-Wunused-const-variable=]
 137 | static const uint8_t SYNAPTICS_DEVICE_ID[] = "SYNA";
 |  ^~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:134:17: 
warning: 'DP_SINK_BRANCH_DEV_NAME_7580' defined but not used 
[-Wunused-const-variable=]
 134 | static const u8 DP_SINK_BRANCH_DEV_NAME_7580[] = "7580\x80u";
 | ^~~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:132:22: 
warning: 'DP_SINK_DEVICE_STR_ID_2' defined but not used 
[-Wunused-const-variable=]
 132 | static const uint8_t DP_SINK_DEVICE_STR_ID_2[] = {7, 1, 8, 7, 5, 0};
 |  ^~~
   drivers/gpu/drm/amd/amdgpu/../display/include/ddc_service_types.h:131:22: 
warning: 'DP_SINK_DEVICE_STR_ID_1' defined but not used 
[-Wunused-const-variable=]
 131 | static const uint8_t DP_SINK_DEVICE_STR_ID_1[] = {7, 1, 8, 7, 3, 0};
 |  ^~~
   cc1: some warnings being treated as errors


vim +260 drivers/gpu/drm/amd/amdgpu/../display/dc/../tests/dc/dc_dmub_srv_test.c

   246  
   247  KUNIT_ARRAY_PARAM(populate_subvp_cmd_drr_info, 
populate_subvp_cmd_drr_info_cases,
   248populate_subvp_cmd_drr_info_test_to_desc);
   249  
   250  static void populate_subvp_cmd_drr_info_test(struct kunit *test)
   251  {
   252  const struct populate_subvp_cmd_drr_info_test_case *test_param =
   253  test->param_value;
   254  struct dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2 *pipe_data;
   255  
   256  pipe_data = kunit_kzalloc(test,
   257sizeof(struct 
dmub_cmd_fw_assisted_mclk_switch_pipe_data_v2),
   258GFP_KERNEL);
   259  
 > 260  populate_subvp_cmd_drr_info(test_param->dc, 
 > test_param->subvp_pipe,
   261  test_param->vblank_pipe, pipe_data);
   262  
   263  KUNIT_EXPECT_EQ(test, test_param->drr_in_use,
   264  
pipe_data->pipe_config.vblank_data.drr_info.drr_in_use);
   265  KUNIT_EXPECT_EQ(test, 

[PATCH v3 7/8] drm/amd/display: Introduce KUnit tests to dc_dmub_srv library

2022-09-12 Thread Maíra Canal
Add unit test to the SubVP feature in order to avoid possible
regressions and assure the code robustness.

Signed-off-by: Maíra Canal 
---
 drivers/gpu/drm/amd/display/Kconfig   |  13 +
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  |   4 +
 .../gpu/drm/amd/display/tests/.kunitconfig|   1 +
 .../amd/display/tests/dc/dc_dmub_srv_test.c   | 285 ++
 4 files changed, 303 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dc_dmub_srv_test.c

diff --git a/drivers/gpu/drm/amd/display/Kconfig 
b/drivers/gpu/drm/amd/display/Kconfig
index 039227baedfa..f667b954f89f 100644
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@ -93,4 +93,17 @@ config AMD_DC_BASICS_KUNIT_TEST
 
If unsure, say N.
 
+config AMD_DC_KUNIT_TEST
+   bool "Enable KUnit tests for the 'utils' sub-component of DAL" if 
!KUNIT_ALL_TESTS
+   depends on DRM_AMD_DC && KUNIT
+   default KUNIT_ALL_TESTS
+   help
+   Enables unit tests for the basics folder of Display Core. Only 
useful for
+   kernel devs running KUnit.
+
+   For more information on KUnit and unit tests in general please 
refer to
+   the KUnit documentation in Documentation/dev-tools/kunit/.
+
+   If unsure, say N.
+
 endmenu
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index 7b765efe0825..2e8d5549a087 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -858,3 +858,7 @@ void dc_dmub_srv_log_diagnostic_data(struct dc_dmub_srv 
*dc_dmub_srv)
diag_data.is_cw0_enabled,
diag_data.is_cw6_enabled);
 }
+
+#if IS_ENABLED(CONFIG_AMD_DC_KUNIT_TEST)
+#include "../tests/dc/dc_dmub_srv_test.c"
+#endif
diff --git a/drivers/gpu/drm/amd/display/tests/.kunitconfig 
b/drivers/gpu/drm/amd/display/tests/.kunitconfig
index eb6f81601757..4c5861ad58bd 100644
--- a/drivers/gpu/drm/amd/display/tests/.kunitconfig
+++ b/drivers/gpu/drm/amd/display/tests/.kunitconfig
@@ -4,5 +4,6 @@ CONFIG_DRM=y
 CONFIG_DRM_AMDGPU=y
 CONFIG_DRM_AMD_DC=y
 CONFIG_AMD_DC_BASICS_KUNIT_TEST=y
+CONFIG_AMD_DC_KUNIT_TEST=y
 CONFIG_DCE_KUNIT_TEST=y
 CONFIG_DML_KUNIT_TEST=y
diff --git a/drivers/gpu/drm/amd/display/tests/dc/dc_dmub_srv_test.c 
b/drivers/gpu/drm/amd/display/tests/dc/dc_dmub_srv_test.c
new file mode 100644
index ..3f1f15397090
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/tests/dc/dc_dmub_srv_test.c
@@ -0,0 +1,285 @@
+// SPDX-License-Identifier: MIT
+/*
+ * KUnit tests for dc_dmub_srv.c
+ *
+ * Copyright (C) 2022, Maíra Canal 
+ */
+
+#include 
+#include "dc_dmub_srv.h"
+
+struct populate_subvp_cmd_drr_info_test_case {
+   const char *desc;
+   struct dc *dc;
+   struct pipe_ctx *subvp_pipe;
+   struct pipe_ctx *vblank_pipe;
+   const u8 drr_in_use;
+   const u8 drr_window_size_ms;
+   const u16 min_vtotal_supported;
+   const u16 max_vtotal_supported;
+   const u8 use_ramping;
+};
+
+struct populate_subvp_cmd_drr_info_test_case 
populate_subvp_cmd_drr_info_cases[] = {
+   {
+   .desc = "Same Clock Frequency",
+   .dc = &(struct dc) {
+   .caps = {
+   .subvp_prefetch_end_to_mall_start_us = 0,
+   }
+   },
+   .subvp_pipe = &(struct pipe_ctx) {
+   .stream = &(struct dc_stream_state) {
+   .timing = {
+   .h_total = 2784,
+   .v_addressable = 1080,
+   .pix_clk_100hz = 1855800,
+   },
+   .mall_stream_config = {
+   .paired_stream = &(struct 
dc_stream_state) {
+   .timing = {
+   .h_total = 3600,
+   .v_total = ,
+   .v_addressable = 1080,
+   .v_front_porch = 3,
+   .pix_clk_100hz = 
1855800,
+   },
+   },
+   },
+   },
+   },
+   .vblank_pipe = &(struct pipe_ctx) {
+   .stream = &(struct dc_stream_state) {
+   .timing = {
+   .h_total = 2784,
+   .v_total = ,
+   .v_addressable = 1080,
+   .pix_clk_100hz = 1855800,
+   },