Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: move xgmi ras functions to xgmi_ras_funcs

xgmi ras is not managed by gpu driver when gpu is
connected to cpu through xgmi. move all xgmi ras
functions to xgmi_ras_funcs so gpu driver only
initializes xgmi ras functions when it manages
xgmi ras.

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Dennis Li <Dennis.Li@amd.com>
Reviewed-by: John Clements <John.Clements@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Hawking Zhang and committed by
Alex Deucher
52137ca8 6e36f231

+42 -17
+14 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
··· 403 403 return r; 404 404 } 405 405 406 - return amdgpu_xgmi_ras_late_init(adev); 406 + if (!adev->gmc.xgmi.connected_to_cpu) 407 + adev->gmc.xgmi.ras_funcs = &xgmi_ras_funcs; 408 + 409 + if (adev->gmc.xgmi.ras_funcs && 410 + adev->gmc.xgmi.ras_funcs->ras_late_init) { 411 + r = adev->gmc.xgmi.ras_funcs->ras_late_init(adev); 412 + if (r) 413 + return r; 414 + } 415 + 416 + return 0; 407 417 } 408 418 409 419 void amdgpu_gmc_ras_fini(struct amdgpu_device *adev) 410 420 { 411 421 amdgpu_umc_ras_fini(adev); 412 422 amdgpu_mmhub_ras_fini(adev); 413 - amdgpu_xgmi_ras_fini(adev); 423 + if (adev->gmc.xgmi.ras_funcs && 424 + adev->gmc.xgmi.ras_funcs->ras_fini) 425 + adev->gmc.xgmi.ras_funcs->ras_fini(adev); 414 426 } 415 427 416 428 /*
+9
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
··· 135 135 unsigned int (*get_vbios_fb_size)(struct amdgpu_device *adev); 136 136 }; 137 137 138 + struct amdgpu_xgmi_ras_funcs { 139 + int (*ras_late_init)(struct amdgpu_device *adev); 140 + void (*ras_fini)(struct amdgpu_device *adev); 141 + int (*query_ras_error_count)(struct amdgpu_device *adev, 142 + void *ras_error_status); 143 + void (*reset_ras_error_count)(struct amdgpu_device *adev); 144 + }; 145 + 138 146 struct amdgpu_xgmi { 139 147 /* from psp */ 140 148 u64 node_id; ··· 159 151 struct ras_common_if *ras_if; 160 152 bool connected_to_cpu; 161 153 bool pending_reset; 154 + const struct amdgpu_xgmi_ras_funcs *ras_funcs; 162 155 }; 163 156 164 157 struct amdgpu_gmc {
+3 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
··· 809 809 adev->nbio.ras_funcs->query_ras_error_count(adev, &err_data); 810 810 break; 811 811 case AMDGPU_RAS_BLOCK__XGMI_WAFL: 812 - amdgpu_xgmi_query_ras_error_count(adev, &err_data); 812 + if (adev->gmc.xgmi.ras_funcs && 813 + adev->gmc.xgmi.ras_funcs->query_ras_error_count) 814 + adev->gmc.xgmi.ras_funcs->query_ras_error_count(adev, &err_data); 813 815 break; 814 816 default: 815 817 break;
+14 -7
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
··· 628 628 return psp_xgmi_terminate(&adev->psp); 629 629 } 630 630 631 - int amdgpu_xgmi_ras_late_init(struct amdgpu_device *adev) 631 + static int amdgpu_xgmi_ras_late_init(struct amdgpu_device *adev) 632 632 { 633 633 int r; 634 634 struct ras_ih_if ih_info = { ··· 642 642 adev->gmc.xgmi.num_physical_nodes == 0) 643 643 return 0; 644 644 645 - amdgpu_xgmi_reset_ras_error_count(adev); 645 + adev->gmc.xgmi.ras_funcs->reset_ras_error_count(adev); 646 646 647 647 if (!adev->gmc.xgmi.ras_if) { 648 648 adev->gmc.xgmi.ras_if = kmalloc(sizeof(struct ras_common_if), GFP_KERNEL); ··· 664 664 return r; 665 665 } 666 666 667 - void amdgpu_xgmi_ras_fini(struct amdgpu_device *adev) 667 + static void amdgpu_xgmi_ras_fini(struct amdgpu_device *adev) 668 668 { 669 669 if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__XGMI_WAFL) && 670 670 adev->gmc.xgmi.ras_if) { ··· 691 691 WREG32_PCIE(pcs_status_reg, 0); 692 692 } 693 693 694 - void amdgpu_xgmi_reset_ras_error_count(struct amdgpu_device *adev) 694 + static void amdgpu_xgmi_reset_ras_error_count(struct amdgpu_device *adev) 695 695 { 696 696 uint32_t i; 697 697 ··· 751 751 return 0; 752 752 } 753 753 754 - int amdgpu_xgmi_query_ras_error_count(struct amdgpu_device *adev, 755 - void *ras_error_status) 754 + static int amdgpu_xgmi_query_ras_error_count(struct amdgpu_device *adev, 755 + void *ras_error_status) 756 756 { 757 757 struct ras_err_data *err_data = (struct ras_err_data *)ras_error_status; 758 758 int i; ··· 801 801 break; 802 802 } 803 803 804 - amdgpu_xgmi_reset_ras_error_count(adev); 804 + adev->gmc.xgmi.ras_funcs->reset_ras_error_count(adev); 805 805 806 806 err_data->ue_count += ue_cnt; 807 807 err_data->ce_count += ce_cnt; 808 808 809 809 return 0; 810 810 } 811 + 812 + const struct amdgpu_xgmi_ras_funcs xgmi_ras_funcs = { 813 + .ras_late_init = amdgpu_xgmi_ras_late_init, 814 + .ras_fini = amdgpu_xgmi_ras_fini, 815 + .query_ras_error_count = amdgpu_xgmi_query_ras_error_count, 816 + .reset_ras_error_count = amdgpu_xgmi_reset_ras_error_count, 817 + };
+1 -6
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
··· 50 50 uint32_t pcs_err_shift; 51 51 }; 52 52 53 + extern const struct amdgpu_xgmi_ras_funcs xgmi_ras_funcs; 53 54 struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev); 54 55 void amdgpu_put_xgmi_hive(struct amdgpu_hive_info *hive); 55 56 int amdgpu_xgmi_update_topology(struct amdgpu_hive_info *hive, struct amdgpu_device *adev); ··· 59 58 int amdgpu_xgmi_set_pstate(struct amdgpu_device *adev, int pstate); 60 59 int amdgpu_xgmi_get_hops_count(struct amdgpu_device *adev, 61 60 struct amdgpu_device *peer_adev); 62 - int amdgpu_xgmi_ras_late_init(struct amdgpu_device *adev); 63 - void amdgpu_xgmi_ras_fini(struct amdgpu_device *adev); 64 61 uint64_t amdgpu_xgmi_get_relative_phy_addr(struct amdgpu_device *adev, 65 62 uint64_t addr); 66 - int amdgpu_xgmi_query_ras_error_count(struct amdgpu_device *adev, 67 - void *ras_error_status); 68 - void amdgpu_xgmi_reset_ras_error_count(struct amdgpu_device *adev); 69 - 70 63 static inline bool amdgpu_xgmi_same_hive(struct amdgpu_device *adev, 71 64 struct amdgpu_device *bo_adev) 72 65 {
+1 -1
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 1208 1208 adev->gmc.xgmi.supported = true; 1209 1209 adev->gmc.xgmi.connected_to_cpu = 1210 1210 adev->smuio.funcs->is_host_gpu_xgmi_supported(adev); 1211 - } 1211 + } 1212 1212 1213 1213 adev->gmc.shared_aperture_start = 0x2000000000000000ULL; 1214 1214 adev->gmc.shared_aperture_end =