From: jsg Date: Mon, 6 May 2024 01:46:20 +0000 (+0000) Subject: drm: add drm_gem_object_is_shared_for_memory_stats() helper X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=df4e0c8e17afb154189d39c8d2ef7a298736fd11;p=openbsd drm: add drm_gem_object_is_shared_for_memory_stats() helper From Alex Deucher a4ae24cd04a8e2c1f61586a2e129b1cbd44a78db in linux-6.6.y/6.6.30 b31f5eba32ae8cc28e7cfa5a55ec8670d8c718e2 in mainline linux --- diff --git a/sys/dev/pci/drm/include/drm/drm_gem.h b/sys/dev/pci/drm/include/drm/drm_gem.h index de5d21d976f..678464ada27 100644 --- a/sys/dev/pci/drm/include/drm/drm_gem.h +++ b/sys/dev/pci/drm/include/drm/drm_gem.h @@ -567,6 +567,19 @@ unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru, int drm_gem_evict(struct drm_gem_object *obj); +/** + * drm_gem_object_is_shared_for_memory_stats - helper for shared memory stats + * + * This helper should only be used for fdinfo shared memory stats to determine + * if a GEM object is shared. + * + * @obj: obj in question + */ +static inline bool drm_gem_object_is_shared_for_memory_stats(struct drm_gem_object *obj) +{ + return (obj->handle_count > 1) || obj->dma_buf; +} + #ifdef CONFIG_LOCKDEP /** * drm_gem_gpuva_set_lock() - Set the lock protecting accesses to the gpuva list.