From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v13 4/9] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults()
Date: Thu, 03 Dec 2026 15:21:28 +0000 [thread overview]
Message-ID: <sashiko-outbox-248098@kernel.org> (raw)
In-Reply-To: <20261203-drm-reset-state-flag-v13-4-b09f19f64e64@kernel.org>
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 <mripard@kernel.org>
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/20261203-drm-reset-state-flag-v13-0-b09f19f64e64@kernel.org?part=4
next prev parent reply other threads:[~2026-12-03 15:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 14:07 [PATCH v13 0/9] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-12-03 14:07 ` [PATCH v13 1/9] drm/lease: Add a helper to tell whether a lease was revoked Maxime Ripard
2026-12-03 14:23 ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 2/9] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-12-03 14:07 ` [PATCH v13 3/9] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-12-03 15:02 ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 4/9] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() Maxime Ripard
2026-12-03 15:21 ` sashiko-bot [this message]
2026-12-03 14:07 ` [PATCH v13 5/9] drm/amd/display: Take over the current stream and dc_state Maxime Ripard
2026-12-03 15:40 ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 6/9] drm/vc4: Carry the HVS channel over to created CRTC states Maxime Ripard
2026-12-03 16:06 ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 7/9] drm/msm/dpu1: Carry the mixers " Maxime Ripard
2026-12-03 16:36 ` sashiko-bot
2026-12-03 14:07 ` [PATCH v13 8/9] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-12-03 14:07 ` [PATCH v13 9/9] drm/vkms: Add driver-specific plane property for testing Maxime Ripard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-248098@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=mripard@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox