Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp294043rdb; Tue, 5 Dec 2023 05:51:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZxt93LXU1fd3o/UYwHhgzH4ZSOnK8w1qi7ucFB2EVut2MXJxYU7YAM79nDbxtjk2ZJXo5 X-Received: by 2002:a05:6a00:8d96:b0:6cd:9033:b3d0 with SMTP id im22-20020a056a008d9600b006cd9033b3d0mr1128046pfb.28.1701784272671; Tue, 05 Dec 2023 05:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701784272; cv=none; d=google.com; s=arc-20160816; b=03tdsItZjg6EsCPQ6fWv+VsC23M5Bp1ATrwp7AXL3P8Ot2kUgoUVeTYVBASK9lzkiR yUREJp35mpkWZUeDLoA0huOD5FZ46YTGNmH8HiMnFuG6PU+3mifAaOte1DYkPNIYeYJm ViGWhbm2XrbYO6IC4AufKom1EQ1jPOCok6zw9pt35MKt+yhGI9Y1qK9n+dxBjX18qK1C 8jwsKN740ddnrLGaxlCWzgwZUNoYhUQic5TD9F9lBtJjtlsFB4sucdCOU56M2KaPqOJx 6Hrk3fcGyf+jcCjPSiS41EumYzOAILlOTcidJsVAMnH8lMKjjHiPV3LLN98/dxT6Gk6M oL1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/I1uufZDd7QijdiBzeS0XEGimD7wQlw3b9L8nqJ9kEE=; fh=Tg+iK/mtBMU5WI6r3+3lxZk/Qs91S9FQJyDwmQJPOUs=; b=AUZyEYScreVlcJwNkkugfuk/R+HSrchGoxlm2mbmPoN+xGxwbugbFgACS0TIcgMsFt VHI6M3CDPrNK6weDfP8h9lDIFZvTO657TAh+wOS7240QI8Ozf5klYO/usHRabHvcD+Kx mtrRa+SB+B8fcG5NBkCdGyHI3bbBtLnYFMjTXiuI+VNoyZYo5YzB9x7KJ0GwwZyZ3BFI Kkn0q9kBoVH9XTHhmoGnnAE5Xy025kbmPv0DzMJ5wqgn4AaJgkpgfWKylmG1MvPShRFN r2ZvayXd8wvc1gGd5fJbmY6aYc5U4tLpzBFjmy3CPC0SDdr5k/mf9LkQHVSB6EUeFYNv 0H0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ROm2MvhM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k16-20020a056a00135000b006ce45456a1dsi4313038pfu.184.2023.12.05.05.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 05:51:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ROm2MvhM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 17DB9808869B; Tue, 5 Dec 2023 05:50:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345554AbjLENuW (ORCPT + 99 others); Tue, 5 Dec 2023 08:50:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345486AbjLENuU (ORCPT ); Tue, 5 Dec 2023 08:50:20 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E58219F for ; Tue, 5 Dec 2023 05:50:25 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C4A7C433C7; Tue, 5 Dec 2023 13:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701784224; bh=qWUHln0TJp06ORs8walMJ6PunzC7TYXw6yHrQTcpoPc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ROm2MvhMPhWU+cwbMFCWKamRD4KzEaSmvrwFla9J1jbXz8suGGD/n5/D369Blq4nF eRZi0n4IocZ9wQaBPBVnP9noDTMjH2bkyjwtalNotv9/AYeoJiog+sWBUrkKhgAs2/ iKi5uKqxbvi6lwgbTRBDE2BHnH0m3AGjwNZ+4kKIeYSy41FnJt7Yycz5L/4aeLxHBp qtTtpT4tuHTfoH9HB+iLM+EQSjFOatfleCmDhRWZng04ylxi91Rq69prso5xx7rdjr 7mNHlJN9xfujWzXTTiXOXnwHMWgdztlu2KssVoSSGrbPymg39/VsM7llV3l+f49/nU ToGsibgKYKh1Q== Date: Tue, 5 Dec 2023 14:50:22 +0100 From: Maxime Ripard To: =?utf-8?Q?Micha=C5=82?= Winiarski Cc: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Rodrigo Vivi , Michal Wajdeczko , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Javier Martinez Canillas , =?utf-8?B?TWHDrXJh?= Canal Subject: Re: [PATCH v2 3/3] drm/tests: managed: Add a simple test for drmm_managed_release Message-ID: References: <20231205012210.1491532-1-michal.winiarski@intel.com> <20231205012210.1491532-4-michal.winiarski@intel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vhxtrj4cat76vpkc" Content-Disposition: inline In-Reply-To: <20231205012210.1491532-4-michal.winiarski@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 05 Dec 2023 05:50:37 -0800 (PST) --vhxtrj4cat76vpkc Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, Thanks for the rework On Tue, Dec 05, 2023 at 02:22:10AM +0100, Micha=C5=82 Winiarski wrote: > Add a simple test that checks whether the action is indeed called right > away and that it is not called on the final drm_dev_put(). >=20 > Signed-off-by: Micha=C5=82 Winiarski > --- > drivers/gpu/drm/tests/drm_managed_test.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) >=20 > diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/t= ests/drm_managed_test.c > index cabe6360aef71..8dfbea21c35c5 100644 > --- a/drivers/gpu/drm/tests/drm_managed_test.c > +++ b/drivers/gpu/drm/tests/drm_managed_test.c > @@ -44,6 +44,29 @@ static void drm_test_managed_run_action(struct kunit *= test) > KUNIT_EXPECT_GT(test, ret, 0); > } > =20 We should have a description of the intent of the test here. > +static void drm_test_managed_release_action(struct kunit *test) > +{ > + struct managed_test_priv *priv =3D test->priv; > + int ret; > + > + ret =3D drmm_add_action_or_reset(&priv->drm, drm_action, priv); > + KUNIT_EXPECT_EQ(test, ret, 0); > + > + ret =3D drm_dev_register(&priv->drm, 0); > + KUNIT_ASSERT_EQ(test, ret, 0); > + > + drmm_release_action(&priv->drm, drm_action, priv); > + KUNIT_EXPECT_TRUE(test, priv->action_done); > + priv->action_done =3D false; > + > + drm_dev_unregister(&priv->drm); > + drm_kunit_helper_free_device(test, priv->drm.dev); > + > + ret =3D wait_event_interruptible_timeout(priv->action_wq, priv->action_= done, > + msecs_to_jiffies(TEST_TIMEOUT_MS)); > + KUNIT_EXPECT_EQ(test, ret, 0); This tests that we have reached the timeout, thus the action never ran. It's not clear to me what your intent is here. This test is: - Registering an action - Registering the DRM device - Calling drmm_release_action on the previously registered action - Checking that the action has been run - Clearing the flag saying the action has been run - Unregistering the DRM device - Freeing the DRM device - Waiting for the action to run, but expecting it to never do? I guess something like static void drm_test_managed_release_action(struct kunit *test) { struct managed_test_priv *priv =3D test->priv; int ret; ret =3D drmm_add_action_or_reset(&priv->drm, drm_action, priv); KUNIT_ASSERT_EQ(test, ret, 0); KUNIT_ASSERT_FALSE(test, priv->action_done); drmm_release_action(&priv->drm, drm_action, priv); ret =3D wait_event_interruptible_timeout(priv->action_wq, priv->action_don= e, msecs_to_jiffies(TEST_TIMEOUT_MS)); KUNIT_EXPECT_GT(test, ret, 0); KUNIT_EXPECT_TRUE(test, priv->action_done); } would be enough? > +} > + > static int drm_managed_test_init(struct kunit *test) > { > struct managed_test_priv *priv; > @@ -65,6 +88,7 @@ static int drm_managed_test_init(struct kunit *test) > =20 > static struct kunit_case drm_managed_tests[] =3D { > KUNIT_CASE(drm_test_managed_run_action), > + KUNIT_CASE(drm_test_managed_release_action), Also, tests should be organized by alphabetical order Maxime --vhxtrj4cat76vpkc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCZW8qngAKCRDj7w1vZxhR xS3aAP9ea8p8iqVNYFgkQf5dD9oheX8j1hbq55d51fmbOZOmjAEA0YOMEP0s+w8O 8tIyQHlWKkd0RJJJu4SBunN5Ox4VoAU= =jlmj -----END PGP SIGNATURE----- --vhxtrj4cat76vpkc--