mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maíra Canal" <mcanal@igalia.com>
To: Maxime Ripard <mripard@kernel.org>,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] drm/vc4: tests: Use return instead of assert
Date: Sun, 23 Mar 2025 15:12:59 -0300	[thread overview]
Message-ID: <d9e7d2a0-d074-4c21-b1a5-70ad93a98ea1@igalia.com> (raw)
In-Reply-To: <20250318-drm-vc4-kunit-failures-v1-1-779864d9ab37@kernel.org>

Hi Maxime,

On 18/03/25 11:17, Maxime Ripard wrote:
> The vc4_mock_atomic_add_output() and vc4_mock_atomic_del_output() assert
> that the functions they are calling didn't fail. Since some of them can
> return EDEADLK, we can't properly deal with it.
> 
> Since both functions are expected to return an int, and all caller check
> the return value, let's just properly propagate the errors when they
> occur.
> 
> Fixes: f759f5b53f1c ("drm/vc4: tests: Introduce a mocking infrastructure")
> Fixes: 76ec18dc5afa ("drm/vc4: tests: Add unit test suite for the PV muxing")
> Signed-off-by: Maxime Ripard <mripard@kernel.org>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra

> ---
>   drivers/gpu/drm/vc4/tests/vc4_mock_output.c | 36 +++++++++++++++++++----------
>   1 file changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock_output.c b/drivers/gpu/drm/vc4/tests/vc4_mock_output.c
> index e70d7c3076acf168782c48301f3b3dfb9be21f22..f0ddc223c1f839e8a14f37fdcbb72e7b2c836aa1 100644
> --- a/drivers/gpu/drm/vc4/tests/vc4_mock_output.c
> +++ b/drivers/gpu/drm/vc4/tests/vc4_mock_output.c
> @@ -73,28 +73,34 @@ int vc4_mock_atomic_add_output(struct kunit *test,
>   	struct drm_encoder *encoder;
>   	struct drm_crtc *crtc;
>   	int ret;
>   
>   	encoder = vc4_find_encoder_by_type(drm, type);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder);
> +	if (!encoder)
> +		return -ENODEV;
>   
>   	crtc = vc4_find_crtc_for_encoder(test, drm, encoder);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc);
> +	if (!crtc)
> +		return -ENODEV;
>   
>   	output = encoder_to_vc4_dummy_output(encoder);
>   	conn = &output->connector;
>   	conn_state = drm_atomic_get_connector_state(state, conn);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
> +	if (IS_ERR(conn_state))
> +		return PTR_ERR(conn_state);
>   
>   	ret = drm_atomic_set_crtc_for_connector(conn_state, crtc);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	if (ret)
> +		return ret;
>   
>   	crtc_state = drm_atomic_get_crtc_state(state, crtc);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
> +	if (IS_ERR(crtc_state))
> +		return PTR_ERR(crtc_state);
>   
>   	ret = drm_atomic_set_mode_for_crtc(crtc_state, &default_mode);
> -	KUNIT_EXPECT_EQ(test, ret, 0);
> +	if (ret)
> +		return ret;
>   
>   	crtc_state->active = true;
>   
>   	return 0;
>   }
> @@ -111,28 +117,34 @@ int vc4_mock_atomic_del_output(struct kunit *test,
>   	struct drm_encoder *encoder;
>   	struct drm_crtc *crtc;
>   	int ret;
>   
>   	encoder = vc4_find_encoder_by_type(drm, type);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder);
> +	if (!encoder)
> +		return -ENODEV;
>   
>   	crtc = vc4_find_crtc_for_encoder(test, drm, encoder);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc);
> +	if (!crtc)
> +		return -ENODEV;
>   
>   	crtc_state = drm_atomic_get_crtc_state(state, crtc);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
> +	if (IS_ERR(crtc_state))
> +		return PTR_ERR(crtc_state);
>   
>   	crtc_state->active = false;
>   
>   	ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
> -	KUNIT_ASSERT_EQ(test, ret, 0);
> +	if (ret)
> +		return ret;
>   
>   	output = encoder_to_vc4_dummy_output(encoder);
>   	conn = &output->connector;
>   	conn_state = drm_atomic_get_connector_state(state, conn);
> -	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
> +	if (IS_ERR(conn_state))
> +		return PTR_ERR(conn_state);
>   
>   	ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
> -	KUNIT_ASSERT_EQ(test, ret, 0);
> +	if (ret)
> +		return ret;
>   
>   	return 0;
>   }
> 


  reply	other threads:[~2025-03-23 18:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-18 14:17 [PATCH 0/4] drm/vc4: tests: Fix locking failures Maxime Ripard
2025-03-18 14:17 ` [PATCH 1/4] drm/vc4: tests: Use return instead of assert Maxime Ripard
2025-03-23 18:12   ` Maíra Canal [this message]
2025-03-18 14:17 ` [PATCH 2/4] drm/vc4: tests: Document output handling functions Maxime Ripard
2025-03-23 18:34   ` Maíra Canal
2025-03-28 15:30     ` Maxime Ripard
2025-03-18 14:17 ` [PATCH 3/4] drm/vc4: tests: Stop allocating the state in test init Maxime Ripard
2025-03-23 18:48   ` Maíra Canal
2025-03-28 15:32     ` Maxime Ripard
2025-03-30 18:10       ` Maíra Canal
2025-03-18 14:17 ` [PATCH 4/4] drm/vc4: tests: Retry pv-muxing tests when EDEADLK Maxime Ripard
2025-03-23 18:07   ` Maíra Canal

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=d9e7d2a0-d074-4c21-b1a5-70ad93a98ea1@igalia.com \
    --to=mcanal@igalia.com \
    --cc=airlied@gmail.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-list@raspberrypi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®