RE: [PATCH V2] usb: gadget/uvc: Remove non-required locking from 'uvc_queue_next_buffer' routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Felipe,

> -----Original Message-----
> From: Bhupesh SHARMA
> Sent: Friday, March 23, 2012 10:23 PM
> To: balbi@xxxxxx
> Cc: linux-usb@xxxxxxxxxxxxxxx; laurent.pinchart@xxxxxxxxxxxxxxxx;
> spear-devel; gregkh@xxxxxxxxxxxxxxxxxxx; Bhupesh SHARMA
> Subject: [PATCH V2] usb: gadget/uvc: Remove non-required locking from
> 'uvc_queue_next_buffer' routine
> 
> This patch removes the non-required spinlock acquire/release calls on
> 'queue->irqlock' from 'uvc_queue_next_buffer' routine.
> 
> This routine is called from 'video->encode' function (which translates
> to either
> 'uvc_video_encode_bulk' or 'uvc_video_encode_isoc') in 'uvc_video.c'.
> As, the 'video->encode' routines are called with 'queue->irqlock'
> already held,
> so acquiring a 'queue->irqlock' again in 'uvc_queue_next_buffer'
> routine causes
> a spin lock recursion.
> 
> Signed-off-by: Bhupesh Sharma <bhupesh.sharma@xxxxxx>
> Acked-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
> ---
> Changes since V1:
> 	- replace 'queue_irqlock' with 'queue->irqlock'
> 
>  drivers/usb/gadget/uvc_queue.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/uvc_queue.c
> b/drivers/usb/gadget/uvc_queue.c
> index d776adb..0cdf89d 100644
> --- a/drivers/usb/gadget/uvc_queue.c
> +++ b/drivers/usb/gadget/uvc_queue.c
> @@ -543,11 +543,11 @@ done:
>  	return ret;
>  }
> 
> +/* called with queue->irqlock held.. */
>  static struct uvc_buffer *
>  uvc_queue_next_buffer(struct uvc_video_queue *queue, struct uvc_buffer
> *buf)
>  {
>  	struct uvc_buffer *nextbuf;
> -	unsigned long flags;
> 
>  	if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) &&
>  	    buf->buf.length != buf->buf.bytesused) {
> @@ -556,14 +556,12 @@ uvc_queue_next_buffer(struct uvc_video_queue
> *queue, struct uvc_buffer *buf)
>  		return buf;
>  	}
> 
> -	spin_lock_irqsave(&queue->irqlock, flags);
>  	list_del(&buf->queue);
>  	if (!list_empty(&queue->irqqueue))
>  		nextbuf = list_first_entry(&queue->irqqueue, struct
> uvc_buffer,
>  					   queue);
>  	else
>  		nextbuf = NULL;
> -	spin_unlock_irqrestore(&queue->irqlock, flags);
> 
>  	buf->buf.sequence = queue->sequence++;
>  	do_gettimeofday(&buf->buf.timestamp);
> --

Please let me know if this patch is fine enough and
you can pick this one in your tree so that it makes a place
in the next pull request to Linus for USB gadget/peripherals.

Thanks,
Bhupesh
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux