Skip to contentSkip to conversation

Use drm_gem_shmem_unpin() to unpin the backing pages for a shmem GEM

PATCH Superseded Xiaolei Wang 2 participants 2 messages Aug 27, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use drm_gem_shmem_unpin() to unpin the backing pages for a shmem GEM

Although drm_gem_shmem_free() will decrease the use count on the backing pages and free backing pages for a GEM object, the pages_pin_count count is not decremented, which results in a warning. Therefore, use drm_gem_shmem_unpin() to unpin the backing pages for a shmem GEM.

WARNING: CPU: 2 PID: 1106 at drivers/gpu/drm/drm_gem_shmem_helper.c:180 drm_gem_shmem_free+0x4d0/0x6f0
 Call trace:
  drm_gem_shmem_free+0x4d0/0x6f0 (P)
  drm_gem_shmem_free_wrapper+0x10/0x1c
  __kunit_action_free+0x50/0x70
  kunit_remove_resource+0x144/0x1e4
  kunit_cleanup+0x64/0xfc
  kunit_try_run_case_cleanup+0xa0/0xd4
  kunit_generic_run_threadfn_adapter+0x80/0xec
  kthread+0x3b8/0x6c0
  ret_from_fork+0x10/0x20
Fixes 93032ae634d4 ("drm/test: add a test suite for GEM objects backed by shmem")
---
 drivers/gpu/drm/tests/drm_gem_shmem_test.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +1 -0
index 68f2c3162354..e0a9f3a917ed 100644
@@ -227,6 +227,7 @@ static void drm_gem_shmem_test_get_pages_sgt(struct kunit *test)
 		len += sg->length;
 	}
 
+	drm_gem_shmem_unpin(shmem);
 	KUNIT_EXPECT_GE(test, len, TEST_SIZE);
 }
 
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Wed, 27 Aug 2025 10:25:16 +0800 Xiaolei Wang <[email protected]>…

Although drm_gem_shmem_free() will decrease the use count on the backing pages and free backing pages for a GEM object, the pages_pin_count count is not decremented, which results in a warning. Therefore, use drm_gem_shmem_unpin() to unpin the backing pages for a shmem GEM.

With the subject prefixed with "drm/gem-shmem: " this is

Quoted 31 lines
WARNING: CPU: 2 PID: 1106 at drivers/gpu/drm/drm_gem_shmem_helper.c:180 drm_gem_shmem_free+0x4d0/0x6f0
 Call trace:
  drm_gem_shmem_free+0x4d0/0x6f0 (P)
  drm_gem_shmem_free_wrapper+0x10/0x1c
  __kunit_action_free+0x50/0x70
  kunit_remove_resource+0x144/0x1e4
  kunit_cleanup+0x64/0xfc
  kunit_try_run_case_cleanup+0xa0/0xd4
  kunit_generic_run_threadfn_adapter+0x80/0xec
  kthread+0x3b8/0x6c0
  ret_from_fork+0x10/0x20
Fixes 93032ae634d4 ("drm/test: add a test suite for GEM objects backed by shmem")
---
 drivers/gpu/drm/tests/drm_gem_shmem_test.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/tests/drm_gem_shmem_test.c +1 -0
index 68f2c3162354..e0a9f3a917ed 100644
@@ -227,6 +227,7 @@ static void drm_gem_shmem_test_get_pages_sgt(struct kunit *test)
 		len += sg->length;
 	}
 
+	drm_gem_shmem_unpin(shmem);
 	KUNIT_EXPECT_GE(test, len, TEST_SIZE);
 }