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

Reapply: drm/amdgpu: Use generic hdp flush function

Except HDP v5.2 all use a common logic for HDP flush. Use a generic
function. HDP v5.2 forces NO_KIQ logic, revisit it later.

Reapply after fixing up an HDP regression.

v2: merge the fix (Alex)

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> (v1)
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
afc6053d dbc064ad

+26 -68
+20
drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.c
··· 22 22 */ 23 23 #include "amdgpu.h" 24 24 #include "amdgpu_ras.h" 25 + #include <uapi/linux/kfd_ioctl.h> 25 26 26 27 int amdgpu_hdp_ras_sw_init(struct amdgpu_device *adev) 27 28 { ··· 46 45 47 46 /* hdp ras follows amdgpu_ras_block_late_init_default for late init */ 48 47 return 0; 48 + } 49 + 50 + void amdgpu_hdp_generic_flush(struct amdgpu_device *adev, 51 + struct amdgpu_ring *ring) 52 + { 53 + if (!ring || !ring->funcs->emit_wreg) { 54 + WREG32((adev->rmmio_remap.reg_offset + 55 + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 56 + 2, 57 + 0); 58 + if (adev->nbio.funcs->get_memsize) 59 + adev->nbio.funcs->get_memsize(adev); 60 + } else { 61 + amdgpu_ring_emit_wreg(ring, 62 + (adev->rmmio_remap.reg_offset + 63 + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 64 + 2, 65 + 0); 66 + } 49 67 }
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_hdp.h
··· 44 44 }; 45 45 46 46 int amdgpu_hdp_ras_sw_init(struct amdgpu_device *adev); 47 + void amdgpu_hdp_generic_flush(struct amdgpu_device *adev, 48 + struct amdgpu_ring *ring); 47 49 #endif /* __AMDGPU_HDP_H__ */
+1 -17
drivers/gpu/drm/amd/amdgpu/hdp_v4_0.c
··· 36 36 #define HDP_MEM_POWER_CTRL__RC_MEM_POWER_LS_EN_MASK 0x00020000L 37 37 #define mmHDP_MEM_POWER_CTRL_BASE_IDX 0 38 38 39 - static void hdp_v4_0_flush_hdp(struct amdgpu_device *adev, 40 - struct amdgpu_ring *ring) 41 - { 42 - if (!ring || !ring->funcs->emit_wreg) { 43 - WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 44 - /* We just need to read back a register to post the write. 45 - * Reading back the remapped register causes problems on 46 - * some platforms so just read back the memory size register. 47 - */ 48 - if (adev->nbio.funcs->get_memsize) 49 - adev->nbio.funcs->get_memsize(adev); 50 - } else { 51 - amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 52 - } 53 - } 54 - 55 39 static void hdp_v4_0_invalidate_hdp(struct amdgpu_device *adev, 56 40 struct amdgpu_ring *ring) 57 41 { ··· 169 185 }; 170 186 171 187 const struct amdgpu_hdp_funcs hdp_v4_0_funcs = { 172 - .flush_hdp = hdp_v4_0_flush_hdp, 188 + .flush_hdp = amdgpu_hdp_generic_flush, 173 189 .invalidate_hdp = hdp_v4_0_invalidate_hdp, 174 190 .update_clock_gating = hdp_v4_0_update_clock_gating, 175 191 .get_clock_gating_state = hdp_v4_0_get_clockgating_state,
+1 -17
drivers/gpu/drm/amd/amdgpu/hdp_v5_0.c
··· 27 27 #include "hdp/hdp_5_0_0_sh_mask.h" 28 28 #include <uapi/linux/kfd_ioctl.h> 29 29 30 - static void hdp_v5_0_flush_hdp(struct amdgpu_device *adev, 31 - struct amdgpu_ring *ring) 32 - { 33 - if (!ring || !ring->funcs->emit_wreg) { 34 - WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 35 - /* We just need to read back a register to post the write. 36 - * Reading back the remapped register causes problems on 37 - * some platforms so just read back the memory size register. 38 - */ 39 - if (adev->nbio.funcs->get_memsize) 40 - adev->nbio.funcs->get_memsize(adev); 41 - } else { 42 - amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 43 - } 44 - } 45 - 46 30 static void hdp_v5_0_invalidate_hdp(struct amdgpu_device *adev, 47 31 struct amdgpu_ring *ring) 48 32 { ··· 206 222 } 207 223 208 224 const struct amdgpu_hdp_funcs hdp_v5_0_funcs = { 209 - .flush_hdp = hdp_v5_0_flush_hdp, 225 + .flush_hdp = amdgpu_hdp_generic_flush, 210 226 .invalidate_hdp = hdp_v5_0_invalidate_hdp, 211 227 .update_clock_gating = hdp_v5_0_update_clock_gating, 212 228 .get_clock_gating_state = hdp_v5_0_get_clockgating_state,
+1 -17
drivers/gpu/drm/amd/amdgpu/hdp_v6_0.c
··· 30 30 #define regHDP_CLK_CNTL_V6_1 0xd5 31 31 #define regHDP_CLK_CNTL_V6_1_BASE_IDX 0 32 32 33 - static void hdp_v6_0_flush_hdp(struct amdgpu_device *adev, 34 - struct amdgpu_ring *ring) 35 - { 36 - if (!ring || !ring->funcs->emit_wreg) { 37 - WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 38 - /* We just need to read back a register to post the write. 39 - * Reading back the remapped register causes problems on 40 - * some platforms so just read back the memory size register. 41 - */ 42 - if (adev->nbio.funcs->get_memsize) 43 - adev->nbio.funcs->get_memsize(adev); 44 - } else { 45 - amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 46 - } 47 - } 48 - 49 33 static void hdp_v6_0_update_clock_gating(struct amdgpu_device *adev, 50 34 bool enable) 51 35 { ··· 138 154 } 139 155 140 156 const struct amdgpu_hdp_funcs hdp_v6_0_funcs = { 141 - .flush_hdp = hdp_v6_0_flush_hdp, 157 + .flush_hdp = amdgpu_hdp_generic_flush, 142 158 .update_clock_gating = hdp_v6_0_update_clock_gating, 143 159 .get_clock_gating_state = hdp_v6_0_get_clockgating_state, 144 160 };
+1 -17
drivers/gpu/drm/amd/amdgpu/hdp_v7_0.c
··· 27 27 #include "hdp/hdp_7_0_0_sh_mask.h" 28 28 #include <uapi/linux/kfd_ioctl.h> 29 29 30 - static void hdp_v7_0_flush_hdp(struct amdgpu_device *adev, 31 - struct amdgpu_ring *ring) 32 - { 33 - if (!ring || !ring->funcs->emit_wreg) { 34 - WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 35 - /* We just need to read back a register to post the write. 36 - * Reading back the remapped register causes problems on 37 - * some platforms so just read back the memory size register. 38 - */ 39 - if (adev->nbio.funcs->get_memsize) 40 - adev->nbio.funcs->get_memsize(adev); 41 - } else { 42 - amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0); 43 - } 44 - } 45 - 46 30 static void hdp_v7_0_update_clock_gating(struct amdgpu_device *adev, 47 31 bool enable) 48 32 { ··· 126 142 } 127 143 128 144 const struct amdgpu_hdp_funcs hdp_v7_0_funcs = { 129 - .flush_hdp = hdp_v7_0_flush_hdp, 145 + .flush_hdp = amdgpu_hdp_generic_flush, 130 146 .update_clock_gating = hdp_v7_0_update_clock_gating, 131 147 .get_clock_gating_state = hdp_v7_0_get_clockgating_state, 132 148 };