Commit 9a3ce1a7 authored by Hawking Zhang's avatar Hawking Zhang Committed by Alex Deucher

drm/amdgpu: Do not access members of xcp w/o check (v2)

Not all the asic needs xcp. ensure check xcp availabity
before accessing its member.

v2: add missing change in kfd_topology.c
Signed-off-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: default avatarLe Ma <le.ma@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0409022c
...@@ -429,17 +429,17 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev, ...@@ -429,17 +429,17 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev,
void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev, void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev,
struct kfd_local_mem_info *mem_info, struct kfd_local_mem_info *mem_info,
uint8_t xcp_id) struct amdgpu_xcp *xcp)
{ {
memset(mem_info, 0, sizeof(*mem_info)); memset(mem_info, 0, sizeof(*mem_info));
if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3)) { if (xcp) {
if (adev->gmc.real_vram_size == adev->gmc.visible_vram_size) if (adev->gmc.real_vram_size == adev->gmc.visible_vram_size)
mem_info->local_mem_size_public = mem_info->local_mem_size_public =
KFD_XCP_MEMORY_SIZE(adev, xcp_id); KFD_XCP_MEMORY_SIZE(adev, xcp->id);
else else
mem_info->local_mem_size_private = mem_info->local_mem_size_private =
KFD_XCP_MEMORY_SIZE(adev, xcp_id); KFD_XCP_MEMORY_SIZE(adev, xcp->id);
} else { } else {
mem_info->local_mem_size_public = adev->gmc.visible_vram_size; mem_info->local_mem_size_public = adev->gmc.visible_vram_size;
mem_info->local_mem_size_private = adev->gmc.real_vram_size - mem_info->local_mem_size_private = adev->gmc.real_vram_size -
......
...@@ -233,7 +233,7 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev, ...@@ -233,7 +233,7 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev,
enum kgd_engine_type type); enum kgd_engine_type type);
void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev, void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev,
struct kfd_local_mem_info *mem_info, struct kfd_local_mem_info *mem_info,
uint8_t xcp_id); struct amdgpu_xcp *xcp);
uint64_t amdgpu_amdkfd_get_gpu_clock_counter(struct amdgpu_device *adev); uint64_t amdgpu_amdkfd_get_gpu_clock_counter(struct amdgpu_device *adev);
uint32_t amdgpu_amdkfd_get_max_engine_clock_in_mhz(struct amdgpu_device *adev); uint32_t amdgpu_amdkfd_get_max_engine_clock_in_mhz(struct amdgpu_device *adev);
......
...@@ -784,7 +784,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd, ...@@ -784,7 +784,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
atomic_set(&node->sram_ecc_flag, 0); atomic_set(&node->sram_ecc_flag, 0);
amdgpu_amdkfd_get_local_mem_info(kfd->adev, amdgpu_amdkfd_get_local_mem_info(kfd->adev,
&node->local_mem_info, node->xcp->id); &node->local_mem_info, node->xcp);
/* Initialize the KFD node */ /* Initialize the KFD node */
if (kfd_init_node(node)) { if (kfd_init_node(node)) {
......
...@@ -1235,7 +1235,7 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev) ...@@ -1235,7 +1235,7 @@ static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev)
* all the banks will report the same mem_clk_max information * all the banks will report the same mem_clk_max information
*/ */
amdgpu_amdkfd_get_local_mem_info(dev->gpu->adev, &local_mem_info, amdgpu_amdkfd_get_local_mem_info(dev->gpu->adev, &local_mem_info,
dev->gpu->xcp->id); dev->gpu->xcp);
list_for_each_entry(mem, &dev->mem_props, list) list_for_each_entry(mem, &dev->mem_props, list)
mem->mem_clk_max = local_mem_info.mem_clk_max; mem->mem_clk_max = local_mem_info.mem_clk_max;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment