[PATCH 2/4] drm/amdgpu: Add bootloader status check

Chen, Guchun Guchun.Chen at amd.com
Fri Aug 11 06:31:53 UTC 2023


[Public]

> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Lijo
> Lazar
> Sent: Friday, August 11, 2023 1:18 PM
> To: amd-gfx at lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Ma, Le
> <Le.Ma at amd.com>; Kamal, Asad <Asad.Kamal at amd.com>; Zhang, Hawking
> <Hawking.Zhang at amd.com>
> Subject: [PATCH 2/4] drm/amdgpu: Add bootloader status check
>
> Add a function to wait till bootloader has reached steady state.
>
> Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
> Reviewed-by: Hawking Zhang <Hawking.Zhang at amd.com>
> Reviewed-by: Asad Kamal <asad.kamal at amd.com>
> Tested-by: Asad Kamal <asad.kamal at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 17 ++++++++++++++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c    | 11 +++++++++++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h    |  3 +++
>  3 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 6809bf7dae57..9061d79cd387 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -885,13 +885,20 @@ static void amdgpu_block_invalid_wreg(struct
> amdgpu_device *adev,
>   */
>  static int amdgpu_device_asic_init(struct amdgpu_device *adev)  {
> +     int ret;
> +
>       amdgpu_asic_pre_asic_init(adev);
>
>       if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 3) ||
> -         adev->ip_versions[GC_HWIP][0] >= IP_VERSION(11, 0, 0))
> -             return amdgpu_atomfirmware_asic_init(adev, true);
> -     else
> +         adev->ip_versions[GC_HWIP][0] >= IP_VERSION(11, 0, 0)) {
> +             amdgpu_psp_wait_for_bootloader(adev);
> +             ret = amdgpu_atomfirmware_asic_init(adev, true);
> +             return ret;

'return amdgpu_atomfirmware_asic_init(adev, true);' may be more simple. Then you can drop variable 'ret'.

Regards,
Guchun

> +     } else {
>               return amdgpu_atom_asic_init(adev-
> >mode_info.atom_context);
> +     }
> +
> +     return 0;
>  }
>
>  /**
> @@ -4702,6 +4709,9 @@ int amdgpu_device_mode1_reset(struct
> amdgpu_device *adev)
>               dev_err(adev->dev, "GPU mode1 reset failed\n");
>
>       amdgpu_device_load_pci_state(adev->pdev);
> +     ret = amdgpu_psp_wait_for_bootloader(adev);
> +     if (ret)
> +             return ret;
>
>       /* wait for asic to come out of reset */
>       for (i = 0; i < adev->usec_timeout; i++) { @@ -4713,6 +4723,7 @@ int
> amdgpu_device_mode1_reset(struct amdgpu_device *adev)
>       }
>
>       amdgpu_atombios_scratch_regs_engine_hung(adev, false);
> +
>       return ret;
>  }
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 8fdca54bb8a1..429ef212c1f2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -2078,6 +2078,17 @@ int psp_securedisplay_invoke(struct psp_context
> *psp, uint32_t ta_cmd_id)  }
>  /* SECUREDISPLAY end */
>
> +int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev) {
> +     struct psp_context *psp = &adev->psp;
> +     int ret = 0;
> +
> +     if (!amdgpu_sriov_vf(adev) && psp->funcs && psp->funcs-
> >wait_for_bootloader != NULL)
> +             ret = psp->funcs->wait_for_bootloader(psp);
> +
> +     return ret;
> +}
> +
>  static int psp_hw_start(struct psp_context *psp)  {
>       struct amdgpu_device *adev = psp->adev; diff --git
> a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> index 3384eb94fde0..3e67ed63e638 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
> @@ -109,6 +109,7 @@ enum psp_reg_prog_id {
>
>  struct psp_funcs {
>       int (*init_microcode)(struct psp_context *psp);
> +     int (*wait_for_bootloader)(struct psp_context *psp);
>       int (*bootloader_load_kdb)(struct psp_context *psp);
>       int (*bootloader_load_spl)(struct psp_context *psp);
>       int (*bootloader_load_sysdrv)(struct psp_context *psp); @@ -533,4
> +534,6 @@ int psp_spatial_partition(struct psp_context *psp, int mode);
>
>  int is_psp_fw_valid(struct psp_bin_desc bin);
>
> +int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
> +
>  #endif
> --
> 2.25.1



More information about the amd-gfx mailing list