drm/test: add a test suite for GEM objects backed by shmem
Subsystems (3)
PATCH v5 1/1 drm/test: add a test suite for GEM objects backed by shmem
This patch introduces an initial KUnit test suite for GEM objects backed by shmem buffers.
v5:
- using __drm_kunit_helper_alloc_drm_device() to avoid local struct v4:
- Add missing MMU dependency for DRM_GEM_SHMEM_HELPER (kernel test robot) v3:
- Explicitly cast pointers in the helpers
- Removed unused pointer to parent dev in struct fake_dev
- Test entries reordering in Kconfig and Makefile sent as a separate patch v2:
- Improved description of test cases
- Cleaner error handling using KUnit actions
- Alphabetical order in Kconfig and Makefile
--- drivers/gpu/drm/Kconfig | 3 +- drivers/gpu/drm/tests/Makefile | 1 + drivers/gpu/drm/tests/drm_gem_shmem_test.c | 383 +++++++++++++++++++++ 3 files changed, 386 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/tests/drm_gem_shmem_test.c
drivers/gpu/drm/Kconfig +2 -1
@@ -74,12 +74,13 @@ config DRM_KUNIT_TEST_HELPERS config DRM_KUNIT_TEST tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS - depends on DRM && KUNIT + depends on DRM && KUNIT && MMU select DRM_BUDDY select DRM_DISPLAY_DP_HELPER select DRM_DISPLAY_HELPER select DRM_EXEC select DRM_EXPORT_FOR_TESTS if m + select DRM_GEM_SHMEM_HELPER select DRM_KMS_HELPER select DRM_KUNIT_TEST_HELPERS select DRM_LIB_RANDOM
drivers/gpu/drm/tests/Makefile +1 -0
@@ -13,6 +13,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_format_helper_test.o \ drm_format_test.o \ drm_framebuffer_test.o \ + drm_gem_shmem_test.o \ drm_managed_test.o \ drm_mm_test.o \ drm_modes_test.o \
drivers/gpu/drm/tests/drm_gem_shmem_test.c new file +383 -0
383 lines not on this page · raw message
base-commit: a13fee31f56449fc600d9e064c7b32302f92dcef
Signature · 1 line
2.43.0
Quoted 6 lines · Marco Pagani
This patch introduces an initial KUnit test suite for GEM objects backed by shmem buffers.
Suggested-by Javier Martinez Canillas <[email protected]>Signed-off-by Marco Pagani <[email protected]>
Quoted 12 lines
v5:
- using__drm_kunit_helper_alloc_drm_device()to avoid local struct v4:
- Add missing MMU dependency forDRM_GEM_SHMEM_HELPER(kernel test robot) v3:
- Explicitly cast pointers in the helpers
- Removed unused pointer to parent dev in structfake_dev
- Test entries reordering inKconfigandMakefilesent as a separate patch v2:
- Improved description of test cases
- Cleaner error handling using KUnit actions
- Alphabetical order inKconfigandMakefile
Applied to drm-misc-next, thanks!
Maxime
Hi,
Quoted 5 lines · Marco Pagani
This patch introduces an initial KUnit test suite for GEM objects backed by shmem buffers.
Suggested-by Javier Martinez Canillas <[email protected]>Signed-off-by Marco Pagani <[email protected]>
When running this in qemu, I get lots of warnings backtraces in the drm core.
WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:327 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:173 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:385 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:211 WARNING: CPU: 0 PID: 1345 at kernel/dma/mapping.c:194 WARNING: CPU: 0 PID: 1347 at drivers/gpu/drm/drm_gem_shmem_helper.c:429 WARNING: CPU: 0 PID: 1349 at drivers/gpu/drm/drm_gem_shmem_helper.c:445
It looks like dma_resv_assert_held() asserts each time it is executed. The backtrace in kernel/dma/mapping.c is triggered by
if (WARN_ON_ONCE(!dev->dma_mask)) return 0;
in __dma_map_sg_attrs().
Is this a possible problem in the test code, or can it be caused by some limitations or bugs in the qemu emulation ? If so, do you have any thoughts or ideas what those limitations / bugs might be ?
Thanks,
Guenter
Quoted 22 lines · Guenter Roeck
Hi,
Quoted 5 lines · Marco Pagani
This patch introduces an initial KUnit test suite for GEM objects backed by shmem buffers.
Suggested-by Javier Martinez Canillas <[email protected]>Signed-off-by Marco Pagani <[email protected]>When running this in qemu, I get lots of warnings backtraces in the drm core.
WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:327 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:173 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:385 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:211 WARNING: CPU: 0 PID: 1345 at kernel/dma/mapping.c:194 WARNING: CPU: 0 PID: 1347 at drivers/gpu/drm/drm_gem_shmem_helper.c:429 WARNING: CPU: 0 PID: 1349 at drivers/gpu/drm/drm_gem_shmem_helper.c:445It looks like
dma_resv_assert_held()asserts each time it is executed. The backtrace inkernel/dma/mapping.cis triggered by
Quoted 7 lines
if (WARN_ON_ONCE(!dev->dma_mask)) return 0;in
__dma_map_sg_attrs().Is this a possible problem in the test code, or can it be caused by some limitations or bugs in the qemu emulation ? If so, do you have any thoughts or ideas what those limitations / bugs might be ?
Hi Guenter,
Thanks for reporting this issue. As you correctly noted, the warnings appear to be caused by the dma_mask in the mock device being uninitialized. I'll send a patch to fix it soon.
Marco
Hi Marco,
Quoted 33 lines · Marco Pagani
Quoted 22 lines · Guenter Roeck
Hi,
Quoted 5 lines · Marco Pagani
This patch introduces an initial KUnit test suite for GEM objects backed by shmem buffers.
Suggested-by Javier Martinez Canillas <[email protected]>Signed-off-by Marco Pagani <[email protected]>When running this in qemu, I get lots of warnings backtraces in the drm core.
WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:327 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:173 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:385 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:211 WARNING: CPU: 0 PID: 1345 at kernel/dma/mapping.c:194 WARNING: CPU: 0 PID: 1347 at drivers/gpu/drm/drm_gem_shmem_helper.c:429 WARNING: CPU: 0 PID: 1349 at drivers/gpu/drm/drm_gem_shmem_helper.c:445It looks like
dma_resv_assert_held()asserts each time it is executed. The backtrace inkernel/dma/mapping.cis triggered byQuoted 7 lines
if (WARN_ON_ONCE(!dev->dma_mask)) return 0;in
__dma_map_sg_attrs().Is this a possible problem in the test code, or can it be caused by some limitations or bugs in the qemu emulation ? If so, do you have any thoughts or ideas what those limitations / bugs might be ?
Quoted 6 lines
Hi Guenter,
Thanks for reporting this issue. As you correctly noted, the warnings appear to be caused by the
dma_maskin the mock device being uninitialized. I'll send a patch to fix it soon.
Thanks a lot for the update.
In this context, the TTM unit tests fail as well in qemu, with worse result:
It seems there is some bad cleanup after a failed test case, causing list corruptions in the drm core and ultimately a crash. I don't know if this is also caused by the missing dma_mask initialization.
Thanks,
Guenter
Quoted 43 lines · Guenter Roeck
Hi Marco,
Quoted 33 lines · Marco Pagani
Quoted 26 lines · Guenter Roeck
Hi,
Quoted 5 lines · Marco Pagani
This patch introduces an initial KUnit test suite for GEM objects backed by shmem buffers.
Suggested-by Javier Martinez Canillas <[email protected]>Signed-off-by Marco Pagani <[email protected]>When running this in qemu, I get lots of warnings backtraces in the drm core.
WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:327 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:173 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:385 WARNING: CPU: 0 PID: 1341 at drivers/gpu/drm/drm_gem_shmem_helper.c:211 WARNING: CPU: 0 PID: 1345 at kernel/dma/mapping.c:194 WARNING: CPU: 0 PID: 1347 at drivers/gpu/drm/drm_gem_shmem_helper.c:429 WARNING: CPU: 0 PID: 1349 at drivers/gpu/drm/drm_gem_shmem_helper.c:445It looks like
dma_resv_assert_held()asserts each time it is executed. The backtrace inkernel/dma/mapping.cis triggered by
if (WARN_ON_ONCE(!dev->dma_mask))
return 0;
in__dma_map_sg_attrs().Quoted 3 lines
Is this a possible problem in the test code, or can it be caused by some limitations or bugs in the qemu emulation ? If so, do you have any thoughts or ideas what those limitations / bugs might be ?
Quoted 6 lines
Hi Guenter,
Thanks for reporting this issue. As you correctly noted, the warnings appear to be caused by the
dma_maskin the mock device being uninitialized. I'll send a patch to fix it soon.
Quoted 7 lines
Thanks a lot for the update.
In this context, the TTM unit tests fail as well in qemu, with worse result:
It seems there is some bad cleanup after a failed test case, causing list corruptions in the drm core and ultimately a crash. I don't know if this is also caused by the missingdma_maskinitialization.
That's interesting. Which --arch argument are you using to run the tests with QEMU?
Thanks,
Marco
Quoted 9 lines · Marco Pagani
Quoted 6 lines
In this context, the TTM unit tests fail as well in qemu, with worse result:
It seems there is some bad cleanup after a failed test case, causing list corruptions in the drm core and ultimately a crash. I don't know if this is also caused by the missingdma_maskinitialization.That's interesting. Which --arch argument are you using to run the tests with QEMU?
Example (I am not sure if any of those parameters matters; it is just one of my tests):
qemu-system-x86_64 -kernel arch/x86/boot/bzImage -M q35 -cpu IvyBridge \ -no-reboot -snapshot -smp 2 \ -device e1000,netdev=net0 -netdev user,id=net0 -m 512 \ -drive file=rootfs.ext2,format=raw,if=ide \ --append "earlycon=uart8250,io,0x3f8,9600n8 root=/dev/sda1 console=ttyS0" \ -d unimp,guest_errors -nographic -monitor none
This results in:
[ ... ]
[ 5.989496] KTAP version 1 [ 5.989639] # Subtest: ttm_device [ 5.989711] # module: ttm_device_test [ 5.989760] 1..5 [ 6.002044] ok 1 ttm_device_init_basic [ 6.013557] ok 2 ttm_device_init_multiple ILLOPC: ffffffffb8ac9350: 0f 0b [ 6.022481] ok 3 ttm_device_fini_basic [ 6.026172] ------------[ cut here ]------------ [ 6.026315] WARNING: CPU: 1 PID: 1575 at drivers/gpu/drm/ttm/ttm_device.c:206 ttm_device_init+0x170/0x190 ... [ 6.135016] ok 3 Above the allocation limit [ 6.138759] ------------[ cut here ]------------ [ 6.138925] WARNING: CPU: 1 PID: 1595 at kernel/dma/mapping.c:503 dma_alloc_attrs+0xf6/0x100 ... [ 6.143850] # ttm_pool_alloc_basic: ASSERTION FAILED at drivers/gpu/drm/ttm/tests/ttm_pool_test.c:162 [ 6.143850] Expected err == 0, but [ 6.143850] err == -12 (0xfffffffffffffff4) [ 6.148824] not ok 4 One page, with coherent DMA mappings enabled
From there things go downhill.
[ 6.152821] list_add corruption. prev->next should be next (ffffffffbbd53950), but was 0000000000000000. (prev=ffff8af1c38f9e20).
and so on until the emulation crashes.
Guenter