From patchwork Wed Dec 7 05:08:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9463931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F39B76074E for ; Wed, 7 Dec 2016 05:08:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E70B628499 for ; Wed, 7 Dec 2016 05:08:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7BC22847E; Wed, 7 Dec 2016 05:08:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32CB52847E for ; Wed, 7 Dec 2016 05:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730AbcLGFIr (ORCPT ); Wed, 7 Dec 2016 00:08:47 -0500 Received: from mail-pg0-f54.google.com ([74.125.83.54]:33420 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752724AbcLGFIq (ORCPT ); Wed, 7 Dec 2016 00:08:46 -0500 Received: by mail-pg0-f54.google.com with SMTP id 3so157603500pgd.0 for ; Tue, 06 Dec 2016 21:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KWUQFC+qmsl6hqF86UCV5BUG52Fe0V8PnnOKU09KyyY=; b=00AMLYrMtrN+W3VDLjGiORQPMgV4j5KsHlREVhr9V8C3vPbX488LO/KaN36FbHM3gP NmdPPRkb2XjM8LBmAkgiyfofCytJy46DeE8x2HeSYgJebzuIxEnXEXUwuntDovpXdICV GdlN84fWudIvqWrMF3jOae7BjYdGQR/07e5E4gJ1u2aOn9YoGBUQAidSoFc/XBxSFjC+ 13M36iDiRT+1ez6ihoXuZQ1CgWbKvx5+YOp6koeYBho293BwEpMTB003aOx9wzcPM7OO 2LlPEAuYeHFE0F8sdGIUntfNZdiBqxNlwsR3WU+2FMsvIvpccNQYZdu81eubIwHQio8l 2z+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KWUQFC+qmsl6hqF86UCV5BUG52Fe0V8PnnOKU09KyyY=; b=OCGVVTiLBqCF/h5aiCAwqiVpE5k9wIGeiEP4W0+O18t87U+RSDezmZ9agGIT7AoFi4 uGwS1EIhCmXFNmnLZjwynbFpO+6VV0yeZDjca+gwIrBSv6nrXV7NSwkxqWBNTmY70DNp FomkLkbd0QjarcsLf5m01Wo77UGFyOmyj7EDu/VktQRFQozo8+jjoRg7TAk4Xr0cagsK zyH0NCt/vsHA59Nc9PWT1w0xcPxuCyaIcOdmCjSHzDLI8+nvhD77G22Arbku5+VknZFh +/Unku2BIynMuRooQCpvgROzkgEmptLgXF5GbCCbo9n0qS/GS0CmOLQWxl//0rhBGosk gMPA== X-Gm-Message-State: AKaTC00u2mav69Vda72Bb0IXzesJBUXeqZCFkfJoyz7XLawZTx0voxhPZ5XVu92rt+nsk5OS X-Received: by 10.98.48.134 with SMTP id w128mr1313786pfw.133.1481087325797; Tue, 06 Dec 2016 21:08:45 -0800 (PST) Received: from localhost (c-98-203-232-209.hsd1.wa.comcast.net. [98.203.232.209]) by smtp.gmail.com with ESMTPSA id a22sm38594947pfg.7.2016.12.06.21.08.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Dec 2016 21:08:45 -0800 (PST) From: Kevin Hilman To: Hans Verkuil , Laurent Pinchart , Sakari Ailus , linux-media@vger.kernel.org Cc: Sekhar Nori , Axel Haslam , =?UTF-8?q?Bartosz=20Go=C5=82aszewski?= , Alexandre Bailon , David Lechner , Patrick Titiano , linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 3/5] [media] davinci: vpif_capture: fix start/stop streaming locking Date: Tue, 6 Dec 2016 21:08:24 -0800 Message-Id: <20161207050826.23174-4-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161207050826.23174-1-khilman@baylibre.com> References: <20161207050826.23174-1-khilman@baylibre.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Video capture subdevs may be over I2C and may sleep during xfer, so we cannot do IRQ-disabled locking when calling the subdev. The IRQ-disabled locking is meant to protect the DMA queue list throughout the rest of the driver, so update the locking in [start|stop]_streaming to protect just this list. Suggested-by: Laurent Pinchart Signed-off-by: Kevin Hilman Reviewed-by: Laurent Pinchart --- drivers/media/platform/davinci/vpif_capture.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index c24049acd40a..f72a719efb3d 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -179,8 +179,6 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) unsigned long addr, flags; int ret; - spin_lock_irqsave(&common->irqlock, flags); - /* Initialize field_id */ ch->field_id = 0; @@ -211,6 +209,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) vpif_config_addr(ch, ret); /* Get the next frame from the buffer queue */ + spin_lock_irqsave(&common->irqlock, flags); common->cur_frm = common->next_frm = list_entry(common->dma_queue.next, struct vpif_cap_buffer, list); /* Remove buffer from the buffer queue */ @@ -244,6 +243,7 @@ static int vpif_start_streaming(struct vb2_queue *vq, unsigned int count) return 0; err: + spin_lock_irqsave(&common->irqlock, flags); list_for_each_entry_safe(buf, tmp, &common->dma_queue, list) { list_del(&buf->list); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED); @@ -287,7 +287,6 @@ static void vpif_stop_streaming(struct vb2_queue *vq) vpif_dbg(1, debug, "stream off failed in subdev\n"); /* release all active buffers */ - spin_lock_irqsave(&common->irqlock, flags); if (common->cur_frm == common->next_frm) { vb2_buffer_done(&common->cur_frm->vb.vb2_buf, VB2_BUF_STATE_ERROR); @@ -300,6 +299,7 @@ static void vpif_stop_streaming(struct vb2_queue *vq) VB2_BUF_STATE_ERROR); } + spin_lock_irqsave(&common->irqlock, flags); while (!list_empty(&common->dma_queue)) { common->next_frm = list_entry(common->dma_queue.next, struct vpif_cap_buffer, list);