drm/amdgpu: use error label to handle exceptional case
Subsystems (2)
PATCH 1/1 drm/amdgpu: use error label to handle exceptional case
Use error label to decrease global item unref and make codes more readable.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13 -9
@@ -89,10 +89,10 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) global_ref->init = &amdgpu_ttm_mem_global_init; global_ref->release = &amdgpu_ttm_mem_global_release; r =drm_global_item_ref (global_ref); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM memory accounting " "subsystem.\n" ); -return r; + goto error_mem; } adev->mman.bo_global_ref.mem_glob =
@@ -103,26 +103,30 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) global_ref->init = &ttm_bo_global_init; global_ref->release = &ttm_bo_global_release; r =drm_global_item_ref (global_ref); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM BO subsystem.\n" ); -drm_global_item_unref (&adev->mman.mem_global_ref); -return r; + goto error_bo; } ring = adev->mman.buffer_funcs_ring; rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL ]; r =amd_sched_entity_init (&ring->sched, &adev->mman.entity, rq, amdgpu_sched_jobs); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM BO move run queue.\n" ); -drm_global_item_unref (&adev->mman.mem_global_ref); -drm_global_item_unref (&adev->mman.bo_global_ref.ref); -return r; + goto error_entity; } adev->mman.mem_global_referenced = true;return 0 ; + +error_entity: +drm_global_item_unref (&adev->mman.bo_global_ref.ref); +error_bo: +drm_global_item_unref (&adev->mman.mem_global_ref); +error_mem: +return r; }static void amdgpu_ttm_global_fini (struct amdgpu_device *adev)
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): 1473414607-19904-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org
Am 09.09.2016 um 11:50 schrieb Huang Rui:
Quoted 4 lines
Use error label to decrease global item unref and make codes more readable.
Signed-off-by Huang Rui <[email protected]>
Nice cleanup, please keep going with that. Probably more than once case where we have things like this.
Patch is Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
Quoted 49 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6
-9@@ -89,10 +89,10 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) global_ref->init = &amdgpu_ttm_mem_global_init; global_ref->release = &amdgpu_ttm_mem_global_release; r =drm_global_item_ref (global_ref); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM memory accounting " "subsystem.\n" ); -return r; + goto error_mem; } adev->mman.bo_global_ref.mem_glob =@@ -103,26 +103,30 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) global_ref->init = &ttm_bo_global_init; global_ref->release = &ttm_bo_global_release; r =drm_global_item_ref (global_ref); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM BO subsystem.\n" ); -drm_global_item_unref (&adev->mman.mem_global_ref); -return r; + goto error_bo; } ring = adev->mman.buffer_funcs_ring; rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL ]; r =amd_sched_entity_init (&ring->sched, &adev->mman.entity, rq, amdgpu_sched_jobs); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM BO move run queue.\n" ); -drm_global_item_unref (&adev->mman.mem_global_ref); -drm_global_item_unref (&adev->mman.bo_global_ref.ref); -return r; + goto error_entity; } adev->mman.mem_global_referenced = true;return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_global_init(struct amdgpu_device *adev) · line 132
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +7
-0+ +error_entity: +drm_global_item_unref (&adev->mman.bo_global_ref.ref); +error_bo: +drm_global_item_unref (&adev->mman.mem_global_ref); +error_mem: +return r; }static void amdgpu_ttm_global_fini (struct amdgpu_device *adev)
_______________________________________________
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): c125876f-8a96-bb6f-21ed-0f2a98876054-5C7GfCeVMHo@public.gmane.org
Edward O'Callaghan
Reviewed-byQuoted 8 lines · Christian König
Am 09.09.2016 um 11:50 schrieb Huang Rui:
Quoted 4 lines
Use error label to decrease global item unref and make codes more readable.
Signed-off-by Huang Rui <[email protected]>Nice cleanup, please keep going with that. Probably more than once case where we have things like this.
Definitely !
Quoted 2 lines
Patch is Reviewed-by: Christian König <[email protected]>.
Quoted 59 lines
Regards,
Christian.Quoted 55 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13
-9@@ -89,10 +89,10 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) global_ref->init = &amdgpu_ttm_mem_global_init; global_ref->release = &amdgpu_ttm_mem_global_release; r =drm_global_item_ref (global_ref); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM memory accounting " "subsystem.\n" ); -return r; + goto error_mem; } adev->mman.bo_global_ref.mem_glob =@@ -103,26 +103,30 @@ int amdgpu_ttm_global_init(struct amdgpu_device *adev) global_ref->init = &ttm_bo_global_init; global_ref->release = &ttm_bo_global_release; r =drm_global_item_ref (global_ref); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM BO subsystem.\n" ); -drm_global_item_unref (&adev->mman.mem_global_ref); -return r; + goto error_bo; } ring = adev->mman.buffer_funcs_ring; rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_KERNEL ]; r =amd_sched_entity_init (&ring->sched, &adev->mman.entity, rq, amdgpu_sched_jobs); -if (r !=0 ) { +if (r) {DRM_ERROR ("Failed setting up TTM BO move run queue.\n" ); -drm_global_item_unref (&adev->mman.mem_global_ref); -drm_global_item_unref (&adev->mman.bo_global_ref.ref); -return r; + goto error_entity; } adev->mman.mem_global_referenced = true;return 0 ; + +error_entity: +drm_global_item_unref (&adev->mman.bo_global_ref.ref); +error_bo: +drm_global_item_unref (&adev->mman.mem_global_ref); +error_mem: +return r;
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_global_init(struct amdgpu_device *adev) · line 132
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0
-0}static void amdgpu_ttm_global_fini (struct amdgpu_device *adev)_______________________________________________
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