linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2 02/17] drm/tests: helpers: Document drm_kunit_device_init()
       [not found] ` <20221123-rpi-kunit-tests-v2-2-efe5ed518b63@cerno.tech>
@ 2022-11-28 19:30   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 19:30 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> Commit 44a3928324e9 ("drm/tests: Add Kunit Helpers") introduced the
> drm_kunit_device_init() function but didn't document it properly. Add
> that documentation.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Just a minor nit on naming, besides that:

Reviewed-by: Maíra Canal <mcanal@igalia.com>

> ---
>  drivers/gpu/drm/tests/drm_kunit_helpers.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> index 6600a4db3158..46a68c2fd80c 100644
> --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c
> +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> @@ -35,6 +35,23 @@ static void dev_free(struct kunit_resource *res)
>  	root_device_unregister(dev);
>  }
>  
> +/**
> + * drm_kunit_device_init - Allocates a mock DRM device for Kunit tests

s/Kunit/KUnit

Best Regards,
- Maíra Canal

> + * @test: The test context object
> + * @features: Mocked DRM device driver features
> + * @name: Name of the struct &device to allocate
> + *
> + * This function allocates a new struct &device, creates a struct
> + * &drm_driver and will create a struct &drm_device using both.
> + *
> + * The device and driver are tied to the @test context and will get
> + * cleaned at the end of the test. The drm_device is allocated through
> + * devm_drm_dev_alloc() and will thus be freed through a device-managed
> + * resource.
> + *
> + * Returns:
> + * A pointer to the new drm_device, or an ERR_PTR() otherwise.
> + */
>  struct drm_device *drm_kunit_device_init(struct kunit *test, u32 features, char *name)
>  {
>  	struct kunit_dev *kdev;
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 04/17] drm/tests: helpers: Remove the name parameter
       [not found] ` <20221123-rpi-kunit-tests-v2-4-efe5ed518b63@cerno.tech>
@ 2022-11-28 19:37   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 19:37 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> The device name isn't really useful, we can just define it instead of
> exposing it in the API.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards
- Maíra Canal

> ---
>  drivers/gpu/drm/tests/drm_client_modeset_test.c | 3 +--
>  drivers/gpu/drm/tests/drm_kunit_helpers.c       | 7 ++++---
>  drivers/gpu/drm/tests/drm_modes_test.c          | 3 +--
>  drivers/gpu/drm/tests/drm_probe_helper_test.c   | 3 +--
>  include/drm/drm_kunit_helpers.h                 | 3 +--
>  5 files changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tests/drm_client_modeset_test.c b/drivers/gpu/drm/tests/drm_client_modeset_test.c
> index 6cdf08f582ce..4d475ae6dbb6 100644
> --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c
> +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c
> @@ -59,8 +59,7 @@ static int drm_client_modeset_test_init(struct kunit *test)
>  
>  	test->priv = priv;
>  
> -	priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET,
> -						      "drm-client-modeset-test");
> +	priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET);
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
>  	ret = drmm_connector_init(priv->drm, &priv->connector,
> diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> index 2f67f6cf78d0..16c7926d83c2 100644
> --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c
> +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> @@ -8,6 +8,8 @@
>  
>  #include <linux/device.h>
>  
> +#define KUNIT_DEVICE_NAME	"drm-kunit-mock-device"
> +
>  struct kunit_dev {
>  	struct drm_device base;
>  };
> @@ -39,7 +41,6 @@ static void dev_free(struct kunit_resource *res)
>   * drm_kunit_helper_alloc_drm_device - Allocates a mock DRM device for Kunit tests
>   * @test: The test context object
>   * @features: Mocked DRM device driver features
> - * @name: Name of the struct &device to allocate
>   *
>   * This function allocates a new struct &device, creates a struct
>   * &drm_driver and will create a struct &drm_device using both.
> @@ -54,7 +55,7 @@ static void dev_free(struct kunit_resource *res)
>   */
>  struct drm_device *
>  drm_kunit_helper_alloc_drm_device(struct kunit *test,
> -				  u32 features, char *name)
> +				  u32 features)
>  {
>  	struct kunit_dev *kdev;
>  	struct drm_device *drm;
> @@ -62,7 +63,7 @@ drm_kunit_helper_alloc_drm_device(struct kunit *test,
>  	struct device *dev;
>  	int ret;
>  
> -	dev = kunit_alloc_resource(test, dev_init, dev_free, GFP_KERNEL, name);
> +	dev = kunit_alloc_resource(test, dev_init, dev_free, GFP_KERNEL, KUNIT_DEVICE_NAME);
>  	if (!dev)
>  		return ERR_PTR(-ENOMEM);
>  
> diff --git a/drivers/gpu/drm/tests/drm_modes_test.c b/drivers/gpu/drm/tests/drm_modes_test.c
> index 6723089dff9f..35965ad86188 100644
> --- a/drivers/gpu/drm/tests/drm_modes_test.c
> +++ b/drivers/gpu/drm/tests/drm_modes_test.c
> @@ -22,8 +22,7 @@ static int drm_test_modes_init(struct kunit *test)
>  	priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
>  	KUNIT_ASSERT_NOT_NULL(test, priv);
>  
> -	priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET,
> -						      "drm-modes-test");
> +	priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET);
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
>  	test->priv = priv;
> diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c b/drivers/gpu/drm/tests/drm_probe_helper_test.c
> index 85236ff4744f..be61a92b79d2 100644
> --- a/drivers/gpu/drm/tests/drm_probe_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c
> @@ -40,8 +40,7 @@ static int drm_probe_helper_test_init(struct kunit *test)
>  	test->priv = priv;
>  
>  	priv->drm = drm_kunit_helper_alloc_drm_device(test,
> -						      DRIVER_MODESET | DRIVER_ATOMIC,
> -						      "drm-probe-helper-test");
> +						      DRIVER_MODESET | DRIVER_ATOMIC);
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
>  	connector = &priv->connector;
> diff --git a/include/drm/drm_kunit_helpers.h b/include/drm/drm_kunit_helpers.h
> index e9870c7911fe..6c12b1426ba0 100644
> --- a/include/drm/drm_kunit_helpers.h
> +++ b/include/drm/drm_kunit_helpers.h
> @@ -8,7 +8,6 @@ struct kunit;
>  
>  struct drm_device *
>  drm_kunit_helper_alloc_drm_device(struct kunit *test,
> -				  u32 features,
> -				  char *name);
> +				  u32 features);
>  
>  #endif // DRM_KUNIT_HELPERS_H_
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 05/17] drm/tests: helpers: Create the device in another function
       [not found] ` <20221123-rpi-kunit-tests-v2-5-efe5ed518b63@cerno.tech>
@ 2022-11-28 19:48   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 19:48 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> We'll need in some tests to control when the device needs to be added
> and removed, so let's split the device creation from the DRM device
> creation function.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Just a small nit below,

Reviewed-by: Maíra Canal <mcanal@igalia.com>

>  
> diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c b/drivers/gpu/drm/tests/drm_probe_helper_test.c
> index be61a92b79d2..438b1d42b843 100644
> --- a/drivers/gpu/drm/tests/drm_probe_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c
> @@ -17,6 +17,7 @@
>  
>  struct drm_probe_helper_test_priv {
>  	struct drm_device *drm;
> +	struct device *dev;
>  	struct drm_connector connector;
>  };
>  
> @@ -39,7 +40,10 @@ static int drm_probe_helper_test_init(struct kunit *test)
>  	KUNIT_ASSERT_NOT_NULL(test, priv);
>  	test->priv = priv;
>  
> -	priv->drm = drm_kunit_helper_alloc_drm_device(test,
> +	priv->dev = drm_kunit_helper_alloc_device(test);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->dev);
> +
> +	priv->drm = drm_kunit_helper_alloc_drm_device(test, priv->dev,
>  						      DRIVER_MODESET | DRIVER_ATOMIC);
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
> @@ -55,6 +59,13 @@ 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;;

There are two semicolons by the end of this statement.

Best Regards,
- Maíra Canal

> +
> +	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 {
> @@ -195,6 +206,7 @@ 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,
>  };
>  
> diff --git a/include/drm/drm_kunit_helpers.h b/include/drm/drm_kunit_helpers.h
> index 6c12b1426ba0..b4277fe92c38 100644
> --- a/include/drm/drm_kunit_helpers.h
> +++ b/include/drm/drm_kunit_helpers.h
> @@ -6,8 +6,11 @@
>  struct drm_device;
>  struct kunit;
>  
> +struct device *drm_kunit_helper_alloc_device(struct kunit *test);
> +void drm_kunit_helper_free_device(struct kunit *test, struct device *dev);
> +
>  struct drm_device *
> -drm_kunit_helper_alloc_drm_device(struct kunit *test,
> +drm_kunit_helper_alloc_drm_device(struct kunit *test, struct device *dev,
>  				  u32 features);
>  
>  #endif // DRM_KUNIT_HELPERS_H_
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 06/17] drm/tests: helpers: Switch to a platform_device
       [not found] ` <20221123-rpi-kunit-tests-v2-6-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:01   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:01 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, 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.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra Canal

> ---
>  drivers/gpu/drm/tests/drm_kunit_helpers.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> index 9fb045fa685f..15678ab823b0 100644
> --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c
> +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> @@ -7,6 +7,7 @@
>  #include <kunit/resource.h>
>  
>  #include <linux/device.h>
> +#include <linux/platform_device.h>
>  
>  #define KUNIT_DEVICE_NAME	"drm-kunit-mock-device"
>  
> @@ -32,7 +33,16 @@ 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(KUNIT_DEVICE_NAME);
> +	struct platform_device *pdev;
> +	int ret;
> +
> +	pdev = platform_device_alloc(KUNIT_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;
>  }
>  EXPORT_SYMBOL(drm_kunit_helper_alloc_device);
>  
> @@ -45,7 +55,9 @@ EXPORT_SYMBOL(drm_kunit_helper_alloc_device);
>   */
>  void drm_kunit_helper_free_device(struct kunit *test, struct device *dev)
>  {
> -	root_device_unregister(dev);
> +	struct platform_device *pdev = to_platform_device(dev);
> +
> +	platform_device_unregister(pdev);
>  }
>  EXPORT_SYMBOL(drm_kunit_helper_free_device);
>  
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 07/17] drm/tests: helpers: Make sure the device is bound
       [not found] ` <20221123-rpi-kunit-tests-v2-7-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:09   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:09 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

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 <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

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);
>  
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 10/17] drm/tests: Add a test for DRM managed actions
       [not found] ` <20221123-rpi-kunit-tests-v2-10-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:14   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:14 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> DRM-managed actions are supposed to be ran whenever the device is
> released. Let's introduce a basic unit test to make sure it happens.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra Canal

> ---
>  drivers/gpu/drm/tests/Makefile           |  1 +
>  drivers/gpu/drm/tests/drm_managed_test.c | 71 ++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+)
> 
> diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile
> index 94fe546d937d..486053052ba9 100644
> --- a/drivers/gpu/drm/tests/Makefile
> +++ b/drivers/gpu/drm/tests/Makefile
> @@ -10,6 +10,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
>  	drm_format_test.o \
>  	drm_framebuffer_test.o \
>  	drm_kunit_helpers.o \
> +	drm_managed_test.o \
>  	drm_mm_test.o \
>  	drm_modes_test.o \
>  	drm_plane_helper_test.o \
> diff --git a/drivers/gpu/drm/tests/drm_managed_test.c b/drivers/gpu/drm/tests/drm_managed_test.c
> new file mode 100644
> index 000000000000..1652dca11d30
> --- /dev/null
> +++ b/drivers/gpu/drm/tests/drm_managed_test.c
> @@ -0,0 +1,71 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <drm/drm_drv.h>
> +#include <drm/drm_kunit_helpers.h>
> +#include <drm/drm_managed.h>
> +
> +#include <kunit/resource.h>
> +
> +#include <linux/device.h>
> +
> +/* Ought to be enough for anybody */
> +#define TEST_TIMEOUT_MS	100
> +
> +struct managed_test_priv {
> +	bool action_done;
> +	wait_queue_head_t action_wq;
> +};
> +
> +static void drm_action(struct drm_device *drm, void *ptr)
> +{
> +	struct managed_test_priv *priv = ptr;
> +
> +	priv->action_done = true;
> +	wake_up_interruptible(&priv->action_wq);
> +}
> +
> +static void drm_test_managed_run_action(struct kunit *test)
> +{
> +	struct managed_test_priv *priv;
> +	struct drm_device *drm;
> +	struct device *dev;
> +	int ret;
> +
> +	priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
> +	init_waitqueue_head(&priv->action_wq);
> +
> +	dev = drm_kunit_helper_alloc_device(test);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
> +
> +	drm = __drm_kunit_helper_alloc_drm_device(test, dev, sizeof(*drm), 0, DRIVER_MODESET);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, drm);
> +
> +	ret = drmm_add_action_or_reset(drm, drm_action, priv);
> +	KUNIT_EXPECT_EQ(test, ret, 0);
> +
> +	ret = drm_dev_register(drm, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	drm_dev_unregister(drm);
> +	drm_kunit_helper_free_device(test, dev);
> +
> +	ret = wait_event_interruptible_timeout(priv->action_wq, priv->action_done,
> +					       msecs_to_jiffies(TEST_TIMEOUT_MS));
> +	KUNIT_EXPECT_GT(test, ret, 0);
> +}
> +
> +static struct kunit_case drm_managed_tests[] = {
> +	KUNIT_CASE(drm_test_managed_run_action),
> +	{}
> +};
> +
> +static struct kunit_suite drm_managed_test_suite = {
> +	.name = "drm-test-managed",
> +	.test_cases = drm_managed_tests
> +};
> +
> +kunit_test_suite(drm_managed_test_suite);
> +
> +MODULE_AUTHOR("Maxime Ripard <maxime@cerno.tech>");
> +MODULE_LICENSE("GPL");
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 11/17] drm/vc4: Move HVS state to main header
       [not found] ` <20221123-rpi-kunit-tests-v2-11-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:16   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:16 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> In order to introduce unit tests for the HVS state computation, we'll
> need access to the vc4_hvs_state struct definition and its associated
> helpers.
> 
> Let's move them in our driver header.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra Canal

> ---
>  drivers/gpu/drm/vc4/vc4_drv.h | 23 +++++++++++++++++++++++
>  drivers/gpu/drm/vc4/vc4_kms.c | 25 +++----------------------
>  2 files changed, 26 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index 6af615c2eb65..051c2e3b6d43 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -355,6 +355,29 @@ struct vc4_hvs {
>  	bool vc5_hdmi_enable_4096by2160;
>  };
>  
> +#define HVS_NUM_CHANNELS 3
> +
> +struct vc4_hvs_state {
> +	struct drm_private_state base;
> +	unsigned long core_clock_rate;
> +
> +	struct {
> +		unsigned in_use: 1;
> +		unsigned long fifo_load;
> +		struct drm_crtc_commit *pending_commit;
> +	} fifo_state[HVS_NUM_CHANNELS];
> +};
> +
> +static inline struct vc4_hvs_state *
> +to_vc4_hvs_state(const struct drm_private_state *priv)
> +{
> +	return container_of(priv, struct vc4_hvs_state, base);
> +}
> +
> +struct vc4_hvs_state *vc4_hvs_get_global_state(struct drm_atomic_state *state);
> +struct vc4_hvs_state *vc4_hvs_get_old_global_state(const struct drm_atomic_state *state);
> +struct vc4_hvs_state *vc4_hvs_get_new_global_state(const struct drm_atomic_state *state);
> +
>  struct vc4_plane {
>  	struct drm_plane base;
>  };
> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index 7282545c54a1..53d9f30460cf 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -25,8 +25,6 @@
>  #include "vc4_drv.h"
>  #include "vc4_regs.h"
>  
> -#define HVS_NUM_CHANNELS 3
> -
>  struct vc4_ctm_state {
>  	struct drm_private_state base;
>  	struct drm_color_ctm *ctm;
> @@ -39,23 +37,6 @@ to_vc4_ctm_state(const struct drm_private_state *priv)
>  	return container_of(priv, struct vc4_ctm_state, base);
>  }
>  
> -struct vc4_hvs_state {
> -	struct drm_private_state base;
> -	unsigned long core_clock_rate;
> -
> -	struct {
> -		unsigned in_use: 1;
> -		unsigned long fifo_load;
> -		struct drm_crtc_commit *pending_commit;
> -	} fifo_state[HVS_NUM_CHANNELS];
> -};
> -
> -static struct vc4_hvs_state *
> -to_vc4_hvs_state(const struct drm_private_state *priv)
> -{
> -	return container_of(priv, struct vc4_hvs_state, base);
> -}
> -
>  struct vc4_load_tracker_state {
>  	struct drm_private_state base;
>  	u64 hvs_load;
> @@ -191,7 +172,7 @@ vc4_ctm_commit(struct vc4_dev *vc4, struct drm_atomic_state *state)
>  		  VC4_SET_FIELD(ctm_state->fifo, SCALER_OLEDOFFS_DISPFIFO));
>  }
>  
> -static struct vc4_hvs_state *
> +struct vc4_hvs_state *
>  vc4_hvs_get_new_global_state(const struct drm_atomic_state *state)
>  {
>  	struct vc4_dev *vc4 = to_vc4_dev(state->dev);
> @@ -204,7 +185,7 @@ vc4_hvs_get_new_global_state(const struct drm_atomic_state *state)
>  	return to_vc4_hvs_state(priv_state);
>  }
>  
> -static struct vc4_hvs_state *
> +struct vc4_hvs_state *
>  vc4_hvs_get_old_global_state(const struct drm_atomic_state *state)
>  {
>  	struct vc4_dev *vc4 = to_vc4_dev(state->dev);
> @@ -217,7 +198,7 @@ vc4_hvs_get_old_global_state(const struct drm_atomic_state *state)
>  	return to_vc4_hvs_state(priv_state);
>  }
>  
> -static struct vc4_hvs_state *
> +struct vc4_hvs_state *
>  vc4_hvs_get_global_state(struct drm_atomic_state *state)
>  {
>  	struct vc4_dev *vc4 = to_vc4_dev(state->dev);
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 12/17] drm/vc4: crtc: Introduce a lower-level crtc init helper
       [not found] ` <20221123-rpi-kunit-tests-v2-12-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:23   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:23 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> The current vc4_crtc_init() helper assumes that we will be using
> hardware planes and calls vc4_plane_init().
> 
> While it's a reasonable assumption, we'll want to mock the plane and
> thus provide our own. Let's create a helper that will take the plane as
> an argument.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Although the commit message explains a bit about why __vc4_crtc_init is
being created, it would be nice to add a comment in the code explaining
that __vc4_crtc_init can be used for tests as it allows mocking the
plane. This way the distinction between vc4_crtc_init and
__vc4_crtc_init will be cleaner to the reader.

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra Canal

> ---
>  drivers/gpu/drm/vc4/vc4_crtc.c | 52 +++++++++++++++++++++++++++---------------
>  drivers/gpu/drm/vc4/vc4_drv.h  |  6 +++++
>  2 files changed, 39 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index 333529ed3a0d..7a2c54efecb0 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -1286,31 +1286,20 @@ static void vc4_set_crtc_possible_masks(struct drm_device *drm,
>  	}
>  }
>  
> -int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
> -		  struct vc4_crtc *vc4_crtc,
> -		  const struct vc4_crtc_data *data,
> -		  const struct drm_crtc_funcs *crtc_funcs,
> -		  const struct drm_crtc_helper_funcs *crtc_helper_funcs,
> -		  bool feeds_txp)
> +int __vc4_crtc_init(struct drm_device *drm,
> +		    struct platform_device *pdev,
> +		    struct vc4_crtc *vc4_crtc,
> +		    const struct vc4_crtc_data *data,
> +		    struct drm_plane *primary_plane,
> +		    const struct drm_crtc_funcs *crtc_funcs,
> +		    const struct drm_crtc_helper_funcs *crtc_helper_funcs,
> +		    bool feeds_txp)
>  {
>  	struct vc4_dev *vc4 = to_vc4_dev(drm);
>  	struct drm_crtc *crtc = &vc4_crtc->base;
> -	struct drm_plane *primary_plane;
>  	unsigned int i;
>  	int ret;
>  
> -	/* For now, we create just the primary and the legacy cursor
> -	 * planes.  We should be able to stack more planes on easily,
> -	 * but to do that we would need to compute the bandwidth
> -	 * requirement of the plane configuration, and reject ones
> -	 * that will take too much.
> -	 */
> -	primary_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_PRIMARY, 0);
> -	if (IS_ERR(primary_plane)) {
> -		dev_err(drm->dev, "failed to construct primary plane\n");
> -		return PTR_ERR(primary_plane);
> -	}
> -
>  	vc4_crtc->data = data;
>  	vc4_crtc->pdev = pdev;
>  	vc4_crtc->feeds_txp = feeds_txp;
> @@ -1342,6 +1331,31 @@ int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
>  	return 0;
>  }
>  
> +int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
> +		  struct vc4_crtc *vc4_crtc,
> +		  const struct vc4_crtc_data *data,
> +		  const struct drm_crtc_funcs *crtc_funcs,
> +		  const struct drm_crtc_helper_funcs *crtc_helper_funcs,
> +		  bool feeds_txp)
> +{
> +	struct drm_plane *primary_plane;
> +
> +	/* For now, we create just the primary and the legacy cursor
> +	 * planes.  We should be able to stack more planes on easily,
> +	 * but to do that we would need to compute the bandwidth
> +	 * requirement of the plane configuration, and reject ones
> +	 * that will take too much.
> +	 */
> +	primary_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_PRIMARY, 0);
> +	if (IS_ERR(primary_plane)) {
> +		dev_err(drm->dev, "failed to construct primary plane\n");
> +		return PTR_ERR(primary_plane);
> +	}
> +
> +	return __vc4_crtc_init(drm, pdev, vc4_crtc, data, primary_plane,
> +			       crtc_funcs, crtc_helper_funcs, feeds_txp);
> +}
> +
>  static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index 051c2e3b6d43..cd2002fff115 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -888,6 +888,12 @@ int vc4_bo_debugfs_init(struct drm_minor *minor);
>  /* vc4_crtc.c */
>  extern struct platform_driver vc4_crtc_driver;
>  int vc4_crtc_disable_at_boot(struct drm_crtc *crtc);
> +int __vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
> +		    struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
> +		    struct drm_plane *primary_plane,
> +		    const struct drm_crtc_funcs *crtc_funcs,
> +		    const struct drm_crtc_helper_funcs *crtc_helper_funcs,
> +		    bool feeds_txp);
>  int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
>  		  struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
>  		  const struct drm_crtc_funcs *crtc_funcs,
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 13/17] drm/vc4: crtc: Make encoder lookup helper public
       [not found] ` <20221123-rpi-kunit-tests-v2-13-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:26   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:26 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins, Dave Stevenson,
	Javier Martinez Canillas, linux-kernel, David Gow

On 11/28/22 11:53, Maxime Ripard wrote:
> We'll need a function that looks up an encoder by its vc4_encoder_type.
> Such a function is already present in the CRTC code, so let's make it
> public so that we can reuse it in the unit tests.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra Canal

> ---
>  drivers/gpu/drm/vc4/vc4_crtc.c | 17 +----------------
>  drivers/gpu/drm/vc4/vc4_drv.h  | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index 7a2c54efecb0..59e473059fa2 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -486,21 +486,6 @@ static int vc4_crtc_disable(struct drm_crtc *crtc,
>  	return 0;
>  }
>  
> -static struct drm_encoder *vc4_crtc_get_encoder_by_type(struct drm_crtc *crtc,
> -							enum vc4_encoder_type type)
> -{
> -	struct drm_encoder *encoder;
> -
> -	drm_for_each_encoder(encoder, crtc->dev) {
> -		struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
> -
> -		if (vc4_encoder->type == type)
> -			return encoder;
> -	}
> -
> -	return NULL;
> -}
> -
>  int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
>  {
>  	struct drm_device *drm = crtc->dev;
> @@ -536,7 +521,7 @@ int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
>  
>  	pv_data = vc4_crtc_to_vc4_pv_data(vc4_crtc);
>  	encoder_type = pv_data->encoder_types[encoder_sel];
> -	encoder = vc4_crtc_get_encoder_by_type(crtc, encoder_type);
> +	encoder = vc4_find_encoder_by_type(drm, encoder_type);
>  	if (WARN_ON(!encoder))
>  		return 0;
>  
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index cd2002fff115..54352db48476 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -495,6 +495,22 @@ to_vc4_encoder(const struct drm_encoder *encoder)
>  	return container_of(encoder, struct vc4_encoder, base);
>  }
>  
> +static inline
> +struct drm_encoder *vc4_find_encoder_by_type(struct drm_device *drm,
> +					     enum vc4_encoder_type type)
> +{
> +	struct drm_encoder *encoder;
> +
> +	drm_for_each_encoder(encoder, drm) {
> +		struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
> +
> +		if (vc4_encoder->type == type)
> +			return encoder;
> +	}
> +
> +	return NULL;
> +}
> +
>  struct vc4_crtc_data {
>  	const char *name;
>  
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 15/17] drm/vc4: tests: Introduce a mocking infrastructure
       [not found] ` <20221123-rpi-kunit-tests-v2-15-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:35   ` Maíra Canal
  2022-11-30  9:59   ` Javier Martinez Canillas
  1 sibling, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:35 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> In order to test the current atomic_check hooks we need to have a DRM
> device that has roughly the same capabilities and layout that the actual
> hardware. We'll also need a bunch of functions to create arbitrary
> atomic states.
> 
> Let's create some helpers to create a device that behaves like the real
> one, and some helpers to maintain the atomic state we want to check.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---
>  drivers/gpu/drm/vc4/Kconfig                 |  15 +++
>  drivers/gpu/drm/vc4/Makefile                |   6 +
>  drivers/gpu/drm/vc4/tests/.kunitconfig      |  14 ++
>  drivers/gpu/drm/vc4/tests/vc4_mock.c        | 200 ++++++++++++++++++++++++++++
>  drivers/gpu/drm/vc4/tests/vc4_mock.h        |  60 +++++++++
>  drivers/gpu/drm/vc4/tests/vc4_mock_crtc.c   |  41 ++++++
>  drivers/gpu/drm/vc4/tests/vc4_mock_output.c |  99 ++++++++++++++
>  drivers/gpu/drm/vc4/tests/vc4_mock_plane.c  |  47 +++++++
>  drivers/gpu/drm/vc4/vc4_crtc.c              |  20 +--
>  drivers/gpu/drm/vc4/vc4_drv.c               |   4 +-
>  drivers/gpu/drm/vc4/vc4_drv.h               |  16 +++
>  drivers/gpu/drm/vc4/vc4_txp.c               |   2 +-
>  12 files changed, 511 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/Kconfig b/drivers/gpu/drm/vc4/Kconfig
> index 246305d17a52..dcdcc9e5cac4 100644
> --- a/drivers/gpu/drm/vc4/Kconfig
> +++ b/drivers/gpu/drm/vc4/Kconfig
> @@ -34,3 +34,18 @@ config DRM_VC4_HDMI_CEC
>  	help
>  	  Choose this option if you have a Broadcom VC4 GPU
>  	  and want to use CEC.
> +
> +config DRM_VC4_KUNIT_TEST
> +	bool "KUnit tests for VC4" if !KUNIT_ALL_TESTS
> +	depends on DRM_VC4 && KUNIT
> +	default KUNIT_ALL_TESTS
> +	help
> +	  This builds unit tests for the VC4 DRM/KMS driver. This option is
> +	  not useful for distributions or general kernels, but only for kernel
> +	  developers working on the VC4 driver.
> +
> +	  For more information on KUnit and unit tests in general,
> +	  please refer to the KUnit documentation in
> +	  Documentation/dev-tools/kunit/.
> +
> +	  If in doubt, say "N".
> diff --git a/drivers/gpu/drm/vc4/Makefile b/drivers/gpu/drm/vc4/Makefile
> index d0163e18e9ca..f974a8c80e2f 100644
> --- a/drivers/gpu/drm/vc4/Makefile
> +++ b/drivers/gpu/drm/vc4/Makefile
> @@ -25,6 +25,12 @@ vc4-y := \
>  	vc4_validate.o \
>  	vc4_validate_shaders.o
>  
> +vc4-$(CONFIG_DRM_VC4_KUNIT_TEST) += \
> +	tests/vc4_mock.o \
> +	tests/vc4_mock_crtc.o \
> +	tests/vc4_mock_output.o \
> +	tests/vc4_mock_plane.o
> +
>  vc4-$(CONFIG_DEBUG_FS) += vc4_debugfs.o
>  
>  obj-$(CONFIG_DRM_VC4)  += vc4.o
> diff --git a/drivers/gpu/drm/vc4/tests/.kunitconfig b/drivers/gpu/drm/vc4/tests/.kunitconfig
> new file mode 100644
> index 000000000000..bfd9899ed6e0
> --- /dev/null
> +++ b/drivers/gpu/drm/vc4/tests/.kunitconfig
> @@ -0,0 +1,14 @@
> +CONFIG_ARCH_BCM=y
> +CONFIG_ARCH_BCM2835=y
> +CONFIG_BCM2835_MBOX=y
> +CONFIG_KUNIT=y
> +CONFIG_DRM=y
> +CONFIG_DRM_KUNIT_TEST=y

I'm not sure if it makes sense to run the DRM tests here as well. Maybe
it would be better to separate the compilation of the drm_kunit_helpers
from the compilation of the rest of the DRM tests. This way, this
Kconfig entry could be dropped and only the vc4 tests would run.
Moreover, it would allow to run the vc4 tests with --arch=arm.

Best Regards,
- Maíra Canal

> +CONFIG_DRM_VC4=y
> +CONFIG_DRM_VC4_KUNIT_TEST=y
> +CONFIG_MAILBOX=y
> +CONFIG_RASPBERRYPI_FIRMWARE=y
> +CONFIG_SND=y
> +CONFIG_SND_SOC=y
> +CONFIG_SOUND=y
> +CONFIG_COMMON_CLK=y
> diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock.c b/drivers/gpu/drm/vc4/tests/vc4_mock.c
> new file mode 100644
> index 000000000000..a4bed26af32f
> --- /dev/null
> +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.c
> @@ -0,0 +1,200 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <drm/drm_drv.h>
> +#include <drm/drm_kunit_helpers.h>
> +
> +#include <kunit/test.h>
> +
> +#include "vc4_mock.h"
> +
> +struct vc4_mock_output_desc {
> +	enum vc4_encoder_type	vc4_encoder_type;
> +	unsigned int		encoder_type;
> +	unsigned int		connector_type;
> +};
> +
> +#define VC4_MOCK_OUTPUT_DESC(_vc4_type, _etype, _ctype)					\
> +	{										\
> +		.vc4_encoder_type = _vc4_type,						\
> +		.encoder_type = _etype,							\
> +		.connector_type = _ctype,						\
> +	}
> +
> +struct vc4_mock_pipe_desc {
> +	const struct vc4_crtc_data *data;
> +	const struct vc4_mock_output_desc *outputs;
> +	unsigned int noutputs;
> +};
> +
> +#define VC4_MOCK_CRTC_DESC(_data, ...)							\
> +	{										\
> +		.data = _data,								\
> +		.outputs = (struct vc4_mock_output_desc[]) { __VA_ARGS__ },		\
> +		.noutputs = sizeof((struct vc4_mock_output_desc[]) { __VA_ARGS__ }) /	\
> +			     sizeof(struct vc4_mock_output_desc),			\
> +	}
> +
> +#define VC4_MOCK_PIXELVALVE_DESC(_data, ...)						\
> +	VC4_MOCK_CRTC_DESC(&(_data)->base, __VA_ARGS__)
> +
> +struct vc4_mock_desc {
> +	const struct vc4_mock_pipe_desc *pipes;
> +	unsigned int npipes;
> +};
> +
> +#define VC4_MOCK_DESC(...)								\
> +	{										\
> +		.pipes = (struct vc4_mock_pipe_desc[]) { __VA_ARGS__ },			\
> +		.npipes = sizeof((struct vc4_mock_pipe_desc[]) { __VA_ARGS__ }) /	\
> +			     sizeof(struct vc4_mock_pipe_desc),				\
> +	}
> +
> +static const struct vc4_mock_desc vc4_mock =
> +	VC4_MOCK_DESC(
> +		VC4_MOCK_CRTC_DESC(&vc4_txp_crtc_data,
> +				   VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_TXP,
> +							DRM_MODE_ENCODER_VIRTUAL,
> +							DRM_MODE_CONNECTOR_WRITEBACK)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2835_pv0_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_DSI0,
> +							      DRM_MODE_ENCODER_DSI,
> +							      DRM_MODE_CONNECTOR_DSI),
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_DPI,
> +							      DRM_MODE_ENCODER_DPI,
> +							      DRM_MODE_CONNECTOR_DPI)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2835_pv1_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_DSI1,
> +							      DRM_MODE_ENCODER_DSI,
> +							      DRM_MODE_CONNECTOR_DSI)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2835_pv2_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_HDMI0,
> +							      DRM_MODE_ENCODER_TMDS,
> +							      DRM_MODE_CONNECTOR_HDMIA),
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_VEC,
> +							      DRM_MODE_ENCODER_TVDAC,
> +							      DRM_MODE_CONNECTOR_Composite)),
> +);
> +
> +static const struct vc4_mock_desc vc5_mock =
> +	VC4_MOCK_DESC(
> +		VC4_MOCK_CRTC_DESC(&vc4_txp_crtc_data,
> +				   VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_TXP,
> +							DRM_MODE_ENCODER_VIRTUAL,
> +							DRM_MODE_CONNECTOR_WRITEBACK)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2711_pv0_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_DSI0,
> +							      DRM_MODE_ENCODER_DSI,
> +							      DRM_MODE_CONNECTOR_DSI),
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_DPI,
> +							      DRM_MODE_ENCODER_DPI,
> +							      DRM_MODE_CONNECTOR_DPI)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2711_pv1_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_DSI1,
> +							      DRM_MODE_ENCODER_DSI,
> +							      DRM_MODE_CONNECTOR_DSI)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2711_pv2_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_HDMI0,
> +							      DRM_MODE_ENCODER_TMDS,
> +							      DRM_MODE_CONNECTOR_HDMIA)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2711_pv3_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_VEC,
> +							      DRM_MODE_ENCODER_TVDAC,
> +							      DRM_MODE_CONNECTOR_Composite)),
> +		VC4_MOCK_PIXELVALVE_DESC(&bcm2711_pv4_data,
> +					 VC4_MOCK_OUTPUT_DESC(VC4_ENCODER_TYPE_HDMI1,
> +							      DRM_MODE_ENCODER_TMDS,
> +							      DRM_MODE_CONNECTOR_HDMIA)),
> +);
> +
> +static int __build_one_pipe(struct kunit *test, struct drm_device *drm,
> +			    const struct vc4_mock_pipe_desc *pipe)
> +{
> +	struct vc4_dummy_plane *dummy_plane;
> +	struct drm_plane *plane;
> +	struct vc4_dummy_crtc *dummy_crtc;
> +	struct drm_crtc *crtc;
> +	unsigned int i;
> +
> +	dummy_plane = vc4_dummy_plane(test, drm, DRM_PLANE_TYPE_PRIMARY);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_plane);
> +
> +	plane = &dummy_plane->plane.base;
> +	dummy_crtc = vc4_mock_pv(test, drm, plane, pipe->data);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_crtc);
> +
> +	crtc = &dummy_crtc->crtc.base;
> +	for (i = 0; i < pipe->noutputs; i++) {
> +		const struct vc4_mock_output_desc *mock_output = &pipe->outputs[i];
> +		struct vc4_dummy_output *dummy_output;
> +
> +		dummy_output = vc4_dummy_output(test, drm, crtc,
> +						mock_output->vc4_encoder_type,
> +						mock_output->encoder_type,
> +						mock_output->connector_type);
> +		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_output);
> +	}
> +
> +	return 0;
> +}
> +
> +static int __build_mock(struct kunit *test, struct drm_device *drm,
> +			const struct vc4_mock_desc *mock)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < mock->npipes; i++) {
> +		const struct vc4_mock_pipe_desc *pipe = &mock->pipes[i];
> +		int ret;
> +
> +		ret = __build_one_pipe(test, drm, pipe);
> +		KUNIT_ASSERT_EQ(test, ret, 0);
> +	}
> +
> +	return 0;
> +}
> +
> +static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
> +{
> +	struct drm_device *drm;
> +	const struct drm_driver *drv = is_vc5 ? &vc5_drm_driver : &vc4_drm_driver;
> +	const struct vc4_mock_desc *desc = is_vc5 ? &vc5_mock : &vc4_mock;
> +	struct vc4_dev *vc4;
> +	struct device *dev;
> +	int ret;
> +
> +	dev = drm_kunit_helper_alloc_device(test);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
> +
> +	vc4 = drm_kunit_helper_alloc_drm_device_with_driver(test, dev,
> +							    struct vc4_dev, base,
> +							    drv);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4);
> +
> +	vc4->dev = dev;
> +	vc4->is_vc5 = is_vc5;
> +
> +	vc4->hvs = __vc4_hvs_alloc(vc4, NULL);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, vc4->hvs);
> +
> +	drm = &vc4->base;
> +	ret = __build_mock(test, drm, desc);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	ret = vc4_kms_load(drm);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	ret = drm_dev_register(drm, 0);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	return vc4;
> +}
> +
> +struct vc4_dev *vc4_mock_device(struct kunit *test)
> +{
> +	return __mock_device(test, false);
> +}
> +
> +struct vc4_dev *vc5_mock_device(struct kunit *test)
> +{
> +	return __mock_device(test, true);
> +}
> diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock.h b/drivers/gpu/drm/vc4/tests/vc4_mock.h
> new file mode 100644
> index 000000000000..ace5b2e00f4a
> --- /dev/null
> +++ b/drivers/gpu/drm/vc4/tests/vc4_mock.h
> @@ -0,0 +1,60 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#ifndef VC4_MOCK_H_
> +#define VC4_MOCK_H_
> +
> +#include "../vc4_drv.h"
> +
> +static inline
> +struct drm_crtc *vc4_find_crtc_for_encoder(struct kunit *test,
> +					   struct drm_device *drm,
> +					   struct drm_encoder *encoder)
> +{
> +	struct drm_crtc *crtc;
> +
> +	KUNIT_ASSERT_EQ(test, hweight32(encoder->possible_crtcs), 1);
> +
> +	drm_for_each_crtc(crtc, drm)
> +		if (encoder->possible_crtcs & drm_crtc_mask(crtc))
> +			return crtc;
> +
> +	return NULL;
> +}
> +
> +struct vc4_dummy_plane {
> +	struct vc4_plane plane;
> +};
> +
> +struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
> +					struct drm_device *drm,
> +					enum drm_plane_type type);
> +
> +struct vc4_dummy_crtc {
> +	struct vc4_crtc crtc;
> +};
> +
> +struct vc4_dummy_crtc *vc4_mock_pv(struct kunit *test,
> +				   struct drm_device *drm,
> +				   struct drm_plane *plane,
> +				   const struct vc4_crtc_data *data);
> +
> +struct vc4_dummy_output {
> +	struct vc4_encoder encoder;
> +	struct drm_connector connector;
> +};
> +
> +struct vc4_dummy_output *vc4_dummy_output(struct kunit *test,
> +					  struct drm_device *drm,
> +					  struct drm_crtc *crtc,
> +					  enum vc4_encoder_type vc4_encoder_type,
> +					  unsigned int kms_encoder_type,
> +					  unsigned int connector_type);
> +
> +struct vc4_dev *vc4_mock_device(struct kunit *test);
> +struct vc4_dev *vc5_mock_device(struct kunit *test);
> +
> +int vc4_mock_atomic_add_output(struct kunit *test, struct drm_device *drm,
> +			       enum vc4_encoder_type type,
> +			       struct drm_atomic_state *state);
> +
> +#endif // VC4_MOCK_H_
> diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock_crtc.c b/drivers/gpu/drm/vc4/tests/vc4_mock_crtc.c
> new file mode 100644
> index 000000000000..5d12d7beef0e
> --- /dev/null
> +++ b/drivers/gpu/drm/vc4/tests/vc4_mock_crtc.c
> @@ -0,0 +1,41 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <drm/drm_atomic_state_helper.h>
> +#include <drm/drm_modeset_helper_vtables.h>
> +
> +#include <kunit/test.h>
> +
> +#include "vc4_mock.h"
> +
> +static const struct drm_crtc_helper_funcs vc4_dummy_crtc_helper_funcs = {
> +	.atomic_check	= vc4_crtc_atomic_check,
> +};
> +
> +static const struct drm_crtc_funcs vc4_dummy_crtc_funcs = {
> +	.atomic_destroy_state	= vc4_crtc_destroy_state,
> +	.atomic_duplicate_state	= vc4_crtc_duplicate_state,
> +	.reset			= vc4_crtc_reset,
> +};
> +
> +struct vc4_dummy_crtc *vc4_mock_pv(struct kunit *test,
> +				   struct drm_device *drm,
> +				   struct drm_plane *plane,
> +				   const struct vc4_crtc_data *data)
> +{
> +	struct vc4_dummy_crtc *dummy_crtc;
> +	struct vc4_crtc *vc4_crtc;
> +	int ret;
> +
> +	dummy_crtc = kunit_kzalloc(test, sizeof(*dummy_crtc), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_NULL(test, dummy_crtc);
> +
> +	vc4_crtc = &dummy_crtc->crtc;
> +	ret = __vc4_crtc_init(drm, NULL,
> +			      vc4_crtc, data, plane,
> +			      &vc4_dummy_crtc_funcs,
> +			      &vc4_dummy_crtc_helper_funcs,
> +			      false);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	return dummy_crtc;
> +}
> diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock_output.c b/drivers/gpu/drm/vc4/tests/vc4_mock_output.c
> new file mode 100644
> index 000000000000..cb16ab4451f7
> --- /dev/null
> +++ b/drivers/gpu/drm/vc4/tests/vc4_mock_output.c
> @@ -0,0 +1,99 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <drm/drm_atomic_state_helper.h>
> +#include <drm/drm_atomic_uapi.h>
> +#include <drm/drm_connector.h>
> +#include <drm/drm_crtc.h>
> +#include <drm/drm_encoder.h>
> +#include <drm/drm_modeset_helper_vtables.h>
> +
> +#include <kunit/test.h>
> +
> +#include "vc4_mock.h"
> +
> +static const struct drm_connector_helper_funcs vc4_dummy_connector_helper_funcs = {
> +};
> +
> +static const struct drm_connector_funcs vc4_dummy_connector_funcs = {
> +	.atomic_destroy_state	= drm_atomic_helper_connector_destroy_state,
> +	.atomic_duplicate_state	= drm_atomic_helper_connector_duplicate_state,
> +	.reset			= drm_atomic_helper_connector_reset,
> +};
> +
> +struct vc4_dummy_output *vc4_dummy_output(struct kunit *test,
> +					  struct drm_device *drm,
> +					  struct drm_crtc *crtc,
> +					  enum vc4_encoder_type vc4_encoder_type,
> +					  unsigned int kms_encoder_type,
> +					  unsigned int connector_type)
> +{
> +	struct vc4_dummy_output *dummy_output;
> +	struct drm_connector *conn;
> +	struct drm_encoder *enc;
> +	int ret;
> +
> +	dummy_output = kunit_kzalloc(test, sizeof(*dummy_output), GFP_KERNEL);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_output);
> +	dummy_output->encoder.type = vc4_encoder_type;
> +
> +	enc = &dummy_output->encoder.base;
> +	ret = drmm_encoder_init(drm, enc,
> +				NULL,
> +				kms_encoder_type,
> +				NULL);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +	enc->possible_crtcs = drm_crtc_mask(crtc);
> +
> +	conn = &dummy_output->connector;
> +	ret = drmm_connector_init(drm, conn,
> +				  &vc4_dummy_connector_funcs,
> +				  connector_type,
> +				  NULL);
> +	KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +	drm_connector_helper_add(conn, &vc4_dummy_connector_helper_funcs);
> +	drm_connector_attach_encoder(conn, enc);
> +
> +	return dummy_output;
> +}
> +
> +static const struct drm_display_mode default_mode = {
> +	DRM_SIMPLE_MODE(640, 480, 64, 48)
> +};
> +
> +int vc4_mock_atomic_add_output(struct kunit *test, struct drm_device *drm,
> +			       enum vc4_encoder_type type,
> +			       struct drm_atomic_state *state)
> +{
> +	struct vc4_dummy_output *output;
> +	struct drm_connector *conn;
> +	struct drm_connector_state *conn_state;
> +	struct drm_encoder *encoder;
> +	struct drm_crtc *crtc;
> +	struct drm_crtc_state *crtc_state;
> +	int ret;
> +
> +	encoder = vc4_find_encoder_by_type(drm, type);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, encoder);
> +
> +	crtc = vc4_find_crtc_for_encoder(test, drm, encoder);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc);
> +
> +	output = container_of(encoder, struct vc4_dummy_output, encoder.base);
> +	conn = &output->connector;
> +	conn_state = drm_atomic_get_connector_state(state, conn);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state);
> +
> +	ret = drm_atomic_set_crtc_for_connector(conn_state, crtc);
> +	KUNIT_EXPECT_EQ(test, ret, 0);
> +
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state);
> +
> +	ret = drm_atomic_set_mode_for_crtc(crtc_state, &default_mode);
> +	KUNIT_EXPECT_EQ(test, ret, 0);
> +
> +	crtc_state->active = true;
> +
> +	return 0;
> +}
> diff --git a/drivers/gpu/drm/vc4/tests/vc4_mock_plane.c b/drivers/gpu/drm/vc4/tests/vc4_mock_plane.c
> new file mode 100644
> index 000000000000..62b18f5f41db
> --- /dev/null
> +++ b/drivers/gpu/drm/vc4/tests/vc4_mock_plane.c
> @@ -0,0 +1,47 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
> +#include <drm/drm_atomic_state_helper.h>
> +#include <drm/drm_fourcc.h>
> +#include <drm/drm_modeset_helper_vtables.h>
> +#include <drm/drm_plane.h>
> +
> +#include <kunit/test.h>
> +
> +#include "vc4_mock.h"
> +
> +static const struct drm_plane_helper_funcs vc4_dummy_plane_helper_funcs = {
> +};
> +
> +static const struct drm_plane_funcs vc4_dummy_plane_funcs = {
> +	.atomic_destroy_state	= drm_atomic_helper_plane_destroy_state,
> +	.atomic_duplicate_state	= drm_atomic_helper_plane_duplicate_state,
> +	.reset			= drm_atomic_helper_plane_reset,
> +};
> +
> +static const uint32_t vc4_dummy_plane_formats[] = {
> +	DRM_FORMAT_XRGB8888,
> +};
> +
> +struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
> +					struct drm_device *drm,
> +					enum drm_plane_type type)
> +{
> +	struct vc4_dummy_plane *dummy_plane;
> +	struct drm_plane *plane;
> +
> +	dummy_plane = drmm_universal_plane_alloc(drm,
> +						 struct vc4_dummy_plane, plane.base,
> +						 0,
> +						 &vc4_dummy_plane_funcs,
> +						 vc4_dummy_plane_formats,
> +						 ARRAY_SIZE(vc4_dummy_plane_formats),
> +						 NULL,
> +						 DRM_PLANE_TYPE_PRIMARY,
> +						 NULL);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_plane);
> +
> +	plane = &dummy_plane->plane.base;
> +	drm_plane_helper_add(plane, &vc4_dummy_plane_helper_funcs);
> +
> +	return dummy_plane;
> +}
> diff --git a/drivers/gpu/drm/vc4/vc4_crtc.c b/drivers/gpu/drm/vc4/vc4_crtc.c
> index 59e473059fa2..21b40d644ace 100644
> --- a/drivers/gpu/drm/vc4/vc4_crtc.c
> +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
> @@ -675,8 +675,8 @@ void vc4_crtc_get_margins(struct drm_crtc_state *state,
>  	}
>  }
>  
> -static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
> -				 struct drm_atomic_state *state)
> +int vc4_crtc_atomic_check(struct drm_crtc *crtc,
> +			  struct drm_atomic_state *state)
>  {
>  	struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
>  									  crtc);
> @@ -1116,7 +1116,7 @@ static const struct drm_crtc_helper_funcs vc4_crtc_helper_funcs = {
>  	.get_scanout_position = vc4_crtc_get_scanout_position,
>  };
>  
> -static const struct vc4_pv_data bcm2835_pv0_data = {
> +const struct vc4_pv_data bcm2835_pv0_data = {
>  	.base = {
>  		.name = "pixelvalve-0",
>  		.debugfs_name = "crtc0_regs",
> @@ -1131,7 +1131,7 @@ static const struct vc4_pv_data bcm2835_pv0_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2835_pv1_data = {
> +const struct vc4_pv_data bcm2835_pv1_data = {
>  	.base = {
>  		.name = "pixelvalve-1",
>  		.debugfs_name = "crtc1_regs",
> @@ -1146,7 +1146,7 @@ static const struct vc4_pv_data bcm2835_pv1_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2835_pv2_data = {
> +const struct vc4_pv_data bcm2835_pv2_data = {
>  	.base = {
>  		.name = "pixelvalve-2",
>  		.debugfs_name = "crtc2_regs",
> @@ -1161,7 +1161,7 @@ static const struct vc4_pv_data bcm2835_pv2_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2711_pv0_data = {
> +const struct vc4_pv_data bcm2711_pv0_data = {
>  	.base = {
>  		.name = "pixelvalve-0",
>  		.debugfs_name = "crtc0_regs",
> @@ -1176,7 +1176,7 @@ static const struct vc4_pv_data bcm2711_pv0_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2711_pv1_data = {
> +const struct vc4_pv_data bcm2711_pv1_data = {
>  	.base = {
>  		.name = "pixelvalve-1",
>  		.debugfs_name = "crtc1_regs",
> @@ -1191,7 +1191,7 @@ static const struct vc4_pv_data bcm2711_pv1_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2711_pv2_data = {
> +const struct vc4_pv_data bcm2711_pv2_data = {
>  	.base = {
>  		.name = "pixelvalve-2",
>  		.debugfs_name = "crtc2_regs",
> @@ -1205,7 +1205,7 @@ static const struct vc4_pv_data bcm2711_pv2_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2711_pv3_data = {
> +const struct vc4_pv_data bcm2711_pv3_data = {
>  	.base = {
>  		.name = "pixelvalve-3",
>  		.debugfs_name = "crtc3_regs",
> @@ -1219,7 +1219,7 @@ static const struct vc4_pv_data bcm2711_pv3_data = {
>  	},
>  };
>  
> -static const struct vc4_pv_data bcm2711_pv4_data = {
> +const struct vc4_pv_data bcm2711_pv4_data = {
>  	.base = {
>  		.name = "pixelvalve-4",
>  		.debugfs_name = "crtc4_regs",
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
> index 5990d8f8c363..3b0ae2c3e33c 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.c
> +++ b/drivers/gpu/drm/vc4/vc4_drv.c
> @@ -196,7 +196,7 @@ static const struct drm_ioctl_desc vc4_drm_ioctls[] = {
>  	DRM_IOCTL_DEF_DRV(VC4_PERFMON_GET_VALUES, vc4_perfmon_get_values_ioctl, DRM_RENDER_ALLOW),
>  };
>  
> -static const struct drm_driver vc4_drm_driver = {
> +const struct drm_driver vc4_drm_driver = {
>  	.driver_features = (DRIVER_MODESET |
>  			    DRIVER_ATOMIC |
>  			    DRIVER_GEM |
> @@ -225,7 +225,7 @@ static const struct drm_driver vc4_drm_driver = {
>  	.patchlevel = DRIVER_PATCHLEVEL,
>  };
>  
> -static const struct drm_driver vc5_drm_driver = {
> +const struct drm_driver vc5_drm_driver = {
>  	.driver_features = (DRIVER_MODESET |
>  			    DRIVER_ATOMIC |
>  			    DRIVER_GEM),
> diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h
> index e0be7a81a24a..418f4f308e36 100644
> --- a/drivers/gpu/drm/vc4/vc4_drv.h
> +++ b/drivers/gpu/drm/vc4/vc4_drv.h
> @@ -24,6 +24,9 @@
>  struct drm_device;
>  struct drm_gem_object;
>  
> +extern const struct drm_driver vc4_drm_driver;
> +extern const struct drm_driver vc5_drm_driver;
> +
>  /* Don't forget to update vc4_bo.c: bo_type_names[] when adding to
>   * this.
>   */
> @@ -523,6 +526,8 @@ struct vc4_crtc_data {
>  	int hvs_output;
>  };
>  
> +extern const struct vc4_crtc_data vc4_txp_crtc_data;
> +
>  struct vc4_pv_data {
>  	struct vc4_crtc_data	base;
>  
> @@ -535,6 +540,15 @@ struct vc4_pv_data {
>  	enum vc4_encoder_type encoder_types[4];
>  };
>  
> +extern const struct vc4_pv_data bcm2835_pv0_data;
> +extern const struct vc4_pv_data bcm2835_pv1_data;
> +extern const struct vc4_pv_data bcm2835_pv2_data;
> +extern const struct vc4_pv_data bcm2711_pv0_data;
> +extern const struct vc4_pv_data bcm2711_pv1_data;
> +extern const struct vc4_pv_data bcm2711_pv2_data;
> +extern const struct vc4_pv_data bcm2711_pv3_data;
> +extern const struct vc4_pv_data bcm2711_pv4_data;
> +
>  struct vc4_crtc {
>  	struct drm_crtc base;
>  	struct platform_device *pdev;
> @@ -920,6 +934,8 @@ int vc4_page_flip(struct drm_crtc *crtc,
>  		  struct drm_pending_vblank_event *event,
>  		  uint32_t flags,
>  		  struct drm_modeset_acquire_ctx *ctx);
> +int vc4_crtc_atomic_check(struct drm_crtc *crtc,
> +			  struct drm_atomic_state *state);
>  struct drm_crtc_state *vc4_crtc_duplicate_state(struct drm_crtc *crtc);
>  void vc4_crtc_destroy_state(struct drm_crtc *crtc,
>  			    struct drm_crtc_state *state);
> diff --git a/drivers/gpu/drm/vc4/vc4_txp.c b/drivers/gpu/drm/vc4/vc4_txp.c
> index 4f7ce5d3e8ad..2b69454b8534 100644
> --- a/drivers/gpu/drm/vc4/vc4_txp.c
> +++ b/drivers/gpu/drm/vc4/vc4_txp.c
> @@ -479,7 +479,7 @@ static irqreturn_t vc4_txp_interrupt(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static const struct vc4_crtc_data vc4_txp_crtc_data = {
> +const struct vc4_crtc_data vc4_txp_crtc_data = {
>  	.name = "txp",
>  	.debugfs_name = "txp_regs",
>  	.hvs_available_channels = BIT(2),
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 03/17] drm/tests: helpers: Rename the device init helper
       [not found] ` <20221123-rpi-kunit-tests-v2-3-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:36   ` Maíra Canal
  0 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:36 UTC (permalink / raw)
  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, linux-kernel, linaro-mm-sig,
	Brendan Higgins, linux-kselftest, kunit-dev, linux-media

On 11/28/22 11:53, Maxime Ripard wrote:
> The name doesn't really fit the conventions for the other helpers in
> DRM/KMS, so let's rename it to make it obvious that we allocate a new
> DRM device.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>

Reviewed-by: Maíra Canal <mcanal@igalia.com>

Best Regards,
- Maíra Canal

> ---
>  drivers/gpu/drm/tests/drm_client_modeset_test.c | 3 ++-
>  drivers/gpu/drm/tests/drm_kunit_helpers.c       | 8 +++++---
>  drivers/gpu/drm/tests/drm_modes_test.c          | 3 ++-
>  drivers/gpu/drm/tests/drm_probe_helper_test.c   | 5 +++--
>  include/drm/drm_kunit_helpers.h                 | 5 ++++-
>  5 files changed, 16 insertions(+), 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 ed2f62e92fea..6cdf08f582ce 100644
> --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c
> +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c
> @@ -59,7 +59,8 @@ static int drm_client_modeset_test_init(struct kunit *test)
>  
>  	test->priv = priv;
>  
> -	priv->drm = drm_kunit_device_init(test, DRIVER_MODESET, "drm-client-modeset-test");
> +	priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET,
> +						      "drm-client-modeset-test");
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
>  	ret = drmm_connector_init(priv->drm, &priv->connector,
> diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> index 46a68c2fd80c..2f67f6cf78d0 100644
> --- a/drivers/gpu/drm/tests/drm_kunit_helpers.c
> +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c
> @@ -36,7 +36,7 @@ static void dev_free(struct kunit_resource *res)
>  }
>  
>  /**
> - * drm_kunit_device_init - Allocates a mock DRM device for Kunit tests
> + * drm_kunit_helper_alloc_drm_device - Allocates a mock DRM device for Kunit tests
>   * @test: The test context object
>   * @features: Mocked DRM device driver features
>   * @name: Name of the struct &device to allocate
> @@ -52,7 +52,9 @@ static void dev_free(struct kunit_resource *res)
>   * Returns:
>   * A pointer to the new drm_device, or an ERR_PTR() otherwise.
>   */
> -struct drm_device *drm_kunit_device_init(struct kunit *test, u32 features, char *name)
> +struct drm_device *
> +drm_kunit_helper_alloc_drm_device(struct kunit *test,
> +				  u32 features, char *name)
>  {
>  	struct kunit_dev *kdev;
>  	struct drm_device *drm;
> @@ -82,7 +84,7 @@ struct drm_device *drm_kunit_device_init(struct kunit *test, u32 features, char
>  
>  	return drm;
>  }
> -EXPORT_SYMBOL(drm_kunit_device_init);
> +EXPORT_SYMBOL(drm_kunit_helper_alloc_drm_device);
>  
>  MODULE_AUTHOR("Maxime Ripard <maxime@cerno.tech>");
>  MODULE_LICENSE("GPL");
> diff --git a/drivers/gpu/drm/tests/drm_modes_test.c b/drivers/gpu/drm/tests/drm_modes_test.c
> index 3953e478c4d0..6723089dff9f 100644
> --- a/drivers/gpu/drm/tests/drm_modes_test.c
> +++ b/drivers/gpu/drm/tests/drm_modes_test.c
> @@ -22,7 +22,8 @@ static int drm_test_modes_init(struct kunit *test)
>  	priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
>  	KUNIT_ASSERT_NOT_NULL(test, priv);
>  
> -	priv->drm = drm_kunit_device_init(test, DRIVER_MODESET, "drm-modes-test");
> +	priv->drm = drm_kunit_helper_alloc_drm_device(test, DRIVER_MODESET,
> +						      "drm-modes-test");
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
>  	test->priv = priv;
> diff --git a/drivers/gpu/drm/tests/drm_probe_helper_test.c b/drivers/gpu/drm/tests/drm_probe_helper_test.c
> index 1f3941c150ae..85236ff4744f 100644
> --- a/drivers/gpu/drm/tests/drm_probe_helper_test.c
> +++ b/drivers/gpu/drm/tests/drm_probe_helper_test.c
> @@ -39,8 +39,9 @@ static int drm_probe_helper_test_init(struct kunit *test)
>  	KUNIT_ASSERT_NOT_NULL(test, priv);
>  	test->priv = priv;
>  
> -	priv->drm = drm_kunit_device_init(test, DRIVER_MODESET | DRIVER_ATOMIC,
> -					  "drm-probe-helper-test");
> +	priv->drm = drm_kunit_helper_alloc_drm_device(test,
> +						      DRIVER_MODESET | DRIVER_ATOMIC,
> +						      "drm-probe-helper-test");
>  	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm);
>  
>  	connector = &priv->connector;
> diff --git a/include/drm/drm_kunit_helpers.h b/include/drm/drm_kunit_helpers.h
> index 20ab6eec4c89..e9870c7911fe 100644
> --- a/include/drm/drm_kunit_helpers.h
> +++ b/include/drm/drm_kunit_helpers.h
> @@ -6,6 +6,9 @@
>  struct drm_device;
>  struct kunit;
>  
> -struct drm_device *drm_kunit_device_init(struct kunit *test, u32 features, char *name);
> +struct drm_device *
> +drm_kunit_helper_alloc_drm_device(struct kunit *test,
> +				  u32 features,
> +				  char *name);
>  
>  #endif // DRM_KUNIT_HELPERS_H_
> 

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 00/17] drm: Introduce Kunit Tests to VC4
       [not found] <20221123-rpi-kunit-tests-v2-0-efe5ed518b63@cerno.tech>
                   ` (10 preceding siblings ...)
       [not found] ` <20221123-rpi-kunit-tests-v2-3-efe5ed518b63@cerno.tech>
@ 2022-11-28 20:48 ` Maíra Canal
       [not found] ` <20221123-rpi-kunit-tests-v2-1-efe5ed518b63@cerno.tech>
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Maíra Canal @ 2022-11-28 20:48 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins, Dave Stevenson,
	Javier Martinez Canillas, linux-kernel, David Gow

On 11/28/22 11:53, Maxime Ripard wrote:
> Hi,
> 
> This series introduce Kunit tests to the vc4 KMS driver, but unlike what we
> have been doing so far in KMS, it actually tests the atomic modesetting code.
> 
> In order to do so, I've had to improve a fair bit on the Kunit helpers already
> found in the tree in order to register a full blown and somewhat functional KMS
> driver.
> 
> It's of course relying on a mock so that we can test it anywhere. The mocking
> approach created a number of issues, the main one being that we need to create
> a decent mock in the first place, see patch 22. The basic idea is that I
> created some structures to provide a decent approximation of the actual
> hardware, and that would support both major architectures supported by vc4.
> 
> This is of course meant to evolve over time and support more tests, but I've
> focused on testing the HVS FIFO assignment code which is fairly tricky (and the
> tests have actually revealed one more bug with our current implementation). I
> used to have a userspace implementation of those tests, where I would copy and
> paste the kernel code and run the tests on a regular basis. It's was obviously
> fairly suboptimal, so it seemed like the perfect testbed for that series.
> 
> It can be run using:
> ./tools/testing/kunit/kunit.py run \
>         --kunitconfig=drivers/gpu/drm/vc4/tests/.kunitconfig \
>         --cross_compile aarch64-linux-gnu- --arch arm64
> 
> Let me know what you think,
> Maxime

Hi Maxime,

It is great to see some device mocking with KUnit! Other than the
comments that I pointed out in the series, I believe that a small entry
on the VC4 documentation would be nice to cover how to run the tests and
also what the tests are currently covering.

Best Regards,
- Maíra Canal

> 
> To: David Airlie <airlied@gmail.com>
> To: Daniel Vetter <daniel@ffwll.ch>
> To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> To: Maxime Ripard <mripard@kernel.org>
> To: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
> Cc: Javier Martinez Canillas <javierm@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Maíra Canal <mairacanal@riseup.net>
> Cc: Brendan Higgins <brendan.higgins@linux.dev>
> Cc: David Gow <davidgow@google.com>
> Cc: linux-kselftest@vger.kernel.org
> Cc: kunit-dev@googlegroups.com
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-media@vger.kernel.org
> Cc: linaro-mm-sig@lists.linaro.org
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> 
> ---
> Changes in v2:
> - Added some documentation for public functions
> - Removed the fake device probe/remove workqueue 
> - Made sure the tests could be compiled as modules
> - Moved the vc4 tests in the vc4 module
> - Applied some of the preliminary patches
> - Rebased on top of current drm-misc-next branch
> - Fixed checkpatch issues
> - Introduced BCM2835 (Pi0-3) tests for muxing
> - Introduced tests to cover past bugs we had
> - Link to v1: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v1-0-051a0bb60a16@cerno.tech
> 
> ---
> Maxime Ripard (17):
>       drm/tests: helpers: Move the helper header to include/drm
>       drm/tests: helpers: Document drm_kunit_device_init()
>       drm/tests: helpers: Rename the device init helper
>       drm/tests: helpers: Remove the name parameter
>       drm/tests: helpers: Create the device in another function
>       drm/tests: helpers: Switch to a platform_device
>       drm/tests: helpers: Make sure the device is bound
>       drm/tests: helpers: Allow for a custom device struct to be allocated
>       drm/tests: helpers: Allow to pass a custom drm_driver
>       drm/tests: Add a test for DRM managed actions
>       drm/vc4: Move HVS state to main header
>       drm/vc4: crtc: Introduce a lower-level crtc init helper
>       drm/vc4: crtc: Make encoder lookup helper public
>       drm/vc4: hvs: Provide a function to initialize the HVS structure
>       drm/vc4: tests: Introduce a mocking infrastructure
>       drm/vc4: tests: Fail the current test if we access a register
>       drm/vc4: tests: Add unit test suite for the PV muxing
> 
>  drivers/gpu/drm/tests/Makefile                  |    1 +
>  drivers/gpu/drm/tests/drm_client_modeset_test.c |   19 +-
>  drivers/gpu/drm/tests/drm_kunit_helpers.c       |  106 ++-
>  drivers/gpu/drm/tests/drm_kunit_helpers.h       |   11 -
>  drivers/gpu/drm/tests/drm_managed_test.c        |   71 ++
>  drivers/gpu/drm/tests/drm_modes_test.c          |   19 +-
>  drivers/gpu/drm/tests/drm_probe_helper_test.c   |   20 +-
>  drivers/gpu/drm/vc4/Kconfig                     |   15 +
>  drivers/gpu/drm/vc4/Makefile                    |    7 +
>  drivers/gpu/drm/vc4/tests/.kunitconfig          |   14 +
>  drivers/gpu/drm/vc4/tests/vc4_mock.c            |  200 +++++
>  drivers/gpu/drm/vc4/tests/vc4_mock.h            |   63 ++
>  drivers/gpu/drm/vc4/tests/vc4_mock_crtc.c       |   41 +
>  drivers/gpu/drm/vc4/tests/vc4_mock_output.c     |  138 +++
>  drivers/gpu/drm/vc4/tests/vc4_mock_plane.c      |   47 +
>  drivers/gpu/drm/vc4/tests/vc4_test_pv_muxing.c  | 1039 +++++++++++++++++++++++
>  drivers/gpu/drm/vc4/vc4_crtc.c                  |  102 ++-
>  drivers/gpu/drm/vc4/vc4_dpi.c                   |   13 +-
>  drivers/gpu/drm/vc4/vc4_drv.c                   |    4 +-
>  drivers/gpu/drm/vc4/vc4_drv.h                   |   91 +-
>  drivers/gpu/drm/vc4/vc4_dsi.c                   |    9 +-
>  drivers/gpu/drm/vc4/vc4_hdmi_regs.h             |    4 +
>  drivers/gpu/drm/vc4/vc4_hvs.c                   |   81 +-
>  drivers/gpu/drm/vc4/vc4_kms.c                   |   25 +-
>  drivers/gpu/drm/vc4/vc4_txp.c                   |   15 +-
>  drivers/gpu/drm/vc4/vc4_vec.c                   |   13 +-
>  include/drm/drm_kunit_helpers.h                 |   91 ++
>  27 files changed, 2087 insertions(+), 172 deletions(-)
> ---
> base-commit: 199557fab92548f8e9d5207e385097213abe0cab
> change-id: 20221123-rpi-kunit-tests-87a388492a73
> 
> Best regards,

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 01/17] drm/tests: helpers: Move the helper header to include/drm
       [not found] ` <20221123-rpi-kunit-tests-v2-1-efe5ed518b63@cerno.tech>
@ 2022-11-30  8:00   ` Javier Martinez Canillas
  2022-12-01 10:27     ` Maxime Ripard
  0 siblings, 1 reply; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-11-30  8:00 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

On 11/28/22 15:53, Maxime Ripard wrote:
> We'll need to use those helpers from drivers too, so let's move it to a
> more visible location.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---
>  drivers/gpu/drm/tests/drm_client_modeset_test.c            | 3 +--
>  drivers/gpu/drm/tests/drm_kunit_helpers.c                  | 3 +--
>  drivers/gpu/drm/tests/drm_modes_test.c                     | 3 +--
>  drivers/gpu/drm/tests/drm_probe_helper_test.c              | 3 +--
>  {drivers/gpu/drm/tests => include/drm}/drm_kunit_helpers.h | 0
>  5 files changed, 4 insertions(+), 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 52929536a158..ed2f62e92fea 100644
> --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c
> +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c
> @@ -8,12 +8,11 @@
>  #include <drm/drm_connector.h>
>  #include <drm/drm_edid.h>
>  #include <drm/drm_drv.h>
> +#include <drm/drm_kunit_helpers.h>

I wonder if now that this header was moved outside of the tests directory,
if we should add stub functions in the header file that are just defined
but do nothing if CONFIG_DRM_KUNIT_TEST isn't enabled. So that including
it in drivers will be a no-op.

Or do you plan to conditionally include this header file in drivers? So
that is only included when CONFIG_DRM_KUNIT_TEST is enabled?

Another thing that wondered is if we want a different namespace for this
header, i.e: <drm/testing/drm_kunit_helpers.h>, to make it clear that is
not part of the DRM API but just for testing helpers.

But these are open questions really, and they can be done as follow-up:

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 08/17] drm/tests: helpers: Allow for a custom device struct to be allocated
       [not found] ` <20221123-rpi-kunit-tests-v2-8-efe5ed518b63@cerno.tech>
@ 2022-11-30  9:13   ` Javier Martinez Canillas
  0 siblings, 0 replies; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-11-30  9:13 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

On 11/28/22 15:53, Maxime Ripard wrote:
> The current helper to allocate a DRM device doesn't allow for any
> subclassing by drivers, which is going to be troublesome as we work on
> getting some kunit testing on atomic modesetting code.
> 
> Let's use a similar pattern to the other allocation helpers by providing
> the structure size and offset as arguments.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

[...]

> -EXPORT_SYMBOL(drm_kunit_helper_alloc_drm_device);
> +EXPORT_SYMBOL(__drm_kunit_helper_alloc_drm_device);
>

I'm not sure if I would add a __ prefix to exported symbols, but I see that
this is a convention in the DRM subsystem so I'm OK with it. 

Another thing that came to mind is if we want to use EXPORT_SYMBOL_GPL()
instead for the DRM KUnit helpers. But that's not related to this series.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>  

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 09/17] drm/tests: helpers: Allow to pass a custom drm_driver
       [not found] ` <20221123-rpi-kunit-tests-v2-9-efe5ed518b63@cerno.tech>
@ 2022-11-30  9:27   ` Javier Martinez Canillas
  0 siblings, 0 replies; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-11-30  9:27 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

On 11/28/22 15:53, Maxime Ripard wrote:
> Some tests will need to provide their own drm_driver instead of relying
> on the dumb one in the helpers, so let's create a helper that allows to
> do so.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 15/17] drm/vc4: tests: Introduce a mocking infrastructure
       [not found] ` <20221123-rpi-kunit-tests-v2-15-efe5ed518b63@cerno.tech>
  2022-11-28 20:35   ` [PATCH v2 15/17] drm/vc4: tests: Introduce a mocking infrastructure Maíra Canal
@ 2022-11-30  9:59   ` Javier Martinez Canillas
  2022-12-01 13:03     ` Maxime Ripard
  1 sibling, 1 reply; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-11-30  9:59 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

On 11/28/22 15:53, Maxime Ripard wrote:
> In order to test the current atomic_check hooks we need to have a DRM
> device that has roughly the same capabilities and layout that the actual
> hardware. We'll also need a bunch of functions to create arbitrary
> atomic states.
> 
> Let's create some helpers to create a device that behaves like the real
> one, and some helpers to maintain the atomic state we want to check.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

[...]

> +
> +config DRM_VC4_KUNIT_TEST
> +	bool "KUnit tests for VC4" if !KUNIT_ALL_TESTS
> +	depends on DRM_VC4 && KUNIT

shouldn't this depend on DRM_KUNIT_TEST instead ?

[...]

> +static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
> +{
> +	struct drm_device *drm;
> +	const struct drm_driver *drv = is_vc5 ? &vc5_drm_driver : &vc4_drm_driver;
> +	const struct vc4_mock_desc *desc = is_vc5 ? &vc5_mock : &vc4_mock;
> +	struct vc4_dev *vc4;

Since it could be vc4 or vc5, maybe can be renamed to just struct vc_dev *vc ?

> +struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
> +					struct drm_device *drm,
> +					enum drm_plane_type type)
> +{
> +	struct vc4_dummy_plane *dummy_plane;
> +	struct drm_plane *plane;
> +
> +	dummy_plane = drmm_universal_plane_alloc(drm,
> +						 struct vc4_dummy_plane, plane.base,
> +						 0,
> +						 &vc4_dummy_plane_funcs,
> +						 vc4_dummy_plane_formats,
> +						 ARRAY_SIZE(vc4_dummy_plane_formats),
> +						 NULL,
> +						 DRM_PLANE_TYPE_PRIMARY,
> +						 NULL);
> +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_plane);
> +
> +	plane = &dummy_plane->plane.base;
> +	drm_plane_helper_add(plane, &vc4_dummy_plane_helper_funcs);
> +
> +	return dummy_plane;
> +}

I guess many of these helpers could grow to be generic, like this one since
most drivers support the DRM_FORMAT_XRGB8888 format for their primary plane.

[...]

>  
> +extern const struct vc4_pv_data bcm2835_pv0_data;
> +extern const struct vc4_pv_data bcm2835_pv1_data;
> +extern const struct vc4_pv_data bcm2835_pv2_data;
> +extern const struct vc4_pv_data bcm2711_pv0_data;
> +extern const struct vc4_pv_data bcm2711_pv1_data;
> +extern const struct vc4_pv_data bcm2711_pv2_data;
> +extern const struct vc4_pv_data bcm2711_pv3_data;
> +extern const struct vc4_pv_data bcm2711_pv4_data;
> +

Maybe the driver could expose a helper function to get the pixelvalve data
and avoid having to expose all of these variables? For example you could
define an enum vc4_pixelvalve type and have something like the following:

const struct vc4_pv_data *vc4_crtc_get_pixelvalve_data(enum vc4_pixelvalve pv);

All these are small nits though, the patch looks great to me and I think is
awesome to have this level of testing with KUnit. Hope other drivers follow
your lead.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 16/17] drm/vc4: tests: Fail the current test if we access a register
       [not found] ` <20221123-rpi-kunit-tests-v2-16-efe5ed518b63@cerno.tech>
@ 2022-11-30 10:09   ` Javier Martinez Canillas
  0 siblings, 0 replies; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-11-30 10:09 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

On 11/28/22 15:53, Maxime Ripard wrote:
> Accessing a register when running under kunit is a bad idea since our
> device is completely mocked.
> 
> Fail the current test if we ever access any of our hardware registers.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

[...]

> -#define CRTC_WRITE(offset, val) writel(val, vc4_crtc->regs + (offset))
> -#define CRTC_READ(offset) readl(vc4_crtc->regs + (offset))
> +#define CRTC_WRITE(offset, val)								\
> +	do {										\
> +		kunit_fail_current_test("Accessing a register in a unit test!\n");	\
> +		writel(val, vc4_crtc->regs + (offset));					\
> +	} while (0)
> +
> +#define CRTC_READ(offset)								\
> +	({										\
> +		kunit_fail_current_test("Accessing a register in a unit test!\n");	\
> +		readl(vc4_crtc->regs + (offset));					\
> +	})
> 

Should this be made conditional on whether DRM_VC4_KUNIT_TEST is enabled ? 

That is, just define the simpler macros when is disabled? The kunit_fail_current_test()
is just a no-op if CONFIG_KUNIT isn't enabled, but I think my question still stands.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 17/17] drm/vc4: tests: Add unit test suite for the PV muxing
       [not found] ` <20221123-rpi-kunit-tests-v2-17-efe5ed518b63@cerno.tech>
@ 2022-11-30 10:15   ` Javier Martinez Canillas
  0 siblings, 0 replies; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-11-30 10:15 UTC (permalink / raw)
  To: Maxime Ripard, Daniel Vetter, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Thomas Zimmermann
  Cc: dri-devel, Greg Kroah-Hartman, kunit-dev, linux-media,
	linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

On 11/28/22 15:53, Maxime Ripard wrote:
> The HVS to PixelValve muxing code is fairly error prone and has a bunch
> of arbitrary constraints due to the hardware setup.
> 
> Let's create a test suite that makes sure that the possible combinations
> work and the invalid ones don't.
> 
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Thanks for this patch. It shows how powerful KUnit can be for testing drivers. 

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 01/17] drm/tests: helpers: Move the helper header to include/drm
  2022-11-30  8:00   ` [PATCH v2 01/17] drm/tests: helpers: Move the helper header to include/drm Javier Martinez Canillas
@ 2022-12-01 10:27     ` Maxime Ripard
  2022-12-01 10:38       ` Javier Martinez Canillas
  0 siblings, 1 reply; 21+ messages in thread
From: Maxime Ripard @ 2022-12-01 10:27 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Daniel Vetter, Maarten Lankhorst, David Airlie,
	Thomas Zimmermann, dri-devel, Greg Kroah-Hartman, kunit-dev,
	linux-media, linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

[-- Attachment #1: Type: text/plain, Size: 2294 bytes --]

Hi Javier,

On Wed, Nov 30, 2022 at 09:00:03AM +0100, Javier Martinez Canillas wrote:
> On 11/28/22 15:53, Maxime Ripard wrote:
> > We'll need to use those helpers from drivers too, so let's move it to a
> > more visible location.
> > 
> > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> > ---
> >  drivers/gpu/drm/tests/drm_client_modeset_test.c            | 3 +--
> >  drivers/gpu/drm/tests/drm_kunit_helpers.c                  | 3 +--
> >  drivers/gpu/drm/tests/drm_modes_test.c                     | 3 +--
> >  drivers/gpu/drm/tests/drm_probe_helper_test.c              | 3 +--
> >  {drivers/gpu/drm/tests => include/drm}/drm_kunit_helpers.h | 0
> >  5 files changed, 4 insertions(+), 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 52929536a158..ed2f62e92fea 100644
> > --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c
> > +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c
> > @@ -8,12 +8,11 @@
> >  #include <drm/drm_connector.h>
> >  #include <drm/drm_edid.h>
> >  #include <drm/drm_drv.h>
> > +#include <drm/drm_kunit_helpers.h>
> 
> I wonder if now that this header was moved outside of the tests directory,
> if we should add stub functions in the header file that are just defined
> but do nothing if CONFIG_DRM_KUNIT_TEST isn't enabled. So that including
> it in drivers will be a no-op.
> 
> Or do you plan to conditionally include this header file in drivers? So
> that is only included when CONFIG_DRM_KUNIT_TEST is enabled?

I'm not entirely sure. I'd expect only the tests to include it, and thus
would depend on DRM_KUNIT_TEST already. But we can always add the stubs
if it's ever included in a different context.

> Another thing that wondered is if we want a different namespace for this
> header, i.e: <drm/testing/drm_kunit_helpers.h>, to make it clear that is
> not part of the DRM API but just for testing helpers.

If there's a single header, I don't think we need to create the
directory. This is also something we can consolidate later on if needed.

> But these are open questions really, and they can be done as follow-up:
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Thanks :)
Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 01/17] drm/tests: helpers: Move the helper header to include/drm
  2022-12-01 10:27     ` Maxime Ripard
@ 2022-12-01 10:38       ` Javier Martinez Canillas
  0 siblings, 0 replies; 21+ messages in thread
From: Javier Martinez Canillas @ 2022-12-01 10:38 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Daniel Vetter, Maarten Lankhorst, David Airlie,
	Thomas Zimmermann, dri-devel, Greg Kroah-Hartman, kunit-dev,
	linux-media, linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

Hello Maxime,

On 12/1/22 11:27, Maxime Ripard wrote:

[...]

>>
>> I wonder if now that this header was moved outside of the tests directory,
>> if we should add stub functions in the header file that are just defined
>> but do nothing if CONFIG_DRM_KUNIT_TEST isn't enabled. So that including
>> it in drivers will be a no-op.
>>
>> Or do you plan to conditionally include this header file in drivers? So
>> that is only included when CONFIG_DRM_KUNIT_TEST is enabled?
> 
> I'm not entirely sure. I'd expect only the tests to include it, and thus
> would depend on DRM_KUNIT_TEST already. But we can always add the stubs
> if it's ever included in a different context.
> 
>> Another thing that wondered is if we want a different namespace for this
>> header, i.e: <drm/testing/drm_kunit_helpers.h>, to make it clear that is
>> not part of the DRM API but just for testing helpers.
> 
> If there's a single header, I don't think we need to create the
> directory. This is also something we can consolidate later on if needed.
>

Agree on both. It's better to land as is and then figure out if needs
to be changed once other drivers add more tests.
 
>> But these are open questions really, and they can be done as follow-up:
>>
>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
> 
> Thanks :)

You are welcome!

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 15/17] drm/vc4: tests: Introduce a mocking infrastructure
  2022-11-30  9:59   ` Javier Martinez Canillas
@ 2022-12-01 13:03     ` Maxime Ripard
  0 siblings, 0 replies; 21+ messages in thread
From: Maxime Ripard @ 2022-12-01 13:03 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Daniel Vetter, Maarten Lankhorst, David Airlie,
	Thomas Zimmermann, dri-devel, Greg Kroah-Hartman, kunit-dev,
	linux-media, linux-kselftest, linaro-mm-sig, Brendan Higgins,
	Maíra Canal, Dave Stevenson, linux-kernel, David Gow

[-- Attachment #1: Type: text/plain, Size: 4111 bytes --]

Hi Javier,

On Wed, Nov 30, 2022 at 10:59:37AM +0100, Javier Martinez Canillas wrote:
> On 11/28/22 15:53, Maxime Ripard wrote:
> > In order to test the current atomic_check hooks we need to have a DRM
> > device that has roughly the same capabilities and layout that the actual
> > hardware. We'll also need a bunch of functions to create arbitrary
> > atomic states.
> > 
> > Let's create some helpers to create a device that behaves like the real
> > one, and some helpers to maintain the atomic state we want to check.
> > 
> > Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> > ---
> 
> [...]
> 
> > +
> > +config DRM_VC4_KUNIT_TEST
> > +	bool "KUnit tests for VC4" if !KUNIT_ALL_TESTS
> > +	depends on DRM_VC4 && KUNIT
> 
> shouldn't this depend on DRM_KUNIT_TEST instead ?
> 
> [...]

You're right, but the rework suggested by Maíra will add a select to the
helpers Kconfig symbol there so we should be safe.

> > +static struct vc4_dev *__mock_device(struct kunit *test, bool is_vc5)
> > +{
> > +	struct drm_device *drm;
> > +	const struct drm_driver *drv = is_vc5 ? &vc5_drm_driver : &vc4_drm_driver;
> > +	const struct vc4_mock_desc *desc = is_vc5 ? &vc5_mock : &vc4_mock;
> > +	struct vc4_dev *vc4;
> 
> Since it could be vc4 or vc5, maybe can be renamed to just struct vc_dev *vc ?

vc4_dev is the main structure in the driver for the DRM device, so we
can't rename it easily.

Generally speaking the driver was (and still is) called vc4 after the IP
name in the original RaspberryPi SoC.

There's been a new generation since, but we supported it through the vc4
driver. Even if it's a bit ambiguous, vc4 refers to both the driver name
and is used extensively in the infrastructure, but also refers to the
initial generation we supported. vc5 is only the new generation.

I'm not sure removing the number would be less confusing.

> > +struct vc4_dummy_plane *vc4_dummy_plane(struct kunit *test,
> > +					struct drm_device *drm,
> > +					enum drm_plane_type type)
> > +{
> > +	struct vc4_dummy_plane *dummy_plane;
> > +	struct drm_plane *plane;
> > +
> > +	dummy_plane = drmm_universal_plane_alloc(drm,
> > +						 struct vc4_dummy_plane, plane.base,
> > +						 0,
> > +						 &vc4_dummy_plane_funcs,
> > +						 vc4_dummy_plane_formats,
> > +						 ARRAY_SIZE(vc4_dummy_plane_formats),
> > +						 NULL,
> > +						 DRM_PLANE_TYPE_PRIMARY,
> > +						 NULL);
> > +	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dummy_plane);
> > +
> > +	plane = &dummy_plane->plane.base;
> > +	drm_plane_helper_add(plane, &vc4_dummy_plane_helper_funcs);
> > +
> > +	return dummy_plane;
> > +}
> 
> I guess many of these helpers could grow to be generic, like this one since
> most drivers support the DRM_FORMAT_XRGB8888 format for their primary plane.

Yeah, that's what I'd expect at some point as well :)

> > +extern const struct vc4_pv_data bcm2835_pv0_data;
> > +extern const struct vc4_pv_data bcm2835_pv1_data;
> > +extern const struct vc4_pv_data bcm2835_pv2_data;
> > +extern const struct vc4_pv_data bcm2711_pv0_data;
> > +extern const struct vc4_pv_data bcm2711_pv1_data;
> > +extern const struct vc4_pv_data bcm2711_pv2_data;
> > +extern const struct vc4_pv_data bcm2711_pv3_data;
> > +extern const struct vc4_pv_data bcm2711_pv4_data;
> > +
> 
> Maybe the driver could expose a helper function to get the pixelvalve data
> and avoid having to expose all of these variables? For example you could
> define an enum vc4_pixelvalve type and have something like the following:
> 
> const struct vc4_pv_data *vc4_crtc_get_pixelvalve_data(enum vc4_pixelvalve pv);
> 
> All these are small nits though, the patch looks great to me and I think is
> awesome to have this level of testing with KUnit. Hope other drivers follow
> your lead.

I'm not sure. It adds an interface for something we don't really need,
so I'm not sure if it's really beneficial.

David pointed at that patch though, which seems more promising:
https://lore.kernel.org/linux-kselftest/20221102175959.2921063-1-rmoar@google.com/

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-12-01 13:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20221123-rpi-kunit-tests-v2-0-efe5ed518b63@cerno.tech>
     [not found] ` <20221123-rpi-kunit-tests-v2-2-efe5ed518b63@cerno.tech>
2022-11-28 19:30   ` [PATCH v2 02/17] drm/tests: helpers: Document drm_kunit_device_init() Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-4-efe5ed518b63@cerno.tech>
2022-11-28 19:37   ` [PATCH v2 04/17] drm/tests: helpers: Remove the name parameter Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-5-efe5ed518b63@cerno.tech>
2022-11-28 19:48   ` [PATCH v2 05/17] drm/tests: helpers: Create the device in another function Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-6-efe5ed518b63@cerno.tech>
2022-11-28 20:01   ` [PATCH v2 06/17] drm/tests: helpers: Switch to a platform_device Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-7-efe5ed518b63@cerno.tech>
2022-11-28 20:09   ` [PATCH v2 07/17] drm/tests: helpers: Make sure the device is bound Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-10-efe5ed518b63@cerno.tech>
2022-11-28 20:14   ` [PATCH v2 10/17] drm/tests: Add a test for DRM managed actions Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-11-efe5ed518b63@cerno.tech>
2022-11-28 20:16   ` [PATCH v2 11/17] drm/vc4: Move HVS state to main header Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-12-efe5ed518b63@cerno.tech>
2022-11-28 20:23   ` [PATCH v2 12/17] drm/vc4: crtc: Introduce a lower-level crtc init helper Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-13-efe5ed518b63@cerno.tech>
2022-11-28 20:26   ` [PATCH v2 13/17] drm/vc4: crtc: Make encoder lookup helper public Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-15-efe5ed518b63@cerno.tech>
2022-11-28 20:35   ` [PATCH v2 15/17] drm/vc4: tests: Introduce a mocking infrastructure Maíra Canal
2022-11-30  9:59   ` Javier Martinez Canillas
2022-12-01 13:03     ` Maxime Ripard
     [not found] ` <20221123-rpi-kunit-tests-v2-3-efe5ed518b63@cerno.tech>
2022-11-28 20:36   ` [PATCH v2 03/17] drm/tests: helpers: Rename the device init helper Maíra Canal
2022-11-28 20:48 ` [PATCH v2 00/17] drm: Introduce Kunit Tests to VC4 Maíra Canal
     [not found] ` <20221123-rpi-kunit-tests-v2-1-efe5ed518b63@cerno.tech>
2022-11-30  8:00   ` [PATCH v2 01/17] drm/tests: helpers: Move the helper header to include/drm Javier Martinez Canillas
2022-12-01 10:27     ` Maxime Ripard
2022-12-01 10:38       ` Javier Martinez Canillas
     [not found] ` <20221123-rpi-kunit-tests-v2-8-efe5ed518b63@cerno.tech>
2022-11-30  9:13   ` [PATCH v2 08/17] drm/tests: helpers: Allow for a custom device struct to be allocated Javier Martinez Canillas
     [not found] ` <20221123-rpi-kunit-tests-v2-9-efe5ed518b63@cerno.tech>
2022-11-30  9:27   ` [PATCH v2 09/17] drm/tests: helpers: Allow to pass a custom drm_driver Javier Martinez Canillas
     [not found] ` <20221123-rpi-kunit-tests-v2-16-efe5ed518b63@cerno.tech>
2022-11-30 10:09   ` [PATCH v2 16/17] drm/vc4: tests: Fail the current test if we access a register Javier Martinez Canillas
     [not found] ` <20221123-rpi-kunit-tests-v2-17-efe5ed518b63@cerno.tech>
2022-11-30 10:15   ` [PATCH v2 17/17] drm/vc4: tests: Add unit test suite for the PV muxing Javier Martinez Canillas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).