aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
diff options
context:
space:
mode:
authorKent Russell <kent.russell@amd.com>2017-08-15 23:00:07 -0400
committerOded Gabbay <oded.gabbay@gmail.com>2017-08-15 23:00:07 -0400
commitab7c16486707f86264c73b043327c70866236722 (patch)
treedafd848eab599c334f131167871ba9d83381ff0b /drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
parentdrm/amdkfd: Change x==NULL/false references to !x (diff)
downloadlinux-dev-ab7c16486707f86264c73b043327c70866236722.tar.xz
linux-dev-ab7c16486707f86264c73b043327c70866236722.zip
drm/amdkfd: Fix goto usage v2
Remove gotos that do not feature any common cleanup, and use gotos instead of repeating cleanup commands. According to kernel.org: "The goto statement comes in handy when a function exits from multiple locations and some common work such as cleanup has to be done. If there is no cleanup needed then just return directly." v2: Applied review suggestions in create_queue_nocpsch Signed-off-by: Kent Russell <kent.russell@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c')
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
index f3b8cc8ea265..c4030b37c2f0 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_packet_manager.c
@@ -442,6 +442,7 @@ int pm_send_set_resources(struct packet_manager *pm,
struct scheduling_resources *res)
{
struct pm4_set_resources *packet;
+ int retval = 0;
BUG_ON(!pm || !res);
@@ -450,9 +451,9 @@ int pm_send_set_resources(struct packet_manager *pm,
sizeof(*packet) / sizeof(uint32_t),
(unsigned int **)&packet);
if (!packet) {
- mutex_unlock(&pm->lock);
pr_err("Failed to allocate buffer on kernel queue\n");
- return -ENOMEM;
+ retval = -ENOMEM;
+ goto out;
}
memset(packet, 0, sizeof(struct pm4_set_resources));
@@ -475,9 +476,10 @@ int pm_send_set_resources(struct packet_manager *pm,
pm->priv_queue->ops.submit_packet(pm->priv_queue);
+out:
mutex_unlock(&pm->lock);
- return 0;
+ return retval;
}
int pm_send_runlist(struct packet_manager *pm, struct list_head *dqm_queues)
@@ -555,9 +557,6 @@ int pm_send_query_status(struct packet_manager *pm, uint64_t fence_address,
packet->data_lo = lower_32_bits((uint64_t)fence_value);
pm->priv_queue->ops.submit_packet(pm->priv_queue);
- mutex_unlock(&pm->lock);
-
- return 0;
fail_acquire_packet_buffer:
mutex_unlock(&pm->lock);
@@ -639,9 +638,6 @@ int pm_send_unmap_queue(struct packet_manager *pm, enum kfd_queue_type type,
pm->priv_queue->ops.submit_packet(pm->priv_queue);
- mutex_unlock(&pm->lock);
- return 0;
-
err_acquire_packet_buffer:
mutex_unlock(&pm->lock);
return retval;