linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, isely@isely.net,
	pali.rohar@gmail.com, Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCH 3/5] uvc gadget: switch to unlocked_ioctl.
Date: Mon, 16 Feb 2015 22:15:37 +0200	[thread overview]
Message-ID: <2390343.jYF8yA1sby@avalon> (raw)
In-Reply-To: <54E208BB.9010804@xs4all.nl>

Hi Hans,

On Monday 16 February 2015 16:11:55 Hans Verkuil wrote:
> On 02/03/2015 02:55 PM, Laurent Pinchart wrote:
> > On Tuesday 03 February 2015 13:47:24 Hans Verkuil wrote:
> >> From: Hans Verkuil <hans.verkuil@cisco.com>
> >> 
> >> Instead of .ioctl use unlocked_ioctl. While all the queue ops
> >> already use a lock, there was no lock to protect uvc_video, so
> >> add that one.
> > 
> > There's more. streamon and streamoff need to be protected by a lock for
> > instance. Wouldn't it be easier to just set vdev->lock for this driver
> > instead of adding manual locking ?
> 
> I could set vdev->lock to &video->mutex and remove the queue->mutex
> altogether since video->mutex will now be used for all locking. I only
> need to take the video->mutex in uvc_v4l2_release() as well.
> 
> If you agree with that, then I'll make that change.

That sounds good to me. I haven't really tried to optimize locking in the UVC 
gadget driver, so relying on core locking is fine. Could you split that in two 
patches, one that switches to core locking, and another that switches to 
unlocked_ioctl ?

> >> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> >> ---
> >> 
> >>  drivers/usb/gadget/function/f_uvc.c    | 1 +
> >>  drivers/usb/gadget/function/uvc.h      | 1 +
> >>  drivers/usb/gadget/function/uvc_v4l2.c | 6 +++++-
> >>  3 files changed, 7 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/usb/gadget/function/f_uvc.c
> >> b/drivers/usb/gadget/function/f_uvc.c index 945b3bd..748a80c 100644
> >> --- a/drivers/usb/gadget/function/f_uvc.c
> >> +++ b/drivers/usb/gadget/function/f_uvc.c
> >> @@ -817,6 +817,7 @@ static struct usb_function *uvc_alloc(struct
> >> usb_function_instance *fi) if (uvc == NULL)
> >> 
> >>  		return ERR_PTR(-ENOMEM);
> >> 
> >> +	mutex_init(&uvc->video.mutex);
> > 
> > We need a corresponding mutex_destroy() somewhere.
> 
> Why? Few drivers do so. If you want it, then I'll do that, but it's not
> required to my knowledge.

I somehow thought mutex_destroy() was required to avoid leakages when mutex 
debugging is enabled, but it turns out I'm wrong. Omitting it thus seems fine.

-- 
Regards,

Laurent Pinchart


  reply	other threads:[~2015-02-16 20:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 12:47 [PATCH 0/5] Remove .ioctl from v4l2_file_operations Hans Verkuil
2015-02-03 12:47 ` [PATCH 1/5] pvrusb2: replace .ioctl by .unlocked_ioctl Hans Verkuil
2015-02-03 12:47 ` [PATCH 2/5] radio-bcm2048: use unlocked_ioctl instead of ioctl Hans Verkuil
2015-02-03 13:01   ` Pali Rohár
2015-02-03 12:47 ` [PATCH 3/5] uvc gadget: switch to unlocked_ioctl Hans Verkuil
2015-02-03 13:55   ` Laurent Pinchart
2015-02-16 15:11     ` Hans Verkuil
2015-02-16 20:15       ` Laurent Pinchart [this message]
2015-02-03 12:47 ` [PATCH 4/5] uvc gadget: set device_caps in querycap Hans Verkuil
2015-02-03 13:44   ` Laurent Pinchart
2015-02-03 12:47 ` [PATCH 5/5] v4l2-core: remove the old .ioctl BKL replacement Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2390343.jYF8yA1sby@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hans.verkuil@cisco.com \
    --cc=hverkuil@xs4all.nl \
    --cc=isely@isely.net \
    --cc=linux-media@vger.kernel.org \
    --cc=pali.rohar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).