drm/xe: Add xe_ttm_vram_get_avail
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Mon, 15 Apr 2024 17:39:34 +0000 (19:39 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Tue, 16 Apr 2024 10:37:31 +0000 (12:37 +0200)
The PF driver will need to know size of the remaining available
VRAM to estimate fair VRAM allocations that could be used across
all VFs in automatic VFs provisioning mode. Add helper function
for that. We will use it in upcoming patch.

Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240415173937.1287-4-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
drivers/gpu/drm/xe/xe_ttm_vram_mgr.h

index 0678faf832126cf199339a0cc1a7ea373571d36d..8a1f460ff20b096d6c2585c7c3d62049e3cc8d09 100644 (file)
@@ -478,3 +478,15 @@ void xe_ttm_vram_get_used(struct ttm_resource_manager *man,
        *used_visible = mgr->visible_size - mgr->visible_avail;
        mutex_unlock(&mgr->lock);
 }
+
+u64 xe_ttm_vram_get_avail(struct ttm_resource_manager *man)
+{
+       struct xe_ttm_vram_mgr *mgr = to_xe_ttm_vram_mgr(man);
+       u64 avail;
+
+       mutex_lock(&mgr->lock);
+       avail =  mgr->mm.avail;
+       mutex_unlock(&mgr->lock);
+
+       return avail;
+}
index d184e19a923050df0c99af8279b0a43d71f20779..cc76050e376dd9843b718039804b6934bab6b00d 100644 (file)
@@ -25,6 +25,7 @@ int xe_ttm_vram_mgr_alloc_sgt(struct xe_device *xe,
 void xe_ttm_vram_mgr_free_sgt(struct device *dev, enum dma_data_direction dir,
                              struct sg_table *sgt);
 
+u64 xe_ttm_vram_get_avail(struct ttm_resource_manager *man);
 u64 xe_ttm_vram_get_cpu_visible_size(struct ttm_resource_manager *man);
 void xe_ttm_vram_get_used(struct ttm_resource_manager *man,
                          u64 *used, u64 *used_visible);