]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu: Skip TMR allocation if not required
authorLijo Lazar <lijo.lazar@amd.com>
Thu, 24 Nov 2022 08:53:58 +0000 (14:23 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:54:23 +0000 (18:54 +0200)
[ Upstream commit 5b03127d4745d6848f208463390e6a76d489eb03 ]

On ASICs with PSPv13.0.6, TMR is reserved at boot time. There is no need
to allocate TMR region by driver. However, it's still required to send
SETUP_TMR command to PSP.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Stable-dep-of: 467e00b30dfe ("drm/amd/amdgpu: Fix missing error return on kzalloc failure")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

index 459a5af3a99ac6e12fbb50a8fe38eba318eed603..cbee5c6cdb36933bb18f7bb0de955aa08838f03e 100644 (file)
@@ -697,8 +697,13 @@ static void psp_prep_tmr_cmd_buf(struct psp_context *psp,
                                 uint64_t tmr_mc, struct amdgpu_bo *tmr_bo)
 {
        struct amdgpu_device *adev = psp->adev;
-       uint32_t size = amdgpu_bo_size(tmr_bo);
-       uint64_t tmr_pa = amdgpu_gmc_vram_pa(adev, tmr_bo);
+       uint32_t size = 0;
+       uint64_t tmr_pa = 0;
+
+       if (tmr_bo) {
+               size = amdgpu_bo_size(tmr_bo);
+               tmr_pa = amdgpu_gmc_vram_pa(adev, tmr_bo);
+       }
 
        if (amdgpu_sriov_vf(psp->adev))
                cmd->cmd_id = GFX_CMD_ID_SETUP_VMR;
@@ -743,6 +748,16 @@ static int psp_load_toc(struct psp_context *psp,
        return ret;
 }
 
+static bool psp_boottime_tmr(struct psp_context *psp)
+{
+       switch (psp->adev->ip_versions[MP0_HWIP][0]) {
+       case IP_VERSION(13, 0, 6):
+               return true;
+       default:
+               return false;
+       }
+}
+
 /* Set up Trusted Memory Region */
 static int psp_tmr_init(struct psp_context *psp)
 {
@@ -810,8 +825,9 @@ static int psp_tmr_load(struct psp_context *psp)
        cmd = acquire_psp_cmd_buf(psp);
 
        psp_prep_tmr_cmd_buf(psp, cmd, psp->tmr_mc_addr, psp->tmr_bo);
-       DRM_INFO("reserve 0x%lx from 0x%llx for PSP TMR\n",
-                amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr);
+       if (psp->tmr_bo)
+               DRM_INFO("reserve 0x%lx from 0x%llx for PSP TMR\n",
+                        amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr);
 
        ret = psp_cmd_submit_buf(psp, NULL, cmd,
                                 psp->fence_buf_mc_addr);
@@ -2098,10 +2114,12 @@ static int psp_hw_start(struct psp_context *psp)
        if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev))
                goto skip_pin_bo;
 
-       ret = psp_tmr_init(psp);
-       if (ret) {
-               DRM_ERROR("PSP tmr init failed!\n");
-               return ret;
+       if (!psp_boottime_tmr(psp)) {
+               ret = psp_tmr_init(psp);
+               if (ret) {
+                       DRM_ERROR("PSP tmr init failed!\n");
+                       return ret;
+               }
        }
 
 skip_pin_bo: