From: Stanislav Vorobiov Date: Tue, 30 Apr 2013 13:10:46 +0000 (+0400) Subject: VIGS: Potential deadlock fixed X-Git-Tag: submit/tizen_common/20140905.094502~117^2~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d482c0ec28441d1ffdaf81d8ef209619a9852a88;p=sdk%2Femulator%2Femulator-kernel.git VIGS: Potential deadlock fixed Change-Id: I6e7bfc824fc637bcc77896919c504da17eddfe2b --- diff --git a/drivers/gpu/drm/vigs/vigs_device.c b/drivers/gpu/drm/vigs/vigs_device.c index aabead480eb5..c1a027fecfbd 100644 --- a/drivers/gpu/drm/vigs/vigs_device.c +++ b/drivers/gpu/drm/vigs/vigs_device.c @@ -9,21 +9,22 @@ #include "vigs_surface.h" #include -/* - * Must be called with drm_device::struct_mutex held. - */ static struct vigs_surface - *vigs_device_reference_surface(struct vigs_device *vigs_dev, - vigsp_surface_id sfc_id) + *vigs_device_reference_surface_unlocked(struct vigs_device *vigs_dev, + vigsp_surface_id sfc_id) { struct vigs_surface *sfc; + mutex_lock(&vigs_dev->drm_dev->struct_mutex); + sfc = idr_find(&vigs_dev->surface_idr, sfc_id); if (sfc) { drm_gem_object_reference(&sfc->gem.base); } + mutex_unlock(&vigs_dev->drm_dev->struct_mutex); + return sfc; } @@ -45,8 +46,6 @@ static int vigs_device_patch_commands(struct vigs_device *vigs_dev, struct vigs_surface *sfc; int ret = 0; - mutex_lock(&vigs_dev->drm_dev->struct_mutex); - /* * GEM is always at least PAGE_SIZE long, so don't check * if batch header is out of bounds. @@ -71,7 +70,7 @@ static int vigs_device_patch_commands(struct vigs_device *vigs_dev, case vigsp_cmd_update_vram: update_vram_request = (struct vigsp_cmd_update_vram_request*)(request_header + 1); - sfc = vigs_device_reference_surface(vigs_dev, update_vram_request->sfc_id); + sfc = vigs_device_reference_surface_unlocked(vigs_dev, update_vram_request->sfc_id); if (!sfc) { DRM_ERROR("Surface %u not found\n", update_vram_request->sfc_id); ret = -EINVAL; @@ -88,7 +87,7 @@ static int vigs_device_patch_commands(struct vigs_device *vigs_dev, case vigsp_cmd_update_gpu: update_gpu_request = (struct vigsp_cmd_update_gpu_request*)(request_header + 1); - sfc = vigs_device_reference_surface(vigs_dev, update_gpu_request->sfc_id); + sfc = vigs_device_reference_surface_unlocked(vigs_dev, update_gpu_request->sfc_id); if (!sfc) { DRM_ERROR("Surface %u not found\n", update_gpu_request->sfc_id); ret = -EINVAL; @@ -111,8 +110,6 @@ static int vigs_device_patch_commands(struct vigs_device *vigs_dev, request_header->size); } - mutex_unlock(&vigs_dev->drm_dev->struct_mutex); - return 0; }