From patchwork Mon Nov 25 09:58:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 3228981 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 9B7BA9F3B8 for ; Mon, 25 Nov 2013 09:59:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F0C0020265 for ; Mon, 25 Nov 2013 09:59:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A233920216 for ; Mon, 25 Nov 2013 09:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751793Ab3KYJ64 (ORCPT ); Mon, 25 Nov 2013 04:58:56 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:56526 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751152Ab3KYJ6z (ORCPT ); Mon, 25 Nov 2013 04:58:55 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MWT00ADXD26E230@mailout1.samsung.com> for linux-media@vger.kernel.org; Mon, 25 Nov 2013 18:58:54 +0900 (KST) X-AuditID: cbfee61a-b7f316d000007e34-90-52931f5e205d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 4D.14.32308.E5F13925; Mon, 25 Nov 2013 18:58:54 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MWT004BMD1ERF40@mmp2.samsung.com>; Mon, 25 Nov 2013 18:58:54 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sw0312.kim@samsung.com, andrzej.p@samsung.com, s.nawrocki@samsung.com, Jacek Anaszewski , Kyungmin Park Subject: [PATCH v2 07/16] s5p-jpeg: Fix lack of spin_lock protection Date: Mon, 25 Nov 2013 10:58:14 +0100 Message-id: <1385373503-1657-8-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1385373503-1657-1-git-send-email-j.anaszewski@samsung.com> References: <1385373503-1657-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHJMWRmVeSWpSXmKPExsVy+t9jQd04+clBBsfW6FrMetnOYtF79Tmj xdmmN+wWPRu2slocftPOajFj8ks2BzaPvi2rGD0+b5ILYIrisklJzcksSy3St0vgyph09SN7 wWT+ijVTN7M0MN7m6WLk5JAQMJHo3/adGcIWk7hwbz1bFyMXh5DAdEaJT2emsEI47UwSV75P ZgepYhMwlPj54jUTiC0iIC/xpPcGWAezwFJGiYuTjoAVCQu4SPw9sQUowcHBIqAqse9XPEiY V8BdYsv1/0wgYQkBBYk5k2xATE4BD4n5k1hBKoSAKpb82Mg+gZF3ASPDKkbR1ILkguKk9FxD veLE3OLSvHS95PzcTYzgUHkmtYNxZYPFIUYBDkYlHl6LyklBQqyJZcWVuYcYJTiYlUR4T0tO DhLiTUmsrEotyo8vKs1JLT7EKM3BoiTOe6DVOlBIID2xJDU7NbUgtQgmy8TBKdXAaPLX3l/Z 2KUxb9dcdnnbU0kT9r9qXf7l+LGjpj+Pp/44+Y7X4oTDLq+5orGXsk/f1fmXcdfeUvO/PF/k 42dv1iZPPlypK+My2zK4dvKx2AdX7t9f9GKD38nnn+PNlO1e7a/25dvB1ZZ75eX3prkWrJvD JgvUZ84Ki1l3JMlcaMUBpn2V09u3iiqxFGckGmoxFxUnAgCt2AOmEQIAAA== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 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 583fcdd..628fde8 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,12 +1422,15 @@ 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; int ret; ret = clk_prepare_enable(jpeg->clk); if (ret < 0) return ret; + spin_lock_irqsave(&jpeg->slock, flags); + /* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component @@ -1433,6 +1440,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; }