Message ID | 20230720-kms-kunit-actions-rework-v2-1-175017bd56ab@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp3048879vqt; Thu, 20 Jul 2023 04:30:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlEi6mZ6utMRevI/r0ZNQRKqbtka7KLmmmBr+nouO0L1GVUdW2HgQukhmtnwhy+5oDFWay8b X-Received: by 2002:ac2:58ec:0:b0:4f9:596d:c803 with SMTP id v12-20020ac258ec000000b004f9596dc803mr1933462lfo.53.1689852626854; Thu, 20 Jul 2023 04:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689852626; cv=none; d=google.com; s=arc-20160816; b=Rqp5gGParId5UwNb21Db/K8E9xoYWp0EApHYbbOl2lvVB2as8FFVqel/y3ZAc+Q/26 3RKcsChF3YfcfyDoavtkdLtIXA7oLQ4IIFkCObqSh55DPxDGbmWTF9mFzgMUJVf07QRZ KOXjNuAAscR3U3Udhawmk3HZgTqf2svT/BeDEXTBUvkpUEkkabNITMZzBO6UY3Ga7bpI Gw6cgWTAZAQ4KO6dhDK+VDeMe0W2TZY6RjBoMGlf/qHI5GD2KiDCn2bUDiqqqF19Jslm eANdwBnEamRVPGUxCGbDrIxvrkj3hTLvGt3g5CYoWZBe6iKhvL9+xKQbUMblfI2seV2F /QSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=XWRLlE18qznDGvjQSof2ldeDzMoiKwqx02lI5BBHLlE=; fh=r3YnEVRF2ge3yIgpTE2H86lvFoURZyw1nrIW71mPVsw=; b=Jza8O8m2rT1ELeg+TT+gKQn8q97qc1bL2k/pjOHRwZzlAiwLEKLznrvW3hrrkmvqCa F8Q5GjFDgaCXFAOxMyUXHDmzV1jaaubo/dxaLUdUnuSfy7mVvn6JRSQg3d2pSRtCN/Mb sc4xkeUsyLDbt8VQ0mCHpOAhev1H0O8H0iVFR/X2Wb2tgHuvadIDm5HMAJUx+KmJbMd/ 4WCdEv6JTcSBEnEMpq9CZSl0VMpbIwCCXEwGhpze3JRlB3ZYTVofE1k+WjVziULe8rMJ kkBxTmwIn5IVQh0IRKSOTDdfbZTBZItI5BXKvIVmFKIAL6Ne5+Rf3p3mRKxObEfm7vCI iWcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O8ku5xZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u25-20020aa7d899000000b0051e162ffa28si619115edq.691.2023.07.20.04.30.01; Thu, 20 Jul 2023 04:30:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O8ku5xZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230137AbjGTLQb (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Thu, 20 Jul 2023 07:16:31 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <mripard@kernel.org> 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, Emma Anholt <emma@anholt.net> Cc: =?utf-8?q?Ma=C3=ADra_Canal?= <mairacanal@riseup.net>, Javier Martinez Canillas <javierm@redhat.com>, dri-devel@lists.freedesktop.org, David Gow <davidgow@google.com>, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, Maxime Ripard <mripard@kernel.org>, Brendan Higgins <brendan.higgins@linux.dev> 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771938907797664291 X-GMAIL-MSGID: 1771938907797664291 |
Series |
drm: kunit: Switch to kunit actions
|
|
Commit Message
Maxime Ripard
July 20, 2023, 11:15 a.m. UTC
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Maxime Ripard <mripard@kernel.org> --- drivers/gpu/drm/tests/drm_kunit_helpers.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
Comments
Hi Maxime, kernel test robot noticed the following build warnings: [auto build test WARNING on c58c49dd89324b18a812762a2bfa5a0458e4f252] url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Ripard/drm-tests-helpers-Switch-to-kunit-actions/20230720-191901 base: c58c49dd89324b18a812762a2bfa5a0458e4f252 patch link: https://lore.kernel.org/r/20230720-kms-kunit-actions-rework-v2-1-175017bd56ab%40kernel.org patch subject: [PATCH v2 01/11] drm/tests: helpers: Switch to kunit actions config: arm64-randconfig-r022-20230720 (https://download.01.org/0day-ci/archive/20230721/202307210148.7gWzLOtn-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210148.7gWzLOtn-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307210148.7gWzLOtn-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/gpu/drm/tests/drm_kunit_helpers.c:53:6: warning: cast from 'void (*)(struct platform_driver *)' to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 53 | (kunit_action_t *)platform_driver_unregister, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> drivers/gpu/drm/tests/drm_kunit_helpers.c:61:6: warning: cast from 'void (*)(struct platform_device *)' to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 61 | (kunit_action_t *)platform_device_put, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/tests/drm_kunit_helpers.c:69:6: warning: cast from 'void (*)(struct platform_device *)' to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 69 | (kunit_action_t *)platform_device_del, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/tests/drm_kunit_helpers.c:89:9: warning: cast from 'void (*)(struct platform_device *)' to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 89 | (kunit_action_t *)platform_device_unregister, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/tests/drm_kunit_helpers.c:93:9: warning: cast from 'void (*)(struct platform_driver *)' to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 93 | (kunit_action_t *)platform_driver_unregister, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 warnings generated. vim +53 drivers/gpu/drm/tests/drm_kunit_helpers.c 28 29 /** 30 * drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test 31 * @test: The test context object 32 * 33 * This allocates a fake struct &device to create a mock for a KUnit 34 * test. The device will also be bound to a fake driver. It will thus be 35 * able to leverage the usual infrastructure and most notably the 36 * device-managed resources just like a "real" device. 37 * 38 * Resources will be cleaned up automatically, but the removal can be 39 * forced using @drm_kunit_helper_free_device. 40 * 41 * Returns: 42 * A pointer to the new device, or an ERR_PTR() otherwise. 43 */ 44 struct device *drm_kunit_helper_alloc_device(struct kunit *test) 45 { 46 struct platform_device *pdev; 47 int ret; 48 49 ret = platform_driver_register(&fake_platform_driver); 50 KUNIT_ASSERT_EQ(test, ret, 0); 51 52 ret = kunit_add_action_or_reset(test, > 53 (kunit_action_t *)platform_driver_unregister, 54 &fake_platform_driver); 55 KUNIT_ASSERT_EQ(test, ret, 0); 56 57 pdev = platform_device_alloc(KUNIT_DEVICE_NAME, PLATFORM_DEVID_NONE); 58 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev); 59 60 ret = kunit_add_action_or_reset(test, > 61 (kunit_action_t *)platform_device_put, 62 pdev); 63 KUNIT_ASSERT_EQ(test, ret, 0); 64 65 ret = platform_device_add(pdev); 66 KUNIT_ASSERT_EQ(test, ret, 0); 67 68 ret = kunit_add_action_or_reset(test, 69 (kunit_action_t *)platform_device_del, 70 pdev); 71 KUNIT_ASSERT_EQ(test, ret, 0); 72 73 return &pdev->dev; 74 } 75 EXPORT_SYMBOL_GPL(drm_kunit_helper_alloc_device); 76
Hi David, Brendan, On Fri, Jul 21, 2023 at 01:14:41AM +0800, kernel test robot wrote: > Hi Maxime, > > kernel test robot noticed the following build warnings: > > [auto build test WARNING on c58c49dd89324b18a812762a2bfa5a0458e4f252] > > url: https://github.com/intel-lab-lkp/linux/commits/Maxime-Ripard/drm-tests-helpers-Switch-to-kunit-actions/20230720-191901 > base: c58c49dd89324b18a812762a2bfa5a0458e4f252 > patch link: https://lore.kernel.org/r/20230720-kms-kunit-actions-rework-v2-1-175017bd56ab%40kernel.org > patch subject: [PATCH v2 01/11] drm/tests: helpers: Switch to kunit actions > config: arm64-randconfig-r022-20230720 (https://download.01.org/0day-ci/archive/20230721/202307210148.7gWzLOtn-lkp@intel.com/config) > compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) > reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210148.7gWzLOtn-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202307210148.7gWzLOtn-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > > >> drivers/gpu/drm/tests/drm_kunit_helpers.c:53:6: warning: cast from 'void (*)(struct platform_driver *)' to 'kunit_action_t *' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] > 53 | (kunit_action_t *)platform_driver_unregister, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I missed that warning before, and I don't think we can address that easily. Should we give up on kunit_action_t entirely? Maxime
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);