]> git.dujemihanovic.xyz Git - linux.git/commitdiff
nouveau: add an ioctl to report vram usage
authorDave Airlie <airlied@redhat.com>
Wed, 24 Jan 2024 04:24:25 +0000 (14:24 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 23 Feb 2024 00:20:07 +0000 (10:20 +1000)
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>
drivers/gpu/drm/nouveau/nouveau_abi16.c
include/uapi/drm/nouveau_drm.h

index 4cb323bc32330651ba5d703a5e346332da7fd9d9..cd14f993bdd1bdad352a70eba9acc473ceab7bdb 100644 (file)
@@ -267,6 +267,11 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
        case NOUVEAU_GETPARAM_VRAM_BAR_SIZE:
                getparam->value = nvkm_device->func->resource_size(nvkm_device, 1);
                break;
+       case NOUVEAU_GETPARAM_VRAM_USED: {
+               struct ttm_resource_manager *vram_mgr = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
+               getparam->value = (u64)ttm_resource_manager_usage(vram_mgr) << PAGE_SHIFT;
+               break;
+       }
        default:
                NV_PRINTK(dbg, cli, "unknown parameter %lld\n", getparam->param);
                return -EINVAL;
index 10a917639d8d3fd54c48de109106f06172d35375..77d7ff0d5b110da4a05a4a7730d01bbd2d7c581e 100644 (file)
@@ -61,6 +61,13 @@ extern "C" {
  */
 #define NOUVEAU_GETPARAM_VRAM_BAR_SIZE 18
 
+/*
+ * NOUVEAU_GETPARAM_VRAM_USED
+ *
+ * Get remaining VRAM size.
+ */
+#define NOUVEAU_GETPARAM_VRAM_USED 19
+
 struct drm_nouveau_getparam {
        __u64 param;
        __u64 value;