Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] drm/vkms: missing vkms_destroy() call in uncreated-device
  KUnit test
- [Medium] drm/vkms: missing second vkms_destroy() in
  vkms_lifecycle_test_double_destroy()
- [Low] drm/vkms: missing connector detach before vkms_destroy() in
  KUnit test
- [Low] drm/vkms: non-portable KASAN and KUNIT_ALL_TESTS in .kunitconfig
- [Low] drm/vkms: EXPORT_SYMBOL_IF_KUNIT(vkms_create) placed after
  vkms_init()
--

commit 638d5ac8d39529e98a29a3faec3aa7ef9239a4d3
Author: Louis Chauvet <[email protected]>

drm/vkms: Add KUnit test for device lifecycle

This commit adds a KUnit test suite exercising VKMS device creation,
destruction, and reference-counted configuration object lifetimes, and
exports vkms_create() and vkms_destroy() for KUnit testing.

> diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig 
> b/drivers/gpu/drm/vkms/tests/.kunitconfig
> index 6a2d87068edc5..c9752bde84874 100644
> --- a/drivers/gpu/drm/vkms/tests/.kunitconfig
> +++ b/drivers/gpu/drm/vkms/tests/.kunitconfig
> @@ -2,3 +2,13 @@ CONFIG_KUNIT=y
>  CONFIG_DRM=y
>  CONFIG_DRM_VKMS=y
>  CONFIG_DRM_VKMS_KUNIT_TEST=y
> +CONFIG_KASAN=y
> +CONFIG_KASAN_INLINE=y
> +CONFIG_KASAN_VMALLOC=y
> +CONFIG_KUNIT_ALL_TESTS=n

[Severity: Low]
Will hardcoding these KASAN options and CONFIG_KUNIT_ALL_TESTS=n break
kunit.py runs?

kunit.py rejects .kunitconfig options that are missing from the final
.config, so CONFIG_KASAN_INLINE=y and CONFIG_KASAN_VMALLOC=y fail on
architectures or build modes that do not support them (such as 32-bit
targets or UML with CONFIG_STATIC_LINK=y).  CONFIG_KUNIT_ALL_TESTS=n also
conflicts with tools/testing/kunit/configs/all_tests.config when running
kunit.py with --alltests, causing kunit_kernel.py to abort with a multiple
values ConfigError.

[ ... ]

> diff --git a/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c 
> b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c
> new file mode 100644
> index 0000000000000..7f7b313687101
> --- /dev/null
> +++ b/drivers/gpu/drm/vkms/tests/vkms_lifecycle_test.c

[ ... ]

> +static void vkms_lifecycle_test_destroy_uncreated_device(struct kunit *test)
> +{
> +     struct vkms_config *config;
> +
> +     config = vkms_config_default_create(true, true, false, false);
> +     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
> +
> +     KUNIT_ASSERT_NULL(test, config->dev);
> +
> +     vkms_config_destroy(config);
> +}

[Severity: Medium]
Should vkms_lifecycle_test_destroy_uncreated_device() call
vkms_destroy(config) before vkms_config_destroy(config)?  Without it, the
!config->dev early return in vkms_destroy() is never exercised.

> +
> +static void vkms_lifecycle_test_double_destroy(struct kunit *test)
> +{
> +     struct vkms_config *config;
> +     int ret;
> +
> +     config = vkms_config_default_create(true, true, false, false);
> +     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
> +     vkms_lifecycle_test_set_unique_name(test, config, test->name);
> +
> +     ret = vkms_create(config);
> +     KUNIT_ASSERT_EQ(test, ret, 0);
> +
> +     vkms_destroy(config);
> +     KUNIT_ASSERT_NULL(test, config->dev);
> +
> +     vkms_config_destroy(config);
> +}

[Severity: Medium]
Is a second vkms_destroy(config) call missing here?  Calling
vkms_destroy(config) only once leaves double destruction untested.

[ ... ]

> +static void vkms_lifecycle_test_connector_static_drmm_release(struct kunit 
> *test)
> +{
> +     struct vkms_config *config;
> +
> +     config = vkms_config_default_create(true, true, false, false);
> +     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
> +     vkms_lifecycle_test_set_unique_name(test, config, test->name);
> +
> +     KUNIT_ASSERT_EQ(test, vkms_create(config), 0);
> +
> +     /* vkms_destroy() runs the drmm action, which frees and detaches the 
> connector. */
> +     vkms_destroy(config);
> +     vkms_config_destroy(config);
> +}

[Severity: Low]
Does vkms_lifecycle_test_connector_static_drmm_release() actually test
releasing the last connector reference from the drmm action?

Even after commit "drm/vkms: Introduce back pointer to connector" adds
vkms_connector_static_cfg_release(), config->connectors still holds its
reference when vkms_destroy(config) runs unless the connector or config is
destroyed first, so this test only repeats a single iteration of
vkms_lifecycle_test_create_destroy_default().

[ ... ]

> diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c
> index 24572bc779b41..f73f136e5588e 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.c
> +++ b/drivers/gpu/drm/vkms/vkms_drv.c

[ ... ]

> @@ -252,6 +253,7 @@ static int __init vkms_init(void)
>  
>       return 0;
>  }
> +EXPORT_SYMBOL_IF_KUNIT(vkms_create);

[Severity: Low]
This isn't a bug, but EXPORT_SYMBOL_IF_KUNIT(vkms_create) is placed after
vkms_init() instead of right after vkms_create().

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=12

Reply via email to