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

drm/amdgpu: consolidate atom scratch reg handling for hangs

Move from asic specific code to common atom code.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+20 -28
+13
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
··· 1784 1784 WREG32(mmBIOS_SCRATCH_0 + i, adev->bios_scratch[i]); 1785 1785 } 1786 1786 1787 + void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, 1788 + bool hung) 1789 + { 1790 + u32 tmp = RREG32(mmBIOS_SCRATCH_3); 1791 + 1792 + if (hung) 1793 + tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; 1794 + else 1795 + tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; 1796 + 1797 + WREG32(mmBIOS_SCRATCH_3, tmp); 1798 + } 1799 + 1787 1800 /* Atom needs data in little endian format 1788 1801 * so swap as appropriate when copying data to 1789 1802 * or from atom. Note that atom operates on
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h
··· 206 206 void amdgpu_atombios_scratch_regs_init(struct amdgpu_device *adev); 207 207 void amdgpu_atombios_scratch_regs_save(struct amdgpu_device *adev); 208 208 void amdgpu_atombios_scratch_regs_restore(struct amdgpu_device *adev); 209 + void amdgpu_atombios_scratch_regs_engine_hung(struct amdgpu_device *adev, 210 + bool hung); 209 211 210 212 void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le); 211 213 int amdgpu_atombios_get_max_vddc(struct amdgpu_device *adev, u8 voltage_type,
+3 -14
drivers/gpu/drm/amd/amdgpu/cik.c
··· 1189 1189 return r; 1190 1190 } 1191 1191 1192 - static void cik_set_bios_scratch_engine_hung(struct amdgpu_device *adev, bool hung) 1193 - { 1194 - u32 tmp = RREG32(mmBIOS_SCRATCH_3); 1195 - 1196 - if (hung) 1197 - tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; 1198 - else 1199 - tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; 1200 - 1201 - WREG32(mmBIOS_SCRATCH_3, tmp); 1202 - } 1203 - 1204 1192 /** 1205 1193 * cik_asic_reset - soft reset GPU 1206 1194 * ··· 1201 1213 static int cik_asic_reset(struct amdgpu_device *adev) 1202 1214 { 1203 1215 int r; 1204 - cik_set_bios_scratch_engine_hung(adev, true); 1216 + 1217 + amdgpu_atombios_scratch_regs_engine_hung(adev, true); 1205 1218 1206 1219 r = cik_gpu_pci_config_reset(adev); 1207 1220 1208 - cik_set_bios_scratch_engine_hung(adev, false); 1221 + amdgpu_atombios_scratch_regs_engine_hung(adev, false); 1209 1222 1210 1223 return r; 1211 1224 }
+2 -14
drivers/gpu/drm/amd/amdgpu/vi.c
··· 729 729 return -EINVAL; 730 730 } 731 731 732 - static void vi_set_bios_scratch_engine_hung(struct amdgpu_device *adev, bool hung) 733 - { 734 - u32 tmp = RREG32(mmBIOS_SCRATCH_3); 735 - 736 - if (hung) 737 - tmp |= ATOM_S3_ASIC_GUI_ENGINE_HUNG; 738 - else 739 - tmp &= ~ATOM_S3_ASIC_GUI_ENGINE_HUNG; 740 - 741 - WREG32(mmBIOS_SCRATCH_3, tmp); 742 - } 743 - 744 732 /** 745 733 * vi_asic_reset - soft reset GPU 746 734 * ··· 742 754 { 743 755 int r; 744 756 745 - vi_set_bios_scratch_engine_hung(adev, true); 757 + amdgpu_atombios_scratch_regs_engine_hung(adev, true); 746 758 747 759 r = vi_gpu_pci_config_reset(adev); 748 760 749 - vi_set_bios_scratch_engine_hung(adev, false); 761 + amdgpu_atombios_scratch_regs_engine_hung(adev, false); 750 762 751 763 return r; 752 764 }