All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on hw_init failure
@ 2019-03-18  2:42 Evan Quan
       [not found] ` <20190318024208.17792-1-evan.quan-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Evan Quan @ 2019-03-18  2:42 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Evan Quan

As the cleanup jobs performed in pre_fini may still need these
buffers. NULL pointer dereference will be triggered without them.

Change-Id: I398efd652584e022debf237950207199a4ea78fc
Signed-off-by: Evan Quan <evan.quan@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 31 ++++++++++---------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 5888e24219d9..2206bb4b0903 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -890,59 +890,52 @@ static int psp_load_fw(struct amdgpu_device *adev)
 					&psp->fence_buf_mc_addr,
 					&psp->fence_buf);
 	if (ret)
-		goto failed_mem2;
+		goto failed;
 
 	ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE, PAGE_SIZE,
 				      AMDGPU_GEM_DOMAIN_VRAM,
 				      &psp->cmd_buf_bo, &psp->cmd_buf_mc_addr,
 				      (void **)&psp->cmd_buf_mem);
 	if (ret)
-		goto failed_mem1;
+		goto failed;
 
 	memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE);
 
 	ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
 	if (ret) {
 		DRM_ERROR("PSP ring init failed!\n");
-		goto failed_mem;
+		goto failed;
 	}
 
 	ret = psp_tmr_init(psp);
 	if (ret) {
 		DRM_ERROR("PSP tmr init failed!\n");
-		goto failed_mem;
+		goto failed;
 	}
 
 	ret = psp_asd_init(psp);
 	if (ret) {
 		DRM_ERROR("PSP asd init failed!\n");
-		goto failed_mem;
+		goto failed;
 	}
 
 skip_memalloc:
 	ret = psp_hw_start(psp);
 	if (ret)
-		goto failed_mem;
+		goto failed;
 
 	ret = psp_np_fw_load(psp);
 	if (ret)
-		goto failed_mem;
+		goto failed;
 
 	return 0;
 
-failed_mem:
-	amdgpu_bo_free_kernel(&psp->cmd_buf_bo,
-			      &psp->cmd_buf_mc_addr,
-			      (void **)&psp->cmd_buf_mem);
-failed_mem1:
-	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
-			      &psp->fence_buf_mc_addr, &psp->fence_buf);
-failed_mem2:
-	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
-			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
 failed:
-	kfree(psp->cmd);
-	psp->cmd = NULL;
+	/*
+	 * all cleanup jobs (xgmi terminate, ras terminate,
+	 * ring destroy, cmd/fence/fw buffers destory,
+	 * psp->cmd destory) are delayed to psp_hw_fini
+	 */
 	return ret;
 }
 
-- 
2.21.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on hw_init failure
       [not found] ` <20190318024208.17792-1-evan.quan-5C7GfCeVMHo@public.gmane.org>
@ 2019-03-22  8:36   ` Quan, Evan
  2019-03-22  8:56   ` Xu, Feifei
  1 sibling, 0 replies; 4+ messages in thread
From: Quan, Evan @ 2019-03-22  8:36 UTC (permalink / raw)
  To: Quan, Evan, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Ping..

> -----Original Message-----
> From: Evan Quan <evan.quan@amd.com>
> Sent: 2019年3月18日 10:42
> To: amd-gfx@lists.freedesktop.org
> Cc: Quan, Evan <Evan.Quan@amd.com>
> Subject: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on
> hw_init failure
> 
> As the cleanup jobs performed in pre_fini may still need these buffers. NULL
> pointer dereference will be triggered without them.
> 
> Change-Id: I398efd652584e022debf237950207199a4ea78fc
> Signed-off-by: Evan Quan <evan.quan@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 31 ++++++++++--------------
> -
>  1 file changed, 12 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 5888e24219d9..2206bb4b0903 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -890,59 +890,52 @@ static int psp_load_fw(struct amdgpu_device
> *adev)
>  					&psp->fence_buf_mc_addr,
>  					&psp->fence_buf);
>  	if (ret)
> -		goto failed_mem2;
> +		goto failed;
> 
>  	ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE,
> PAGE_SIZE,
>  				      AMDGPU_GEM_DOMAIN_VRAM,
>  				      &psp->cmd_buf_bo, &psp-
> >cmd_buf_mc_addr,
>  				      (void **)&psp->cmd_buf_mem);
>  	if (ret)
> -		goto failed_mem1;
> +		goto failed;
> 
>  	memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE);
> 
>  	ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
>  	if (ret) {
>  		DRM_ERROR("PSP ring init failed!\n");
> -		goto failed_mem;
> +		goto failed;
>  	}
> 
>  	ret = psp_tmr_init(psp);
>  	if (ret) {
>  		DRM_ERROR("PSP tmr init failed!\n");
> -		goto failed_mem;
> +		goto failed;
>  	}
> 
>  	ret = psp_asd_init(psp);
>  	if (ret) {
>  		DRM_ERROR("PSP asd init failed!\n");
> -		goto failed_mem;
> +		goto failed;
>  	}
> 
>  skip_memalloc:
>  	ret = psp_hw_start(psp);
>  	if (ret)
> -		goto failed_mem;
> +		goto failed;
> 
>  	ret = psp_np_fw_load(psp);
>  	if (ret)
> -		goto failed_mem;
> +		goto failed;
> 
>  	return 0;
> 
> -failed_mem:
> -	amdgpu_bo_free_kernel(&psp->cmd_buf_bo,
> -			      &psp->cmd_buf_mc_addr,
> -			      (void **)&psp->cmd_buf_mem);
> -failed_mem1:
> -	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
> -			      &psp->fence_buf_mc_addr, &psp->fence_buf);
> -failed_mem2:
> -	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
> -			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
>  failed:
> -	kfree(psp->cmd);
> -	psp->cmd = NULL;
> +	/*
> +	 * all cleanup jobs (xgmi terminate, ras terminate,
> +	 * ring destroy, cmd/fence/fw buffers destory,
> +	 * psp->cmd destory) are delayed to psp_hw_fini
> +	 */
>  	return ret;
>  }
> 
> --
> 2.21.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on hw_init failure
       [not found] ` <20190318024208.17792-1-evan.quan-5C7GfCeVMHo@public.gmane.org>
  2019-03-22  8:36   ` Quan, Evan
@ 2019-03-22  8:56   ` Xu, Feifei
       [not found]     ` <BYAPR12MB3048705E0C7567603C1D804AFE430-ZGDeBxoHBPnONjofGsFOUAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Xu, Feifei @ 2019-03-22  8:56 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Quan, Evan

 Have you tested in S3 and gpu_recovery?

If yes. Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>

-----Original Message-----
From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Evan Quan
Sent: Monday, March 18, 2019 10:42 AM
To: amd-gfx@lists.freedesktop.org
Cc: Quan, Evan <Evan.Quan@amd.com>
Subject: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on hw_init failure

As the cleanup jobs performed in pre_fini may still need these buffers. NULL pointer dereference will be triggered without them.

Change-Id: I398efd652584e022debf237950207199a4ea78fc
Signed-off-by: Evan Quan <evan.quan@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 31 ++++++++++---------------
 1 file changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 5888e24219d9..2206bb4b0903 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -890,59 +890,52 @@ static int psp_load_fw(struct amdgpu_device *adev)
 					&psp->fence_buf_mc_addr,
 					&psp->fence_buf);
 	if (ret)
-		goto failed_mem2;
+		goto failed;
 
 	ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE, PAGE_SIZE,
 				      AMDGPU_GEM_DOMAIN_VRAM,
 				      &psp->cmd_buf_bo, &psp->cmd_buf_mc_addr,
 				      (void **)&psp->cmd_buf_mem);
 	if (ret)
-		goto failed_mem1;
+		goto failed;
 
 	memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE);
 
 	ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
 	if (ret) {
 		DRM_ERROR("PSP ring init failed!\n");
-		goto failed_mem;
+		goto failed;
 	}
 
 	ret = psp_tmr_init(psp);
 	if (ret) {
 		DRM_ERROR("PSP tmr init failed!\n");
-		goto failed_mem;
+		goto failed;
 	}
 
 	ret = psp_asd_init(psp);
 	if (ret) {
 		DRM_ERROR("PSP asd init failed!\n");
-		goto failed_mem;
+		goto failed;
 	}
 
 skip_memalloc:
 	ret = psp_hw_start(psp);
 	if (ret)
-		goto failed_mem;
+		goto failed;
 
 	ret = psp_np_fw_load(psp);
 	if (ret)
-		goto failed_mem;
+		goto failed;
 
 	return 0;
 
-failed_mem:
-	amdgpu_bo_free_kernel(&psp->cmd_buf_bo,
-			      &psp->cmd_buf_mc_addr,
-			      (void **)&psp->cmd_buf_mem);
-failed_mem1:
-	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
-			      &psp->fence_buf_mc_addr, &psp->fence_buf);
-failed_mem2:
-	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
-			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
 failed:
-	kfree(psp->cmd);
-	psp->cmd = NULL;
+	/*
+	 * all cleanup jobs (xgmi terminate, ras terminate,
+	 * ring destroy, cmd/fence/fw buffers destory,
+	 * psp->cmd destory) are delayed to psp_hw_fini
+	 */
 	return ret;
 }
 
--
2.21.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on hw_init failure
       [not found]     ` <BYAPR12MB3048705E0C7567603C1D804AFE430-ZGDeBxoHBPnONjofGsFOUAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
@ 2019-03-22  9:31       ` Quan, Evan
  0 siblings, 0 replies; 4+ messages in thread
From: Quan, Evan @ 2019-03-22  9:31 UTC (permalink / raw)
  To: Xu, Feifei, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This affects hw_init only. It's not on the path of S3/resume and gpu_recovery/resume.
So, they are not affected.


Regards,
Evan
> -----Original Message-----
> From: Xu, Feifei
> Sent: 2019年3月22日 16:56
> To: Quan, Evan <Evan.Quan@amd.com>; amd-gfx@lists.freedesktop.org
> Cc: Quan, Evan <Evan.Quan@amd.com>
> Subject: RE: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on
> hw_init failure
> 
>  Have you tested in S3 and gpu_recovery?
> 
> If yes. Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
> 
> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Evan
> Quan
> Sent: Monday, March 18, 2019 10:42 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Quan, Evan <Evan.Quan@amd.com>
> Subject: [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on
> hw_init failure
> 
> As the cleanup jobs performed in pre_fini may still need these buffers. NULL
> pointer dereference will be triggered without them.
> 
> Change-Id: I398efd652584e022debf237950207199a4ea78fc
> Signed-off-by: Evan Quan <evan.quan@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 31 ++++++++++--------------
> -
>  1 file changed, 12 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> index 5888e24219d9..2206bb4b0903 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
> @@ -890,59 +890,52 @@ static int psp_load_fw(struct amdgpu_device
> *adev)
>  					&psp->fence_buf_mc_addr,
>  					&psp->fence_buf);
>  	if (ret)
> -		goto failed_mem2;
> +		goto failed;
> 
>  	ret = amdgpu_bo_create_kernel(adev, PSP_CMD_BUFFER_SIZE,
> PAGE_SIZE,
>  				      AMDGPU_GEM_DOMAIN_VRAM,
>  				      &psp->cmd_buf_bo, &psp-
> >cmd_buf_mc_addr,
>  				      (void **)&psp->cmd_buf_mem);
>  	if (ret)
> -		goto failed_mem1;
> +		goto failed;
> 
>  	memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE);
> 
>  	ret = psp_ring_init(psp, PSP_RING_TYPE__KM);
>  	if (ret) {
>  		DRM_ERROR("PSP ring init failed!\n");
> -		goto failed_mem;
> +		goto failed;
>  	}
> 
>  	ret = psp_tmr_init(psp);
>  	if (ret) {
>  		DRM_ERROR("PSP tmr init failed!\n");
> -		goto failed_mem;
> +		goto failed;
>  	}
> 
>  	ret = psp_asd_init(psp);
>  	if (ret) {
>  		DRM_ERROR("PSP asd init failed!\n");
> -		goto failed_mem;
> +		goto failed;
>  	}
> 
>  skip_memalloc:
>  	ret = psp_hw_start(psp);
>  	if (ret)
> -		goto failed_mem;
> +		goto failed;
> 
>  	ret = psp_np_fw_load(psp);
>  	if (ret)
> -		goto failed_mem;
> +		goto failed;
> 
>  	return 0;
> 
> -failed_mem:
> -	amdgpu_bo_free_kernel(&psp->cmd_buf_bo,
> -			      &psp->cmd_buf_mc_addr,
> -			      (void **)&psp->cmd_buf_mem);
> -failed_mem1:
> -	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
> -			      &psp->fence_buf_mc_addr, &psp->fence_buf);
> -failed_mem2:
> -	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
> -			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
>  failed:
> -	kfree(psp->cmd);
> -	psp->cmd = NULL;
> +	/*
> +	 * all cleanup jobs (xgmi terminate, ras terminate,
> +	 * ring destroy, cmd/fence/fw buffers destory,
> +	 * psp->cmd destory) are delayed to psp_hw_fini
> +	 */
>  	return ret;
>  }
> 
> --
> 2.21.0
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-22  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18  2:42 [PATCH] drm/amdgpu: defer cmd/fence/fw buffers destroy on hw_init failure Evan Quan
     [not found] ` <20190318024208.17792-1-evan.quan-5C7GfCeVMHo@public.gmane.org>
2019-03-22  8:36   ` Quan, Evan
2019-03-22  8:56   ` Xu, Feifei
     [not found]     ` <BYAPR12MB3048705E0C7567603C1D804AFE430-ZGDeBxoHBPnONjofGsFOUAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-03-22  9:31       ` Quan, Evan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.