From 103db99decb643c852c08f975e4df38647572355 Mon Sep 17 00:00:00 2001 From: Fei Jiang Date: Thu, 19 Apr 2012 23:05:29 +0800 Subject: [PATCH] kernel-drm: remove duplicated down_read to mmap_sem and add DRM_UNLOCKED flag for all video related ioctls. BZ: 29375 DRM big mutex has big impact to the video performance and maybe trigger dead lock issue. Change-Id: I7943f113009ae5d9a6206c4bf23728d06c2831af Reviewed-on: http://android.intel.com:8080/44098 Reviewed-by: Jiang, Fei Reviewed-by: buildbot Reviewed-by: Ding, Haitao Tested-by: Ding, Haitao --- drivers/gpu/drm/ttm/ttm_tt.c | 9 ++++++--- drivers/staging/mrst/drv/psb_drv.c | 18 +++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index 0b6188f..8067600 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -464,10 +464,12 @@ static int alloc_user_pages_ttm(struct ttm_tt *ttm, * and map to user space */ if (vma->vm_flags & (VM_IO | VM_PFNMAP)) { + down_read(¤t->mm->mmap_sem); page_nr = get_pfnmap_pages(current, current->mm, (unsigned long)userptr, (int)(ttm->num_pages), 1, 0, ttm->pages, NULL); + up_read(¤t->mm->mmap_sem); } else { /*Handle frame buffer allocated in user space*/ down_read(¤t->mm->mmap_sem); @@ -515,19 +517,20 @@ int ttm_tt_set_user(struct ttm_tt *ttm, if (unlikely(ret != 0)) return ret; - down_read(&mm->mmap_sem); - /** * get_user_pages can only handle the buffer allocated from user space, * but we need handle the buffer allocated from other kernel driver */ #if 0 + down_read(&mm->mmap_sem); + ret = get_user_pages(tsk, mm, start, num_pages, write, 0, ttm->pages, NULL); + up_read(&mm->mmap_sem); #else ret = alloc_user_pages_ttm(ttm, start); #endif - up_read(&mm->mmap_sem); + if (ret != num_pages && write) { ttm_tt_free_user_pages(ttm); diff --git a/drivers/staging/mrst/drv/psb_drv.c b/drivers/staging/mrst/drv/psb_drv.c index c89dff8..43024ed 100644 --- a/drivers/staging/mrst/drv/psb_drv.c +++ b/drivers/staging/mrst/drv/psb_drv.c @@ -547,29 +547,29 @@ static struct drm_ioctl_desc psb_ioctls[] = { DRM_AUTH),*/ PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_CREATE, psb_pl_create_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_REFERENCE, psb_pl_reference_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_UNREF, psb_pl_unref_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_SYNCCPU, psb_pl_synccpu_ioctl, DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_WAITIDLE, psb_pl_waitidle_ioctl, DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_SETSTATUS, psb_pl_setstatus_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_PL_CREATE_UB, psb_pl_ub_create_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_FENCE_SIGNALED, - psb_fence_signaled_ioctl, DRM_AUTH), + psb_fence_signaled_ioctl, DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_FENCE_FINISH, psb_fence_finish_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_PSB_TTM_FENCE_UNREF, psb_fence_unref_ioctl, - DRM_AUTH), + DRM_AUTH | DRM_UNLOCKED), /*to be removed later */ /*PSB_IOCTL_DEF(DRM_IOCTL_PSB_FLIP, psb_page_flip, DRM_AUTH),*/ PSB_IOCTL_DEF(DRM_IOCTL_LNC_VIDEO_GETPARAM, - lnc_video_getparam, DRM_AUTH), + lnc_video_getparam, DRM_AUTH | DRM_UNLOCKED), PSB_IOCTL_DEF(DRM_IOCTL_BUFFER_CLASS_VIDEO, BC_Video_Bridge, DRM_AUTH), #endif -- 2.7.4