Skip to content

Commit 50203bc

Browse files
alexdeucherSasha Levin
authored andcommitted
drm: add drm_gem_object_is_shared_for_memory_stats() helper
[ Upstream commit b31f5eb ] 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: a6ff969 ("drm/amdgpu: fix visible VRAM handling during faults") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 83c2132 commit 50203bc

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
@@ -544,6 +544,19 @@ unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru,
544544

545545
int drm_gem_evict(struct drm_gem_object *obj);
546546

547+
/**
548+
* drm_gem_object_is_shared_for_memory_stats - helper for shared memory stats
549+
*
550+
* This helper should only be used for fdinfo shared memory stats to determine
551+
* if a GEM object is shared.
552+
*
553+
* @obj: obj in question
554+
*/
555+
static inline bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_object *obj)
556+
{
557+
return (obj->handle_count > 1) || obj->dma_buf;
558+
}
559+
547560
#ifdef CONFIG_LOCKDEP
548561
/**
549562
* drm_gem_gpuva_set_lock() - Set the lock protecting accesses to the gpuva list.

0 commit comments

Comments
 (0)