drm/xe: Track page table memory usage for client
authorTejas Upadhyay <tejas.upadhyay@intel.com>
Thu, 14 Sep 2023 09:55:16 +0000 (15:25 +0530)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 21 Dec 2023 16:41:15 +0000 (11:41 -0500)
Account page table memory usage in the owning client
memory usage stats.

V2:
  - Minor tweak to if (vm->pt_root[id]) check - Himal

Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_pt.c
drivers/gpu/drm/xe/xe_vm.c

index 21a3dfe99e05a511f9731cbf61655f3240fcfd15..b3e23d8ed8eefb004032e4fbbf1cecd5d081596d 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "xe_bo.h"
 #include "xe_device.h"
+#include "xe_drm_client.h"
 #include "xe_gt.h"
 #include "xe_gt_tlb_invalidation.h"
 #include "xe_migrate.h"
@@ -196,6 +197,8 @@ struct xe_pt *xe_pt_create(struct xe_vm *vm, struct xe_tile *tile,
        pt->level = level;
        pt->base.dir = level ? &as_xe_pt_dir(pt)->dir : NULL;
 
+       if (vm->xef)
+               xe_drm_client_add_bo(vm->xef->client, pt->bo);
        xe_tile_assert(tile, level <= XE_VM_MAX_LEVEL);
 
        return pt;
index 92d682ee60306328b561e557cfc88b64d057688e..fac722074004b8a6a69c7d3337fd33abafe72743 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "xe_bo.h"
 #include "xe_device.h"
+#include "xe_drm_client.h"
 #include "xe_exec_queue.h"
 #include "xe_gt.h"
 #include "xe_gt_pagefault.h"
@@ -1981,6 +1982,7 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
        struct xe_device *xe = to_xe_device(dev);
        struct xe_file *xef = to_xe_file(file);
        struct drm_xe_vm_create *args = data;
+       struct xe_tile *tile;
        struct xe_vm *vm;
        u32 id, asid;
        int err;
@@ -2060,6 +2062,11 @@ int xe_vm_create_ioctl(struct drm_device *dev, void *data,
        args->vm_id = id;
        vm->xef = xef;
 
+       /* Record BO memory for VM pagetable created against client */
+       for_each_tile(tile, xe, id)
+               if (vm->pt_root[id])
+                       xe_drm_client_add_bo(vm->xef->client, vm->pt_root[id]->bo);
+
 #if IS_ENABLED(CONFIG_DRM_XE_DEBUG_MEM)
        /* Warning: Security issue - never enable by default */
        args->reserved[0] = xe_bo_main_addr(vm->pt_root[0]->bo, XE_PAGE_SIZE);