From patchwork Tue Nov 6 21:27:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 10671421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4766F1751 for ; Tue, 6 Nov 2018 21:27:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39A162AF66 for ; Tue, 6 Nov 2018 21:27:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D7FD2AF69; Tue, 6 Nov 2018 21:27:33 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D04242AF74 for ; Tue, 6 Nov 2018 21:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726611AbeKGGyo (ORCPT ); Wed, 7 Nov 2018 01:54:44 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:55676 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbeKGGyn (ORCPT ); Wed, 7 Nov 2018 01:54:43 -0500 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BBFCA590; Tue, 6 Nov 2018 22:27:27 +0100 (CET) From: Kieran Bingham To: Laurent Pinchart , linux-media@vger.kernel.org Cc: Guennadi Liakhovetski , Olivier BRAUN , Troy Kisky , Randy Dunlap , Philipp Zabel , Ezequiel Garcia , Kieran Bingham Subject: [PATCH v5 4/9] media: uvcvideo: queue: Simplify spin-lock usage Date: Tue, 6 Nov 2018 21:27:15 +0000 Message-Id: <210be9b2f38af75b3747415d0372f4f12b2bee19.1541534872.git-series.kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: 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 From: Kieran Bingham Both uvc_start_streaming(), and uvc_stop_streaming() are called from userspace context, with interrupts enabled. As such, they do not need to save the IRQ state, and can use spin_lock_irq() and spin_unlock_irq() respectively. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v4: - Rebase to v4.16 (linux-media/master) v5: - Provide lockdep validation drivers/media/usb/uvc/uvc_queue.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c index 74f9483911d0..bebf2415d9de 100644 --- a/drivers/media/usb/uvc/uvc_queue.c +++ b/drivers/media/usb/uvc/uvc_queue.c @@ -169,18 +169,19 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) { struct uvc_video_queue *queue = vb2_get_drv_priv(vq); struct uvc_streaming *stream = uvc_queue_to_stream(queue); - unsigned long flags; int ret; + lockdep_assert_irqs_enabled(); + queue->buf_used = 0; ret = uvc_video_enable(stream, 1); if (ret == 0) return 0; - spin_lock_irqsave(&queue->irqlock, flags); + spin_lock_irq(&queue->irqlock); uvc_queue_return_buffers(queue, UVC_BUF_STATE_QUEUED); - spin_unlock_irqrestore(&queue->irqlock, flags); + spin_unlock_irq(&queue->irqlock); return ret; } @@ -188,14 +189,15 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) static void uvc_stop_streaming(struct vb2_queue *vq) { struct uvc_video_queue *queue = vb2_get_drv_priv(vq); - unsigned long flags; + + lockdep_assert_irqs_enabled(); if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) uvc_video_enable(uvc_queue_to_stream(queue), 0); - spin_lock_irqsave(&queue->irqlock, flags); + spin_lock_irq(&queue->irqlock); uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); - spin_unlock_irqrestore(&queue->irqlock, flags); + spin_unlock_irq(&queue->irqlock); } static const struct vb2_ops uvc_queue_qops = {