Hi, On Tue, Nov 14, 2023 at 05:18:08PM +0100, Marco Pagani wrote: > On 2023-11-10 15:41, Maxime Ripard wrote: > > On Wed, Nov 08, 2023 at 02:42:03PM +0100, Marco Pagani wrote: > >> This patch introduces an initial KUnit test suite for GEM objects > >> backed by shmem buffers. > >> > >> Suggested-by: Javier Martinez Canillas <javierm@xxxxxxxxxx> > >> Signed-off-by: Marco Pagani <marpagan@xxxxxxxxxx> > >> > >> v2: > >> - Improved description of test cases > >> - Cleaner error handling using KUnit actions > >> - Alphabetical order in Kconfig and Makefile > >> --- > >> drivers/gpu/drm/Kconfig | 9 +- > >> drivers/gpu/drm/tests/Makefile | 5 +- > >> drivers/gpu/drm/tests/drm_gem_shmem_test.c | 381 +++++++++++++++++++++ > >> 3 files changed, 389 insertions(+), 6 deletions(-) > >> create mode 100644 drivers/gpu/drm/tests/drm_gem_shmem_test.c > >> > >> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > >> index 3eee8636f847..a2551c8c393a 100644 > >> --- a/drivers/gpu/drm/Kconfig > >> +++ b/drivers/gpu/drm/Kconfig > >> @@ -76,14 +76,15 @@ config DRM_KUNIT_TEST > >> tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS > >> depends on DRM && KUNIT > >> select PRIME_NUMBERS > >> + select DRM_BUDDY > >> select DRM_DISPLAY_DP_HELPER > >> select DRM_DISPLAY_HELPER > >> - select DRM_LIB_RANDOM > >> - select DRM_KMS_HELPER > >> - select DRM_BUDDY > >> + select DRM_EXEC > >> select DRM_EXPORT_FOR_TESTS if m > >> + select DRM_GEM_SHMEM_HELPER > >> + select DRM_KMS_HELPER > >> select DRM_KUNIT_TEST_HELPERS > >> - select DRM_EXEC > >> + select DRM_LIB_RANDOM > >> default KUNIT_ALL_TESTS > >> help > >> This builds unit tests for DRM. This option is not useful for > >> diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile > >> index ba7baa622675..d6183b3d7688 100644 > >> --- a/drivers/gpu/drm/tests/Makefile > >> +++ b/drivers/gpu/drm/tests/Makefile > >> @@ -9,15 +9,16 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ > >> drm_connector_test.o \ > >> drm_damage_helper_test.o \ > >> drm_dp_mst_helper_test.o \ > >> + drm_exec_test.o \ > >> drm_format_helper_test.o \ > >> drm_format_test.o \ > >> drm_framebuffer_test.o \ > >> + drm_gem_shmem_test.o \ > >> drm_managed_test.o \ > >> drm_mm_test.o \ > >> drm_modes_test.o \ > >> drm_plane_helper_test.o \ > >> drm_probe_helper_test.o \ > >> - drm_rect_test.o \ > >> - drm_exec_test.o > >> + drm_rect_test.o > > > > Thanks for reordering the tests and symbols, but they should part of a > > preliminary patch. > > > > Okay, I'll send it as a separate patch before v3. Thanks for taking care of this. [...] > >> +/* > >> + * Wrappers to avoid an explicit type casting when passing action > >> + * functions to kunit_add_action(). > >> + */ > >> +static void kfree_wrapper(void *p) > >> +{ > >> + kfree(p); > >> +} > >> + > >> +static void sg_free_table_wrapper(void *sgt) > >> +{ > >> + sg_free_table(sgt); > >> +} > >> + > >> +static void drm_gem_shmem_free_wrapper(void *shmem) > >> +{ > >> + drm_gem_shmem_free(shmem); > >> +} > > > > I think you need to explicitly cast the pointer (or do a temporary > > assignment to the proper type) to avoid a compiler warning. > > > > Do you mean like: > > static void drm_gem_shmem_free_wrapper(void *shmem) > { > drm_gem_shmem_free((struct drm_gem_shmem_object *)shmem); > } yeah, or static void drm_gem_shmem_free_wrapper(void *ptr) { struct drm_gem_shmem_object *shmem = ptr; drm_gem_shmem_free(shmem); } > I built the current version with clang 16.0.6 and gcc 13.2.1 but got > no cast warnings. Clang spotted an uninitialized variable, though. The same thing happened to me, gcc didn't spot those issues but Intel's build bot did. They might run with extra warnings. Maxime
Attachment:
signature.asc
Description: PGP signature