Skip to content

Commit 543e93a

Browse files
alexdeucherMa Wupeng
authored andcommitted
drm: add drm_gem_object_is_shared_for_memory_stats() helper
stable inclusion from stable-v6.6.30 commit a4ae24cd04a8e2c1f61586a2e129b1cbd44a78db bugzilla: https://gitee.com/openeuler/kernel/issues/I9MPZ8 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=a4ae24cd04a8e2c1f61586a2e129b1cbd44a78db -------------------------------- [ Upstream commit b31f5eba32ae8cc28e7cfa5a55ec8670d8c718e2 ] Add a helper so that drm drivers can consistently report shared status via the fdinfo shared memory stats interface. In addition to handle count, show buffers as shared if they are shared via dma-buf as well (e.g., shared with v4l or some other subsystem). v2: switch to inline function Link: https://lore.kernel.org/all/20231207180225.439482-1-alexander.deucher@amd.com/ Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> (v1) Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christian König <christian.keonig@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com> Stable-dep-of: a6ff969fe9cb ("drm/amdgpu: fix visible VRAM handling during faults") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: ZhangPeng <zhangpeng362@huawei.com>
1 parent 024996d commit 543e93a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/drm/drm_gem.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,19 @@ unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru,
552552

553553
int drm_gem_evict(struct drm_gem_object *obj);
554554

555+
/**
556+
* drm_gem_object_is_shared_for_memory_stats - helper for shared memory stats
557+
*
558+
* This helper should only be used for fdinfo shared memory stats to determine
559+
* if a GEM object is shared.
560+
*
561+
* @obj: obj in question
562+
*/
563+
static inline bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_object *obj)
564+
{
565+
return (obj->handle_count > 1) || obj->dma_buf;
566+
}
567+
555568
#ifdef CONFIG_LOCKDEP
556569
/**
557570
* drm_gem_gpuva_set_lock() - Set the lock protecting accesses to the gpuva list.

0 commit comments

Comments
 (0)