[<prev] [next>] [day] [month] [year] [list]
Message-ID: <56cbef35-da0e-d278-fef5-83b0944ed416@redhat.com>
Date: Fri, 25 Nov 2022 10:25:24 +0100
From: Javier Martinez Canillas <javierm@...hat.com>
To: Maxime Ripard <maxime@...no.tech>,
Maxime Ripard <mripard@...nel.org>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...il.com>,
Thomas Zimmermann <tzimmermann@...e.de>
Cc: David Gow <davidgow@...gle.com>, linaro-mm-sig@...ts.linaro.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kselftest@...r.kernel.org,
MaĆra Canal <mairacanal@...eup.net>,
linux-media@...r.kernel.org, kunit-dev@...glegroups.com,
dri-devel@...ts.freedesktop.org,
Brendan Higgins <brendan.higgins@...ux.dev>,
linux-kernel@...r.kernel.org,
Dave Stevenson <dave.stevenson@...pberrypi.com>
Subject: Re: [PATCH 04/24] drm/tests: helpers: Switch to a platform_device
On 11/23/22 16:25, Maxime Ripard wrote:
> The device managed resources are ran if the device has bus, which is not
> the case of a root_device.
>
> Let's use a platform_device instead.
>
> Signed-off-by: Maxime Ripard <maxime@...no.tech>
> ---
> drivers/gpu/drm/tests/drm_kunit_helpers.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> index 2f974f45c5b4..651aa93a98a8 100644
> --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c
> +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> @@ -6,6 +6,7 @@
> #include <kunit/resource.h>
>
> #include <linux/device.h>
> +#include <linux/platform_device.h>
>
> #include "drm_kunit_helpers.h"
>
> @@ -20,12 +21,26 @@ static const struct drm_mode_config_funcs drm_mode_config_funcs = {
>
> struct device *drm_kunit_helper_alloc_device(struct kunit *test)
> {
> - return root_device_register(FAKE_DEVICE_NAME);
> + struct platform_device *pdev;
> + int ret;
> +
> + ret = platform_driver_register(&fake_platform_driver);
Maybe the platform_driver_register() is something that should be done
in the drm_client_modeset_test_init() callback ?
I would also as a part of this series rename the kunit_suite from
"drm_test_pick_cmdline_test_suite" to "drm_test_modeset_test_suite"
or something like that. Since you are already setting the .init and
.exit callbacks to allocate and release the devices. So it is more
than just a test suite for cmdline params testing.
> + KUNIT_ASSERT_EQ(test, ret, 0);
> +
> + pdev = platform_device_alloc(FAKE_DEVICE_NAME, PLATFORM_DEVID_NONE);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pdev);
> +
> + ret = platform_device_add(pdev);
> + KUNIT_ASSERT_EQ(test, ret, 0);
> +
> + return &pdev->dev;
> }
>
Probably won't do it as a part of this series to avoid making it cross
subsystem, but I think there's room to further consolidation since this
helper seems to be quite generic and something that would be useful for
other subsystems. So it would make sense for kunit to have helpers to
manage platform drivers and devices.
In fact, I see that drivers/base/test/test_async_driver_probe.c already
has similar helpers that could be exposed to the rest of the kernel.
The patch looks good to me though and any of these changes could be done
as a follow-up:
Reviewed-by: Javier Martinez Canillas <javierm@...hat.com>
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
Powered by blists - more mailing lists