From patchwork Tue Nov 4 20:34:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sensoray-dev X-Patchwork-Id: 5230921 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8BFA3C11AC for ; Tue, 4 Nov 2014 20:56:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7DCC2015A for ; Tue, 4 Nov 2014 20:56:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D001820160 for ; Tue, 4 Nov 2014 20:56:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039AbaKDU4W (ORCPT ); Tue, 4 Nov 2014 15:56:22 -0500 Received: from gateway06.websitewelcome.com ([67.18.21.22]:45038 "EHLO gateway06.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbaKDU4W (ORCPT ); Tue, 4 Nov 2014 15:56:22 -0500 X-Greylist: delayed 1306 seconds by postgrey-1.27 at vger.kernel.org; Tue, 04 Nov 2014 15:56:21 EST Received: by gateway06.websitewelcome.com (Postfix, from userid 5007) id A21EA24F20CC2; Tue, 4 Nov 2014 14:34:29 -0600 (CST) Received: from cm2.websitewelcome.com (unknown [192.185.178.13]) by gateway06.websitewelcome.com (Postfix) with ESMTP id 7AA6F24F20C07 for ; Tue, 4 Nov 2014 14:34:29 -0600 (CST) Received: from gator3086.hostgator.com ([50.87.144.121]) by cm2.websitewelcome.com with id BYaT1p01W2dN8Wi01YaVmF; Tue, 04 Nov 2014 14:34:29 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sensoray.com; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=jlAs4RCCNrt5RMJYb5bkLUSeJ+cXbpILckN1zCU/txo=; b=BCNtgH5x4OnsWKOAZYq+3aTpmE5YAZh86cYH1EIkCSfdXZudGJ2axBDgwum2NOfiliRMnv4vGFIWDFvhPsPjFtwagp9D2uZjesv8JKGlsUCPgm9dHjMa6h6nwExT/zCxeDaoPGh2WSKIFwmNs/pqsiLHRoBAguWUEozt5FRpnWs=; Received: from [50.43.67.108] (port=56806 helo=localhost.localdomain) by gator3086.hostgator.com with esmtpa (Exim 4.82) (envelope-from ) id 1Xlko7-00034r-8m; Tue, 04 Nov 2014 14:34:27 -0600 From: Dean Anderson To: linux-media@vger.kernel.org, hverkuil@xs4all.nl Cc: Dean Anderson Subject: [PATCH] [media] s2255drv: fix spinlock issue Date: Tue, 4 Nov 2014 12:34:03 -0800 Message-Id: <1415133243-9929-1-git-send-email-linux-dev@sensoray.com> X-Mailer: git-send-email 1.9.1 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3086.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sensoray.com X-BWhitelist: no X-Source-IP: 50.43.67.108 X-Exim-ID: 1Xlko7-00034r-8m X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (localhost.localdomain) [50.43.67.108]:56806 X-Source-Auth: dean@sensoray.com X-Email-Count: 3 X-Source-Cap: c2Vuc29yYXk7c2Vuc29yYXk7Z2F0b3IzMDg2Lmhvc3RnYXRvci5jb20= 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,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 qlock spinlock controls access to buf_list and sequence. qlock spinlock should not be locked during a copy to video buffers, an operation that may sleep. Signed-off-by: Dean Anderson --- drivers/media/usb/s2255/s2255drv.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index ccc0009..24c4413 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -558,27 +558,31 @@ static void s2255_fwchunk_complete(struct urb *urb) } -static int s2255_got_frame(struct s2255_vc *vc, int jpgsize) +static void s2255_got_frame(struct s2255_vc *vc, int jpgsize) { struct s2255_buffer *buf; struct s2255_dev *dev = to_s2255_dev(vc->vdev.v4l2_dev); unsigned long flags = 0; - int rc = 0; + spin_lock_irqsave(&vc->qlock, flags); if (list_empty(&vc->buf_list)) { dprintk(dev, 1, "No active queue to serve\n"); - rc = -1; - goto unlock; + spin_unlock_irqrestore(&vc->qlock, flags); + return; } buf = list_entry(vc->buf_list.next, struct s2255_buffer, list); list_del(&buf->list); v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); + buf->vb.v4l2_buf.field = vc->field; + buf->vb.v4l2_buf.sequence = vc->frame_count; + spin_unlock_irqrestore(&vc->qlock, flags); + s2255_fillbuff(vc, buf, jpgsize); + /* tell v4l buffer was filled */ + vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); dprintk(dev, 2, "%s: [buf] [%p]\n", __func__, buf); -unlock: - spin_unlock_irqrestore(&vc->qlock, flags); - return rc; + return; } static const struct s2255_fmt *format_by_fourcc(int fourcc) @@ -649,11 +653,6 @@ static void s2255_fillbuff(struct s2255_vc *vc, } dprintk(dev, 2, "s2255fill at : Buffer 0x%08lx size= %d\n", (unsigned long)vbuf, pos); - /* tell v4l buffer was filled */ - buf->vb.v4l2_buf.field = vc->field; - buf->vb.v4l2_buf.sequence = vc->frame_count; - v4l2_get_timestamp(&buf->vb.v4l2_buf.timestamp); - vb2_buffer_done(&buf->vb, VB2_BUF_STATE_DONE); }