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

drm/amdgpu: add ras_late_init callback function for nbio v7_4 (v3)

ras_late_init callback function will be used to do common ras
init in late init phase.

v2: call ras_late_fini to do cleanup when fails to enable interrupt

v3: rename sysfs/debugfs node name to pcie_bif_xxx

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Hawking Zhang and committed by
Alex Deucher
9ad1dc29 dda79907

+47
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
··· 81 81 void (*handle_ras_err_event_athub_intr_no_bifring)(struct amdgpu_device *adev); 82 82 int (*init_ras_controller_interrupt)(struct amdgpu_device *adev); 83 83 int (*init_ras_err_event_athub_interrupt)(struct amdgpu_device *adev); 84 + int (*ras_late_init)(struct amdgpu_device *adev); 84 85 }; 85 86 86 87 struct amdgpu_nbio { 87 88 const struct nbio_hdp_flush_reg *hdp_flush_reg; 88 89 struct amdgpu_irq_src ras_controller_irq; 89 90 struct amdgpu_irq_src ras_err_event_athub_irq; 91 + struct ras_common_if *ras_if; 90 92 const struct amdgpu_nbio_funcs *funcs; 91 93 }; 92 94
+45
drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c
··· 23 23 #include "amdgpu.h" 24 24 #include "amdgpu_atombios.h" 25 25 #include "nbio_v7_4.h" 26 + #include "amdgpu_ras.h" 26 27 27 28 #include "nbio/nbio_7_4_offset.h" 28 29 #include "nbio/nbio_7_4_sh_mask.h" ··· 469 468 return 0; 470 469 } 471 470 471 + static int nbio_v7_4_ras_late_init(struct amdgpu_device *adev) 472 + { 473 + int r; 474 + struct ras_ih_if ih_info = { 475 + .cb = NULL, 476 + }; 477 + struct ras_fs_if fs_info = { 478 + .sysfs_name = "pcie_bif_err_count", 479 + .debugfs_name = "pcie_bif_err_inject", 480 + }; 481 + 482 + if (!adev->nbio.ras_if) { 483 + adev->nbio.ras_if = kmalloc(sizeof(struct ras_common_if), GFP_KERNEL); 484 + if (!adev->nbio.ras_if) 485 + return -ENOMEM; 486 + adev->nbio.ras_if->block = AMDGPU_RAS_BLOCK__PCIE_BIF; 487 + adev->nbio.ras_if->type = AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE; 488 + adev->nbio.ras_if->sub_block_index = 0; 489 + strcpy(adev->nbio.ras_if->name, "pcie_bif"); 490 + } 491 + ih_info.head = fs_info.head = *adev->nbio.ras_if; 492 + r = amdgpu_ras_late_init(adev, adev->nbio.ras_if, 493 + &fs_info, &ih_info); 494 + if (r) 495 + goto free; 496 + 497 + if (amdgpu_ras_is_supported(adev, adev->nbio.ras_if->block)) { 498 + r = amdgpu_irq_get(adev, &adev->nbio.ras_controller_irq, 0); 499 + if (r) 500 + goto late_fini; 501 + r = amdgpu_irq_get(adev, &adev->nbio.ras_err_event_athub_irq, 0); 502 + if (r) 503 + goto late_fini; 504 + } 505 + 506 + return 0; 507 + late_fini: 508 + amdgpu_ras_late_fini(adev, adev->nbio.ras_if, &ih_info); 509 + free: 510 + kfree(adev->nbio.ras_if); 511 + return r; 512 + } 513 + 472 514 const struct amdgpu_nbio_funcs nbio_v7_4_funcs = { 473 515 .get_hdp_flush_req_offset = nbio_v7_4_get_hdp_flush_req_offset, 474 516 .get_hdp_flush_done_offset = nbio_v7_4_get_hdp_flush_done_offset, ··· 537 493 .handle_ras_err_event_athub_intr_no_bifring = nbio_v7_4_handle_ras_err_event_athub_intr_no_bifring, 538 494 .init_ras_controller_interrupt = nbio_v7_4_init_ras_controller_interrupt, 539 495 .init_ras_err_event_athub_interrupt = nbio_v7_4_init_ras_err_event_athub_interrupt, 496 + .ras_late_init = nbio_v7_4_ras_late_init, 540 497 };