From: José Expósito <[email protected]>
drm_gem_shmem_test_purge intermittently fails on ppc64le and s390x CI
systems with a DMA address overflow: [1]
DMA addr 0x0000000100307000+4096 overflow (mask ffffffff, bus limit 0)
WARNING: kernel/dma/direct.h:114 dma_direct_map_sg+0x778/0x920
drm_gem_shmem_test_purge: ASSERTION FAILED at
drivers/gpu/drm/tests/drm_gem_shmem_test.c:330
Expected sgt is not error, but is: -5
The call chain leading to the failure is:
drm_gem_shmem_test_purge()
drm_gem_shmem_get_pages_sgt()
drm_gem_shmem_get_pages_sgt_locked() [drm_gem_shmem_helper.c]
dma_map_sgtable() [mapping.c]
__dma_map_sg_attrs()
dma_direct_map_sg() [direct.c]
dma_direct_map_phys() [kernel/dma/direct.h]
dma_capable() Checks addr against DMA mask
-> FAILS: addr > 0xFFFFFFFF
The root cause is that KUnit devices are initialized with a 32-bit DMA
mask (DMA_BIT_MASK(32)) in lib/kunit/device.c. On ppc64le and s390x
systems with physical memory above 4GB, page allocations can land at
addresses that exceed this mask. When drm_gem_shmem_get_pages_sgt()
attempts to DMA-map these pages via dma_map_sgtable(), the DMA layer
rejects the mapping because the physical address overflows the 32-bit
mask.
The failure is intermittent because pages may or may not be allocated
above 4GB on any given run depend on memory pressure.
Fix by setting a 64-bit DMA mask on the device before calling
drm_gem_shmem_get_pages_sgt(), following the same pattern already used
in drm_gem_shmem_test_obj_create_private().
[1]
https://s3.amazonaws.com/arr-cki-prod-trusted-artifacts/trusted-artifacts/2643976103/test_s390x/15128551935/artifacts/jobwatch/logs/recipes/21561049/tasks/220716793/results/1014626315/logs/dmesg.log
Fixes: 93032ae634d4 ("drm/test: add a test suite for GEM objects backed by
shmem")
Closes: https://datawarehouse.cki-project.org/issue/5345
Assisted-by: Claude:claude-4.6-opus
Signed-off-by: José Expósito <[email protected]>
---
drivers/gpu/drm/tests/drm_gem_shmem_test.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_gem_shmem_test.c
b/drivers/gpu/drm/tests/drm_gem_shmem_test.c
index c217a9ec7240..66dea51ac456 100644
--- a/drivers/gpu/drm/tests/drm_gem_shmem_test.c
+++ b/drivers/gpu/drm/tests/drm_gem_shmem_test.c
@@ -325,6 +325,9 @@ static void drm_gem_shmem_test_purge(struct kunit *test)
struct sg_table *sgt;
int ret;
+ ret = dma_set_mask(drm_dev->dev, DMA_BIT_MASK(64));
+ KUNIT_ASSERT_EQ(test, ret, 0);
+
shmem = drm_gem_shmem_create(drm_dev, TEST_SIZE);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, shmem);
--
2.54.0