Skip to content

drm/amd/display: Introduce KUnit to Display Mode Library

Rodrigo Siqueira amd-gfx dri-devel linux-doc 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest8 patches 2 repliesIn review
  2. v48 patches 1 replySuperseded

Changes in v5 from the cover letter

- Rebase.
- Change the folder organization to better align with the display code.
- Fix the wrong CONFIG used in the FPU code.
- Drop unstable tests.

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8drm/amd/display: Introduce KUnit tests for fixed31_32 librarydrivers/gpu/drm/amd/display/Kconfig drivers/gpu/drm/amd/display/Makefile drivers/gpu/drm/amd/display/test/kunit/.kunitconfig +2 more+264 -10 replies
2/8drm/amd/display: Introduce KUnit tests to the bw_fixed librarydrivers/gpu/drm/amd/display/Kconfig drivers/gpu/drm/amd/display/test/kunit/.kunitconfig drivers/gpu/drm/amd/display/test/kunit/dc/dml/calcs/bw_fixed_test.c+337 -00 replies
3/8drm/amd/display: Introduce KUnit tests to display_rq_dlg_calc_20drivers/gpu/drm/amd/display/Kconfig drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c drivers/gpu/drm/amd/display/test/kunit/.kunitconfig +1 more+142 -00 replies
4/8drm/amd/display: Introduce KUnit tests to the display_mode_vba librarydrivers/gpu/drm/amd/display/test/kunit/Makefile drivers/gpu/drm/amd/display/test/kunit/dc/dml/display_mode_vba_test.c+746 -00 replies
5/8drm/amd/display: Introduce KUnit to dcn20/display_mode_vba_20 librarydrivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c drivers/gpu/drm/amd/display/test/kunit/dc/dml/dcn20/display_mode_vba_20_test.c+784 -00 replies
6/8drm/amd/display: Introduce KUnit tests for dcn20_fpudrivers/gpu/drm/amd/display/test/kunit/Makefile drivers/gpu/drm/amd/display/test/kunit/dc/dml/dcn20/dcn20_fpu_test.c+563 -10 replies
7/8drm/amd/display: Introduce KUnit tests to dc_dmub_srv librarydrivers/gpu/drm/amd/display/Kconfig drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c drivers/gpu/drm/amd/display/test/kunit/.kunitconfig +1 more+177 -02 replies
8/8Documentation/gpu: Add Display Core Unit Test documentationDocumentation/gpu/amdgpu/display/display-test.rst Documentation/gpu/amdgpu/display/index.rst+89 -00 replies

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by.

PatchDavid Gow
1/8R-b
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/8] drm/amd/display: Introduce KUnit to Display Mode Library

In 2022, we got a great patchset from a GSoC project introducing unit tests to the amdgpu display. Since version 3, this effort was put on hold, and now I'm attempting to revive it. I'll add part of the original cover letter at the bottom of this cover letter, but you can read all the original messages at:

https://lore.kernel.org/amd-gfx/[email protected]/

Changes since V3:
- Rebase and adjust conflicts.
- Rewrite part of the dc_dmub_srv_test to represent a real scenario that simulates some parameter configuration for using 4k144 and 4k240 displays.

Changes since v4:
- Rebase.
- Change the folder organization to better align with the display code.
- Fix the wrong CONFIG used in the FPU code.
- Drop unstable tests.

Thanks
Siqueira

Original cover letter

Hello,

This series is version 3 of the introduction of unit testing to the AMDPGU driver [1].

Our main goal is to bring unit testing to the AMD display driver; in particular, we'll focus on the Display Mode Library (DML) for DCN2.0, DMUB, 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 AMD display 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 [2] provides ease of use, but we are also working on integrating KUnit into IGT [3].

Since the second version, we've chosen a mix of approaches to integrate KUnit tests into amdgpu:
1. Tests that use static functions are included through guards [4].
2. Tests without static functions are included through a Makefile.

We understand that testing static functions is not ideal, but taking into consideration that this driver relies heavily on static functions with complex behavior which would benefit from unit testing, otherwise, black-box tested through public functions with dozens of arguments and sometimes high cyclomatic complexity.

The first seven patches represent what we intend to do for 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.

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 [5] later fixed by 9ad5d02c2a [6].

In this series, there's also an example of how unit tests can help avoid regressions and keep track of changes in behavior.

[..]

Isabella Basso (1):
drm/amd/display: Introduce KUnit tests to display_rq_dlg_calc_20

Magali Lemes (1):
drm/amd/display: Introduce KUnit tests for dcn20_fpu

Maíra Canal (5):
drm/amd/display: Introduce KUnit tests to the bw_fixed library drm/amd/display: Introduce KUnit tests to the display_mode_vba library drm/amd/display: Introduce KUnit to dcn20/display_mode_vba_20 library drm/amd/display: Introduce KUnit tests to dc_dmub_srv library Documentation/gpu: Add Display Core Unit Test documentation

Tales Aparecida (1):
drm/amd/display: Introduce KUnit tests for fixed31_32 library

 .../gpu/amdgpu/display/display-test.rst       |  88 ++
 Documentation/gpu/amdgpu/display/index.rst    |   1 +
 drivers/gpu/drm/amd/display/Kconfig           |  52 ++
 drivers/gpu/drm/amd/display/Makefile          |   2 +-
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  |   4 +
 .../dc/dml/dcn20/display_mode_vba_20.c        |   4 +
 .../dc/dml/dcn20/display_rq_dlg_calc_20.c     |   4 +
 .../drm/amd/display/test/kunit/.kunitconfig   |   9 +
 .../gpu/drm/amd/display/test/kunit/Makefile   |  18 +
 .../test/kunit/dc/basics/fixpt31_32_test.c    | 232 ++++++
 .../display/test/kunit/dc/dc_dmub_srv_test.c  | 159 ++++
 .../test/kunit/dc/dml/calcs/bw_fixed_test.c   | 323 ++++++++
 .../test/kunit/dc/dml/dcn20/dcn20_fpu_test.c  | 561 +++++++++++++
 .../dc/dml/dcn20/display_mode_vba_20_test.c   | 780 ++++++++++++++++++
 .../dml/dcn20/display_rq_dlg_calc_20_test.c   | 124 +++
 .../test/kunit/dc/dml/display_mode_vba_test.c | 741 +++++++++++++++++
 16 files changed, 3101 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/gpu/amdgpu/display/display-test.rst
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/.kunitconfig
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/Makefile
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/basics/fixpt31_32_test.c
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/dc_dmub_srv_test.c
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/dml/calcs/bw_fixed_test.c
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/dml/dcn20/dcn20_fpu_test.c
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/dml/dcn20/display_mode_vba_20_test.c
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/dml/dcn20/display_rq_dlg_calc_20_test.c
 create mode 100644 drivers/gpu/drm/amd/display/test/kunit/dc/dml/display_mode_vba_test.c
Signature · 1 line
2.43.0