On Fri, Apr 11, 2025 at 8:16 AM Lijo Lazar <lijo.la...@amd.com> wrote:
>
> There are a few prechecks made before HDP flush like a flush is not
> required on APU bare metal. Using hdp callback directly bypasses those
> checks. Use amdgpu_device_flush_hdp which takes care of prechecks.
>
> Signed-off-by: Lijo Lazar <lijo.la...@amd.com>

Reviewed-by: Alex Deucher <alexander.deuc...@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c |  8 ++++----
>  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 12 ++++++------
>  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c |  6 +++---
>  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c |  4 ++--
>  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c |  4 ++--
>  drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c |  4 ++--
>  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  |  2 +-
>  drivers/gpu/drm/amd/amdgpu/psp_v11_0.c |  2 +-
>  drivers/gpu/drm/amd/amdgpu/psp_v13_0.c |  2 +-
>  drivers/gpu/drm/amd/amdgpu/psp_v14_0.c |  2 +-
>  10 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> index f5dcb72a6bf5..00eb4cfecf8f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
> @@ -6172,7 +6172,7 @@ static int gfx_v10_0_cp_gfx_load_pfp_microcode(struct 
> amdgpu_device *adev)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, mmCP_PFP_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_PFP_IC_BASE_CNTL, VMID, 0);
> @@ -6250,7 +6250,7 @@ static int gfx_v10_0_cp_gfx_load_ce_microcode(struct 
> amdgpu_device *adev)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, mmCP_CE_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_CE_IC_BASE_CNTL, VMID, 0);
> @@ -6327,7 +6327,7 @@ static int gfx_v10_0_cp_gfx_load_me_microcode(struct 
> amdgpu_device *adev)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, mmCP_ME_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_ME_IC_BASE_CNTL, VMID, 0);
> @@ -6702,7 +6702,7 @@ static int gfx_v10_0_cp_compute_load_microcode(struct 
> amdgpu_device *adev)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, mmCP_CPC_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, CACHE_POLICY, 0);
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 91d29f482c3c..fa39ae17222f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -2481,7 +2481,7 @@ static int gfx_v11_0_config_me_cache(struct 
> amdgpu_device *adev, uint64_t addr)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, regCP_ME_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_ME_IC_BASE_CNTL, VMID, 0);
> @@ -2525,7 +2525,7 @@ static int gfx_v11_0_config_pfp_cache(struct 
> amdgpu_device *adev, uint64_t addr)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, regCP_PFP_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_PFP_IC_BASE_CNTL, VMID, 0);
> @@ -2570,7 +2570,7 @@ static int gfx_v11_0_config_mec_cache(struct 
> amdgpu_device *adev, uint64_t addr)
>         }
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         tmp = RREG32_SOC15(GC, 0, regCP_CPC_IC_BASE_CNTL);
>         tmp = REG_SET_FIELD(tmp, CP_CPC_IC_BASE_CNTL, CACHE_POLICY, 0);
> @@ -3206,7 +3206,7 @@ static int 
> gfx_v11_0_cp_gfx_load_pfp_microcode_rs64(struct amdgpu_device *adev)
>         amdgpu_bo_unreserve(adev->gfx.pfp.pfp_fw_data_obj);
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         WREG32_SOC15(GC, 0, regCP_PFP_IC_BASE_LO,
>                 lower_32_bits(adev->gfx.pfp.pfp_fw_gpu_addr));
> @@ -3424,7 +3424,7 @@ static int 
> gfx_v11_0_cp_gfx_load_me_microcode_rs64(struct amdgpu_device *adev)
>         amdgpu_bo_unreserve(adev->gfx.me.me_fw_data_obj);
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         WREG32_SOC15(GC, 0, regCP_ME_IC_BASE_LO,
>                 lower_32_bits(adev->gfx.me.me_fw_gpu_addr));
> @@ -4620,7 +4620,7 @@ static int gfx_v11_0_gfxhub_enable(struct amdgpu_device 
> *adev)
>         if (r)
>                 return r;
>
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
>                 false : true;
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> index 2474006b1a34..f347921fa909 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
> @@ -2389,7 +2389,7 @@ static int 
> gfx_v12_0_cp_gfx_load_pfp_microcode_rs64(struct amdgpu_device *adev)
>         amdgpu_bo_unreserve(adev->gfx.pfp.pfp_fw_data_obj);
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         WREG32_SOC15(GC, 0, regCP_PFP_IC_BASE_LO,
>                 lower_32_bits(adev->gfx.pfp.pfp_fw_gpu_addr));
> @@ -2533,7 +2533,7 @@ static int 
> gfx_v12_0_cp_gfx_load_me_microcode_rs64(struct amdgpu_device *adev)
>         amdgpu_bo_unreserve(adev->gfx.me.me_fw_data_obj);
>
>         if (amdgpu_emu_mode == 1)
> -               adev->hdp.funcs->flush_hdp(adev, NULL);
> +               amdgpu_device_flush_hdp(adev, NULL);
>
>         WREG32_SOC15(GC, 0, regCP_ME_IC_BASE_LO,
>                 lower_32_bits(adev->gfx.me.me_fw_gpu_addr));
> @@ -3503,7 +3503,7 @@ static int gfx_v12_0_gfxhub_enable(struct amdgpu_device 
> *adev)
>         if (r)
>                 return r;
>
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
>                 false : true;
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> index b6ac4c7adc8a..7648e977b44b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> @@ -268,7 +268,7 @@ static void gmc_v10_0_flush_gpu_tlb(struct amdgpu_device 
> *adev, uint32_t vmid,
>         ack = hub->vm_inv_eng0_ack + hub->eng_distance * eng;
>
>         /* flush hdp cache */
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         /* This is necessary for SRIOV as well as for GFXOFF to function
>          * properly under bare metal
> @@ -965,7 +965,7 @@ static int gmc_v10_0_gart_enable(struct amdgpu_device 
> *adev)
>         adev->hdp.funcs->init_registers(adev);
>
>         /* Flush HDP after it is initialized */
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
>                 false : true;
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> index 5c91d4445418..7f5ca170f141 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
> @@ -229,7 +229,7 @@ static void gmc_v11_0_flush_gpu_tlb(struct amdgpu_device 
> *adev, uint32_t vmid,
>         ack = hub->vm_inv_eng0_ack + hub->eng_distance * eng;
>
>         /* flush hdp cache */
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         /* This is necessary for SRIOV as well as for GFXOFF to function
>          * properly under bare metal
> @@ -895,7 +895,7 @@ static int gmc_v11_0_gart_enable(struct amdgpu_device 
> *adev)
>                 return r;
>
>         /* Flush HDP after it is initialized */
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
>                 false : true;
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
> index d544419e3b44..b645d3e6a6c8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
> @@ -297,7 +297,7 @@ static void gmc_v12_0_flush_gpu_tlb(struct amdgpu_device 
> *adev, uint32_t vmid,
>                 return;
>
>         /* flush hdp cache */
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         /* This is necessary for SRIOV as well as for GFXOFF to function
>          * properly under bare metal
> @@ -877,7 +877,7 @@ static int gmc_v12_0_gart_enable(struct amdgpu_device 
> *adev)
>                 return r;
>
>         /* Flush HDP after it is initialized */
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         value = (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS) ?
>                 false : true;
> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> index 8d3560314e5b..53050176c244 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
> @@ -2425,7 +2425,7 @@ static int gmc_v9_0_hw_init(struct amdgpu_ip_block 
> *ip_block)
>         adev->hdp.funcs->init_registers(adev);
>
>         /* After HDP is initialized, flush HDP.*/
> -       adev->hdp.funcs->flush_hdp(adev, NULL);
> +       amdgpu_device_flush_hdp(adev, NULL);
>
>         if (amdgpu_vm_fault_stop == AMDGPU_VM_FAULT_STOP_ALWAYS)
>                 value = false;
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> index bb5dfc410a66..215543575f47 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c
> @@ -533,7 +533,7 @@ static int psp_v11_0_memory_training(struct psp_context 
> *psp, uint32_t ops)
>                         }
>
>                         memcpy_toio(adev->mman.aper_base_kaddr, buf, sz);
> -                       adev->hdp.funcs->flush_hdp(adev, NULL);
> +                       amdgpu_device_flush_hdp(adev, NULL);
>                         vfree(buf);
>                         drm_dev_exit(idx);
>                 } else {
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c 
> b/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c
> index 17f1ccd8bd53..f5f616ab20e7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v13_0.c
> @@ -610,7 +610,7 @@ static int psp_v13_0_memory_training(struct psp_context 
> *psp, uint32_t ops)
>                         }
>
>                         memcpy_toio(adev->mman.aper_base_kaddr, buf, sz);
> -                       adev->hdp.funcs->flush_hdp(adev, NULL);
> +                       amdgpu_device_flush_hdp(adev, NULL);
>                         vfree(buf);
>                         drm_dev_exit(idx);
>                 } else {
> diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c 
> b/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c
> index 7c49c3f3c388..256288c6cd78 100644
> --- a/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/psp_v14_0.c
> @@ -498,7 +498,7 @@ static int psp_v14_0_memory_training(struct psp_context 
> *psp, uint32_t ops)
>                         }
>
>                         memcpy_toio(adev->mman.aper_base_kaddr, buf, sz);
> -                       adev->hdp.funcs->flush_hdp(adev, NULL);
> +                       amdgpu_device_flush_hdp(adev, NULL);
>                         vfree(buf);
>                         drm_dev_exit(idx);
>                 } else {
> --
> 2.25.1
>

Reply via email to