From patchwork Wed Dec 7 18:30:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 9465049 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 A0AB060459 for ; Wed, 7 Dec 2016 18:32:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9666727F99 for ; Wed, 7 Dec 2016 18:32:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AC3B284FD; Wed, 7 Dec 2016 18:32:57 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2271427F99 for ; Wed, 7 Dec 2016 18:32:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEh0B-0006X8-PJ; Wed, 07 Dec 2016 18:31:35 +0000 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cEgzT-00069o-Og for linux-arm-kernel@lists.infradead.org; Wed, 07 Dec 2016 18:30:53 +0000 Received: by mail-pg0-x22c.google.com with SMTP id 3so164639698pgd.0 for ; Wed, 07 Dec 2016 10:30:31 -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=+NbSPbx079VyYoo07GcALM1wMftuQGsVBqCFCxdB6+A=; b=NTyXuC9GkuHx3wpM0ZALq7dCk7ZztCeI08aCgmY2RsBPzUpj19mZYo2cqbmYMAD0mZ gidyoVf6yRta06wNknU0+a74JOVsL2csqEVABCgG1o8rLcq7r2Z6cHdDwXtfJtWz6Xgc NrLtBHhXpWd6ig2lzOswEqfcgQfCu3dDOR4LoNbUffI+aMQHrSVq8QAcApio49i2A4QJ 7Uh5RjTF8LYwsiHQw5R13TQc9rYI32/QHHeAbZ5N2ST2yiyFh8CFiKCTSqlHDTcF36qM X7YHsGFnHP85MzwOlOPejLTIXq4gYRY2JDWjuVv0zo8mY7s5i0ObhKwS2vVrqA5J0kfJ llNg== 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=+NbSPbx079VyYoo07GcALM1wMftuQGsVBqCFCxdB6+A=; b=abID7oJlnDM5Xff9ThuFOfVL9ytSLJSULA7iu4ezNhQQwFibDJ4vByJc1OBz1lLMUN oThhxsFbXixgE/PXI6nq4RMvHJcGvEgVWmYCmzazeE8gugRq16opWVt4lrRHRi1nVfu0 YwspRquiJkyv5fJEpUhNCbtNneTHm5UJlDBs7AUcgBAbO5pfe2H8xEgSINddSkh9a/g6 U2C8L8Z6ZaUiv+HK3tXz9GkRIsp/0RnpCOhBBuu7fKYM9af3DalVKUIH3eikBA6yskWJ /Ubz9BW67YQdVokH6xKNcFi1F/wGlcdWfqfd52VaX3PWowwKC2bfHRFryFk1ovEgUnqa NBbg== X-Gm-Message-State: AKaTC01sRnJuqKG3BlBdKO2+MxedRr4+lcSMSQyarUoJyOCYZ+dcrZHQQ/1I6Udr0uosSFZ7 X-Received: by 10.99.62.13 with SMTP id l13mr123512936pga.112.1481135430773; Wed, 07 Dec 2016 10:30:30 -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 x4sm44507097pgc.14.2016.12.07.10.30.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Dec 2016 10:30:30 -0800 (PST) From: Kevin Hilman To: Hans Verkuil , Laurent Pinchart , Sakari Ailus , linux-media@vger.kernel.org Subject: [PATCH v6 3/5] [media] davinci: vpif_capture: fix start/stop streaming locking Date: Wed, 7 Dec 2016 10:30:23 -0800 Message-Id: <20161207183025.20684-4-khilman@baylibre.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161207183025.20684-1-khilman@baylibre.com> References: <20161207183025.20684-1-khilman@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161207_103051_978903_20290232 X-CRM114-Status: GOOD ( 14.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Lechner , Axel Haslam , Sekhar Nori , =?UTF-8?q?Bartosz=20Go=C5=82aszewski?= , Alexandre Bailon , Patrick Titiano , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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, and update the irqlock comment to reflect what it actually protects. Suggested-by: Laurent Pinchart Reviewed-by: Laurent Pinchart Signed-off-by: Kevin Hilman --- drivers/media/platform/davinci/vpif_capture.c | 6 +++--- drivers/media/platform/davinci/vpif_capture.h | 2 +- 2 files changed, 4 insertions(+), 4 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); diff --git a/drivers/media/platform/davinci/vpif_capture.h b/drivers/media/platform/davinci/vpif_capture.h index 9e35b6771d22..1d2c052deedf 100644 --- a/drivers/media/platform/davinci/vpif_capture.h +++ b/drivers/media/platform/davinci/vpif_capture.h @@ -67,7 +67,7 @@ struct common_obj { struct vb2_queue buffer_queue; /* Queue of filled frames */ struct list_head dma_queue; - /* Used in video-buf */ + /* Protects the dma_queue field */ spinlock_t irqlock; /* lock used to access this structure */ struct mutex lock;