Skip to content

Commit 72fa02f

Browse files
committed
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>
1 parent 3f4d8aa commit 72fa02f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

drivers/gpu/drm/nouveau/nouveau_abi16.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
267267
case NOUVEAU_GETPARAM_VRAM_BAR_SIZE:
268268
getparam->value = nvkm_device->func->resource_size(nvkm_device, 1);
269269
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+
}
270275
default:
271276
NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param);
272277
return -EINVAL;

include/uapi/drm/nouveau_drm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ extern "C" {
6161
*/
6262
#define NOUVEAU_GETPARAM_VRAM_BAR_SIZE 18
6363

64+
/*
65+
* NOUVEAU_GETPARAM_VRAM_USED
66+
*
67+
* Get remaining VRAM size.
68+
*/
69+
#define NOUVEAU_GETPARAM_VRAM_USED 19
70+
6471
struct drm_nouveau_getparam {
6572
__u64 param;
6673
__u64 value;

0 commit comments

Comments
 (0)