Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] drm/tests: KUNIT_ASSERT aborts while holding modeset locks in new tests - [Low] drm/tests: remove unused drm_auth.h and drm_file.h includes - [Low] drm/tests: colorop leaked on early init failure in color_pipeline test --
commit 40e2b43507596f3808aa229d7ee7b0f6dbdc124d Author: Maxime Ripard <[email protected]> drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() This commit adds six KUnit tests for drm_atomic_commit_fill_with_defaults(), covering resetting an active output, committing the reset state, derived color management and zpos flags, and avoiding modesets when re-applying the same configuration. > diff --git a/drivers/gpu/drm/tests/drm_atomic_test.c > b/drivers/gpu/drm/tests/drm_atomic_test.c > index 5e156d09e56f1..69f9071fc2d39 100644 > --- a/drivers/gpu/drm/tests/drm_atomic_test.c > +++ b/drivers/gpu/drm/tests/drm_atomic_test.c > @@ -2,12 +2,17 @@ > /* > * Kunit test for drm_atomic functions > */ > + > #include <drm/drm_atomic.h> > #include <drm/drm_atomic_state_helper.h> > #include <drm/drm_atomic_uapi.h> > +#include <drm/drm_auth.h> > +#include <drm/drm_colorop.h> > #include <drm/drm_encoder.h> > +#include <drm/drm_file.h> > #include <drm/drm_kunit_helpers.h> > #include <drm/drm_modeset_helper_vtables.h> > +#include <drm/drm_property.h> [Severity: Low] Are the drm_auth.h and drm_file.h includes needed here? Nothing in drm_atomic_test.c uses anything from either header, and struct drm_file is already forward-declared by drm_atomic.h. [ ... ] > +static void drm_test_check_fill_with_defaults(struct kunit *test) > +{ [ ... ] > + drm_modeset_acquire_init(&ctx, 0); > + > +retry_enable: > + ret = drm_kunit_helper_enable_crtc_connector(test, drm, > + priv->crtc, > + &priv->connector, > + mode, &ctx); > + if (ret == -EDEADLK) { > + ret = drm_modeset_backoff(&ctx); > + if (!ret) > + goto retry_enable; > + } > + KUNIT_ASSERT_EQ(test, ret, 0); > + > + state = drm_kunit_helper_atomic_state_alloc(test, drm, &ctx); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); > + > +retry_fill: > + ret = drm_atomic_commit_fill_with_defaults(NULL, state); > + if (ret == -EDEADLK) { > + drm_atomic_commit_clear(state); > + ret = drm_modeset_backoff(&ctx); > + if (!ret) > + goto retry_fill; > + } > + KUNIT_ASSERT_EQ(test, ret, 0); > + > + new_crtc_state = drm_atomic_get_new_crtc_state(state, priv->crtc); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_crtc_state); [Severity: Medium] Can a failing KUNIT_ASSERT_* here abort the test thread while modeset locks are still held? The same pattern appears in all six new tests. KUNIT_ASSERT_* exits the test kthread via kunit_try_catch_throw() -> kthread_exit() without unwinding the stack, skipping drm_modeset_drop_locks(&ctx) and drm_modeset_acquire_fini(&ctx). If an assertion fails after locks are acquired, do_exit() triggers debug_check_no_locks_held() and disables lockdep, and KUnit teardown hits WARN_ON(!list_empty(&lock->head)) in drm_modeset_lock_fini() because the locks remain linked on the exited thread's ctx.locked list. Dropping the locks and finalizing ctx before invoking KUNIT_ASSERT_* (for example via an unlock cleanup path) would avoid exiting with locks held. [ ... ] > +static void drm_test_check_fill_with_defaults_color_pipeline(struct kunit > *test) > +{ [ ... ] > + /* Freed through the funcs destroy hook by drm_mode_config_cleanup() */ > + colorop = kzalloc_obj(*colorop); > + KUNIT_ASSERT_NOT_NULL(test, colorop); > + > + ret = drm_plane_colorop_curve_1d_init(drm, colorop, priv->plane, > + &drm_atomic_test_colorop_funcs, > + > BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF), > + DRM_COLOROP_FLAG_ALLOW_BYPASS); > + KUNIT_ASSERT_EQ(test, ret, 0); [Severity: Low] Can this leak colorop if drm_plane_colorop_curve_1d_init() fails early? If drm_mode_object_add() fails inside drm_plane_colorop_init(), it returns before linking colorop onto dev->mode_config.colorop_list. KUNIT_ASSERT_EQ() then aborts the test, and drm_mode_config_cleanup() never calls colorop->funcs->destroy() for it. Allocating colorop with kunit_kzalloc() or drmm_kzalloc() and using a destroy hook that only calls drm_colorop_cleanup() would avoid both the leak and a double free if init fails after registration. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=4
