Draft: ⭐ for-amd-all-guarded | [PATCH 0/5] drm/amd/display: Introduce KUnit to Display Mode Library
git format-patch -$(git rev-list --count for-amd-prereq..HEAD) --base amd/amd-staging-drm-next --cover-letter -o /tmp/$(git name-rev --name-only HEAD)
<!-- isso é só pra eu ver o tamanho das linhas -->
00000000011111111112222222222333333333344444444445555555555666666666677777777778
12345678901234567890123456789012345678901234567890123456789012345678901234567890
From f61dc49f1401af24bddfe56dfb2d1570f759b82c Mon Sep 17 00:00:00 2001
From: "Tales Aparecida" <tales.aparecida@gmail.com>
Date: Wed, 5 Aug 2022 12:00:00 -0300
Subject: [PATCH 0/5] drm/amd/display: Introduce KUnit to Display Mode Library
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Hello,
This series is the consolidation of a RFC sent earlier this year [RFC] bringing
unit testing to the AMDPGU driver. [gsoc]
Our main goal is to bring unit testing to the AMDPGU driver; in particular,
we'll focus on the Display Mode Library (DML) for DCN2.0 and some of the DCE
functions. This implementation intends to help developers to recognize bugs
before they are merged into the mainline and also makes it possible for future
code refactors of the AMDGPU driver.
For the implementation of the tests, we decided to go with the Kernel Unit
Testing Framework (KUnit). KUnit makes it possible to run test suites on
kernel boot or load the tests as a module. It reports all test case results
through a TAP (Test Anything Protocol) in the kernel log. Moreover, KUnit
unifies the test structure and provides tools to simplify the testing for
developers and CI systems.
In regards to CI pipelines, we believe kunit_tool[kunit_tool] provides ease of
use, but we are also working on integrating Kunit into IGT, for those already
depending on the tool [igt_patch].
This series depends on a couple of Kunit patches already merged into torvalds/master,
which themselves depends on older patches:
61695f8c5d51 kunit: split resource API from test.h into new resource.h
2852ca7fba9f panic: Taint kernel if tests are run
cfc1d277891e module: Move all into module/
cdebea6968fa kunit: split resource API impl from test.c into new resource.c
cae56e1740f5 kunit: rename print_subtest_{start,end} for clarity (s/subtest/suite)
1cdba21db2ca kunit: add ability to specify suite-level init and exit functions
c272612cb4a2 kunit: Taint the kernel when KUnit tests are run
3d6e44623841 kunit: unify module and builtin suite definitions
a02353f49162 kunit: bail out of test filtering logic quicker if OOM
1b11063d32d7 kunit: fix executor OOM error handling logic on non-UML
e5857d396f35 kunit: flatten kunit_suite*** to kunit_suite** in .kunit_test_suites
94681e289bf5 kunit: executor: Fix a memory leak on failure in kunit_filter_tests
You can get a for branch ready for compilation at https://gitlab.freedesktop.org/isinyaaa/linux/-/tags/introduce-kunit-for-amd-v1
The first two patches add KUnit tests to fixed_31_32 and bw_fixed functions.
These patches represent what we intend to do on the rest of the DML modules:
systematic testing of the DML functions, especially mathematically
complicated functions. Also, it shows how simple it is to add new tests to the
DML.
We are using the one of the simplest approaches to integrate kunit tests [kunit_static]
Among the tests we highlight the dcn20_fpu_test, which, had it existed then,
could catch the defects introduced to dcn20_fpu.c by 8861c27a6c [dcn20_bug] later fixed
by 9ad5d02c2a [dcn20_fix].
In this series there's an example of how unit tests can help avoiding regressions.
Applying this series on top of the current amd-staging-drm-next (2305916dca04)
and running its tests will result on a failure in the `dc_dmub_srv` test,
you can verify that with:
$ ./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig=drivers/gpu/drm/amd/display/tests
... [20:19:00] # Subtest: populate_subvp_cmd_drr_info_test [20:19:00] # populate_subvp_cmd_drr_info_test: pass:0 fail:5 skip:0 total:5 [20:19:00] not ok 1 - populate_subvp_cmd_drr_info_test [20:19:00] ======== [FAILED] populate_subvp_cmd_drr_info_test ========= [20:19:00] # Subtest: dc_dmub_srv [20:19:00] 1..1 [20:19:00] # Totals: pass:0 fail:5 skip:0 total:5 [20:19:00] not ok 8 - dc_dmub_srv [20:19:00] =================== [FAILED] dc_dmub_srv =================== [20:19:00] ============================================================ [20:19:00] Testing complete. Passed: 59, Failed: 5, Crashed: 0, Skipped: 0, Errors: 0
Full output at: https://share.riseup.net/#ta5pInvi0I7CqFIPU3yJ4w
This is due a known regression introduced by 5da7f4134357b0d782e7542c6789334ac82104ac [dmub_bug],
currently being worked on [dmub_fix].
As an exercise, you can revert the offending patch and run the tests again:
$ git revert 5da7f4134357b0d782e7542c6789334ac82104ac
$ ./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig=drivers/gpu/drm/amd/display/tests
<!-- output esperado: sucesso -->
Thanks in advance for your time taking a look and sending any feedback!
Best regards,
Isabella Basso, Magali Lemes, Maíra Canal, and Tales Aparecida
[RFC] https://lore.kernel.org/amd-gfx/20220608010709.272962-1-maira.canal@usp.br/
[gsoc] https://summerofcode.withgoogle.com/programs/2022/organizations/xorg-foundation
[kunit_tool] https://www.kernel.org/doc/html/latest/dev-tools/kunit/kunit-tool.html
[igt_patch] <!-- This would be nice -->
[kunit_static] https://docs.kernel.org/dev-tools/kunit/usage.html#testing-static-functions
[dcn20_bug] https://lore.kernel.org/amd-gfx/20220603185042.3408844-6-Rodrigo.Siqueira@amd.com/
[dcn20_fix] https://lore.kernel.org/amd-gfx/20220608164856.1870594-1-sunpeng.li@amd.com/
[dmub_bug] https://lore.kernel.org/amd-gfx/20220708052650.1029150-1-alexander.deucher@amd.com/
[dmub_fix] https://lore.kernel.org/amd-gfx/?q=nq%3AFixes+5da7f4134357
[kunit_patch] https://groups.google.com/g/kunit-dev/c/hbJbh8L37FU/m/EmszZE9qBAAJ
Magali Lemes (1):
drm/amd/display: Add KUnit tests for dcn20_fpu
Maíra Canal (3):
drm/amd/display: Move bw_fixed macros to header file
drm/amd/display: Introduce KUnit tests to the bw_fixed library
drm/amd/display: Introduce KUnit tests to the display_mode_vba library
Tales Aparecida (1):
drm/amd/display: Introduce KUnit tests for fixed31_32 library
drivers/gpu/drm/amd/display/Kconfig | 25 +
.../drm/amd/display/dc/basics/fixpt31_32.c | 4 +
.../drm/amd/display/dc/dml/calcs/bw_fixed.c | 15 +-
.../drm/amd/display/dc/dml/dcn20/dcn20_fpu.c | 4 +
.../drm/amd/display/dc/dml/display_mode_vba.c | 3 +
drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h | 12 +
.../gpu/drm/amd/display/tests/.kunitconfig | 7 +
.../dc/basics/dc_basics_fixpt31_32_test.c | 234 ++++++++
.../tests/dc/dml/calcs/bw_fixed_test.c | 328 ++++++++++
.../tests/dc/dml/dcn20/dcn20_fpu_test.c | 558 ++++++++++++++++++
.../tests/dc/dml/display_mode_vba_test.c | 490 +++++++++++++++
11 files changed, 1668 insertions(+), 12 deletions(-)
create mode 100644 drivers/gpu/drm/amd/display/tests/.kunitconfig
create mode 100644 drivers/gpu/drm/amd/display/tests/dc/basics/dc_basics_fixpt31_32_test.c
create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/calcs/bw_fixed_test.c
create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/dcn20/dcn20_fpu_test.c
create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/display_mode_vba_test.c
base-commit: 2305916dca043ed69bd464f74a886b0216780aa6
prerequisite-patch-id: 60af3dadcfd4a778f10dd09fafbde6061d98528b
prerequisite-patch-id: 92d9259125f2982da5945be995b4ae2af1ca7c32
prerequisite-patch-id: 9664d8e1e71e5541aa39094992aa575bc8c5563b
prerequisite-patch-id: ba795b981f3e94890540f452e658e28408b500d2
prerequisite-patch-id: abd5e51f483a9afb08af468db043e2ebc7ce6867
prerequisite-patch-id: 8d804dd9cd62213fee48ead530b89b3f9c8bbbc2
prerequisite-patch-id: 676824fea3af9ef8a4bb8a5ee79a35709b641ef0
prerequisite-patch-id: 83185f6c5da6070e7b0b608bc705a2d3bf295ae6
--
2.25.1