drm/amdgpu: Add support for reporting VRAM usage
authorKent Russell <kent.russell@amd.com>
Sat, 9 Dec 2017 04:09:05 +0000 (23:09 -0500)
committerOded Gabbay <oded.gabbay@gmail.com>
Sat, 9 Dec 2017 04:09:05 +0000 (23:09 -0500)
Add functions to report the vram_usage from the amdgpu_device

Signed-off-by: Kent Russell <kent.russell@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
drivers/gpu/drm/amd/include/kgd_kfd_interface.h

index 996d3538f75158bec88b8ce90e5596e68265c6d7..335e454e2ee15a180a6b741c16d356cdb4b91c65 100644 (file)
@@ -347,3 +347,10 @@ void get_cu_info(struct kgd_dev *kgd, struct kfd_cu_info *cu_info)
        cu_info->max_scratch_slots_per_cu = acu_info.max_scratch_slots_per_cu;
        cu_info->lds_size = acu_info.lds_size;
 }
+
+uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
+
+       return amdgpu_vram_mgr_usage(&adev->mman.bdev.man[TTM_PL_VRAM]);
+}
index eed7dea5e8ac5f8d8bedadc2116e9e946469d582..2a519f9062eeaf3357c378f90b4c0ef8c0971fd4 100644 (file)
@@ -62,6 +62,7 @@ uint64_t get_gpu_clock_counter(struct kgd_dev *kgd);
 
 uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd);
 void get_cu_info(struct kgd_dev *kgd, struct kfd_cu_info *cu_info);
+uint64_t amdgpu_amdkfd_get_vram_usage(struct kgd_dev *kgd);
 
 #define read_user_wptr(mmptr, wptr, dst)                               \
        ({                                                              \
index c9e2fbe151ffee7b9a0d02696a57dd164c952e37..3d60e1fd9b680af72802821b3961c4c0fd33510f 100644 (file)
@@ -200,7 +200,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .get_fw_version = get_fw_version,
        .set_scratch_backing_va = set_scratch_backing_va,
        .get_tile_config = get_tile_config,
-       .get_cu_info = get_cu_info
+       .get_cu_info = get_cu_info,
+       .get_vram_usage = amdgpu_amdkfd_get_vram_usage
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_7_get_functions(void)
index 72ff6463594da02550db3d1ae699df85fc479805..66b513e96437395e2ca2bfa50f1d35ee8e88f1b8 100644 (file)
@@ -161,7 +161,8 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .get_fw_version = get_fw_version,
        .set_scratch_backing_va = set_scratch_backing_va,
        .get_tile_config = get_tile_config,
-       .get_cu_info = get_cu_info
+       .get_cu_info = get_cu_info,
+       .get_vram_usage = amdgpu_amdkfd_get_vram_usage
 };
 
 struct kfd2kgd_calls *amdgpu_amdkfd_gfx_8_0_get_functions(void)
index 0899cee6a60f7c732ef7f0296322bd72846ec084..a6752bd0c87131e57801786bac66ce9bbe9c6d1e 100644 (file)
@@ -177,6 +177,8 @@ struct tile_config {
  *
  * @get_cu_info: Retrieves activated cu info
  *
+ * @get_vram_usage: Returns current VRAM usage
+ *
  * This structure contains function pointers to services that the kgd driver
  * provides to amdkfd driver.
  *
@@ -267,6 +269,7 @@ struct kfd2kgd_calls {
 
        void (*get_cu_info)(struct kgd_dev *kgd,
                        struct kfd_cu_info *cu_info);
+       uint64_t (*get_vram_usage)(struct kgd_dev *kgd);
 };
 
 /**