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

drm/amdgpu/jpeg: Add jpeg ras error query support

RAS error query support addition for JPEG 2.6

V2: removed unused options and corrected comment format.
Moved register definition to header file.

V3: poison query status check added.
Removed the error query support

V4: Return statement refactored.

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

authored by

Mohammad Zafar Ziya and committed by
Alex Deucher
749831ac c543dcbe

+81
+74
drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.c
··· 26 26 #include "soc15.h" 27 27 #include "soc15d.h" 28 28 #include "jpeg_v2_0.h" 29 + #include "jpeg_v2_5.h" 29 30 30 31 #include "vcn/vcn_2_5_offset.h" 31 32 #include "vcn/vcn_2_5_sh_mask.h" ··· 40 39 static void jpeg_v2_5_set_irq_funcs(struct amdgpu_device *adev); 41 40 static int jpeg_v2_5_set_powergating_state(void *handle, 42 41 enum amd_powergating_state state); 42 + static void jpeg_v2_5_set_ras_funcs(struct amdgpu_device *adev); 43 43 44 44 static int amdgpu_ih_clientid_jpeg[] = { 45 45 SOC15_IH_CLIENTID_VCN, ··· 72 70 73 71 jpeg_v2_5_set_dec_ring_funcs(adev); 74 72 jpeg_v2_5_set_irq_funcs(adev); 73 + jpeg_v2_5_set_ras_funcs(adev); 75 74 76 75 return 0; 77 76 } ··· 733 730 .rev = 0, 734 731 .funcs = &jpeg_v2_6_ip_funcs, 735 732 }; 733 + 734 + static uint32_t jpeg_v2_6_query_poison_by_instance(struct amdgpu_device *adev, 735 + uint32_t instance, uint32_t sub_block) 736 + { 737 + uint32_t poison_stat = 0, reg_value = 0; 738 + 739 + switch (sub_block) { 740 + case AMDGPU_JPEG_V2_6_JPEG0: 741 + reg_value = RREG32_SOC15(JPEG, instance, mmUVD_RAS_JPEG0_STATUS); 742 + poison_stat = REG_GET_FIELD(reg_value, UVD_RAS_JPEG0_STATUS, POISONED_PF); 743 + break; 744 + case AMDGPU_JPEG_V2_6_JPEG1: 745 + reg_value = RREG32_SOC15(JPEG, instance, mmUVD_RAS_JPEG1_STATUS); 746 + poison_stat = REG_GET_FIELD(reg_value, UVD_RAS_JPEG1_STATUS, POISONED_PF); 747 + break; 748 + default: 749 + break; 750 + } 751 + 752 + if (poison_stat) 753 + dev_info(adev->dev, "Poison detected in JPEG%d sub_block%d\n", 754 + instance, sub_block); 755 + 756 + return poison_stat; 757 + } 758 + 759 + static bool jpeg_v2_6_query_ras_poison_status(struct amdgpu_device *adev) 760 + { 761 + uint32_t inst = 0, sub = 0, poison_stat = 0; 762 + 763 + for (inst = 0; inst < adev->jpeg.num_jpeg_inst; inst++) 764 + for (sub = 0; sub < AMDGPU_JPEG_V2_6_MAX_SUB_BLOCK; sub++) 765 + poison_stat += 766 + jpeg_v2_6_query_poison_by_instance(adev, inst, sub); 767 + 768 + return !!poison_stat; 769 + } 770 + 771 + const struct amdgpu_ras_block_hw_ops jpeg_v2_6_ras_hw_ops = { 772 + .query_poison_status = jpeg_v2_6_query_ras_poison_status, 773 + }; 774 + 775 + static struct amdgpu_jpeg_ras jpeg_v2_6_ras = { 776 + .ras_block = { 777 + .hw_ops = &jpeg_v2_6_ras_hw_ops, 778 + }, 779 + }; 780 + 781 + static void jpeg_v2_5_set_ras_funcs(struct amdgpu_device *adev) 782 + { 783 + switch (adev->ip_versions[JPEG_HWIP][0]) { 784 + case IP_VERSION(2, 6, 0): 785 + adev->jpeg.ras = &jpeg_v2_6_ras; 786 + break; 787 + default: 788 + break; 789 + } 790 + 791 + if (adev->jpeg.ras) { 792 + amdgpu_ras_register_ras_block(adev, &adev->jpeg.ras->ras_block); 793 + 794 + strcpy(adev->jpeg.ras->ras_block.ras_comm.name, "jpeg"); 795 + adev->jpeg.ras->ras_block.ras_comm.block = AMDGPU_RAS_BLOCK__JPEG; 796 + adev->jpeg.ras->ras_block.ras_comm.type = AMDGPU_RAS_ERROR__POISON; 797 + adev->jpeg.ras_if = &adev->jpeg.ras->ras_block.ras_comm; 798 + 799 + /* If don't define special ras_late_init function, use default ras_late_init */ 800 + if (!adev->jpeg.ras->ras_block.ras_late_init) 801 + adev->jpeg.ras->ras_block.ras_late_init = amdgpu_ras_block_late_init; 802 + } 803 + }
+7
drivers/gpu/drm/amd/amdgpu/jpeg_v2_5.h
··· 24 24 #ifndef __JPEG_V2_5_H__ 25 25 #define __JPEG_V2_5_H__ 26 26 27 + enum amdgpu_jpeg_v2_6_sub_block { 28 + AMDGPU_JPEG_V2_6_JPEG0 = 0, 29 + AMDGPU_JPEG_V2_6_JPEG1, 30 + 31 + AMDGPU_JPEG_V2_6_MAX_SUB_BLOCK, 32 + }; 33 + 27 34 extern const struct amdgpu_ip_block_version jpeg_v2_5_ip_block; 28 35 extern const struct amdgpu_ip_block_version jpeg_v2_6_ip_block; 29 36