Skip to contentSkip to conversation

drm/amdgpu/sriov:now must reinit psp

PATCH In review Monk Liu 2 participants 3 messages Sep 22, 2017 – Sep 26, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/2 drm/amdgpu/sriov:now must reinit psp

otherwise after VF FLR the KIQ cannot work

Change-Id Icb18e794b5e4dccfd70c811c138c7102df874203
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index a86d856..08bc0cf 100644
@@ -1880,6 +1880,7 @@ static int amdgpu_sriov_reinit_late(struct amdgpu_device *adev)
 
 	static enum amd_ip_block_type ip_order[] = {
 		AMD_IP_BLOCK_TYPE_SMC,
+		AMD_IP_BLOCK_TYPE_PSP,
 		AMD_IP_BLOCK_TYPE_DCE,
 		AMD_IP_BLOCK_TYPE_GFX,
 		AMD_IP_BLOCK_TYPE_SDMA,
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#2 lore raw

PATCH 2/2 drm/amdgpu/sriov:fix memory leak in psp_load_fw

In reply to a message not in the archive

when doing gpu reset this routine shouldn't do anything resource allocating otherwise SRIOV gpu reset will cause memory leak

Change-Id I25da3a5b475196c75c7e639adc40751754625968
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +12 -8
index 447d446..52daabc 100644
@@ -334,23 +334,26 @@ static int psp_load_fw(struct amdgpu_device *adev)
 	int ret;
 	struct psp_context *psp = &adev->psp;
 
+	if (amdgpu_sriov_vf(adev) && adev->in_sriov_reset != 0)
+		goto skip_memalloc;
+
 	psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
 	if (!psp->cmd)
 		return -ENOMEM;
 
 	ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
-				      AMDGPU_GEM_DOMAIN_GTT,
-				      &psp->fw_pri_bo,
-				      &psp->fw_pri_mc_addr,
-				      &psp->fw_pri_buf);
+					AMDGPU_GEM_DOMAIN_GTT,
+					&psp->fw_pri_bo,
+					&psp->fw_pri_mc_addr,
+					&psp->fw_pri_buf);
 	if (ret)
 		goto failed;
 
 	ret = amdgpu_bo_create_kernel(adev, PSP_FENCE_BUFFER_SIZE, PAGE_SIZE,
-				      AMDGPU_GEM_DOMAIN_VRAM,
-				      &psp->fence_buf_bo,
-				      &psp->fence_buf_mc_addr,
-				      &psp->fence_buf);
+					AMDGPU_GEM_DOMAIN_VRAM,
+					&psp->fence_buf_bo,
+					&psp->fence_buf_mc_addr,
+					&psp->fence_buf);
 	if (ret)
 		goto failed_mem2;
 
@@ -375,6 +378,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
 	if (ret)
 		goto failed_mem;
 
+skip_memalloc:
 	ret = psp_hw_start(psp);
 	if (ret)
 		goto failed_mem;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#4 lore raw

Re: [PATCH 2/2] drm/amdgpu/sriov:fix memory leak in psp_load_fw

In reply to a message not in the archive
Quoted 6 lines · Monk Liu

when doing gpu reset this routine shouldn't do anything resource allocating otherwise SRIOV gpu reset will cause memory leak

Change-Id I25da3a5b475196c75c7e639adc40751754625968

A couple of comments below. With those fixed, series is:

Quoted 18 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -0
index 447d446..52daabc 100644
@@ -334,23 +334,26 @@ static int psp_load_fw(struct amdgpu_device *adev)
        int ret;
        struct psp_context *psp = &adev->psp;
 
+       if (amdgpu_sriov_vf(adev) && adev->in_sriov_reset != 0)
+               goto skip_memalloc;
+
        psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL);
        if (!psp->cmd)
                return -ENOMEM;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 348

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -4
 
        ret = amdgpu_bo_create_kernel(adev, PSP_1_MEG, PSP_1_MEG,
-                                     AMDGPU_GEM_DOMAIN_GTT,
-                                     &psp->fw_pri_bo,
-                                     &psp->fw_pri_mc_addr,
-                                     &psp->fw_pri_buf);
+                                       AMDGPU_GEM_DOMAIN_GTT,
+                                       &psp->fw_pri_bo,
+                                       &psp->fw_pri_mc_addr,
+                                       &psp->fw_pri_buf);

drop whitespace change.

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_load_fw(struct amdgpu_device *adev) · line 356

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -4
        if (ret)
                goto failed;
 
        ret = amdgpu_bo_create_kernel(adev, PSP_FENCE_BUFFER_SIZE, PAGE_SIZE,
-                                     AMDGPU_GEM_DOMAIN_VRAM,
-                                     &psp->fence_buf_bo,
-                                     &psp->fence_buf_mc_addr,
-                                     &psp->fence_buf);
+                                       AMDGPU_GEM_DOMAIN_VRAM,
+                                       &psp->fence_buf_bo,
+                                       &psp->fence_buf_mc_addr,
+                                       &psp->fence_buf);

Same here.

Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
        if (ret)
                goto failed_mem2;
 
@@ -375,6 +378,7 @@ static int psp_load_fw(struct amdgpu_device *adev)
        if (ret)
                goto failed_mem;
 
+skip_memalloc:
        ret = psp_hw_start(psp);
        if (ret)
                goto failed_mem;
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx