History log of /linux-master/drivers/gpu/drm/tests/drm_kunit_helpers.c
Revision Date Author Comments
# 51f90720 22-Feb-2024 Maxime Ripard <mripard@kernel.org>

drm/tests: Add helper to create mock crtc

We're going to need a full-blown, functional, KMS device to test more
components of the atomic modesetting infrastructure.

Let's add a new helper to create a dumb, mocked, CRTC. By default it
will create a CRTC relying only on the default helpers, but drivers are
free to deviate from that.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240222-kms-hdmi-connector-state-v7-4-8f4af575fce2@kernel.org


# 7a48da0f 22-Feb-2024 Maxime Ripard <mripard@kernel.org>

drm/tests: Add helper to create mock plane

We're going to need a full-blown, functional, KMS device to test more
components of the atomic modesetting infrastructure.

Let's add a new helper to create a dumb, mocked, primary plane. By
default, it will create a linear XRGB8888 plane, using the default
helpers.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240222-kms-hdmi-connector-state-v7-3-8f4af575fce2@kernel.org


# 66671944 22-Feb-2024 Maxime Ripard <mripard@kernel.org>

drm/tests: helpers: Add atomic helpers

The mock device we were creating was missing any of the driver-wide
helpers. That was fine before since we weren't testing the atomic state
path, but we're going to start, so let's use the default
implementations.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240222-kms-hdmi-connector-state-v7-2-8f4af575fce2@kernel.org


# d393acce 15-Dec-2023 Maxime Ripard <mripard@kernel.org>

drm/tests: Switch to kunit devices

Kunit recently gained helpers to create test managed devices. This means
that we no longer have to roll our own helpers in KMS and we can reuse
them.

Signed-off-by: Maxime Ripard <mripard@kernel.org>
Tested-by: David Gow <davidgow@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# e847934b 28-Nov-2023 David Gow <davidgow@google.com>

drm/tests: Use KUNIT_DEFINE_ACTION_WRAPPER()

In order to pass functions to kunit_add_action(), they need to be of the
kunit_action_t type. While casting the function pointer can work, it
will break control-flow integrity.

drm_kunit_helpers already defines wrappers, but we now have a macro
which does this automatically. Using this greatly reduces the
boilerplate needed.

Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>


# 885291ab 20-Sep-2023 Arthur Grillo <arthurgrillo@riseup.net>

drm/tests: Fix kunit_release_action ctx argument

The kunit_action_platform_driver_unregister is added with
&fake_platform_driver as ctx, but the kunit_release_action is called
pdev as ctx. Fix that by replacing it with &fake_platform_driver.

Fixes: 4f2b0b583baa ("drm/tests: helpers: Switch to kunit actions")
Signed-off-by: Arthur Grillo <arthurgrillo@riseup.net>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230920-kunit-kasan-fixes-v1-1-1a0fc261832d@riseup.net


# 91dc5215 24-Aug-2023 Lee Jones <lee@kernel.org>

drm/tests/drm_kunit_helpers: Place correct function name in the comment header

Fixes the following W=1 kernel build warning(s):

drivers/gpu/drm/tests/drm_kunit_helpers.c:172: warning: expecting prototype for drm_kunit_helper_context_alloc(). Prototype was for drm_kunit_helper_acquire_ctx_alloc() instead

Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230824073710.2677348-10-lee@kernel.org
Link: https://lore.kernel.org/r/20230824073710.2677348-14-lee@kernel.org
[mripard: Squashed the two patches together]
Signed-off-by: Maxime Ripard <mripard@kernel.org>


# 394ba10e 28-Jul-2023 Maxime Ripard <mripard@kernel.org>

drm/tests: helpers: Create a helper to allocate an atomic state

As we gain more tests, boilerplate to allocate an atomic state and free
it starts to be there more and more as well.

In order to reduce the allocation boilerplate, we can create a helper
to create that atomic state, and call an action when the test is done.
This will also clean up the exit path.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20230728-kms-kunit-actions-rework-v3-6-952565ccccfe@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>


# 6e193f9f 28-Jul-2023 Maxime Ripard <mripard@kernel.org>

drm/tests: helpers: Create a helper to allocate a locking ctx

As we get more and more tests, the locking context initialisation
creates more and more boilerplate, both at creation and destruction.

Let's create a helper that will allocate, initialise a context, and
register kunit actions to clean up once the test is done.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20230728-kms-kunit-actions-rework-v3-5-952565ccccfe@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>


# 4f2b0b58 28-Jul-2023 Maxime Ripard <mripard@kernel.org>

drm/tests: helpers: Switch to kunit actions

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20230728-kms-kunit-actions-rework-v3-1-952565ccccfe@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>


# 96c25b03 24-Feb-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

drm/tests: helpers: Drop empty platform remove function

A remove callback just returning 0 is equivalent to no remove callback
at all. So drop the useless function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Signed-off-by: Maíra Canal <mairacanal@riseup.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20230224221417.1712368-1-u.kleine-koenig@pengutronix.de


# d9878031 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Allow to pass a custom drm_driver

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.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-11-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# a9143c58 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Allow for a custom device struct to be allocated

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.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-10-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 57a84a97 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Make sure the device is bound

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.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-9-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 0bdc2e28 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Switch to a platform_device

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>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-8-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 9ecd8045 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Create the device in another function

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.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-7-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 1d041a46 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Remove the name parameter

The device name isn't really useful, we can just define it instead of
exposing it in the API.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-6-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 83ee69a8 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Rename the device init helper

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.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-5-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 642ef3fb 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Switch to EXPORT_SYMBOL_GPL

drm_kunit_device_init() among other things will allocate a device and
wrap around root_device_register. This function is exported with
EXPORT_SYMBOL_GPL, so we can't really change the license.

Fixes: a77a3ffa151b ("drm/tests: helpers: Add missing export")
Suggested-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-4-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# cee6ec3b 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Document drm_kunit_device_init()

Commit 44a3928324e9 ("drm/tests: Add Kunit Helpers") introduced the
drm_kunit_device_init() function but didn't document it properly. Add
that documentation.

Reviewed-by: Maíra Canal <mcanal@igalia.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-3-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 0c3627c7 01-Dec-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Move the helper header to include/drm

We'll need to use those helpers from drivers too, so let's move it to a
more visible location.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20221123-rpi-kunit-tests-v3-1-4615a663a84a@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# a77a3ffa 28-Nov-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Add missing export

drm_kunit_device_init() is a public function meant to be used by other
tests, but isn't exported. This leads to modpost errors when the other
tests are compiled as module.

Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://patchwork.freedesktop.org/patch/msgid/20221128081938.742410-3-maxime@cerno.tech


# 35c3a2d0 16-Nov-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Add SPDX header

The SPDX header is missing, let's add it and fix the corresponding
checkpatch warning.

Suggested-by: Maíra Canal <mairacanal@riseup.net>
Fixes: 44a3928324e9 ("drm/tests: Add Kunit Helpers")
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20221116151833.1679379-2-maxime@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 330ff5a5 16-Nov-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: helpers: Add module infos

The MODULE_LICENSE macro is missing from the kunit helpers file, thus
leading to a build error.

Let's introduce it along with MODULE_AUTHOR.

Fixes: 44a3928324e9 ("drm/tests: Add Kunit Helpers")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20221116091712.1309651-2-maxime@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# f7711fdd 16-Nov-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: Include helpers header

The kunit helpers code weren't including its header, leading to a
warning that no previous prototype had been defined for public
functions.

Include the matching header to fix the warning.

Fixes: 44a3928324e9 ("drm/tests: Add Kunit Helpers")
Reported-by: kernel test robot <lkp@intel.com>
Reviewed-by: Maíra Canal <mairacanal@riseup.net>
Link: https://lore.kernel.org/r/20221116091712.1309651-1-maxime@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>


# 44a39283 14-Nov-2022 Maxime Ripard <maxime@cerno.tech>

drm/tests: Add Kunit Helpers

As the number of kunit tests in KMS grows further, we start to have
multiple test suites that, for example, need to register a mock DRM
driver to interact with the KMS function they are supposed to test.

Let's add a file meant to provide those kind of helpers to avoid
duplication.

Reviewed-by: Noralf Trønnes <noralf@tronnes.org>
Tested-by: Mateusz Kwiatkowski <kfyatek+publicgit@gmail.com>
Link: https://lore.kernel.org/r/20220728-rpi-analog-tv-properties-v9-2-24b168e5bcd5@cerno.tech
Signed-off-by: Maxime Ripard <maxime@cerno.tech>