Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nouveau: add an ioctl to report vram usage

This reports the currently used vram allocations.

userspace using this has been proposed for nvk, but
it's a rather trivial uapi addition.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

+12
+5
drivers/gpu/drm/nouveau/nouveau_abi16.c
··· 267 267 case NOUVEAU_GETPARAM_VRAM_BAR_SIZE: 268 268 getparam->value = nvkm_device->func->resource_size(nvkm_device, 1); 269 269 break; 270 + case NOUVEAU_GETPARAM_VRAM_USED: { 271 + struct ttm_resource_manager *vram_mgr = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM); 272 + getparam->value = (u64)ttm_resource_manager_usage(vram_mgr) << PAGE_SHIFT; 273 + break; 274 + } 270 275 default: 271 276 NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param); 272 277 return -EINVAL;
+7
include/uapi/drm/nouveau_drm.h
··· 61 61 */ 62 62 #define NOUVEAU_GETPARAM_VRAM_BAR_SIZE 18 63 63 64 + /* 65 + * NOUVEAU_GETPARAM_VRAM_USED 66 + * 67 + * Get remaining VRAM size. 68 + */ 69 + #define NOUVEAU_GETPARAM_VRAM_USED 19 70 + 64 71 struct drm_nouveau_getparam { 65 72 __u64 param; 66 73 __u64 value;