From patchwork Thu Jul 20 11:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320325 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 935B8EB64DC for ; Thu, 20 Jul 2023 11:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230058AbjGTLQa (ORCPT ); Thu, 20 Jul 2023 07:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229779AbjGTLQ3 (ORCPT ); Thu, 20 Jul 2023 07:16:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E2A2D4A; Thu, 20 Jul 2023 04:16:01 -0700 (PDT) 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 264FB61A32; Thu, 20 Jul 2023 11:15:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11272C433C8; Thu, 20 Jul 2023 11:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851758; bh=/rkNjrxerN0rrN6VUl+VmzclsPanUGawK+BoOr9yqMg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=O8ku5xZOj45PrctUd2XegxQhPy1mG9fVcUNBMBjoGEBdUh8u4DOpmf8bicCWQIBtQ 4tIHgHKK6IfNunA2aYGMvMsaY73KpDI/CYldneB3s3lnrZihTpShKs6WcoWAEtVO6s 8N00iNyfXWWgifqzlvim9hv/0D2WV1L8vgvGkBveIXNUhhpGd4TyUrR9DgTOoavLGD /C2sHgA1hRtrRdAmBjFlFKHTn3j4XQzMF1HvaMQZ4xL7QG61JpTER939YIRJ7O+dX6 KFG7vSybXmJ4iG357J8nC8mEnC6YBnsNnCUXblQNPSyGWeHFaH2jnSikqcuvD3/y+T bl6xf2pehay9Q== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:46 +0200 Subject: [PATCH v2 01/11] drm/tests: helpers: Switch to kunit actions MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-1-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2424; i=mripard@kernel.org; h=from:subject:message-id; bh=/rkNjrxerN0rrN6VUl+VmzclsPanUGawK+BoOr9yqMg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTOqRM/cfHv0Ztw5hlTmmjvMJxQN3t1QPPXx1zfRR SLrLufu6ShlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBE7m9gZHi/6fO9X4/qlT1D Z3R8XXZ6gbRnrVm25M+UkxM+lV7ekt/KyPBu12zLcpMVk/K+qrKsleG8/PLfhvlOSjtmJilkfb4 SrsgDAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_kunit_helpers.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 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..5856beb7f7d7 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,27 @@ 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); + ret = kunit_add_action_or_reset(test, + (kunit_action_t *)platform_device_del, + pdev); + KUNIT_ASSERT_EQ(test, ret, 0); + return &pdev->dev; } EXPORT_SYMBOL_GPL(drm_kunit_helper_alloc_device); @@ -70,8 +85,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 Thu Jul 20 11:15:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320327 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7989DEB64DA for ; Thu, 20 Jul 2023 11:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230471AbjGTLQh (ORCPT ); Thu, 20 Jul 2023 07:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjGTLQb (ORCPT ); Thu, 20 Jul 2023 07:16:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53AA02D58; Thu, 20 Jul 2023 04:16:05 -0700 (PDT) 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 E23FB61A28; Thu, 20 Jul 2023 11:16:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D216EC433C7; Thu, 20 Jul 2023 11:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851761; bh=on1Ib/kmGdNbcufdxrj7WeqtPtfL4L5bH7r+5VawDuk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=llG11i4EVQXKrbvkGXtR1u46+LVcmwYBDERDalrk8JDZXiDyhHL8TGR/NwHOOMvNz 1PWyswk6BwwW7bADHTdCleZ1q+vqrR3D3u3eaufT50uTXj60V1Su0aWH9Ba7sJbIF9 C1lIZS6rDfVEXMfQ2RyGo3KTZUkp1v12raxzjCB7vJhIu1rE8VExCd3ofIP27V6UuG kswXF7cP+gbLMfATq2j2h+Agerjhq+i/iFBA8bWywwvLa84PCUTtHVsRaZXPcA4wrO XZiq9fsnDj4348m77XsPXkDF3ePIYbvnggXL5vqW7Ya+MGp5OB0kFEID0KZ1GyGlSQ lytxEZwckbsbg== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:47 +0200 Subject: [PATCH v2 02/11] drm/tests: client-modeset: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-2-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1405; i=mripard@kernel.org; h=from:subject:message-id; bh=on1Ib/kmGdNbcufdxrj7WeqtPtfL4L5bH7r+5VawDuk=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTMutReF1l6zX6Prf8JdTimR747i00X/wr9cjlP+s PSsZL1wRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACbyl5vhf45OjvbEhkh2RtlL 2yz0e+fl+WevT8w0X1sz22zH0st3JRn+6W68zv7FoE1pB59SzjMVVw+r+StS0v92ZK1zC3mx0qO WAwA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320326 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27323EB64DA for ; Thu, 20 Jul 2023 11:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230292AbjGTLQe (ORCPT ); Thu, 20 Jul 2023 07:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230080AbjGTLQb (ORCPT ); Thu, 20 Jul 2023 07:16:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D78682D56; Thu, 20 Jul 2023 04:16:04 -0700 (PDT) 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 B1D3561A2A; Thu, 20 Jul 2023 11:16:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A1C8C433C8; Thu, 20 Jul 2023 11:16:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851764; bh=WCfLzKJ9sM8i+BLjxKY6Cmt+LRE3//pdjKIz70DXm0E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UNaf6uTbWK2GPJonf5J7mfU2ptw6C7UGMCgxsyCSYwLHB3D636hw4r33zJpx9bYeZ VD6RTESqqz2fi3vosR8f3K4hw6Mnl5bWI5Hj9SBSYMQskpG+sDUVlPk8ZwQgfcsdFz 43zNnRa6famQsILB7m+ijEZKIw0YZysU1unNJrtHfcK+sqUfzoCroZ+SLzG5MAesP+ 9a5HGw1UMS1MKys0T7NCe21aARXQrw1nM2jcHkM2b7tXuQL0po2RN6OeVrUHfyJ6cP uo054JNiLq9ulYxTGQnzcVTPcndy7HsUIus2nHsxaeRW8a1+DewnAMBQoe6RjYiOga GB+eELLrpjqcw== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:48 +0200 Subject: [PATCH v2 03/11] drm/tests: modes: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-3-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1295; i=mripard@kernel.org; h=from:subject:message-id; bh=WCfLzKJ9sM8i+BLjxKY6Cmt+LRE3//pdjKIz70DXm0E=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTNce5ez58hlbNrX8dW3Q625/pewoty87DUhp/96n nWv23q1o5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNZY8Tw3+eTaXLC9wYzG7Eb e8OeXuayXSIW43jS58j8ct11PRGn0hgZPl2/fPBtQvY5L8tb9pPF89n+S3av9Ni/7IuaiPV3q/g 7DAA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320329 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51EB9C0015E for ; Thu, 20 Jul 2023 11:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbjGTLQj (ORCPT ); Thu, 20 Jul 2023 07:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbjGTLQd (ORCPT ); Thu, 20 Jul 2023 07:16:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F142D270B; Thu, 20 Jul 2023 04:16:07 -0700 (PDT) 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 634F061A22; Thu, 20 Jul 2023 11:16:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61B63C433C7; Thu, 20 Jul 2023 11:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851766; bh=lolA781m2pvNRYndxxR6VFXpaiQRr55iVDwxTaDQ5Cg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dTYuZxfdBdBE4uVyYSw1okw02GNpd3y/cPPtAQH5kOZN05SRokADcJOknZmXVWvuE 3GVK6YatJzb3/7INyVcGVPXS/K7Dv4YF9y0JAiCMiC6s+lAmTkW3QWPkf5f+qLLwo3 DDt8ojhhGirvs63NQqLzBv7zKaejXoPaqoBI9JjYDt9uDw+L+wK9VxORVAbaoIHTNH Om+lfBGw7an1vRpNb25o5edTtjIBoSVcGWHwgIcnQ6OtO0O6ru1jvzbPCevP8MbYns fmEok7SZIrHuDAGCez4A0vfJ88CzhmlYm6nvGniEkV4p1Ix7MvuRdFcuLBJ/qgVFVd ASXMThOuUR2cA== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:49 +0200 Subject: [PATCH v2 04/11] drm/tests: probe-helper: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-4-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1442; i=mripard@kernel.org; h=from:subject:message-id; bh=lolA781m2pvNRYndxxR6VFXpaiQRr55iVDwxTaDQ5Cg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTN+ed+ROjlv+d053PHpDT9F7Cy6r0czLD/5QeDR/ uW2BzsEO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjARbR+G/84z1p/Vt4iSEfVZ 7qTu/UJT/Z1W4v1Uk3OO7Wv0sxL95zAyLGoMM+ap3J7fGjpDem/pO+Npf687vcze8HnmQTPrx+E neQE= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320328 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D8BDEB64DC for ; Thu, 20 Jul 2023 11:16:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbjGTLQi (ORCPT ); Thu, 20 Jul 2023 07:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjGTLQd (ORCPT ); Thu, 20 Jul 2023 07:16:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31D152706; Thu, 20 Jul 2023 04:16:11 -0700 (PDT) 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 7C43C61A33; Thu, 20 Jul 2023 11:16:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67340C433C8; Thu, 20 Jul 2023 11:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851769; bh=CXPsdCVxz77cgfDGMI4BSalP4ePPYu8Tjf40VvpURr4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=peC6XHDlEo9ViqK8GjRcdygHlyFRs4WTMcmRssoW59KEKeh3xvg9kpYr+4c/3R7Wq d6VUIrqPvsBxv6MWCQ5huSN+Nm/oOFrtPjBeL8gJa5oeL8o4dpLIRv9w89rkWloDuu aWaEQJgNtCOvyv0ELmmuFoy3xKTS1uxGQyvCd6lTaFFIQoyFgu8mwaB4u0g6uJyHV5 A4ET8iadCrvlGJ2doFhrrWS1SeVwHIEknYq1+VDbRysTskWEB12h1ho0qMIOZ6anUk 7tGJfrB6SdjO3/PE+RR6eh17XxtlvOFBzLRNXtfKPPdOA5/gY7EW1TfVWjHUPfecgF kHeyl98s0yTnQ== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:50 +0200 Subject: [PATCH v2 05/11] drm/tests: helpers: Create a helper to allocate a locking ctx MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-5-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2652; i=mripard@kernel.org; h=from:subject:message-id; bh=CXPsdCVxz77cgfDGMI4BSalP4ePPYu8Tjf40VvpURr4=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTOKj0Vt+pHu+uzCVas+w/2m0qWbm/zXOqXZ+9/5s WffA9XVHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZgIz39Ghom3ShRDzrhZBcdO va37oeD4z0v8+153n3Xb6rP+bXcN90ZGhrcd5V85I9QfbDk3gYlrVqGr4CWpsC/SnrUuJ9q4Vx5 7zQkA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 5856beb7f7d7..5130d4553262 100644 --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -120,5 +120,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 Thu Jul 20 11:15:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320330 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0491C0015E for ; Thu, 20 Jul 2023 11:16:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjGTLQr (ORCPT ); Thu, 20 Jul 2023 07:16:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjGTLQd (ORCPT ); Thu, 20 Jul 2023 07:16:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E607270A; Thu, 20 Jul 2023 04:16:14 -0700 (PDT) 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 9756061A30; Thu, 20 Jul 2023 11:16:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7122EC433C8; Thu, 20 Jul 2023 11:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851772; bh=RTSEK9AuzInb7QEn851gyVYlX2dE99c4ygJyZxMvK4w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LGJjo1RlmLqvxcMtAHqsnDWNrG5LnXneK5Yg0asEY0wUnpmxf5EQlxVYZJ8fb68ZI lBh084z2BgcXsxbtV/T1m272twTAM1vFVk9Hg34KEldAaPxAIzxtphK6ntKVgLHfPr jhY2pI01EwRFI1TwI5Hh/0k0aayQyCEZXjPsTpN/LGzff2+gzAzhMK+2qyY979qd+2 nSim8I6Nq+K3ofrZt7GZEO+gFtJxsSoQ0FM9pnNr40woS40ERxBQD0RGKNX3T0ACu/ Gk4wux8xPAAqc0P/hcRTC/pzVhFAyOwzGT8N9jwiEsrzqLfV4RsD9Ai4fceVMrhQW3 t+JJX09qz25hg== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:51 +0200 Subject: [PATCH v2 06/11] drm/tests: helpers: Create a helper to allocate an atomic state MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-6-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2883; i=mripard@kernel.org; h=from:subject:message-id; bh=RTSEK9AuzInb7QEn851gyVYlX2dE99c4ygJyZxMvK4w=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTN2dsp7mT+PKRU0fMZ0W2y+0tkJTOdv7lYX9XqXw 7Pw487tHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZiI9D+Gf5o9nI4NK7yXLVTa fmQLo2K/59RURseeN08+bVy5oEfvxhuG/5E2IpVf37O1V4YvvvtnpfA1uXMiYR25zy4KJCZJ7+q oYwcA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 a helper to create that atomic state, and call an action when the test is done. This will also clean up the exit path. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 5130d4553262..d3b2c6b48163 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 @@ -161,5 +162,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 Thu Jul 20 11:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320331 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66513EB64DA for ; Thu, 20 Jul 2023 11:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjGTLQz (ORCPT ); Thu, 20 Jul 2023 07:16:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbjGTLQg (ORCPT ); Thu, 20 Jul 2023 07:16:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6FEB26B5; Thu, 20 Jul 2023 04:16:16 -0700 (PDT) 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 51E1661A04; Thu, 20 Jul 2023 11:16:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 297AFC433C7; Thu, 20 Jul 2023 11:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851775; bh=aEbBH90Q7xkJQdnrDQMeL1MCCt2R23BBm7z0R3SziVE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Wo0cwtVmdDvOk9uIrmrFk6ErNrzUBBnsC1KZRI0wB6MqBpUTTifHbXi+Q4ti9Pbko 12mq6XNT8eOBWCdWlbwzOBlhe9KVggkqh+EKhyEeZyG/iP6X3PnsoZBPvzHkk648Wq rtqP2cp9ScuibEqlH3GCvC3OWvhXwDm2HEPBy0CZXlQz681b01VoBnYsviO78MC5cf 1WWoOK9D0delsBrtpsrRg7t9/zFEu7AazZ+aTLKEmDJ849xEvcL65lzDsra6FZGHSI IDWrl+5h+vsFQsI70F8zz6UHV3d2dCpT6fHEoTNgwhgVCsKAEt6Mm2T7Bdg6xy0ZHg zSehdjDP93cuw== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:52 +0200 Subject: [PATCH v2 07/11] drm/vc4: tests: pv-muxing: Remove call to drm_kunit_helper_free_device() MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-7-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1853; i=mripard@kernel.org; h=from:subject:message-id; bh=aEbBH90Q7xkJQdnrDQMeL1MCCt2R23BBm7z0R3SziVE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTM439+7/nvW7ivPzsaz771auWPBlMt35ySmWTOye NgGxRbHd5SyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAi/9YwMnyOn6ax4phyFusi 94dmrS7bJut2Otc9vHfP/RjDe8dZbosY/ln5yfjZvcm+9W3/+Ul1wk1K8iz6wp65WSzuOX6+jRp RjAA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320334 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE01EEB64DA for ; Thu, 20 Jul 2023 11:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229751AbjGTLRB (ORCPT ); Thu, 20 Jul 2023 07:17:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230506AbjGTLQr (ORCPT ); Thu, 20 Jul 2023 07:16:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E79726B7; Thu, 20 Jul 2023 04:16:27 -0700 (PDT) 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 5A36461A40; Thu, 20 Jul 2023 11:16:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45EFBC433C8; Thu, 20 Jul 2023 11:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851778; bh=JWFUwbalD9zxa7dO/ypOz2ghZPZM+ydDXz32zJavDmo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rEatctXrj2El/Oqy1p1LuoVHjODRVKHwABdheYr7D+onnRgjPQTdG04aSVp5k6iJ6 ONrLpEmbwfdS3BxkhZGwQFFpldyp9azcoIZ0aYplDhEuXeccqzPcp4hwLrWLIzASZ3 bcdaCziIgQLc2VnyxscUOXxsJk2eHVlI8CJtgqdyVgmJfTtMPEVWHIiPphmCmhtSRJ oOCHKeXaJjrI7rAjpFzveNdCKwaHz6Pr0378if2GvSQSyLqD9niZrOPiM191dy5Mu8 NODcJukr9fAyDiyPODWUv0u/TR9oywflLWAy+fdXNRtXxkLEXcW+WotSumAN8hu762 WiAT/WaGzWHWg== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:53 +0200 Subject: [PATCH v2 08/11] drm/vc4: tests: mock: Use a kunit action to unregister DRM device MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-8-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2707; i=mripard@kernel.org; h=from:subject:message-id; bh=JWFUwbalD9zxa7dO/ypOz2ghZPZM+ydDXz32zJavDmo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTNeBN0RPz+jjEX21DPrzuOxy6YveKE35Yznh8v9j vta1heqdZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAi/2UZ/kdYbWP8pSvxfSfn VO67jkdayo8wb39xZJZT3HvDt0/uMmYw/OGde3vF5/su7RukFuiu4dP83rgt/5r1rLKGi1M/L33 2qpgJAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320333 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1349BEB64DD for ; Thu, 20 Jul 2023 11:17:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230518AbjGTLQ7 (ORCPT ); Thu, 20 Jul 2023 07:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbjGTLQr (ORCPT ); Thu, 20 Jul 2023 07:16:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075C026A4; Thu, 20 Jul 2023 04:16:27 -0700 (PDT) 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 0F03961943; Thu, 20 Jul 2023 11:16:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A4EFC433C7; Thu, 20 Jul 2023 11:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851781; bh=juQ2m7xou5mMg6r42FUm4fzdZ7mTdNjeC346O1aspUU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=u5K6U4twXCxqhcSDvnRP1UfLNhlkbKUFgB9NPFSYz4RJQ3OlfJ9bE+ObxBxQuNHFl l990FFRmvZ8MZDiaLnA2+3+aYSHID/2pKSAr8I7N6BM/fTPmjo+iG0QThb15Pb2Rpt ihBzyNfT99InGFR6EtFMPQ+GTEiZJxSK3perz+AJ+xcxfad2CSmUXJ+wnUVqEnx3+l TT0izJtBayWf5/CC2zJLQYgA+U6Y4gZvue0nbYsVmli6ioYfkHEE+SIDFUfynUPEJo DXHSWYn3ww2lkxGqvnH24D2DJ54li2F2Cz8RSuZfUS9SOC/v9N93JZtk9az6vxCaCl FR6gLPf/rJh9g== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:54 +0200 Subject: [PATCH v2 09/11] drm/vc4: tests: pv-muxing: Switch to managed locking init MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-9-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6503; i=mripard@kernel.org; h=from:subject:message-id; bh=juQ2m7xou5mMg6r42FUm4fzdZ7mTdNjeC346O1aspUU=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTMq91Y/+8R4aurp74GLlZYw/Fn22qtJr+oKG3/J7 MInrD9CO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCR7esYGToPLLyZMTWhdzcP 91KvTTWSXyRyFA9fMOvu+vv0e5nz1K+MDO9NrN/MvpTwkGGp/+9MKZXf236xCR+U+OU35cO+rGN X3dgB X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The new helper to init the locking context allows to remove some boilerplate. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320332 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1275EB64DC for ; Thu, 20 Jul 2023 11:17:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231276AbjGTLQ7 (ORCPT ); Thu, 20 Jul 2023 07:16:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230508AbjGTLQr (ORCPT ); Thu, 20 Jul 2023 07:16:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F59426AD; Thu, 20 Jul 2023 04:16:29 -0700 (PDT) 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 21E28618C8; Thu, 20 Jul 2023 11:16:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E170C433C8; Thu, 20 Jul 2023 11:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851784; bh=HNjCpgftiIlvFffeczCsnLqPGw+XAfACZlhyJdStoFw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lzo1xmCivendmDDU1pgho+HmsqDv2rh4T4g3SbWZb91SbztWE/BHARezPsy/5VzlE jiO0ROl59GzSLjoJOz12QlZ+CE4T85mskC2jvHi/+YRoD7/T3lxSVvxb6CGz/XN22g R27btFMfBHZrGbrA7NF/i1lXdrJHFNOJCSidVArffoMsUob+3lVfNeY8X6uuIUyk1A Lc8BqbVr/elNDSu7GLNuRNMam44wE1VoK0HCX7NGfsyC2AnEEZFws8OCvfC9xd+r/m Bx4zUTyWWsBHE6H/tMQz/rl4FfIfSFsQWlb7990CTBjS7Nv41oFpjurLwU1z9bqnrR 7TmUD4cEIZkRg== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:55 +0200 Subject: [PATCH v2 10/11] drm/vc4: tests: Switch to atomic state allocation helper MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-10-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6185; i=mripard@kernel.org; h=from:subject:message-id; bh=HNjCpgftiIlvFffeczCsnLqPGw+XAfACZlhyJdStoFw=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTP6VjQ0Nk09v//4i5ZXx5c09ATpMH44/7azSTnoy AfxnZ9Pd5SyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiwnMZGdb+esYxWWDJR8dD N49/vxPOOTfkIOPs8zknumbs9/ne+NaNkeHOPGeT+yIK3+dpicVeWJyhdf5ga7ZLYH/NlK67Mwy YHjEBAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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 Thu Jul 20 11:15:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13320335 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92985C001E0 for ; Thu, 20 Jul 2023 11:17:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbjGTLRC (ORCPT ); Thu, 20 Jul 2023 07:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230513AbjGTLQr (ORCPT ); Thu, 20 Jul 2023 07:16:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E53626BA; Thu, 20 Jul 2023 04:16:29 -0700 (PDT) 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 EE78861A3C; Thu, 20 Jul 2023 11:16:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC9B7C433C8; Thu, 20 Jul 2023 11:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689851787; bh=1nrTAqbBZBRZUWDEE1a4SHpcULf4RL/1UmtaRjuNMUQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lz8IptbCLxR2awc9YH2yICNKvrOS1iLA0ys8CGXwD+1ZP9bB6leHWgjd9xk44hFt9 z/HNJuRve2OSgiwQ6MVOAKkQFdcdXk3OwiWojddAcTNK6E39iNt3OEJ9gJVUBNodq9 QgacqYyNYJAhsXxnfFnEGTNENiIpP6J0ySOPJYwgaCe3MvP7BhWydIqyZv8vbjq5Bd k1OvSsI9Zvm9WFZr6e1kMyZeTPl6aQkxGxMgjExGUeG9uHlGmcwRBt5RJwvXsz5wQ9 lgsHMFe2vlINz41eBlt6b0oQWIDr8wbU0OrHUBg60Eupig6CA8MWV781ws9aEOLsDr acEnsjlp4qQJQ== From: Maxime Ripard Date: Thu, 20 Jul 2023 13:15:56 +0200 Subject: [PATCH v2 11/11] drm/vc4: tests: pv-muxing: Document test scenario MIME-Version: 1.0 Message-Id: <20230720-kms-kunit-actions-rework-v2-11-175017bd56ab@kernel.org> References: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> In-Reply-To: <20230720-kms-kunit-actions-rework-v2-0-175017bd56ab@kernel.org> To: David Airlie , Daniel Vetter , Maarten Lankhorst , Thomas Zimmermann , Emma Anholt Cc: =?utf-8?q?Ma=C3=ADra_Canal?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, David Gow , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard , Brendan Higgins X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2062; i=mripard@kernel.org; h=from:subject:message-id; bh=1nrTAqbBZBRZUWDEE1a4SHpcULf4RL/1UmtaRjuNMUQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7xTNaps5z1zfa0BmT7dNsLnmD7dCelUXi6zYKbuwRv cKss0+ko5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABPh4WT4K7ki8gvLjBfx+RGv DcQ+Sq3e+7svemfO20LBAnG5xy4PYhkZtrCtZ1jtxlJ0pthq2knuaTuWNs3u8Z8yc1m56q0jQi9 jWAE= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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. Reviewed-by: Javier Martinez Canillas Signed-off-by: Maxime Ripard --- 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) {