*/
 #include "amdgpu.h"
 #include "amdgpu_ras.h"
+#include <uapi/linux/kfd_ioctl.h>
 
 int amdgpu_hdp_ras_sw_init(struct amdgpu_device *adev)
 {
        /* hdp ras follows amdgpu_ras_block_late_init_default for late init */
        return 0;
 }
+
+void amdgpu_hdp_generic_flush(struct amdgpu_device *adev,
+                             struct amdgpu_ring *ring)
+{
+       if (!ring || !ring->funcs->emit_wreg) {
+               WREG32((adev->rmmio_remap.reg_offset +
+                       KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >>
+                              2,
+                      0);
+               if (adev->nbio.funcs->get_memsize)
+                       adev->nbio.funcs->get_memsize(adev);
+       } else {
+               amdgpu_ring_emit_wreg(ring,
+                                     (adev->rmmio_remap.reg_offset +
+                                      KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >>
+                                             2,
+                                     0);
+       }
+}
 
 };
 
 int amdgpu_hdp_ras_sw_init(struct amdgpu_device *adev);
+void amdgpu_hdp_generic_flush(struct amdgpu_device *adev,
+                             struct amdgpu_ring *ring);
 #endif /* __AMDGPU_HDP_H__ */
 
 #define HDP_MEM_POWER_CTRL__RC_MEM_POWER_LS_EN_MASK     0x00020000L
 #define mmHDP_MEM_POWER_CTRL_BASE_IDX   0
 
-static void hdp_v4_0_flush_hdp(struct amdgpu_device *adev,
-                               struct amdgpu_ring *ring)
-{
-       if (!ring || !ring->funcs->emit_wreg) {
-               WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-               /* We just need to read back a register to post the write.
-                * Reading back the remapped register causes problems on
-                * some platforms so just read back the memory size register.
-                */
-               if (adev->nbio.funcs->get_memsize)
-                       adev->nbio.funcs->get_memsize(adev);
-       } else {
-               amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-       }
-}
-
 static void hdp_v4_0_invalidate_hdp(struct amdgpu_device *adev,
                                    struct amdgpu_ring *ring)
 {
 };
 
 const struct amdgpu_hdp_funcs hdp_v4_0_funcs = {
-       .flush_hdp = hdp_v4_0_flush_hdp,
+       .flush_hdp = amdgpu_hdp_generic_flush,
        .invalidate_hdp = hdp_v4_0_invalidate_hdp,
        .update_clock_gating = hdp_v4_0_update_clock_gating,
        .get_clock_gating_state = hdp_v4_0_get_clockgating_state,
 
 #include "hdp/hdp_5_0_0_sh_mask.h"
 #include <uapi/linux/kfd_ioctl.h>
 
-static void hdp_v5_0_flush_hdp(struct amdgpu_device *adev,
-                               struct amdgpu_ring *ring)
-{
-       if (!ring || !ring->funcs->emit_wreg) {
-               WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-               /* We just need to read back a register to post the write.
-                * Reading back the remapped register causes problems on
-                * some platforms so just read back the memory size register.
-                */
-               if (adev->nbio.funcs->get_memsize)
-                       adev->nbio.funcs->get_memsize(adev);
-       } else {
-               amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-       }
-}
-
 static void hdp_v5_0_invalidate_hdp(struct amdgpu_device *adev,
                                    struct amdgpu_ring *ring)
 {
 }
 
 const struct amdgpu_hdp_funcs hdp_v5_0_funcs = {
-       .flush_hdp = hdp_v5_0_flush_hdp,
+       .flush_hdp = amdgpu_hdp_generic_flush,
        .invalidate_hdp = hdp_v5_0_invalidate_hdp,
        .update_clock_gating = hdp_v5_0_update_clock_gating,
        .get_clock_gating_state = hdp_v5_0_get_clockgating_state,
 
 #define regHDP_CLK_CNTL_V6_1   0xd5
 #define regHDP_CLK_CNTL_V6_1_BASE_IDX 0
 
-static void hdp_v6_0_flush_hdp(struct amdgpu_device *adev,
-                               struct amdgpu_ring *ring)
-{
-       if (!ring || !ring->funcs->emit_wreg) {
-               WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-               /* We just need to read back a register to post the write.
-                * Reading back the remapped register causes problems on
-                * some platforms so just read back the memory size register.
-                */
-               if (adev->nbio.funcs->get_memsize)
-                       adev->nbio.funcs->get_memsize(adev);
-       } else {
-               amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-       }
-}
-
 static void hdp_v6_0_update_clock_gating(struct amdgpu_device *adev,
                                         bool enable)
 {
 }
 
 const struct amdgpu_hdp_funcs hdp_v6_0_funcs = {
-       .flush_hdp = hdp_v6_0_flush_hdp,
+       .flush_hdp = amdgpu_hdp_generic_flush,
        .update_clock_gating = hdp_v6_0_update_clock_gating,
        .get_clock_gating_state = hdp_v6_0_get_clockgating_state,
 };
 
 #include "hdp/hdp_7_0_0_sh_mask.h"
 #include <uapi/linux/kfd_ioctl.h>
 
-static void hdp_v7_0_flush_hdp(struct amdgpu_device *adev,
-                               struct amdgpu_ring *ring)
-{
-       if (!ring || !ring->funcs->emit_wreg) {
-               WREG32((adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-               /* We just need to read back a register to post the write.
-                * Reading back the remapped register causes problems on
-                * some platforms so just read back the memory size register.
-                */
-               if (adev->nbio.funcs->get_memsize)
-                       adev->nbio.funcs->get_memsize(adev);
-       } else {
-               amdgpu_ring_emit_wreg(ring, (adev->rmmio_remap.reg_offset + KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL) >> 2, 0);
-       }
-}
-
 static void hdp_v7_0_update_clock_gating(struct amdgpu_device *adev,
                                         bool enable)
 {
 }
 
 const struct amdgpu_hdp_funcs hdp_v7_0_funcs = {
-       .flush_hdp = hdp_v7_0_flush_hdp,
+       .flush_hdp = amdgpu_hdp_generic_flush,
        .update_clock_gating = hdp_v7_0_update_clock_gating,
        .get_clock_gating_state = hdp_v7_0_get_clockgating_state,
 };