Skip to contentSkip to conversation

drm/test/shmem: set a DMA mask for the mock device

PATCH In review Marco Pagani 2 participants 4 messages Feb 26, 2024 – Feb 27, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/test/shmem: set a DMA mask for the mock device

Set a DMA mask for the mock device to avoid warnings generated in dma_map_sgtable().

---
 drivers/gpu/drm/tests/drm_gem_shmem_test.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +4 -0
index 91202e40cde9..d691b29a4312 100644
@@ -341,11 +341,15 @@ static int drm_gem_shmem_test_init(struct kunit *test)
 {
 	struct device *dev;
 	struct drm_device *drm_dev;
+	int ret;
 
 	/* Allocate a parent device */
 	dev = drm_kunit_helper_alloc_device(test);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
 
+	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
+	KUNIT_EXPECT_EQ(test, ret, 0);
+
 	/*
 	 * The DRM core will automatically initialize the GEM core and create
 	 * a DRM Memory Manager object which provides an address space pool
Signature · 1 line
2.43.2
#2 lore raw
Quoted 6 lines · Maxime Ripard

Hi,

Quoted 3 lines · Marco Pagani

Set a DMA mask for the mock device to avoid warnings generated in dma_map_sgtable().

Quoted 8 lines
Quoted 2 lines

I've submitted last week this patch:
https://lore.kernel.org/all/[email protected]/

Which should be equivalent, but fixes the issue for all users in the tree.

Hi, thanks for letting me know. Fixing this issue for all DRM tests that were using platform devices through the helpers makes perfect sense to me. I'm a little more thoughtful about setting the mask for all KUnit tests that use fake devices since there may be specific use cases. Just one curiosity: why setting the default mask manually instead of using one of the dma_set_*() functions?

Thanks,
Marco

maintainer
#3 lore raw

Hi,

Quoted 14 lines · Marco Pagani
Quoted 12 lines · Maxime Ripard

Hi,

Quoted 5 lines · Marco Pagani

Set a DMA mask for the mock device to avoid warnings generated in dma_map_sgtable().

I've submitted last week this patch:
https://lore.kernel.org/all/[email protected]/

Quoted 8 lines
Quoted 2 lines

Which should be equivalent, but fixes the issue for all users in the tree.

Hi, thanks for letting me know. Fixing this issue for all DRM tests that were using platform devices through the helpers makes perfect sense to me. I'm a little more thoughtful about setting the mask for all KUnit tests that use fake devices since there may be specific use cases. Just one curiosity: why setting the default mask manually instead of using one of the dma_set_*() functions?

I think the (well, mine at least) expectation is that a kunit device is a device that can be used in all reasonable contexts. Setting up the device to be able to use any DMA-related function (or functions that use a DMA-related function) makes total sense to me.

But it's a discussion worth having I think, so it would make sense to raise this point with the kunit maintainers if you feel like it.

Maxime