Skip to contentSkip to conversation

drm/amdgpu: cleanup amdgpu_cs_ioctl to make code logicality clear

PATCH In review Huang Rui 2 participants 5 messages Oct 31, 2016 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: cleanup amdgpu_cs_ioctl to make code logicality clear

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +16 -16
index 0cb27c3..d73dd1b 100644
@@ -1052,29 +1052,29 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 	r = amdgpu_cs_parser_init(&parser, data);
 	if (r) {
 		DRM_ERROR("Failed to initialize parser !\n");
-		amdgpu_cs_parser_fini(&parser, r, false);
-		r = amdgpu_cs_handle_lockup(adev, r);
-		return r;
-	}
-	r = amdgpu_cs_parser_bos(&parser, data);
-	if (r == -ENOMEM)
-		DRM_ERROR("Not enough memory for command submission!\n");
-	else if (r && r != -ERESTARTSYS)
-		DRM_ERROR("Failed to process the buffer list %d!\n", r);
-	else if (!r) {
-		reserved_buffers = true;
-		r = amdgpu_cs_ib_fill(adev, &parser);
+		goto out;
 	}
 
-	if (!r) {
-		r = amdgpu_cs_dependencies(adev, &parser);
-		if (r)
-			DRM_ERROR("Failed in the dependencies handling %d!\n", r);
+	r = amdgpu_cs_parser_bos(&parser, data);
+	if (r) {
+		if (r == -ENOMEM)
+			DRM_ERROR("Not enough memory for command submission!\n");
+		else if (r != -ERESTARTSYS)
+			DRM_ERROR("Failed to process the buffer list %d!\n", r);
+		goto out;
 	}
 
+	reserved_buffers = true;
+	r = amdgpu_cs_ib_fill(adev, &parser);
 	if (r)
 		goto out;
 
+	r = amdgpu_cs_dependencies(adev, &parser);
+	if (r) {
+		DRM_ERROR("Failed in the dependencies handling %d!\n", r);
+		goto out;
+	}
+
 	for (i = 0; i < parser.job->num_ibs; i++)
 		trace_amdgpu_cs(&parser, i);
 
Signature · 6 lines
2.7.4

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

A message that is not in the archive (sent off-list or not yet received): 1477879680-21488-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 31.10.2016 um 03:08 schrieb Huang Rui:

Quoted 1 line

Looks good to me, patch is Reviewed-by: Christian König <[email protected]>.

BTW: amdgpu_cs_handle_lockup() is a leftover from radeon and can be removed. Would be nice if you can take care of this as well.

Regards,
Christian.

Quoted 44 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 32 ++++++++++++++++----------------
  1 file changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +10 -16
index 0cb27c3..d73dd1b 100644
@@ -1052,29 +1052,29 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
  	r = amdgpu_cs_parser_init(&parser, data);
  	if (r) {
  		DRM_ERROR("Failed to initialize parser !\n");
-		amdgpu_cs_parser_fini(&parser, r, false);
-		r = amdgpu_cs_handle_lockup(adev, r);
-		return r;
-	}
-	r = amdgpu_cs_parser_bos(&parser, data);
-	if (r == -ENOMEM)
-		DRM_ERROR("Not enough memory for command submission!\n");
-	else if (r && r != -ERESTARTSYS)
-		DRM_ERROR("Failed to process the buffer list %d!\n", r);
-	else if (!r) {
-		reserved_buffers = true;
-		r = amdgpu_cs_ib_fill(adev, &parser);
+		goto out;
  	}
 
-	if (!r) {
-		r = amdgpu_cs_dependencies(adev, &parser);
-		if (r)
-			DRM_ERROR("Failed in the dependencies handling %d!\n", r);
+	r = amdgpu_cs_parser_bos(&parser, data);
+	if (r) {
+		if (r == -ENOMEM)
+			DRM_ERROR("Not enough memory for command submission!\n");
+		else if (r != -ERESTARTSYS)
+			DRM_ERROR("Failed to process the buffer list %d!\n", r);
+		goto out;
  	}
 
+	reserved_buffers = true;
+	r = amdgpu_cs_ib_fill(adev, &parser);
  	if (r)
  		goto out;

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1080

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -0
 
+	r = amdgpu_cs_dependencies(adev, &parser);
+	if (r) {
+		DRM_ERROR("Failed in the dependencies handling %d!\n", r);
+		goto out;
+	}
+
  	for (i = 0; i < parser.job->num_ibs; i++)
  		trace_amdgpu_cs(&parser, i);
 

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

A message that is not in the archive (sent off-list or not yet received): 54bf14e1-8a3c-2710-df52-0f9d82f91a90-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#4 lore raw
Quoted 9 lines · Christian König

Am 31.10.2016 um 03:08 schrieb Huang Rui:

Quoted 1 line

Looks good to me, patch is Reviewed-by: Christian König <[email protected]>.

BTW: amdgpu_cs_handle_lockup() is a leftover from radeon and can be removed. Would be nice if you can take care of this as well.

Sure. amdgpu_cs_handle_lockup actually will trigger a gpu reset when r == -EDEADLK. I'm not very clear with why we needn't gpu reset on that case yet, could you explain?

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

#5 lore raw

Am 31.10.2016 um 09:58 schrieb Huang Rui:

Quoted 6 lines · Christian König
Quoted 5 lines

Am 31.10.2016 um 03:08 schrieb Huang Rui:

Quoted 1 line

Looks good to me, patch is Reviewed-by: Christian König <[email protected]>.

Quoted 6 lines
Quoted 3 lines

BTW: amdgpu_cs_handle_lockup() is a leftover from radeon and can be removed. Would be nice if you can take care of this as well.

Sure. amdgpu_cs_handle_lockup actually will trigger a gpu reset when r == -EDEADLK. I'm not very clear with why we needn't gpu reset on that case yet, could you explain?

On radeon the fence wait function returned -EDEADLK when it detected that the hardware is locked up.

In the CS and GEM IOCTLs we then catch this error, reseted the hardware and tried again.

Since we never return -EDEADLK any more we can just drop the handling for this.

Regards,
Christian.

Quoted 3 lines

Thanks,
Rui

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

A message that is not in the archive (sent off-list or not yet received): 34d30f03-b833-ce49-b50b-bf6b81f46886-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#7 lore raw
Quoted 14 lines · Christian K�nig

Am 31.10.2016 um 09:58 schrieb Huang Rui:

Quoted 6 lines · Christian K?nig
Quoted 5 lines

Am 31.10.2016 um 03:08 schrieb Huang Rui:

Quoted 1 line

Looks good to me, patch is Reviewed-by: Christian K?nig <[email protected]>.

Quoted 6 lines
Quoted 3 lines

BTW: amdgpu_cs_handle_lockup() is a leftover from radeon and can be removed. Would be nice if you can take care of this as well.

Sure. amdgpu_cs_handle_lockup actually will trigger a gpu reset when r == -EDEADLK. I'm not very clear with why we needn't gpu reset on that case yet, could you explain?

Quoted 9 lines

On radeon the fence wait function returned -EDEADLK when it detected that the hardware is locked up.

In the CS and GEM IOCTLs we then catch this error, reseted the hardware and tried again.

Since we never return -EDEADLK any more we can just drop the handling for this.

Yep, I see. Thanks to clarify it.

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