From patchwork Tue Nov 19 14:26:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3202481 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5FB0D9F3A0 for ; Tue, 19 Nov 2013 14:28:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B92920373 for ; Tue, 19 Nov 2013 14:28:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DC95620318 for ; Tue, 19 Nov 2013 14:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752996Ab3KSO1w (ORCPT ); Tue, 19 Nov 2013 09:27:52 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:55604 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752726Ab3KSO1t (ORCPT ); Tue, 19 Nov 2013 09:27:49 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWI00M2MLI2NH40@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Nov 2013 23:27:48 +0900 (KST) X-AuditID: cbfee61a-b7f836d0000025d7-bd-528b7564c703 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A6.B8.09687.4657B825; Tue, 19 Nov 2013 23:27:48 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWI00IBKLHFEGB0@mmp1.samsung.com>; Tue, 19 Nov 2013 23:27:48 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: kyungmin.park@samsung.com, s.nawrocki@samsung.com, sw0312.kim@samsung.com, Jacek Anaszewski Subject: [PATCH 07/16] s5p-jpeg: Fix lack of spin_lock protection Date: Tue, 19 Nov 2013 15:26:59 +0100 Message-id: <1384871228-6648-8-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1384871228-6648-1-git-send-email-j.anaszewski@samsung.com> References: <1384871228-6648-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJJMWRmVeSWpSXmKPExsVy+t9jAd2U0u4gg2ubLCx6rz5ntDjb9Ibd omfDVlaLw2/aWS1mTH7J5sDq0bdlFaPH501yAUxRXDYpqTmZZalF+nYJXBmNP+axFzzgq5jx XaiBcQ9PFyMnh4SAicTUlqdMELaYxIV769m6GLk4hAQWMUocX/KIHcJpZ5KY+7YbrIpNwFDi 54vXYLaIgLzEk94bbCA2s0CNxJStN9hBbGEBR4nTG++DxVkEVCW+nb/HDGLzCrhLPDryFSjO AbRNQWLOJBuQMKeAh8SUhdvBWoWASs5vPMk+gZF3ASPDKkbR1ILkguKk9FxDveLE3OLSvHS9 5PzcTYzgAHkmtYNxZYPFIUYBDkYlHt4J7l1BQqyJZcWVuYcYJTiYlUR4G/O7g4R4UxIrq1KL 8uOLSnNSiw8xSnOwKInzHmi1DhQSSE8sSc1OTS1ILYLJMnFwSjUwJnSaLODZGzMv7HHXrsoL Nc0fG+6z61vN0NLN2XLI7eGxrj+9v4y6/M64p0TU1f/uTWaedjx+4qazanc/nJhvG6rs9ORY g9zNyBk/t79ckbVx3oeDHBelZ+/O/Oy9TftRrJ1yYoLVJ/9beyZ7i5k+XHe3WqA5uqXIVnwy f8rWp2mXVz1WMVt0VYmlOCPRUIu5qDgRANcRA/YMAgAA Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP s5p_jpeg_device_run and s5p_jpeg_runtime_resume callbacks should have spin_lock protection as they alter device registers. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 328bb8b..650c4d3 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -930,7 +930,9 @@ static void s5p_jpeg_device_run(void *priv) struct s5p_jpeg_ctx *ctx = priv; struct s5p_jpeg *jpeg = ctx->jpeg; struct vb2_buffer *src_buf, *dst_buf; - unsigned long src_addr, dst_addr; + unsigned long src_addr, dst_addr, flags; + + spin_lock_irqsave(&ctx->jpeg->slock, flags); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -998,6 +1000,8 @@ static void s5p_jpeg_device_run(void *priv) } jpeg_start(jpeg->regs); + + spin_unlock_irqrestore(&ctx->jpeg->slock, flags); } static int s5p_jpeg_job_ready(void *priv) @@ -1418,9 +1422,12 @@ static int s5p_jpeg_runtime_suspend(struct device *dev) static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + unsigned long flags; clk_prepare_enable(jpeg->clk); + spin_lock_irqsave(&jpeg->slock, flags); + /* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component @@ -1430,6 +1437,8 @@ static int s5p_jpeg_runtime_resume(struct device *dev) s5p_jpeg_set_hactbl(jpeg->regs); s5p_jpeg_set_hactblg(jpeg->regs); + spin_unlock_irqrestore(&jpeg->slock, flags); + return 0; }