From patchwork Wed Nov 21 15:33:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 1781421 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id B36A83FCA5 for ; Wed, 21 Nov 2012 15:34:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755202Ab2KUPd4 (ORCPT ); Wed, 21 Nov 2012 10:33:56 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:31446 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755145Ab2KUPdy (ORCPT ); Wed, 21 Nov 2012 10:33:54 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDU007LOGK5H700@mailout1.samsung.com> for linux-media@vger.kernel.org; Thu, 22 Nov 2012 00:33:53 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-79-50acf4616adf Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 32.4C.12699.164FCA05; Thu, 22 Nov 2012 00:33:53 +0900 (KST) Received: from amdc1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDU007TRGK1BY80@mmp1.samsung.com> for linux-media@vger.kernel.org; Thu, 22 Nov 2012 00:33:53 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: sw0312.kim@samsung.com, Sylwester Nawrocki , Kyungmin Park Subject: [PATCH] s5p-fimc: Don't use mutex_lock_interruptible() in device release() Date: Wed, 21 Nov 2012 16:33:35 +0100 Message-id: <1353512015-15850-2-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1353512015-15850-1-git-send-email-s.nawrocki@samsung.com> References: <1353512015-15850-1-git-send-email-s.nawrocki@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIJMWRmVeSWpSXmKPExsVy+t9jAd3EL2sCDDpWmln0bNjK6sDo8XmT XABjFJdNSmpOZllqkb5dAlfGsy/T2Aqmi1Sc3faSpYFxp2AXIyeHhICJxMuTjUwQtpjEhXvr 2boYuTiEBBYxSlx5OpcZwlnBJPHly15mkCo2AUOJ3qN9jCC2iIC8xJPeG2wgNrNAicT0NR/A JgkLhEq0HjzKAmKzCKhKTF5ykBXE5hVwk9j7qBcozgG0TUFiziQbkDCngLvEuj07wcYIAZXM /rGPfQIj7wJGhlWMoqkFyQXFSem5RnrFibnFpXnpesn5uZsYwR5/Jr2DcVWDxSFGAQ5GJR5e iX2rA4RYE8uKK3MPMUpwMCuJ8O54uCZAiDclsbIqtSg/vqg0J7X4EKM0B4uSOG+zR0qAkEB6 YklqdmpqQWoRTJaJg1OqgbH08NuXV37bGyaUpi59sN341TrWprLcs6wfU2b2KPGICaxWP5TH 3tzQPVeDlTeqOPzJky49g/PSMgfZjI7zfYl/kO43Vdgir0VlauXj8tBgBQf2wF9+p2tKL8xy Lm+/eMB4edKjj+2SJUpv0m0mKDx9lOX/P+fpqxdmu3j+1Erwr5CrCg53UmIpzkg01GIuKk4E AP9WYTf0AQAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Use uninterruptible mutex_lock in the release() file op to make sure all resources are properly freed when a process is being terminated. Returning -ERESTARTSYS has no effect for a terminating process and this caused driver resources no to be released. Not releasing the buffer queue also prevented other drivers to free memory, e.g. in MMAP -> USERPTR scenario. Reported-by: Kamil Debski Reported-by: Marek Szyprowski Signed-off-by: Sylwester Nawrocki Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-fimc/fimc-capture.c | 3 +-- drivers/media/platform/s5p-fimc/fimc-lite.c | 3 +-- drivers/media/platform/s5p-fimc/fimc-m2m.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c index 3d39d97..e10d6b1 100644 --- a/drivers/media/platform/s5p-fimc/fimc-capture.c +++ b/drivers/media/platform/s5p-fimc/fimc-capture.c @@ -556,8 +556,7 @@ static int fimc_capture_close(struct file *file) dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); - if (mutex_lock_interruptible(&fimc->lock)) - return -ERESTARTSYS; + mutex_lock(&fimc->lock); if (--fimc->vid_cap.refcnt == 0) { clear_bit(ST_CAPT_BUSY, &fimc->state); diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c b/drivers/media/platform/s5p-fimc/fimc-lite.c index 9db246b..2f0a39b 100644 --- a/drivers/media/platform/s5p-fimc/fimc-lite.c +++ b/drivers/media/platform/s5p-fimc/fimc-lite.c @@ -491,8 +491,7 @@ static int fimc_lite_close(struct file *file) struct fimc_lite *fimc = video_drvdata(file); int ret; - if (mutex_lock_interruptible(&fimc->lock)) - return -ERESTARTSYS; + mutex_lock(&fimc->lock); if (--fimc->ref_count == 0 && fimc->out_path == FIMC_IO_DMA) { clear_bit(ST_FLITE_IN_USE, &fimc->state); diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c b/drivers/media/platform/s5p-fimc/fimc-m2m.c index 4c4e901..dbb7385 100644 --- a/drivers/media/platform/s5p-fimc/fimc-m2m.c +++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c @@ -718,8 +718,7 @@ static int fimc_m2m_release(struct file *file) dbg("pid: %d, state: 0x%lx, refcnt= %d", task_pid_nr(current), fimc->state, fimc->m2m.refcnt); - if (mutex_lock_interruptible(&fimc->lock)) - return -ERESTARTSYS; + mutex_lock(&fimc->lock); v4l2_m2m_ctx_release(ctx->m2m_ctx); fimc_ctrls_delete(ctx);