All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/3] drm/amd/display: Introduce KUnit to Display Mode Library
@ 2022-06-08  1:07 ` Maíra Canal
  0 siblings, 0 replies; 32+ messages in thread
From: Maíra Canal @ 2022-06-08  1:07 UTC (permalink / raw)
  To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
	christian.koenig, Dmytro Laktyushkin, Jun Lei, Nicholas Choi,
	Harrison Chiu, Mark Yacoub, Sean Paul, Daniel Vetter,
	Javier Martinez Canillas, Isabella Basso, magalilemes00,
	tales.aparecida, mwen, andrealmeid, David Gow, Daniel Latypov,
	brendanhiggins
  Cc: Maíra Canal, kunit-dev, dri-devel, amd-gfx, linux-kernel

This RFC is a preview of the work being developed by Isabella Basso [1],
Maíra Canal [2], and Tales Lelo [3], as part of their Google Summer of Code
projects [4], and Magali Lemes [5], as part of her capstone project.

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. The modern AMD Linux kernel graphics driver is the single largest
driver in the mainline Linux codebase [6]. As AMD releases new GPU models,
the size of AMDGPU drivers is only becoming even larger.

Assuring the drivers' quality and reliability becomes a complex task without
systematic testing, especially for graphic drivers - which usually involve
tons of complex calculations. Also, keeping bugs away becomes an increasingly
hard task with the introduction of new code. Moreover, developers might want
to refactor old code without fear of the introduction of new issues.

In that sense, it is possible to argue for the benefits of implementing unit
testing at the AMDGPU drivers. This implementation will 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.

When analyzing the AMDGPU driver, a particular part of the driver highlights
itself as a good candidate for the implementation of unit tests: the Display
Mode Library (DML), as it is focused on mathematical operations.

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.

That said, we developed a little snippet on what we intend to develop in our
summer. We planned the basic structure on how the tests will be introduced
into the codebase and, on the concern of the CI systems, developed a structure
where the unit tests can be introduced as modules and run on IGT (the IGT patch
will be introduced soon).

The way the modules are implemented might seem a little unusual for KUnit
developers. We need to call the KUnit init function inside the AMDGPU stack,
otherwise, the test won't compile as a module. So, the solution to this
problem was based on the unit tests for the Thunderbolt driver, which uses
KUnit and also tests a physical driver.

As kunit_test_suites() defines itself as an init_module(), it conflicts with
the existing one at amdgpu_drv. So, if we use kunit_test_suites(), we won't
be able to compile the tests as modules and, therefore, won't be able to use
IGT to run the tests. This problem with kunit_test_suites() was already
discussed in the KUnit mailing list, as can be seen in [7].

The first patch configures the basic structure of the KUnit Tests, setting the
proper Makefile, Kconfig, and init function. It also contains a simple test
involving DML logging, which is the pretext for building the testing structure.

The second patch adds KUnit tests to bw_fixed functions. This patch represents
what we intend to do on the rest of the DML modules: systematic testing of the
public functions of the DML, especially mathematically complicated functions.
Also, it shows how simple it is to add new tests to the DML with the structure
we built.

Any feedback or ideas for the project are welcome!

[1] https://crosscat.me
[2] https://mairacanal.github.io
[3] https://tales-aparecida.github.io/
[4] https://summerofcode.withgoogle.com/programs/2022/organizations/xorg-foundation
[5] https://magalilemes.github.io/
[6] https://www.phoronix.com/scan.php?page=news_item&px=AMDGPU-Closing-4-Million
[7] https://groups.google.com/g/kunit-dev/c/hbJbh8L37FU/m/EmszZE9qBAAJ

- Isabella Basso, Magali Lemes, Maíra Canal, and Tales Lelo

Magali Lemes (1):
  drm/amd/display: Introduce KUnit tests to the bw_fixed library

Maíra Canal (2):
  drm/amd/display: Introduce KUnit to DML
  drm/amd/display: Move bw_fixed macros to header file

 drivers/gpu/drm/amd/display/Kconfig           |   1 +
 .../gpu/drm/amd/display/amdgpu_dm/Makefile    |   5 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   3 +
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   3 +
 .../drm/amd/display/amdgpu_dm/tests/Kconfig   |  41 +++
 .../drm/amd/display/amdgpu_dm/tests/Makefile  |  18 +
 .../amdgpu_dm/tests/calcs/bw_fixed_test.c     | 322 ++++++++++++++++++
 .../amdgpu_dm/tests/display_mode_lib_test.c   |  83 +++++
 .../amd/display/amdgpu_dm/tests/dml_test.c    |  26 ++
 .../amd/display/amdgpu_dm/tests/dml_test.h    |  21 ++
 .../drm/amd/display/dc/dml/calcs/bw_fixed.c   |  14 +-
 drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h |  14 +
 12 files changed, 538 insertions(+), 13 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/Kconfig
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/Makefile
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/calcs/bw_fixed_test.c
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/display_mode_lib_test.c
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/dml_test.c
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/tests/dml_test.h

-- 
2.36.1


^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2022-06-22 22:56 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08  1:07 [RFC 0/3] drm/amd/display: Introduce KUnit to Display Mode Library Maíra Canal
2022-06-08  1:07 ` Maíra Canal
2022-06-08  1:07 ` [RFC 1/3] drm/amd/display: Introduce KUnit to DML Maíra Canal
2022-06-08  1:07   ` Maíra Canal
2022-06-08  2:36   ` Daniel Latypov
2022-06-08  2:36     ` Daniel Latypov
2022-06-08  2:36     ` Daniel Latypov
2022-06-15 15:05     ` Maíra Canal
2022-06-15 15:05       ` Maíra Canal
2022-06-15 15:05       ` Maíra Canal
2022-06-08  1:07 ` [RFC 2/3] drm/amd/display: Move bw_fixed macros to header file Maíra Canal
2022-06-08  1:07   ` Maíra Canal
2022-06-08  1:07 ` [RFC 3/3] drm/amd/display: Introduce KUnit tests to the bw_fixed library Maíra Canal
2022-06-08  1:07   ` Maíra Canal
2022-06-16 14:39 ` [RFC 0/3] drm/amd/display: Introduce KUnit to Display Mode Library David Gow
2022-06-16 14:39   ` David Gow
2022-06-16 14:39   ` David Gow
2022-06-16 22:41   ` Maíra Canal
2022-06-16 22:41     ` Maíra Canal
2022-06-16 22:41     ` Maíra Canal
2022-06-17  7:55     ` David Gow
2022-06-17  7:55       ` David Gow
2022-06-17  7:55       ` David Gow
2022-06-17 20:24       ` Maíra Canal
2022-06-17 20:24         ` Maíra Canal
2022-06-17 20:24         ` Maíra Canal
2022-06-18  9:08         ` David Gow
2022-06-18  9:08           ` David Gow
2022-06-18  9:08           ` David Gow
2022-06-22 22:55           ` Rodrigo Siqueira Jordao
2022-06-22 22:55             ` Rodrigo Siqueira Jordao
2022-06-22 22:55             ` Rodrigo Siqueira Jordao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.