Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp15521477rwb; Mon, 28 Nov 2022 12:37:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xz2nyJSLilv5A5mqZCQ/fzDlqZfhdDk5cNTnQaP4/tY7XD043LhIL/NpC2Lbt71jRC2TX X-Received: by 2002:a17:906:1cf:b0:7bb:f0eb:a350 with SMTP id 15-20020a17090601cf00b007bbf0eba350mr17169701ejj.575.1669667829230; Mon, 28 Nov 2022 12:37:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669667829; cv=none; d=google.com; s=arc-20160816; b=TjsepR6Z9k+W9O3ATphtXS5Pu6b/++PdHcWE9tUivbbtFA66wDSekG3czFPlr0J2cM nhtaVuuSmPHIyUmtmVgziwHD19TksBl0YE7+stR+LGtRJ14Yl0ur85HqrWhowmWFhUvT yuOZi1ytgJIYUDeUEDYNiQp4I26sXAvVR9kWUOrjlenhGLdp87riaQLHRC7MFVlnREV0 kdEPd+BNNABxQMvIqNmMBlI731uMF9bXBOoUr2pLajZVIYtDGE6+jsZcsK14Iif6esoV 5Kg7Dm2YlwFOOkCO6g0pciXRVsyQq2ePe5EbPbe3hHGH/Kj5HXt+w92qM5N2tY1Xo1fs rAFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=0INozCygsrzYRHIPWCYY88aXHMGFfj1kNMWkQlBvxRM=; b=PVa9lO20Wc5hW9D8Y4ABXKZyycHQzaPVVinj4kW87s4RutFCfz77w/t4g7pZTDEDh3 cEhBv200EO5IQ9BBFi+L6nYDWtY8ukOP1lCQtUE0gHgjLf9JOqrvv3170d0cWNdPsROd Y9ZYYgniJgvFW15cuvlxE1ifunxQHE1qSEG2Ct7IOcBljTG4i5v9sRrAmkmhVin41zFv vRe+Au+gWeIja97SlFeq1leuGxvP8dg8glmYFJD3Uv3UaZ8jLgQY3C8uOenAjq4GfRAF 3HRuG6moUo7MUd21EdiTzsuQWTSjfG3vBVA3SjWRDXRRYvX/1KskYsd1/uG0TEXQLoE8 btag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@igalia.com header.s=20170329 header.b=Z8qJhYlP; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt10-20020a170907728a00b007a7424836d5si10644407ejc.234.2022.11.28.12.36.48; Mon, 28 Nov 2022 12:37:09 -0800 (PST) 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=fail header.i=@igalia.com header.s=20170329 header.b=Z8qJhYlP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233238AbiK1UJd (ORCPT + 84 others); Mon, 28 Nov 2022 15:09:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233142AbiK1UJb (ORCPT ); Mon, 28 Nov 2022 15:09:31 -0500 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C805CFAD5; Mon, 28 Nov 2022 12:09:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0INozCygsrzYRHIPWCYY88aXHMGFfj1kNMWkQlBvxRM=; b=Z8qJhYlPU3DCTrelXjO2K07BcE On0eNgfVvJsermEmQ7OcZSA487+YB6k2mduXohpmL4e6a4kPJEzdBf8CUxL3Y7XiwLURBrzedamHJ oZ7sMQ7EveWpp0IUareCXQFd4wQyshUlb9kDtD/jH7ghK56LivS27fV8OfpSTgVuz4jtChapW1jSv R9afS9ayoWRufqgUXDVKKVaDg4AnMDv/olhafTFIT5m7IYrGhZ9T5VugJw4m2WmDqHiNwpR8UgrZY YogIzaPrtTuxEE7JDDTLfBMYaNoAyXo7IhrO8g1VW+070aYBEb4AoYmRJtW88jIvvOEPQcUZ0WMtE ubCjxwBg==; Received: from [177.34.169.227] (helo=[192.168.0.8]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1ozkRF-00AcE5-LC; Mon, 28 Nov 2022 21:09:15 +0100 Message-ID: Date: Mon, 28 Nov 2022 17:09:06 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2 07/17] drm/tests: helpers: Make sure the device is bound Content-Language: en-US To: Maxime Ripard , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , David Airlie , Thomas Zimmermann Cc: David Gow , Greg Kroah-Hartman , Dave Stevenson , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Brendan Higgins , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-media@vger.kernel.org References: <20221123-rpi-kunit-tests-v2-0-efe5ed518b63@cerno.tech> <20221123-rpi-kunit-tests-v2-7-efe5ed518b63@cerno.tech> From: =?UTF-8?Q?Ma=c3=adra_Canal?= In-Reply-To: <20221123-rpi-kunit-tests-v2-7-efe5ed518b63@cerno.tech> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, 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 On 11/28/22 11:53, Maxime Ripard wrote: > The device managed resources are freed when the device is detached, so > it has to be bound in the first place. > > Let's create a fake driver that we will bind to our fake device to > benefit from the device managed cleanups in our tests. > > Signed-off-by: Maxime Ripard Reviewed-by: Maíra Canal Best Regards, - Maíra Canal > --- > drivers/gpu/drm/tests/drm_kunit_helpers.c | 26 +++++++++++++++++++++++++- > 1 file changed, 25 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c > index 15678ab823b0..5d3e29353d1a 100644 > --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c > +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c > @@ -18,12 +18,32 @@ struct kunit_dev { > static const struct drm_mode_config_funcs drm_mode_config_funcs = { > }; > > +static int fake_probe(struct platform_device *pdev) > +{ > + return 0; > +} > + > +static int fake_remove(struct platform_device *pdev) > +{ > + return 0; > +} > + > +static struct platform_driver fake_platform_driver = { > + .probe = fake_probe, > + .remove = fake_remove, > + .driver = { > + .name = KUNIT_DEVICE_NAME, > + }, > +}; > + > /** > * drm_kunit_helper_alloc_device - Allocate a mock device for a KUnit test > * @test: The test context object > * > * This allocates a fake struct &device to create a mock for a Kunit > - * test. > + * test. The device will also be bound to a fake driver. It will thus be > + * 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. > @@ -36,6 +56,9 @@ struct device *drm_kunit_helper_alloc_device(struct kunit *test) > struct platform_device *pdev; > int ret; > > + ret = platform_driver_register(&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); > > @@ -58,6 +81,7 @@ 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); > } > EXPORT_SYMBOL(drm_kunit_helper_free_device); > >