mbox series

[v4,0/8] drm/amd/display: Introduce KUnit to Display Mode Library

Message ID 20240126155022.1184856-1-Rodrigo.Siqueira@amd.com (mailing list archive)
Headers show
Series drm/amd/display: Introduce KUnit to Display Mode Library | expand

Message

Rodrigo Siqueira Jordao Jan. 26, 2024, 3:48 p.m. UTC
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/20220912155919.39877-1-mairacanal@riseup.net/

Anyway, this new version changes are:
- 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.

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 +
 drivers/gpu/drm/amd/display/tests/Makefile    |  18 +
 .../display/tests/dc/basics/fixpt31_32_test.c | 232 +++++
 .../amd/display/tests/dc/dc_dmub_srv_test.c   | 159 ++++
 .../tests/dc/dml/calcs/bw_fixed_test.c        | 323 +++++++
 .../tests/dc/dml/dcn20/dcn20_fpu_test.c       | 561 +++++++++++
 .../dc/dml/dcn20/display_mode_vba_20_test.c   | 888 ++++++++++++++++++
 .../dml/dcn20/display_rq_dlg_calc_20_test.c   | 124 +++
 .../tests/dc/dml/display_mode_vba_test.c      | 741 +++++++++++++++
 15 files changed, 3200 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/gpu/amdgpu/display/display-test.rst
 create mode 100644 drivers/gpu/drm/amd/display/tests/Makefile
 create mode 100644 drivers/gpu/drm/amd/display/tests/dc/basics/fixpt31_32_test.c
 create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dc_dmub_srv_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/dcn20/display_mode_vba_20_test.c
 create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/dcn20/display_rq_dlg_calc_20_test.c
 create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/display_mode_vba_test.c

Comments

Christian König Jan. 29, 2024, 3:26 p.m. UTC | #1
That we include so many C files with relative paths seems to be odd.

Apart from that looks good to me.

Christian.

Am 26.01.24 um 16:48 schrieb Rodrigo Siqueira:
> 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/20220912155919.39877-1-mairacanal@riseup.net/
>
> Anyway, this new version changes are:
> - 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.
>
> 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 +
>   drivers/gpu/drm/amd/display/tests/Makefile    |  18 +
>   .../display/tests/dc/basics/fixpt31_32_test.c | 232 +++++
>   .../amd/display/tests/dc/dc_dmub_srv_test.c   | 159 ++++
>   .../tests/dc/dml/calcs/bw_fixed_test.c        | 323 +++++++
>   .../tests/dc/dml/dcn20/dcn20_fpu_test.c       | 561 +++++++++++
>   .../dc/dml/dcn20/display_mode_vba_20_test.c   | 888 ++++++++++++++++++
>   .../dml/dcn20/display_rq_dlg_calc_20_test.c   | 124 +++
>   .../tests/dc/dml/display_mode_vba_test.c      | 741 +++++++++++++++
>   15 files changed, 3200 insertions(+), 1 deletion(-)
>   create mode 100644 Documentation/gpu/amdgpu/display/display-test.rst
>   create mode 100644 drivers/gpu/drm/amd/display/tests/Makefile
>   create mode 100644 drivers/gpu/drm/amd/display/tests/dc/basics/fixpt31_32_test.c
>   create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dc_dmub_srv_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/dcn20/display_mode_vba_20_test.c
>   create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/dcn20/display_rq_dlg_calc_20_test.c
>   create mode 100644 drivers/gpu/drm/amd/display/tests/dc/dml/display_mode_vba_test.c
>