From patchwork Mon Jul 10 07:47:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83922EB64DC for ; Mon, 10 Jul 2023 07:47:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C5F710E205; Mon, 10 Jul 2023 07:47:46 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9436510E203 for ; Mon, 10 Jul 2023 07:47:44 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1732B60EBA; Mon, 10 Jul 2023 07:47:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1955FC433C7; Mon, 10 Jul 2023 07:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975263; bh=2lYoGYtWk31ktlt2bmZpFNtrbTluQtTeAWfgUJXbu8w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BC9eEcKZFIgPUCFoGh862D2q/k94PW3B/ZjOJUm0R+Zu5wU3BnSrA3LxiOk0OXBHR ufDfH8FLqYqBrbj7P+bfU9vansFcBLwqYH/ZN4FEVLmFAOmAJbKN6c0NNIwuUMbHAs y4Hn3US6ErmTjary5i0AlyEOXkjsV+vYq5XB+0rEgsyjJRPLxJ/XD3RO1+W8pPlSb4 T9SREwnCAVH4CS3qn6h9lQYLMJxvsSXrocITyuGPHfaYMeD7q5IFRD/jp7At/AVrUD Y68ngwjQBARIrTbpv5f8pHgNliTp4txgComMF9+vsbgy9N9T+5Cd3pEu6NfYtnO88/ KwU+GDIsod59g== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:32 +0200 Subject: [PATCH 01/11] drm/tests: helpers: Switch to kunit actions MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-1-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2470; i=mripard@kernel.org; h=from:subject:message-id; bh=2lYoGYtWk31ktlt2bmZpFNtrbTluQtTeAWfgUJXbu8w=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt0+fybmcLXMiQ/bv/Dcz3zctP13KrLFq299nnVE/rUUm Ljcv6ShlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEPBIZ/qd+T0/3mTZFKEsn85vzzN /5po5ldxSfKaaVX5lmWZGRw87I8ETi6V2mJT7H9v/Yyx/6+wWrf/1z3XXZDzY0CJx5Lzl7DSMA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_kunit_helpers.c | 32 +++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c index 4df47071dc88..38211fea9ae6 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -35,8 +35,8 @@ static struct platform_driver fake_platform_driver = { * able to leverage the usual infrastructure and most notably the * device-managed resources just like a "real" device. * - * Callers need to make sure drm_kunit_helper_free_device() on the - * device when done. + * Resources will be cleaned up automatically, but the removal can be + * forced using @drm_kunit_helper_free_device. * * Returns: * A pointer to the new device, or an ERR_PTR() otherwise. @@ -49,12 +49,31 @@ struct device *drm_kunit_helper_alloc_device(struct kunit *test) ret = platform_driver_register(&fake_platform_driver); KUNIT_ASSERT_EQ(test, ret, 0); + ret = kunit_add_action_or_reset(test, + (kunit_action_t *)platform_driver_unregister, + &fake_platform_driver); + KUNIT_ASSERT_EQ(test, ret, 0); + pdev = platform_device_alloc(KUNIT_DEVICE_NAME, PLATFORM_DEVID_NONE); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); + ret = kunit_add_action_or_reset(test, + (kunit_action_t *)platform_device_put, + pdev); + KUNIT_ASSERT_EQ(test, ret, 0); + ret = platform_device_add(pdev); KUNIT_ASSERT_EQ(test, ret, 0); + kunit_remove_action(test, + (kunit_action_t *)platform_device_put, + pdev); + + ret = kunit_add_action_or_reset(test, + (kunit_action_t *)platform_device_unregister, + pdev); + KUNIT_ASSERT_EQ(test, ret, 0); + return &pdev->dev; } EXPORT_SYMBOL_GPL(drm_kunit_helper_alloc_device); @@ -70,8 +89,13 @@ void drm_kunit_helper_free_device(struct kunit *test, struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - platform_device_unregister(pdev); - platform_driver_unregister(&fake_platform_driver); + kunit_release_action(test, + (kunit_action_t *)platform_device_unregister, + pdev); + + kunit_release_action(test, + (kunit_action_t *)platform_driver_unregister, + &fake_platform_driver); } EXPORT_SYMBOL_GPL(drm_kunit_helper_free_device); From patchwork Mon Jul 10 07:47:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98961EB64D9 for ; Mon, 10 Jul 2023 07:47:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7FB6C10E208; Mon, 10 Jul 2023 07:47:50 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 95F8A10E204 for ; Mon, 10 Jul 2023 07:47:48 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF23760EB8; Mon, 10 Jul 2023 07:47:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F7DCC433C9; Mon, 10 Jul 2023 07:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975266; bh=xWovrJZer1W7AjsxvLVKMJnE5oarV1IwKSg4Wq6t9kE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ALd6PxwN7gs9AOQ9IIcA1aTr9WugCcwY4yNHmfKBr7AlYy2CXaas4ntrMpr3VvqrY Ev6RA+QI46zmOkcRfm9/Ufn1GovH4i4TG0azF5RpYqvjwFZPyS9kvDhtgs++3t4vhp wTwbsNY0jI+6IpilfVp52Rs3W6LCH1eWLelgxR4BjlVTrSbrgvPCNkQiYW4FaHX4JZ e6+xCv3EvNTAG3aMqhVcwueVPxzSo4R/x0qoskZikJeY02iaINN3KVF7xU3BSx8I1S d+2crBXnTAmkFJMToplXDK8ZHrmdXyQ/W/qynntvl/dpilgb8vvUlHpI+5PJEVr969 e26T+DDC6c2Iw== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:33 +0200 Subject: [PATCH 02/11] drm/tests: client-modeset: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-2-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1345; i=mripard@kernel.org; h=from:subject:message-id; bh=xWovrJZer1W7AjsxvLVKMJnE5oarV1IwKSg4Wq6t9kE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt89YqvEpYsXW57qTdpsVTH83WfZV7lfpqr3TT15sn3U5 5PfN1o5SFgYxLgZZMUWWGGHzJXGnZr3uZOObBzOHlQlkCAMXpwBMRNyA4Z+2/jkvG/6/V1Njchce+M pz+NFy3ug3Czo39604d2L146tLGBmeXvN4qTC/PSDz77GiPJEt3dIXBS8pOHzttj+Y9O/6+Ve8AA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Calling drm_kunit_helper_free_device() to clean up the resources allocated by drm_kunit_helper_alloc_device() is now optional and not needed in most cases. Remove it. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_client_modeset_test.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_client_modeset_test.c b/drivers/gpu/drm/tests/drm_client_modeset_test.c index 416a279b6dae..7516f6cb36e4 100644 --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c @@ -82,13 +82,6 @@ static int drm_client_modeset_test_init(struct kunit *test) return 0; } -static void drm_client_modeset_test_exit(struct kunit *test) -{ - struct drm_client_modeset_test_priv *priv = test->priv; - - drm_kunit_helper_free_device(test, priv->dev); -} - static void drm_test_pick_cmdline_res_1920_1080_60(struct kunit *test) { struct drm_client_modeset_test_priv *priv = test->priv; @@ -188,7 +181,6 @@ static struct kunit_case drm_test_pick_cmdline_tests[] = { static struct kunit_suite drm_test_pick_cmdline_test_suite = { .name = "drm_test_pick_cmdline", .init = drm_client_modeset_test_init, - .exit = drm_client_modeset_test_exit, .test_cases = drm_test_pick_cmdline_tests }; From patchwork Mon Jul 10 07:47:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B38BCEB64D9 for ; Mon, 10 Jul 2023 07:47:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1D81D10E20A; Mon, 10 Jul 2023 07:47:54 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93B5F10E216 for ; Mon, 10 Jul 2023 07:47:51 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7FEF60EB8; Mon, 10 Jul 2023 07:47:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CDD4C433C7; Mon, 10 Jul 2023 07:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975270; bh=ESA0y0NXrSvpPjbIAHKbdqC7HnGx+32+DeIPn5Bsru4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pZ8Q6H+eqITfqMayWd+SJ0YWIwM4w+0mClw1EjmaLdSoGIF4WWFyAqqybxUf16tGL 6ArmiNLhhAvBnhA8KtdGLVXTeXwIJ25f8ULMi3Y8W6pK9y5z+56cFeVjZfsEQiy0SE Yr0+8mzB2CcGtiivAC7EshSeDxDbzbUxcPE0UAN9KgSdrTl/YAQd+Gsuj0ds83+maq u3G9fr7haXi6pwAcpINt5BAnNXFXuvCU0vz1wRFgsWpe2CYNBtbrKM/nWYULgmKIn6 TkWqg/+GddLjaxHZ+UJQU0qrF2i6kWdO/iyRbJLnczGq7R4w0CqYhNDv3vVtZp7iJX PB3P+60woanCw== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:34 +0200 Subject: [PATCH 03/11] drm/tests: modes: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-3-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1235; i=mripard@kernel.org; h=from:subject:message-id; bh=ESA0y0NXrSvpPjbIAHKbdqC7HnGx+32+DeIPn5Bsru4=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt8/QyzP82jNtlwaXx53+bdniGR/XtlXOtZRqFtvEeuLw TuONHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZiIQx0jw4euqxNvu9sfSxa+tvqr3L RmxVYhsZWt3PPevvxWaniIZy/D/zwrwxO2j/elGTbHNnveMNMJV2BfclB32109zbke0//s5wUA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Calling drm_kunit_helper_free_device() to clean up the resources allocated by drm_kunit_helper_alloc_device() is now optional and not needed in most cases. Remove it. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_modes_test.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_modes_test.c b/drivers/gpu/drm/tests/drm_modes_test.c index bc4aa2ce78be..1e9f63fbfead 100644 --- a/drivers/gpu/drm/tests/drm_modes_test.c +++ b/drivers/gpu/drm/tests/drm_modes_test.c @@ -36,13 +36,6 @@ static int drm_test_modes_init(struct kunit *test) return 0; } -static void drm_test_modes_exit(struct kunit *test) -{ - struct drm_test_modes_priv *priv = test->priv; - - drm_kunit_helper_free_device(test, priv->dev); -} - static void drm_test_modes_analog_tv_ntsc_480i(struct kunit *test) { struct drm_test_modes_priv *priv = test->priv; @@ -148,7 +141,6 @@ static struct kunit_case drm_modes_analog_tv_tests[] = { static struct kunit_suite drm_modes_analog_tv_test_suite = { .name = "drm_modes_analog_tv", .init = drm_test_modes_init, - .exit = drm_test_modes_exit, .test_cases = drm_modes_analog_tv_tests, }; From patchwork Mon Jul 10 07:47:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3E62EB64D9 for ; Mon, 10 Jul 2023 07:47:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0EAC10E204; Mon, 10 Jul 2023 07:47:56 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3D94910E20B for ; Mon, 10 Jul 2023 07:47:54 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AEAD960EBF; Mon, 10 Jul 2023 07:47:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B52F9C433C7; Mon, 10 Jul 2023 07:47:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975273; bh=b3jsj7BIiDtYO4ydj4H5h/qkxK67fbZ/H7CaIS33J9o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mqTyuIWhmfTWFYsc4wzr5/nJCuQaTk4tTZ+B5HbgmzhawJBR6NKKVUXq3aCRP3fgq RuWQt4FFlpOKA8m1QddpC57zLgj9bPwr+jIGlV7dOrDPT+qUBhOEeEQ8R/YSdJYGAc MKKa4F1mXQ6ix8BXPE178SlBFB2pp7dv7NLzlL2P1NIJ+wzrjGrJk+87UPwueGIHBf XyRvV6etN21B/ygNKYWl7aFznehnPxURt1kz7vkEsnjcwRIxsES4wjJYiRxXfy5dYb DUxcpZQqxJggjALzcuhj+fZR1vmqtSJKgeJMbi6LrSj15javuXgIdhuoDFNfXyu808 P2iTGc9PMinYg== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:35 +0200 Subject: [PATCH 04/11] drm/tests: probe-helper: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-4-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1382; i=mripard@kernel.org; h=from:subject:message-id; bh=b3jsj7BIiDtYO4ydj4H5h/qkxK67fbZ/H7CaIS33J9o=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt88QWvBp8qITl77lqIh4fby8j19FcOKMhIkiMoK9svff dmgc6ihlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEQgoZ/qmcDn27zKIkYr2g07Zoba lNJ3bvnfH6qEJYyfprx+ZulTrC8Fd4F6fM8zQ2dcOl95zm61swu964crF1cl1ix/2fG+ee7OICAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Calling drm_kunit_helper_free_device() to clean up the resources allocated by drm_kunit_helper_alloc_device() is now optional and not needed in most cases. Remove it. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_probe_helper_test.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c b/drivers/gpu/drm/tests/drm_probe_helper_test.c index 0ee65828623e..1a2044070a6c 100644 --- a/drivers/gpu/drm/tests/drm_probe_helper_test.c +++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c @@ -60,13 +60,6 @@ static int drm_probe_helper_test_init(struct kunit *test) return 0; } -static void drm_probe_helper_test_exit(struct kunit *test) -{ - struct drm_probe_helper_test_priv *priv = test->priv; - - drm_kunit_helper_free_device(test, priv->dev); -} - typedef struct drm_display_mode *(*expected_mode_func_t)(struct drm_device *); struct drm_connector_helper_tv_get_modes_test { @@ -208,7 +201,6 @@ static struct kunit_case drm_test_connector_helper_tv_get_modes_tests[] = { static struct kunit_suite drm_test_connector_helper_tv_get_modes_suite = { .name = "drm_connector_helper_tv_get_modes", .init = drm_probe_helper_test_init, - .exit = drm_probe_helper_test_exit, .test_cases = drm_test_connector_helper_tv_get_modes_tests, }; From patchwork Mon Jul 10 07:47:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0841DEB64D9 for ; Mon, 10 Jul 2023 07:48:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FAA510E20B; Mon, 10 Jul 2023 07:47:59 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 06CF610E20B for ; Mon, 10 Jul 2023 07:47:57 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7C71B60EBA; Mon, 10 Jul 2023 07:47:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91087C433C9; Mon, 10 Jul 2023 07:47:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975275; bh=92Z66pevW+elalzHRPcF5q2TXp4Zof6H0dCZ1lsPh08=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=i4P+qdzQM8FjAv5I66MjcyeKFkZA8kjn/csJpN3q4yC1nyX/nQ8sSnIyBOe995Bs7 KLcKxMOH6mpoy6XfBuoZUtjgPV9dM/A2T2fAw4QfIQ580FttabPI4Z6wttGkgDzRLU ebwdtcyC1XCj51MNv0+9HMPkXro17s6FMYl63/GapMntc9e/a77l9o81d7G3+W+G7l kqEAIkRKcRE05ZcT4+mAPjYzF7z8BoE/bX296bx+ull620ecL0Usr3M2tpmQSgfIyG wdbAPjhBeOg2dNSOhEkszPTMFTRHiEcL0VXcJocqXMtcUk8iCrHp83D7btSTXJgCl3 jq7rcNGBz+TGg== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:36 +0200 Subject: [PATCH 05/11] drm/tests: helpers: Create an helper to allocate a locking ctx MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-5-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2592; i=mripard@kernel.org; h=from:subject:message-id; bh=92Z66pevW+elalzHRPcF5q2TXp4Zof6H0dCZ1lsPh08=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt894fF9O9eqDwqQD4n3qmzXunui2vKk//+CEVv+FPmLF 53M2dJSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAi++UZGRojfM6uzt4wI6FEZdoRae EZlryr3ZuX6gROrd9d+eUSmzLDP9OT/Pk7LjR0XbBR8ngxNyXh9d2YQzbvk3/4fxGfcJ/hECsA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As we get more and more tests, the locking context initialisation creates more and more boilerplate, both at creation and destruction. Let's create a helper that will allocate, initialise a context, and register kunit actions to clean up once the test is done. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_kunit_helpers.c | 41 +++++++++++++++++++++++++++++++ include/drm/drm_kunit_helpers.h | 2 ++ 2 files changed, 43 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c index 38211fea9ae6..40a27c78d692 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -124,5 +124,46 @@ __drm_kunit_helper_alloc_drm_device_with_driver(struct kunit *test, } EXPORT_SYMBOL_GPL(__drm_kunit_helper_alloc_drm_device_with_driver); +static void action_drm_release_context(void *ptr) +{ + struct drm_modeset_acquire_ctx *ctx = ptr; + + drm_modeset_drop_locks(ctx); + drm_modeset_acquire_fini(ctx); +} + +/** + * drm_kunit_helper_context_alloc - Allocates an acquire context + * @test: The test context object + * + * Allocates and initializes a modeset acquire context. + * + * The context is tied to the kunit test context, so we must not call + * drm_modeset_acquire_fini() on it, it will be done so automatically. + * + * Returns: + * An ERR_PTR on error, a pointer to the newly allocated context otherwise + */ +struct drm_modeset_acquire_ctx * +drm_kunit_helper_acquire_ctx_alloc(struct kunit *test) +{ + struct drm_modeset_acquire_ctx *ctx; + int ret; + + ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, ctx); + + drm_modeset_acquire_init(ctx, 0); + + ret = kunit_add_action_or_reset(test, + action_drm_release_context, + ctx); + if (ret) + return ERR_PTR(ret); + + return ctx; +} +EXPORT_SYMBOL_GPL(drm_kunit_helper_acquire_ctx_alloc); + MODULE_AUTHOR("Maxime Ripard "); MODULE_LICENSE("GPL"); diff --git a/include/drm/drm_kunit_helpers.h b/include/drm/drm_kunit_helpers.h index ed013fdcc1ff..4ba5e10653c6 100644 --- a/include/drm/drm_kunit_helpers.h +++ b/include/drm/drm_kunit_helpers.h @@ -87,5 +87,7 @@ __drm_kunit_helper_alloc_drm_device(struct kunit *test, sizeof(_type), \ offsetof(_type, _member), \ _feat)) +struct drm_modeset_acquire_ctx * +drm_kunit_helper_acquire_ctx_alloc(struct kunit *test); #endif // DRM_KUNIT_HELPERS_H_ From patchwork Mon Jul 10 07:47:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306402 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 622AAEB64DC for ; Mon, 10 Jul 2023 07:48:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A3EDA10E20C; Mon, 10 Jul 2023 07:48:03 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9029D10E20C for ; Mon, 10 Jul 2023 07:48:00 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0599F60EB8; Mon, 10 Jul 2023 07:48:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97EA5C433CC; Mon, 10 Jul 2023 07:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975279; bh=yyOzLwcA8+MLX2ZufFLGFyhRNFINdgUwJ7WOz6NATOo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ev0++KRl7X5fDJRzgC0KAVucSZOr90RLppLhwpgBemBAj0uuGAmS64AiBnjD0BY2B 2FwR4AWNDTstXQvI+Dgid9oYaA15ir6wStflexPmIN5QFu+qkajBJTAPazNv6i1Lxz b6xsXQycMFMEUUU4nMaLMhALmIvUG4gUWWk/lSB1LHA64LzwBSIl5Uf+4j/JGwgixv hUkPONa3CBweO0S5I/cLcDvGtWYDX/Mb8G9+5b0viXN2z30dpaY0ChdZASLqGbU6hB 9ELLjgCoIgzmNcPhc4YJ8vs95K3nQDP8bwyuKEkI7svKD9xdgaWNrGQ3eNoOBws2Yr 0CeRp8RNOhE2w== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:37 +0200 Subject: [PATCH 06/11] drm/tests: helpers: Create an helper to allocate an atomic state MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-6-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2824; i=mripard@kernel.org; h=from:subject:message-id; bh=yyOzLwcA8+MLX2ZufFLGFyhRNFINdgUwJ7WOz6NATOo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt8842N69JPSDNsPi6Zu3qvItcm0TqDt+kOVibJP3lbLd HX3rOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCR6DaGvxKPdc1f2L4P9kvNubCEn3 PG/TUvDI9tWSTr3HXj9+Xb1VMYGXb8zG2IPMnMGsP0aM6lSU+vNJzrS+6dPqWh8q3f8b7E3TwA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" As we gain more tests, boilerplate to allocate an atomic state and free it starts to be there more and more as well. In order to reduce the allocation boilerplate, we can create an helper to create that atomic state, and call an action when the test is done. This will also clean up the exit path. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/tests/drm_kunit_helpers.c | 39 +++++++++++++++++++++++++++++++ include/drm/drm_kunit_helpers.h | 5 ++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c index 40a27c78d692..3f3331bc389f 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include @@ -165,5 +166,43 @@ drm_kunit_helper_acquire_ctx_alloc(struct kunit *test) } EXPORT_SYMBOL_GPL(drm_kunit_helper_acquire_ctx_alloc); +/** + * drm_kunit_helper_atomic_state_alloc - Allocates an atomic state + * @test: The test context object + * @drm: The device to alloc the state for + * @ctx: Locking context for that atomic update + * + * Allocates a empty atomic state. + * + * The state is tied to the kunit test context, so we must not call + * drm_atomic_state_put() on it, it will be done so automatically. + * + * Returns: + * An ERR_PTR on error, a pointer to the newly allocated state otherwise + */ +struct drm_atomic_state * +drm_kunit_helper_atomic_state_alloc(struct kunit *test, + struct drm_device *drm, + struct drm_modeset_acquire_ctx *ctx) +{ + struct drm_atomic_state *state; + int ret; + + state = drm_atomic_state_alloc(drm); + if (!state) + return ERR_PTR(-ENOMEM); + + ret = kunit_add_action_or_reset(test, + (kunit_action_t *)drm_atomic_state_put, + state); + if (ret) + return ERR_PTR(ret); + + state->acquire_ctx = ctx; + + return state; +} +EXPORT_SYMBOL_GPL(drm_kunit_helper_atomic_state_alloc); + MODULE_AUTHOR("Maxime Ripard "); MODULE_LICENSE("GPL"); diff --git a/include/drm/drm_kunit_helpers.h b/include/drm/drm_kunit_helpers.h index 4ba5e10653c6..514c8a7a32f0 100644 --- a/include/drm/drm_kunit_helpers.h +++ b/include/drm/drm_kunit_helpers.h @@ -90,4 +90,9 @@ __drm_kunit_helper_alloc_drm_device(struct kunit *test, struct drm_modeset_acquire_ctx * drm_kunit_helper_acquire_ctx_alloc(struct kunit *test); +struct drm_atomic_state * +drm_kunit_helper_atomic_state_alloc(struct kunit *test, + struct drm_device *drm, + struct drm_modeset_acquire_ctx *ctx); + #endif // DRM_KUNIT_HELPERS_H_ From patchwork Mon Jul 10 07:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06650EB64DA for ; Mon, 10 Jul 2023 07:48:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0655810E20E; Mon, 10 Jul 2023 07:48:05 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 13E7110E20C for ; Mon, 10 Jul 2023 07:48:03 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8957160EBC; Mon, 10 Jul 2023 07:48:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95B71C433C7; Mon, 10 Jul 2023 07:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975281; bh=P6AkzZmEIp/9uMOYra9+RhYe8NGkgtrmUDZAyGSGwBY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZS2qTM59an4tTDOc/lHUMdZ9YWW2KcLdikHB/RwLYbQIQxBy9AQttNMyXpYmiTRmE u3rLEY8OKJqGnuapdPgZIh5DyBJxyua8mSYSs+q/E2/OWAKDskriPj2RdXjU8I8vg0 HWX8fdr0XAl2w8iDuEdWuZJbgOhUh1OKO+6aa4Nbx5xqeNh4xDnKHFjicEpg4V16jB PwKkz8GlYI3dfNx7J+eU1lCFkc3HMvk92le5597HdkbJST72dqbFePH5z1pGd/l46g AXfe8nVNIRjH2MLC3OgJwkTCc1RPddJ9cd3Y8LJFn2ofkX4HeZCsC48XcjIiVulKnQ QwfLGwKiSRBzA== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:38 +0200 Subject: [PATCH 07/11] drm/vc4: tests: pv-muxing: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-7-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1793; i=mripard@kernel.org; h=from:subject:message-id; bh=P6AkzZmEIp/9uMOYra9+RhYe8NGkgtrmUDZAyGSGwBY=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt89o+CqzKlOs84+vi93Tq8Zbmjd8ql4+9dVal+01jn1H F3Ef6ShlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEFnxn+GdvJlsnJ/36KTObdzeblH jMBOOa8LgHE15u/e+/NyfvlzHDf/9vemerQ1fvuH710F274O3NHnceR1/87xT98Ge51DPHdnYA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Calling drm_kunit_helper_free_device() to clean up the resources allocated by drm_kunit_helper_alloc_device() is now optional and not needed in most cases. Remove it. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c index ae0bd0f81698..6c982e72cae8 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c @@ -762,7 +762,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test) drm_modeset_drop_locks(&priv->ctx); drm_modeset_acquire_fini(&priv->ctx); drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, vc4->dev); } static struct kunit_case vc4_pv_muxing_tests[] = { @@ -873,7 +872,6 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, vc4->dev); } static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) @@ -963,7 +961,6 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, vc4->dev); } static void @@ -1017,7 +1014,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); drm_dev_unregister(drm); - drm_kunit_helper_free_device(test, vc4->dev); } static struct kunit_case vc5_pv_muxing_bugs_tests[] = { From patchwork Mon Jul 10 07:47:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E045EB64DA for ; Mon, 10 Jul 2023 07:48:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AD0B10E210; Mon, 10 Jul 2023 07:48:08 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id EFF0D10E210 for ; Mon, 10 Jul 2023 07:48:05 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5FB7360E9E; Mon, 10 Jul 2023 07:48:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75EA1C433C8; Mon, 10 Jul 2023 07:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975284; bh=fPdxAPJD7CpD3AfQBHyKw92YCMzAMwqXjaFIYguE02o=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=E+/jYc+X+JfKXjXj4itmX1fGoj+DANb8FwUhV7qUTm3rOWT8eoltcsHw0bLOR9Ort 2ge/7liyze5sejdX6n9qxhJVvrJ9f5LcgtAAd7c2Le5HUcGkNE0Luh2a6E4AJAVmto h5Sw9hG8VPXzYznNfAOW8va+jVrz7edAffgEsm5+GFlqJRymyzoKvs3v7kqBvhikzl SKzzLK4dBdWV3HzMS4zm5WnhYROdkwyINjQgLncAHsK+q+XGNqNMxEYzt07rEYoVGA DiVx3/yIrueyyd8/EuqI4D7Vgzie9oYYtZTzzEvoqf/m5CXx3ukWj89FBirgFP2aDv z3lJSdbVJ4MaQ== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:39 +0200 Subject: [PATCH 08/11] drm/vc4: tests: mock: Use a kunit action to unregister DRM device MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-8-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2647; i=mripard@kernel.org; h=from:subject:message-id; bh=fPdxAPJD7CpD3AfQBHyKw92YCMzAMwqXjaFIYguE02o=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt8+4s67/9OcVT2x9VX4mPp21o8iVZ+I2s8nJ8cnzpD4u Yd3R2VHKwiDGxSArpsgSI2y+JO7UrNedbHzzYOawMoEMYeDiFICJ3L/K8D/YMUd04udJs8TENs+Wv8 EoLnZyVTNjzUdBtprnlvfldKQZGV4rbpzvevn4wZ9lORFMJ6btZe99t4llrsKUv04P0rcG+zIDAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The *_mock_device functions allocate a DRM device that needs to be released using drm_dev_unregister. Now that we have a kunit release action API, we can switch to it and don't require any kind of garbage collection from the caller. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/vc4/tests/vc4_mock.c | 5 +++++ drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock.c b/drivers/gpu/drm/vc4/tests/vc4_mock.c index a4bed26af32f..00825ddc52f0 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_mock.c +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c @@ -186,6 +186,11 @@ static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5) ret = drm_dev_register(drm, 0); KUNIT_ASSERT_EQ(test, ret, 0); + ret = kunit_add_action_or_reset(test, + (kunit_action_t *)drm_dev_unregister, + drm); + KUNIT_ASSERT_EQ(test, ret, 0); + return vc4; } diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c index 6c982e72cae8..776a7b01608f 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c @@ -754,14 +754,11 @@ static int vc4_pv_muxing_test_init(struct kunit *test) static void vc4_pv_muxing_test_exit(struct kunit *test) { struct pv_muxing_priv *priv = test->priv; - struct vc4_dev *vc4 = priv->vc4; - struct drm_device *drm = &vc4->base; struct drm_atomic_state *state = priv->state; drm_atomic_state_put(state); drm_modeset_drop_locks(&priv->ctx); drm_modeset_acquire_fini(&priv->ctx); - drm_dev_unregister(drm); } static struct kunit_case vc4_pv_muxing_tests[] = { @@ -871,7 +868,6 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes drm_atomic_state_put(state); drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); - drm_dev_unregister(drm); } static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) @@ -960,7 +956,6 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) drm_atomic_state_put(state); drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); - drm_dev_unregister(drm); } static void @@ -1013,7 +1008,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku drm_atomic_state_put(state); drm_modeset_drop_locks(&ctx); drm_modeset_acquire_fini(&ctx); - drm_dev_unregister(drm); } static struct kunit_case vc5_pv_muxing_bugs_tests[] = { From patchwork Mon Jul 10 07:47:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F38F6EB64DA for ; Mon, 10 Jul 2023 07:48:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4556910E211; Mon, 10 Jul 2023 07:48:11 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id A298010E211 for ; Mon, 10 Jul 2023 07:48:08 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E84C160EB6; Mon, 10 Jul 2023 07:48:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68AE0C433C8; Mon, 10 Jul 2023 07:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975287; bh=A/pLaw+uJXzMbunZZUuKSY2x3xf0ard7YULxacsm45Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=q2z39TMdCYZM+Q2tQJuFxEf6HqVLTv9g12+ayp23zgEZnd5/eEgS35Mdc6QNJRxi0 +U0u0qcdztqisN0Pqe9a1tfpmO79G04THLzCryM3gKtuvYeiwKCFj8GpyfEAynK9mQ ycgyGYFQ+gsKFcukvesTuNQqDAdROYCq7PE6gjHeDiC3U6nnQKLQOWpB+A5fLIQ7KI f6cLe1mQ/MblUa3iLjB5iY1nch0S4qxaPCTo8KXl7hPAp3nM+unyRmib/Yz8Wneph/ chKCi6ckbwywl9A+dKZl732XiBYYfZ6we1ikeRnTGkhnMV0mQ4YlK2mcBfM419lhZ9 ia667Nv1dCMUA== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:40 +0200 Subject: [PATCH 09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-9-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=6443; i=mripard@kernel.org; h=from:subject:message-id; bh=A/pLaw+uJXzMbunZZUuKSY2x3xf0ard7YULxacsm45Y=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt8+oemwbXvDae/Uz97eLHxj097/m3FhmtGLGthkx839t 5NPq7ChlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBE7pQzMtwRd7rmz7t40XoRm19RDr t6dR9mczB4cb7+ER04Ue1/w2qGvwJ86z8k2PE/nCte/1w+0WKFe/bvtHUluswLd05/sb1MjBsA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The new helper to init the locking context allows to remove some boilerplate. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 42 ++++++++++++-------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c index 776a7b01608f..ff1deaed0cab 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c @@ -20,7 +20,6 @@ struct pv_muxing_priv { struct vc4_dev *vc4; - struct drm_modeset_acquire_ctx ctx; struct drm_atomic_state *state; }; @@ -725,6 +724,7 @@ static void drm_vc4_test_pv_muxing_invalid(struct kunit *test) static int vc4_pv_muxing_test_init(struct kunit *test) { const struct pv_muxing_param *params = test->param_value; + struct drm_modeset_acquire_ctx *ctx; struct drm_atomic_state *state; struct pv_muxing_priv *priv; struct drm_device *drm; @@ -738,13 +738,14 @@ static int vc4_pv_muxing_test_init(struct kunit *test) KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); priv->vc4 = vc4; - drm_modeset_acquire_init(&priv->ctx, 0); + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &priv->ctx; + state->acquire_ctx = ctx; priv->state = state; @@ -757,8 +758,6 @@ static void vc4_pv_muxing_test_exit(struct kunit *test) struct drm_atomic_state *state = priv->state; drm_atomic_state_put(state); - drm_modeset_drop_locks(&priv->ctx); - drm_modeset_acquire_fini(&priv->ctx); } static struct kunit_case vc4_pv_muxing_tests[] = { @@ -798,7 +797,7 @@ static struct kunit_suite vc5_pv_muxing_test_suite = { */ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *test) { - struct drm_modeset_acquire_ctx ctx; + struct drm_modeset_acquire_ctx *ctx; struct drm_atomic_state *state; struct vc4_crtc_state *new_vc4_crtc_state; struct vc4_hvs_state *new_hvs_state; @@ -811,13 +810,14 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes vc4 = vc5_mock_device(test); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); - drm_modeset_acquire_init(&ctx, 0); + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &ctx; + state->acquire_ctx = ctx; ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -844,7 +844,7 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &ctx; + state->acquire_ctx = ctx; ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); KUNIT_ASSERT_EQ(test, ret, 0); @@ -866,13 +866,11 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel); drm_atomic_state_put(state); - drm_modeset_drop_locks(&ctx); - drm_modeset_acquire_fini(&ctx); } static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) { - struct drm_modeset_acquire_ctx ctx; + struct drm_modeset_acquire_ctx *ctx; struct drm_atomic_state *state; struct vc4_crtc_state *new_vc4_crtc_state; struct vc4_hvs_state *new_hvs_state; @@ -885,13 +883,14 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) vc4 = vc5_mock_device(test); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); - drm_modeset_acquire_init(&ctx, 0); + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &ctx; + state->acquire_ctx = ctx; ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -929,7 +928,7 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &ctx; + state->acquire_ctx = ctx; ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -954,14 +953,12 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) } drm_atomic_state_put(state); - drm_modeset_drop_locks(&ctx); - drm_modeset_acquire_fini(&ctx); } static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct kunit *test) { - struct drm_modeset_acquire_ctx ctx; + struct drm_modeset_acquire_ctx *ctx; struct drm_atomic_state *state; struct vc4_crtc_state *new_vc4_crtc_state; struct drm_device *drm; @@ -971,13 +968,14 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku vc4 = vc5_mock_device(test); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4); - drm_modeset_acquire_init(&ctx, 0); + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &ctx; + state->acquire_ctx = ctx; ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -993,7 +991,7 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku state = drm_atomic_state_alloc(drm); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = &ctx; + state->acquire_ctx = ctx; ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); KUNIT_ASSERT_EQ(test, ret, 0); @@ -1006,8 +1004,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku KUNIT_EXPECT_NULL(test, new_vc4_crtc_state); drm_atomic_state_put(state); - drm_modeset_drop_locks(&ctx); - drm_modeset_acquire_fini(&ctx); } static struct kunit_case vc5_pv_muxing_bugs_tests[] = { From patchwork Mon Jul 10 07:47:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0F36CEB64DC for ; Mon, 10 Jul 2023 07:48:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4149B10E212; Mon, 10 Jul 2023 07:48:13 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD32F10E213 for ; Mon, 10 Jul 2023 07:48:11 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4F1D960EBA; Mon, 10 Jul 2023 07:48:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A237C433C8; Mon, 10 Jul 2023 07:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975290; bh=sh661OiebuthJZpmMjfk/uDz8mfCFIBOnwj6laIfZvA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=H2lP3U9cY4rSUv9Cw8OH5npmN1IbNMWpBdTRyoHqZiTFZ+N12+8Fx7Amri+c1oH+S 0v1c3c6zPzFuj15OlDjXhM2j4HkG1NbSx0rrPU9nodGgVZu6WiQdU+ZA8ilpKf6hZn yAheO9nrMy8byNlePMvbVDttZhRZ4o3F3k5mAIzF4jyLoxK02/GIpUJOhcXJv30jRQ sCBvkrU/1qxaF21YdWiv2oVGN+qpI2W17jKcZsI44PXp2L/v0iojo6sgL5TopRvvRM NDRUduGvofFZ+FMof3SC7ckWmWWXP+P506Q+eXOSdlL8yPjYvKpjC4IZomS5TPUNNi rRzaJOGneLDiw== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:41 +0200 Subject: [PATCH 10/11] drm/vc4: tests: Switch to atomic state allocation helper MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-10-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=6125; i=mripard@kernel.org; h=from:subject:message-id; bh=sh661OiebuthJZpmMjfk/uDz8mfCFIBOnwj6laIfZvA=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt88ITQ9eoX/QfYmP89PJ82c+bGfg1MhIbxFvObPCd2PF 6YVNHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZjIax+Gv4JTF/ptLczneyz92uRIr1 ZcqOW96zzL/87nWyey98Ly+kuMDLsD/Y0XFIjazrsju0Ona2rHwiw1iZOHzv3d729Tz6zNygYA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Now that we have a helper that takes care of an atomic state allocation and cleanup, we can migrate to it to simplify our tests. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 55 ++++---------------------- 1 file changed, 8 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c index ff1deaed0cab..5f9f5626329d 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c @@ -725,7 +725,6 @@ static int vc4_pv_muxing_test_init(struct kunit *test) { const struct pv_muxing_param *params = test->param_value; struct drm_modeset_acquire_ctx *ctx; - struct drm_atomic_state *state; struct pv_muxing_priv *priv; struct drm_device *drm; struct vc4_dev *vc4; @@ -742,24 +741,12 @@ static int vc4_pv_muxing_test_init(struct kunit *test) KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; - state = drm_atomic_state_alloc(drm); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - - state->acquire_ctx = ctx; - - priv->state = state; + priv->state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->state); return 0; } -static void vc4_pv_muxing_test_exit(struct kunit *test) -{ - struct pv_muxing_priv *priv = test->priv; - struct drm_atomic_state *state = priv->state; - - drm_atomic_state_put(state); -} - static struct kunit_case vc4_pv_muxing_tests[] = { KUNIT_CASE_PARAM(drm_vc4_test_pv_muxing, vc4_test_pv_muxing_gen_params), @@ -771,7 +758,6 @@ static struct kunit_case vc4_pv_muxing_tests[] = { static struct kunit_suite vc4_pv_muxing_test_suite = { .name = "vc4-pv-muxing-combinations", .init = vc4_pv_muxing_test_init, - .exit = vc4_pv_muxing_test_exit, .test_cases = vc4_pv_muxing_tests, }; @@ -786,7 +772,6 @@ static struct kunit_case vc5_pv_muxing_tests[] = { static struct kunit_suite vc5_pv_muxing_test_suite = { .name = "vc5-pv-muxing-combinations", .init = vc4_pv_muxing_test_init, - .exit = vc4_pv_muxing_test_exit, .test_cases = vc5_pv_muxing_tests, }; @@ -814,11 +799,9 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; - state = drm_atomic_state_alloc(drm); + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = ctx; - ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -839,13 +822,9 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes ret = drm_atomic_helper_swap_state(state, false); KUNIT_ASSERT_EQ(test, ret, 0); - drm_atomic_state_put(state); - - state = drm_atomic_state_alloc(drm); + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = ctx; - ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); KUNIT_ASSERT_EQ(test, ret, 0); @@ -864,8 +843,6 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes KUNIT_ASSERT_TRUE(test, new_hvs_state->fifo_state[hdmi1_channel].in_use); KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel); - - drm_atomic_state_put(state); } static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) @@ -887,11 +864,9 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; - state = drm_atomic_state_alloc(drm); + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = ctx; - ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -923,13 +898,9 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) ret = drm_atomic_helper_swap_state(state, false); KUNIT_ASSERT_EQ(test, ret, 0); - drm_atomic_state_put(state); - - state = drm_atomic_state_alloc(drm); + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = ctx; - ret = vc4_mock_atomic_del_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -951,8 +922,6 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) KUNIT_EXPECT_EQ(test, old_hdmi1_channel, hdmi1_channel); } - - drm_atomic_state_put(state); } static void @@ -972,11 +941,9 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); drm = &vc4->base; - state = drm_atomic_state_alloc(drm); + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = ctx; - ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_ASSERT_EQ(test, ret, 0); @@ -986,13 +953,9 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku ret = drm_atomic_helper_swap_state(state, false); KUNIT_ASSERT_EQ(test, ret, 0); - drm_atomic_state_put(state); - - state = drm_atomic_state_alloc(drm); + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); - state->acquire_ctx = ctx; - ret = vc4_mock_atomic_add_output(test, state, VC4_ENCODER_TYPE_HDMI1); KUNIT_ASSERT_EQ(test, ret, 0); @@ -1002,8 +965,6 @@ drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct ku new_vc4_crtc_state = get_vc4_crtc_state_for_encoder(test, state, VC4_ENCODER_TYPE_HDMI0); KUNIT_EXPECT_NULL(test, new_vc4_crtc_state); - - drm_atomic_state_put(state); } static struct kunit_case vc5_pv_muxing_bugs_tests[] = { From patchwork Mon Jul 10 07:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13306407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84759EB64D9 for ; Mon, 10 Jul 2023 07:48:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C26C710E215; Mon, 10 Jul 2023 07:48:16 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id A157710E213 for ; Mon, 10 Jul 2023 07:48:14 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E614760EBC; Mon, 10 Jul 2023 07:48:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F130EC433C8; Mon, 10 Jul 2023 07:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688975293; bh=16TekcNJuTfVyllw7nW85RcUQBjN4RlFG7QvXpxKfus=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aPZ/SRybsonfjxn87sVXsQVAfm8/hSViEfIkh2um+Bu/KDfax48CyrSZgSh9NB+gp QLyUg2fsUPjEUwIZkiBuZHgsAKUHhVGdeYeilhiCH4e29ZizFPYcc+B1SH8k+EaSVz HIvjRTVca/pGZ2F9ulezJVqBti6JkxQKRBTd0wzr7jBcyJ62EK08B3qbJ4m4UloL2f p5AjMfOJbpGPdDCLMUiaJyY5YqZCHvb2l/9y5Ncd4/ht0A1k2lxAHCTzCPk5uG4q+N MdzGp3efocrXoBis6u0dIIDqBOccwJN+PLxwcD2ysVIEW3veHml8BG50wCUjRG+61Z PC0YCMDOPe54g== From: Maxime Ripard Date: Mon, 10 Jul 2023 09:47:42 +0200 Subject: [PATCH 11/11] drm/vc4: tests: pv-muxing: Document test scenario MIME-Version: 1.0 Message-Id: <20230710-kms-kunit-actions-rework-v1-11-722c58d72c72@kernel.org> References: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> In-Reply-To: <20230710-kms-kunit-actions-rework-v1-0-722c58d72c72@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2002; i=mripard@kernel.org; h=from:subject:message-id; bh=16TekcNJuTfVyllw7nW85RcUQBjN4RlFG7QvXpxKfus=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCmrt8/Yo2+y5cu1UPXXup3+aVuktpco688961VxVGVn1f3q JxslO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRCGNGhoXMwuy3I97lPVRwyNRNar 14/8GelZnuk5je5E5+d8ju2gJGhg7damVj7auJfyVOvd39vHFfQn53ycu4uHqV24/zXT4wcAAA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We've had a couple of tests that weren't really obvious, nor did they document what they were supposed to test. Document that to make it hopefully more obvious. Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c index 5f9f5626329d..61622e951031 100644 --- a/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c +++ b/drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c @@ -845,6 +845,13 @@ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable(struct kunit *tes KUNIT_EXPECT_NE(test, hdmi0_channel, hdmi1_channel); } +/* + * This test makes sure that we never change the FIFO of an active HVS + * channel if we disable a FIFO with a lower index. + * + * Doing so would result in a FIFO stall and would disrupt an output + * supposed to be unaffected by the commit. + */ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) { struct drm_modeset_acquire_ctx *ctx; @@ -924,6 +931,21 @@ static void drm_test_vc5_pv_muxing_bugs_stable_fifo(struct kunit *test) } } +/* + * Test that if we affect a single output, only the CRTC state of that + * output will be pulled in the global atomic state. + * + * This is relevant for two things: + * + * - If we don't have that state at all, we are unlikely to affect the + * FIFO muxing. This is somewhat redundant with + * drm_test_vc5_pv_muxing_bugs_stable_fifo() + * + * - KMS waits for page flips to occur on all the CRTC found in the + * CRTC state. Since the CRTC is unaffected, we would over-wait, but + * most importantly run into corner cases like waiting on an + * inactive CRTC that never completes. + */ static void drm_test_vc5_pv_muxing_bugs_subsequent_crtc_enable_too_many_crtc_state(struct kunit *test) {