Commit fd506558 authored by Huang Rui's avatar Huang Rui Committed by Alex Deucher

drm/amdgpu: move some release handles into fail labels (v2)

Clean up the codes to move the release handles into fail labels.

v2: squash in Christian's regression fix
Signed-off-by: default avatarHuang Rui <ray.huang@amd.com>
Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent f166d9f2
...@@ -250,32 +250,25 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) ...@@ -250,32 +250,25 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo); AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
if (err) { if (err) {
dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err); dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
err = -ENOMEM;
goto failed; goto failed;
} }
err = amdgpu_bo_reserve(*bo, false); err = amdgpu_bo_reserve(*bo, false);
if (err) { if (err) {
amdgpu_bo_unref(bo);
dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err); dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
goto failed; goto failed_reserve;
} }
err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr); err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
if (err) { if (err) {
amdgpu_bo_unreserve(*bo);
amdgpu_bo_unref(bo);
dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err); dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
goto failed; goto failed_pin;
} }
err = amdgpu_bo_kmap(*bo, &fw_buf_ptr); err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
if (err) { if (err) {
dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err); dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
amdgpu_bo_unpin(*bo); goto failed_kmap;
amdgpu_bo_unreserve(*bo);
amdgpu_bo_unref(bo);
goto failed;
} }
amdgpu_bo_unreserve(*bo); amdgpu_bo_unreserve(*bo);
...@@ -290,9 +283,15 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev) ...@@ -290,9 +283,15 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); fw_offset += ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
} }
} }
return 0;
failed_kmap:
amdgpu_bo_unpin(*bo);
failed_pin:
amdgpu_bo_unreserve(*bo);
failed_reserve:
amdgpu_bo_unref(bo);
failed: failed:
if (err)
adev->firmware.smu_load = false; adev->firmware.smu_load = false;
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment