Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp554367rwb; Mon, 26 Sep 2022 02:46:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7COMi9b5Ps7wCxHp0thrm3uT2iFCjTyxDvzx5uNa13tYOKxFcuMwgEKls4xATB7+wp2p2D X-Received: by 2002:a17:903:2595:b0:178:6b71:2eea with SMTP id jb21-20020a170903259500b001786b712eeamr21283491plb.143.1664185581513; Mon, 26 Sep 2022 02:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664185581; cv=none; d=google.com; s=arc-20160816; b=WtufhYjXJ0be+cAtjYA885CnUJr4uuxc2dsgcnuqTpcoxet/zTd94MaXXq59nXELT/ zgxlxm+CmNOQMCmFsl0+CL1qLL7jLedwbIud/4GFuJurljAEQuG/Rw2oJM+O3UnJl98S /kopoCEzxf094hX5QXt4prKk/XmJMH83tsnXvZcz1Ab05zCm7euB/R3INFXdLCJPb+A0 wY62nL7EJbvSi2LFpTkd6UECFj8eSSSObRWCJKzcTnroRZxMpNwpc0YC4kC7DKcUFU5u ls6En5IzNdxLaHP5L5lsWSoEG7k+CLXn8o+n4ub02VxpW1MJVOQjVuJtJe2jKx2hGuJz M2Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=iMhV2MQCYEl08x7MCNwj+bMXhT0kipZzBnwNpIfB8gg=; b=Th8D7jmlk4u7nY7hXCAFrobaTAg0yM2RlTytuVRJAD5XJjr3gqytsorCDg7oBcQ400 9FjAIM0a72ejv6dNR1ygJQZJHN5gyZEmj7KMmNAwYRgM8gYBy3RJSv2aEaqbJtgkdoiP zFJVr061HpFvY+3IuMXDiFgafwxWUcjHlellWSO1Mg34oSmvcEGwix8r1HDiJTquiZz9 jcSheKFXgIWNaq6y4wopQThRIcUsIFHeCF6buMyA186mcQ3yUBbEvClgHqKhM9VZS/OW 0PUV/zUUm6hoXT31t0JtZvdpE67jgO0vqWK+Gy03Neze3gPgS/M4TI52Ni810BCqY3Mq 8YrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=nJeRGFAL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=SvSPhEi0; 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=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a170902dacc00b00177e1d604d5si13225937plx.609.2022.09.26.02.46.08; Mon, 26 Sep 2022 02:46:21 -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=@cerno.tech header.s=fm2 header.b=nJeRGFAL; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=SvSPhEi0; 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=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234341AbiIZJg0 (ORCPT + 99 others); Mon, 26 Sep 2022 05:36:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233444AbiIZJgY (ORCPT ); Mon, 26 Sep 2022 05:36:24 -0400 Received: from wnew3-smtp.messagingengine.com (wnew3-smtp.messagingengine.com [64.147.123.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6542B22BDA for ; Mon, 26 Sep 2022 02:36:22 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id A27792B0689B; Mon, 26 Sep 2022 05:36:16 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 26 Sep 2022 05:36:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1664184976; x=1664192176; bh=iMhV2MQCYE l08x7MCNwj+bMXhT0kipZzBnwNpIfB8gg=; b=nJeRGFALZvB203VwJ3MiqZV0H9 SgOgeQdWX4BuXqw5zho/RS25xCKP8KzdQRqm2mCuyRCuOyNsg99A+lAMh76HqDOD x+eTg6WYdZgrHKS0zSICLvO8j/3SJP13HCCOJDkPl0uPhzva8dlItg1Ao8XIGumK Vbx9nh+ELeMIBIDKskokk2eSRhBBTy+Ebrn/rCkgwq5UieGaMJkByqoK+baIJH2C 5/HTEUfuOUF0Aewimr0CqDc5o4qad0/cuXBZvtQDDPTeP6obnNVGzbrPy1O7EYyt KA2581CvfZVH/CjRitmTgJKzFxhYz6lW5pJezzh6VmVJ0W1Vk1jK/Rf7r3oA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1664184976; x=1664192176; bh=iMhV2MQCYEl08x7MCNwj+bMXhT0k ipZzBnwNpIfB8gg=; b=SvSPhEi02+Ihox7kOmDVhX4pbeqMyi4CJjvjX99cbEyr +Smb2FJx3Ykc2JdeOsoir0jS89/4SjDKcOp0VS69YroKe5ZScShh/wzbeal++grP T3kz/sLVTtvTxyWcC7amFT8p0IQ7unvvIhjLZMctMR9p2aebfl5O2flACUCM2iCZ 2P5b3wXbgjghbYrR6Kyohv5VMzKI7Yp0WJKOOxliNMEAlU2NYmH7nDfcOatZJmwA R60diWPuTdqMHff6/EjwHJOUIq8bKG5D5uiy2lrUcwW+cHnxd0gbHlloPbAiVSxw 3+0du3C5VZZ06FibJPIilHWQYsr44TrJRhrXkcRR1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeegvddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtudenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeejveefheefkeeiffegveelveetgffffeektdefuefhtedtgeejhefggedu ffffudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 26 Sep 2022 05:36:14 -0400 (EDT) Date: Mon, 26 Sep 2022 11:36:12 +0200 From: Maxime Ripard To: Noralf =?utf-8?Q?Tr=C3=B8nnes?= Cc: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai , Hans de Goede , nouveau@lists.freedesktop.org, Geert Uytterhoeven , Dave Stevenson , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Phil Elwell , intel-gfx@lists.freedesktop.org, Dom Cobley , linux-sunxi@lists.linux.dev, Mateusz Kwiatkowski , dri-devel@lists.freedesktop.org Subject: Re: [PATCH v2 02/33] drm/tests: Add Kunit Helpers Message-ID: <20220926093612.wvbou2srbo3uinar@houat> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> <20220728-rpi-analog-tv-properties-v2-2-f733a0ed9f90@cerno.tech> <3f7000ab-b845-a7e8-f215-02121da779b7@tronnes.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wdbx6g5pylyw5se6" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --wdbx6g5pylyw5se6 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Noralf, On Sat, Sep 24, 2022 at 08:06:17PM +0200, Noralf Tr=F8nnes wrote: > Den 24.09.2022 19.56, skrev Noralf Tr=F8nnes: > >=20 > >=20 > > Den 22.09.2022 16.25, skrev Maxime Ripard: > >> As the number of kunit tests in KMS grows further, we start to have > >> multiple test suites that, for example, need to register a mock DRM > >> driver to interact with the KMS function they are supposed to test. > >> > >> Let's add a file meant to provide those kind of helpers to avoid > >> duplication. > >> > >> Signed-off-by: Maxime Ripard > >> > >> diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Ma= kefile > >> index 2d9f49b62ecb..b29ef1085cad 100644 > >> --- a/drivers/gpu/drm/tests/Makefile > >> +++ b/drivers/gpu/drm/tests/Makefile > >> @@ -8,6 +8,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) +=3D \ > >> drm_format_helper_test.o \ > >> drm_format_test.o \ > >> drm_framebuffer_test.o \ > >> + drm_kunit_helpers.o \ > >> drm_mm_test.o \ > >> drm_plane_helper_test.o \ > >> drm_rect_test.o > >> diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/d= rm/tests/drm_kunit_helpers.c > >> new file mode 100644 > >> index 000000000000..7ebd620481c1 > >> --- /dev/null > >> +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c > >> @@ -0,0 +1,54 @@ > >> +#include > >> +#include > >> + > >> +#include > >> + > >> +static const struct drm_mode_config_funcs drm_mode_config_funcs =3D { > >> +}; > >> + > >> +static const struct drm_driver drm_mode_driver =3D { > >> +}; > >> + > >> +static void drm_kunit_free_device(struct drm_device *drm, void *ptr) > >> +{ > >> + struct device *dev =3D ptr; > >> + > >> + root_device_unregister(dev); > >> +} > >> + > >> +struct drm_device *drm_kunit_device_init(const char *name) > >> +{ > >> + struct drm_device *drm; > >> + struct device *dev; > >> + int ret; > >> + > >> + dev =3D root_device_register(name); > >> + if (IS_ERR(dev)) > >> + return ERR_CAST(dev); > >> + > >> + drm =3D drm_dev_alloc(&drm_mode_driver, dev); > >=20 > > I can't find drm being freed anywhere? > > Maybe you could assign it to drm->managed.final_kfree. There's a drm_dev_put in the test_exit hook which should free it. > Perhaps a better solution would be to use devm_drm_dev_alloc() and > unregister the root device on exit. That avoids reaching into the drm > managed internals and it looks more like a regular driver. But yeah, this is a good idea, I'll do it. Maxime --wdbx6g5pylyw5se6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCYzFyjAAKCRDj7w1vZxhR xfL5AP9r8SOCVdiPcnR+tkP1VdDT4xdxvsJmgcz60MJ5iuvezwEAwp/UpYjOSXCb YrQ0Vm/0KNnlKIDIInbF28eMSo1bSw0= =31r4 -----END PGP SIGNATURE----- --wdbx6g5pylyw5se6--