Merge tag '6.6-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6
[sfrench/cifs-2.6.git] / drivers / gpu / drm / amd / amdgpu / psp_v13_0.c
index 10b17bd5aebe501ae1b61f603a6f3ba12e21099f..469eed084976c73af5f82fb989bda67f36592098 100644 (file)
@@ -133,12 +133,32 @@ static bool psp_v13_0_is_sos_alive(struct psp_context *psp)
        return sol_reg != 0x0;
 }
 
-static int psp_v13_0_wait_for_bootloader(struct psp_context *psp)
+static int psp_v13_0_wait_for_vmbx_ready(struct psp_context *psp)
 {
        struct amdgpu_device *adev = psp->adev;
+       int retry_loop, ret;
 
-       int ret;
-       int retry_loop;
+       for (retry_loop = 0; retry_loop < 70; retry_loop++) {
+               /* Wait for bootloader to signify that is
+                  ready having bit 31 of C2PMSG_33 set to 1 */
+               ret = psp_wait_for(
+                       psp, SOC15_REG_OFFSET(MP0, 0, regMP0_SMN_C2PMSG_33),
+                       0x80000000, 0xffffffff, false);
+
+               if (ret == 0)
+                       break;
+       }
+
+       if (ret)
+               dev_warn(adev->dev, "Bootloader wait timed out");
+
+       return ret;
+}
+
+static int psp_v13_0_wait_for_bootloader(struct psp_context *psp)
+{
+       struct amdgpu_device *adev = psp->adev;
+       int retry_loop, ret;
 
        /* Wait for bootloader to signify that it is ready having bit 31 of
         * C2PMSG_35 set to 1. All other bits are expected to be cleared.
@@ -157,6 +177,19 @@ static int psp_v13_0_wait_for_bootloader(struct psp_context *psp)
        return ret;
 }
 
+static int psp_v13_0_wait_for_bootloader_steady_state(struct psp_context *psp)
+{
+       struct amdgpu_device *adev = psp->adev;
+
+       if (adev->ip_versions[MP0_HWIP][0] == IP_VERSION(13, 0, 6)) {
+               psp_v13_0_wait_for_vmbx_ready(psp);
+
+               return psp_v13_0_wait_for_bootloader(psp);
+       }
+
+       return 0;
+}
+
 static int psp_v13_0_bootloader_load_component(struct psp_context      *psp,
                                               struct psp_bin_desc      *bin_desc,
                                               enum psp_bootloader_cmd  bl_cmd)
@@ -714,6 +747,7 @@ static int psp_v13_0_fatal_error_recovery_quirk(struct psp_context *psp)
 
 static const struct psp_funcs psp_v13_0_funcs = {
        .init_microcode = psp_v13_0_init_microcode,
+       .wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
        .bootloader_load_kdb = psp_v13_0_bootloader_load_kdb,
        .bootloader_load_spl = psp_v13_0_bootloader_load_spl,
        .bootloader_load_sysdrv = psp_v13_0_bootloader_load_sysdrv,