drm/amdkfd: Show KFD node memory partition info
authorPhilip Yang <Philip.Yang@amd.com>
Thu, 26 Jan 2023 23:11:29 +0000 (18:11 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 13:59:58 +0000 (09:59 -0400)
Show KFD node memory partition id and size, add helper function
KFD_XCP_MEMORY_SIZE to get kfd node memory size, will be used
later to support memory accounting per partition.

Signed-off-by: Philip Yang <Philip.Yang@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdkfd/kfd_device.c

index e4e1dbb..324cb56 100644 (file)
@@ -330,6 +330,11 @@ int amdgpu_amdkfd_reserve_mem_limit(struct amdgpu_device *adev,
 void amdgpu_amdkfd_unreserve_mem_limit(struct amdgpu_device *adev,
                uint64_t size, u32 alloc_flag);
 
+#define KFD_XCP_MEMORY_SIZE(n) ((n)->adev->gmc.num_mem_partitions ?\
+               (n)->adev->gmc.mem_partitions[(n)->xcp->mem_id].size /\
+               (n)->adev->xcp_mgr->num_xcp_per_mem_partition :\
+               (n)->adev->gmc.real_vram_size)
+
 #if IS_ENABLED(CONFIG_HSA_AMD)
 void amdgpu_amdkfd_gpuvm_init_mem_limits(void);
 void amdgpu_amdkfd_gpuvm_destroy_cb(struct amdgpu_device *adev,
index b5497d2..db5b53f 100644 (file)
@@ -724,7 +724,6 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 
        kfd_cwsr_init(kfd);
 
-       /* TODO: Needs to be updated for memory partitioning */
        svm_migrate_init(kfd->adev);
 
        amdgpu_amdkfd_get_local_mem_info(kfd->adev, &kfd->local_mem_info);
@@ -754,6 +753,12 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
                                (1U << NUM_XCC(kfd->adev->gfx.xcc_mask)) - 1;
                }
 
+               if (node->xcp) {
+                       dev_info(kfd_device, "KFD node %d partition %d size %lldM\n",
+                               node->node_id, node->xcp->mem_id,
+                               KFD_XCP_MEMORY_SIZE(node) >> 20);
+               }
+
                if (KFD_GC_VERSION(kfd) == IP_VERSION(9, 4, 3) &&
                    partition_mode == AMDGPU_CPX_PARTITION_MODE &&
                    kfd->num_nodes != 1) {