drm/test: fix the gem shmem test to map the sg table.
Subsystems (2)
Dave Airlie
maintainerPATCH 1/1 drm/test: fix the gem shmem test to map the sg table.
From: Dave Airlie <[email protected]>
The test here creates an sg table, but never maps it, when we get to drm_gem_shmem_free, the helper tries to unmap and this causes warnings on some platforms and debug kernels.
This also sets a 64-bit dma mask, as I see an swiotlb warning if I stick with the default 32-bit one.
--- drivers/gpu/drm/tests/drm_gem_shmem_test.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +11 -0
@@ -102,6 +102,17 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test)sg_init_one (sgt->sgl, buf,TEST_SIZE ); +/* +* Set the DMA mask to 64-bits and map the sgtables +* otherwise drm_gem_shmem_free will cause a warning +* on debug kernels. +* */ + ret =dma_set_mask (drm_dev->dev,DMA_BIT_MASK (64 )); +KUNIT_ASSERT_EQ (test, ret,0 ); + + ret =dma_map_sgtable (drm_dev->dev, sgt,DMA_BIDIRECTIONAL ,0 ); +KUNIT_ASSERT_EQ (test, ret,0 ); +/* Init a mock DMA-BUF */ buf_mock.size =TEST_SIZE ; attach_mock.dmabuf = &buf_mock;
Signature · 1 line
2.45.0
Quoted 7 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Dave Airlie
Sent: Monday, July 15, 2024 4:36 AM
To: [email protected]
Subject: [PATCH] drm/test: fix the gem shmem test to map the sg table.
Quoted 5 lines
From: Dave Airlie <[email protected]>
The test here creates an sg table, but never maps it, when we get to
drm_gem_shmem_free, the helper tries to unmap and this causes warnings on some platforms and debug kernels.
This looks pretty straightforward...
However, should drm_gem_shmem_free() really give an error if the mapping didn't happen?
I.e. just because you have an sgt pointer, should you also have a mapping?
If the errors are really just noise (form the specific platforms), and this patch is covering for that, then:
Thanks,
Mike
Quoted 37 lines
This also sets a 64-bit dma mask, as I see an swiotlb warning if I stick with the default 32-bit one.
Fixes 93032ae634d4 ("drm/test: add a test suite for GEM objects backed byshmem")
Signed-off-by Dave Airlie <[email protected]>---
drivers/gpu/drm/tests/drm_gem_shmem_test.c| 11 +++++++++++1 file changed, 11 insertions(+)drivers/gpu/drm/tests/drm_gem_shmem_test.c +11
-0@@ -102,6 +102,17 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test) sg_init_one(sgt->sgl, buf, TEST_SIZE); +/* +* Set the DMA mask to 64-bits and map the sgtables +* otherwise drm_gem_shmem_free will cause a warning +* on debug kernels. +* */ + ret =dma_set_mask (drm_dev->dev,DMA_BIT_MASK (64 )); +KUNIT_ASSERT_EQ (test, ret,0 ); + + ret =dma_map_sgtable (drm_dev->dev, sgt,DMA_BIDIRECTIONAL ,0 ); +KUNIT_ASSERT_EQ (test, ret,0 ); +/* Init a mock DMA-BUF */ buf_mock.size =TEST_SIZE ;attach_mock.dmabuf = &buf_mock;--
2.45.0
Daniel Vetter
Acked-byQuoted 13 lines · Michael J
Quoted 7 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Dave Airlie
Sent: Monday, July 15, 2024 4:36 AM
To: [email protected]
Subject: [PATCH] drm/test: fix the gem shmem test to map the sg table.Quoted 5 lines
From: Dave Airlie <[email protected]>
The test here creates an sg table, but never maps it, when we get to
drm_gem_shmem_free, the helper tries to unmap and this causes warnings on some platforms and debug kernels.
Quoted 6 lines
This looks pretty straightforward...
However, should
drm_gem_shmem_free()really give an error if the mapping didn't happen?I.e. just because you have an sgt pointer, should you also have a mapping?
Yes, I think only allocating an sgt but not setting it up is a bug. So the fix looks correct, and isn't just papering over noise.
Quoted 4 lines
If the errors are really just noise (form the specific platforms), and this patch is covering for that, then:
Reviewed-by Michael J. Ruhl <[email protected]>
Cheers, Sima
Quoted 43 lines
Thanks,
Mike
Quoted 37 lines
This also sets a 64-bit dma mask, as I see an swiotlb warning if I stick with the default 32-bit one.
Fixes 93032ae634d4 ("drm/test: add a test suite for GEM objects backed byshmem")
Signed-off-by Dave Airlie <[email protected]>---
drivers/gpu/drm/tests/drm_gem_shmem_test.c| 11 +++++++++++1 file changed, 11 insertions(+)drivers/gpu/drm/tests/drm_gem_shmem_test.c +11
-0@@ -102,6 +102,17 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test) sg_init_one(sgt->sgl, buf, TEST_SIZE); +/* +* Set the DMA mask to 64-bits and map the sgtables +* otherwise drm_gem_shmem_free will cause a warning +* on debug kernels. +* */ + ret =dma_set_mask (drm_dev->dev,DMA_BIT_MASK (64 )); +KUNIT_ASSERT_EQ (test, ret,0 ); + + ret =dma_map_sgtable (drm_dev->dev, sgt,DMA_BIDIRECTIONAL ,0 ); +KUNIT_ASSERT_EQ (test, ret,0 ); +/* Init a mock DMA-BUF */ buf_mock.size =TEST_SIZE ;attach_mock.dmabuf = &buf_mock;--
2.45.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 24 lines
-----Original Message-----
From: Daniel Vetter <[email protected]>
Sent: Tuesday, July 16, 2024 5:34 AM
To: Ruhl, Michael J <[email protected]>
Cc: Dave Airlie <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/test: fix the gem shmem test to map the sg table.Quoted 2 lines · Michael J
Quoted 2 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf OfDave
Quoted 13 lines
Quoted 10 lines
Airlie
Sent: Monday, July 15, 2024 4:36 AM
To: [email protected]
Subject: [PATCH] drm/test: fix the gem shmem test to map the sg table.From: Dave Airlie <[email protected]>
The test here creates an sg table, but never maps it, when we get to
drm_gem_shmem_free, the helper tries to unmap and this causes warnings on some platforms and debug kernels.This looks pretty straightforward...
Quoted 7 lines
Quoted 4 lines
However, should
drm_gem_shmem_free()really give an error if the mapping didn't happen?I.e. just because you have an sgt pointer, should you also have a mapping?
Yes, I think only allocating an sgt but not setting it up is a bug. So the fix looks correct, and isn't just papering over noise.
I guess my concern here is that the mapping could fail.
If that happens, what is the error path?
Can I call _shmem_free?
Mike
Quoted 57 lines
Quoted 1 line
If the errors are really just noise (form the specific platforms), and this patch is
covering
Quoted 3 lines
for that, then:
Reviewed-by Michael J. Ruhl <[email protected]>Acked-by Daniel Vetter <[email protected]>Cheers, Sima
Quoted 26 lines
Thanks,
Mike
Quoted 21 lines
This also sets a 64-bit dma mask, as I see an swiotlb warning if I stick with the default 32-bit one.
Fixes 93032ae634d4 ("drm/test: add a test suite for GEM objects backed byshmem")
Signed-off-by Dave Airlie <[email protected]>---
drivers/gpu/drm/tests/drm_gem_shmem_test.c| 11 +++++++++++1 file changed, 11 insertions(+)drivers/gpu/drm/tests/drm_gem_shmem_test.c +0
-0@@ -102,6 +102,17 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test) sg_init_one(sgt->sgl, buf, TEST_SIZE);Quoted 17 lines
Quoted 14 lines
drivers/gpu/drm/tests/drm_gem_shmem_test.c +11
-0+/* +* Set the DMA mask to 64-bits and map the sgtables +* otherwise drm_gem_shmem_free will cause a warning +* on debug kernels. +* */ + ret =dma_set_mask (drm_dev->dev,DMA_BIT_MASK (64 )); +KUNIT_ASSERT_EQ (test, ret,0 ); + + ret =dma_map_sgtable (drm_dev->dev, sgt,DMA_BIDIRECTIONAL ,0 ); +KUNIT_ASSERT_EQ (test, ret,0 ); +/* Init a mock DMA-BUF */ buf_mock.size =TEST_SIZE ;attach_mock.dmabuf = &buf_mock;Quoted 2 lines
--
2.45.0--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Marco Pagani
Reviewed-byQuoted 29 lines · Michael J
Quoted 29 lines
-----Original Message-----
From: Daniel Vetter <[email protected]>
Sent: Tuesday, July 16, 2024 5:34 AM
To: Ruhl, Michael J <[email protected]>
Cc: Dave Airlie <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/test: fix the gem shmem test to map the sg table.Quoted 2 lines · Michael J
Quoted 2 lines
-----Original Message-----
From: dri-devel <[email protected]> On Behalf OfDave
Quoted 17 lines
Quoted 10 lines
Airlie
Sent: Monday, July 15, 2024 4:36 AM
To: [email protected]
Subject: [PATCH] drm/test: fix the gem shmem test to map the sg table.From: Dave Airlie <[email protected]>
The test here creates an sg table, but never maps it, when we get to
drm_gem_shmem_free, the helper tries to unmap and this causes warnings on some platforms and debug kernels.This looks pretty straightforward...
However, should
drm_gem_shmem_free()really give an error if the mapping didn't happen?I.e. just because you have an sgt pointer, should you also have a mapping?
Quoted 8 lines
Quoted 2 lines
Yes, I think only allocating an sgt but not setting it up is a bug. So the fix looks correct, and isn't just papering over noise.
I guess my concern here is that the mapping could fail.
If that happens, what is the error path?
Can I call
_shmem_free?
In this case, if the mapping fails, the test case will be aborted, and the sg_table will be freed by the action that calls sg_free_table_wrapper(). However, I also think drm_gem_shmem_free() should behave well even if the sg_table is not mapped. Is there any advantage in issuing a warning when freeing the object if the sg_table is not mapped?
Thanks,
Marco
Quoted 61 lines
Mike
Quoted 57 lines
Quoted 1 line
If the errors are really just noise (form the specific platforms), and this patch is
covering
Quoted 3 lines
for that, then:
Reviewed-by Michael J. Ruhl <[email protected]>Acked-by Daniel Vetter <[email protected]>Cheers, Sima
Quoted 26 lines
Thanks,
Mike
Quoted 21 lines
This also sets a 64-bit dma mask, as I see an swiotlb warning if I stick with the default 32-bit one.
Fixes 93032ae634d4 ("drm/test: add a test suite for GEM objects backed byshmem")
Signed-off-by Dave Airlie <[email protected]>---
drivers/gpu/drm/tests/drm_gem_shmem_test.c| 11 +++++++++++1 file changed, 11 insertions(+)drivers/gpu/drm/tests/drm_gem_shmem_test.c +0
-0@@ -102,6 +102,17 @@ static void drm_gem_shmem_test_obj_create_private(struct kunit *test) sg_init_one(sgt->sgl, buf, TEST_SIZE);Quoted 17 lines
Quoted 14 lines
drivers/gpu/drm/tests/drm_gem_shmem_test.c +11
-0+/* +* Set the DMA mask to 64-bits and map the sgtables +* otherwise drm_gem_shmem_free will cause a warning +* on debug kernels. +* */ + ret =dma_set_mask (drm_dev->dev,DMA_BIT_MASK (64 )); +KUNIT_ASSERT_EQ (test, ret,0 ); + + ret =dma_map_sgtable (drm_dev->dev, sgt,DMA_BIDIRECTIONAL ,0 ); +KUNIT_ASSERT_EQ (test, ret,0 ); +/* Init a mock DMA-BUF */ buf_mock.size =TEST_SIZE ;attach_mock.dmabuf = &buf_mock;Quoted 2 lines
--
2.45.0--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Quoted 8 lines · Dave Airlie
The test here creates an sg table, but never maps it, when we get to
drm_gem_shmem_free, the helper tries to unmap and this causes warnings on some platforms and debug kernels.This also sets a 64-bit dma mask, as I see an swiotlb warning if I stick with the default 32-bit one.
[...]
Applied to misc/kernel.git (drm-misc-fixes).
Thanks!
Maxime