All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 11/14] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults()
Date: Fri, 16 Oct 2026 07:52:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-173975@kernel.org> (raw)
In-Reply-To: <20261016-drm-reset-state-flag-v5-11-dad2d64b693b@kernel.org>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] drm/tests: modeset lock leak on KUNIT_ASSERT failure
- [Medium] drm/tests: mock connector lacks atomic_create_state causing test failure
- [Medium] drm/tests: plane is not enabled before reset in fill_with_defaults test
--

commit 181cb0103d707708bd4c194386205faf1d9fca47
Author: Maxime Ripard <mripard@kernel.org>

drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults()

This commit adds KUnit test coverage for
drm_atomic_commit_fill_with_defaults() to ensure it properly resets CRTC,
plane, and connector states. The tests verify both the reset state and a
subsequent modeset commit sequence.

> diff --git a/drivers/gpu/drm/tests/drm_atomic_test.c b/drivers/gpu/drm/tests/drm_atomic_test.c
> index ea91bec6569e6..988ec5523147d 100644
> --- a/drivers/gpu/drm/tests/drm_atomic_test.c
> +++ b/drivers/gpu/drm/tests/drm_atomic_test.c
[ ... ]
> @@ -140,13 +140,137 @@ static struct kunit_case drm_atomic_get_connector_for_encoder_tests[] = {
>  /*
>   * Test that after enabling a CRTC, plane, and connector, filling with
>   * defaults produces a state where all objects are disabled: CRTC is
[ ... ]
> +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);

[Severity: Medium]
The commit message states the test "enables a CRTC, plane, and connector",
but drm_kunit_helper_enable_crtc_connector() configures the CRTC and
connector without assigning a framebuffer or CRTC to the plane.

Since the plane is never actively enabled before the reset, does this test
only verify that an already-disabled plane remains disabled rather than
testing the teardown transition of an active plane?

> +	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);
> +
> +	ret = drm_atomic_commit_fill_with_defaults(state);

[Severity: Medium]
Will drm_atomic_commit_fill_with_defaults() unconditionally return
-EOPNOTSUPP here?

The mock connector initialized with drm_atomic_init_connector_funcs lacks
the .atomic_create_state hook. Since drm_atomic_commit_fill_with_defaults()
iterates over connectors and requires this hook, this seems like it will
unconditionally fail the test.

> +	KUNIT_ASSERT_EQ(test, ret, 0);

[Severity: Medium]
If this assertion (or any subsequent KUNIT_ASSERT_*) fails, it forces an
immediate return from the function. 

Since drm_modeset_acquire_init() and drm_kunit_helper_enable_crtc_connector()
acquired modeset locks, would an early return bypass
drm_modeset_drop_locks(&ctx) and leak the ww_mutexes and ww_acquire_ctx?

Should KUNIT_EXPECT_* macros combined with a cleanup goto label or KUnit
deferred actions be used instead of KUNIT_ASSERT_* to ensure locks are
released?

> +
> +	new_crtc_state = drm_atomic_get_new_crtc_state(state, priv->crtc);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, new_crtc_state);
[ ... ]
> +static void drm_test_check_fill_with_defaults_commit(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);

[Severity: Medium]
Similar to the first test, this helper omits enabling the plane before
performing the reset round-trip. Could this leave the plane teardown
untested as well?

> +	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);
> +
> +	ret = drm_atomic_commit_fill_with_defaults(state);
> +	KUNIT_ASSERT_EQ(test, ret, 0);

[Severity: Medium]
As in the previous function, an assertion failure here would skip the
cleanup block at the end of the function. Can this leak the modeset locks
acquired above?

> +
> +	state->allow_modeset = true;
> +
> +	ret = drm_atomic_commit(state);
> +	KUNIT_EXPECT_EQ(test, ret, 0);
> +
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016-drm-reset-state-flag-v5-0-dad2d64b693b@kernel.org?part=11

  reply	other threads:[~2026-10-16  7:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  7:31 [PATCH v5 00/14] drm: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 01/14] drm/atomic: Switch to krealloc_array() in drm_atomic_get_private_obj_state() Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 02/14] drm/atomic: Use __GFP_ZERO instead of explicit memset " Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 03/14] drm/atomic: Use __GFP_ZERO instead of explicit memset in drm_atomic_get_connector_state() Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 04/14] drm/atomic: Create function to insert CRTC state into a commit Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 05/14] drm/atomic: Create function to insert plane " Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 06/14] drm/atomic: Create function to insert colorop " Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 07/14] drm/atomic: Create function to insert private obj " Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 08/14] drm/atomic: Create function to insert connector " Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 09/14] drm/atomic: Add drm_atomic_implements_create_state() helper Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 10/14] drm/atomic: Allow filling a commit with pristine object states Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 11/14] drm/tests: atomic: Add tests for drm_atomic_commit_fill_with_defaults() Maxime Ripard
2026-10-16  7:52   ` sashiko-bot [this message]
2026-10-16  7:31 ` [PATCH v5 12/14] drm/atomic-uapi: Add DRM_MODE_ATOMIC_RESET flag Maxime Ripard
2026-10-16  7:54   ` sashiko-bot
2026-10-16  7:31 ` [PATCH v5 13/14] drm/vkms: Switch container_of helpers to container_of_const Maxime Ripard
2026-10-16  7:31 ` [PATCH v5 14/14] drm/vkms: Add driver-specific plane property for testing Maxime Ripard
2026-10-16  7:49   ` sashiko-bot

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-173975@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 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.