linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [Regression w/ patch] Media commit causes user space to misbahave (was: Re: Linux 3.8-rc1)
Date: Mon, 24 Dec 2012 17:28:38 -0200	[thread overview]
Message-ID: <20121224172838.162b3597@redhat.com> (raw)
In-Reply-To: <CA+55aFzX56kPPwSO97X=UyPaMzV5QRNG9ScN=nxnHFjmz=_8yA@mail.gmail.com>

Em Sun, 23 Dec 2012 14:29:04 -0800
Linus Torvalds <torvalds@linux-foundation.org> escreveu:

> On Sun, Dec 23, 2012 at 12:21 PM, Mauro Carvalho Chehab
> <mchehab@redhat.com> wrote:
> >
> > Agreed: ENOENT was a bad choice, and it should be reverted.
> 
> Well, *any* other error value is likely a bad choice.

Well, UVC should return the same error codes as the other drivers,
for the same error types. That's what that patch was trying to fix
(unfortunately, doing the wrong thing).

> > What I'm trying to understand is why pulseaudio is complaining.
> > Is it because it only accepts EINVAL error code for media controls?
> 
> What I am trying to understand is why you even care, and how you could
> *possibly* ever even consider this to be a user-space bug.

Because there are other error codes that can be returned by other
drivers when this specific ioctl (VIDIOC_QUERYCTRL) is called.

Let me take one step back and explain what this patch were
trying to do.

What happens is that the V4L2 API is very complex (~80 ioctls).
In practice, that means that two drivers implementing the API
might behave a little different than the others, with causes
troubles on userspace. We're working to fix it, by testing all
of them using userspace testing tools.

In the specific case of VIDIOC_QUERYCTRL, most drivers now use
some functions inside the v4l2 core that warrants that they all
work the same way. 

UVC is an special case, as it can dynamically create media controls
in runtime. The new uvc 1.5 spec will make it even harder to use the
core.

So, UVC has its own implementation for this ioctl, with can
unfortunately led into a different behavior from userspace. This
was actually happening, and Laurent's (broken) patch were trying
to address it.

Unfortunately, the tool he used to test had a bug. So, he didn't
noticed that his patch were broken.

>From my side, when I saw Rafael's complaint, what I wanted were
just to understand a little more what happened, before
applying his patch. Sorry if I miss-expressed.

> Applications *do* care about error return values. There's no way in
> hell you can willy-nilly just change them. And if you do change them,
> and applications break, there is no way in hell you can then blame the
> application.

Yes. What we're trying to do is to make sure that all drivers will
return the same error codes, and not to change the API.

> Yes, I'm upset. Very upset. Why was the error value changed in the
> first place? There was no reason given, and it was changed to a
> completely idiotic value. And when applications - understandably -
> broke, you start asking "why?"
> 
> If applications didn't care about specific error values, then it
> wouldn't make sense to have more than one to begin with, and you
> shouldn't care which one that was. But since applications *do* care,
> and since we *do* have multiple error values, we stick to the old
> ones, unless there are some *very* good reasons not to.

Fully agreed.

> And those reasons really need to be very good, and spelled out and
> explained. In this case, none of that was even remotely the case.
> 
> So your question "why would pulseaudio care" is totally *irrelevant*,
> senseless, and has nothing to do with anything. Pulseaudio cares, and
> caring fundamentally makes sense. It's questioning that obvious fact
> that does not make sense!

With audio devices, pulseaudio opens devices on its start and keep it open
forever. 

>From Rafael's email, it seemed that newer versions could also be doing
something similar. On such case, this would likely break all drivers
(even on kernel 2.6 or earlier), because the drivers lock the streaming
capabilities to the firstly opened handler, due to hardware limitation
(the DMA engines at the hardware only support one transfer at the same
time). There's an ioctl that overrides its behavior, that should be called
by an application that wants to force its ownership, but most applications
don't use it.

Cheers,
Mauro

  reply	other threads:[~2012-12-24 19:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-22  2:00 Linux 3.8-rc1 Linus Torvalds
2012-12-22  2:57 ` Steven Rostedt
2013-01-16  9:25   ` David Nyström
2012-12-23 13:39 ` [Regression w/ patch] Media commit causes user space to misbahave (was: Re: Linux 3.8-rc1) Rafael J. Wysocki
2012-12-23 14:08   ` Mauro Carvalho Chehab
2012-12-23 17:36     ` Linus Torvalds
2012-12-23 20:21       ` Mauro Carvalho Chehab
2012-12-23 22:29         ` Linus Torvalds
2012-12-24 19:28           ` Mauro Carvalho Chehab [this message]
2012-12-23 20:39       ` Laurent Pinchart
2012-12-23 22:04 ` linux-next stats (Was: " Stephen Rothwell
     [not found] ` <50D764BA.1030501@gmail.com>
2012-12-23 22:35   ` Linux 3.8-rc1 - another regression on USB :-( Linus Torvalds
2012-12-23 23:27     ` Greg Kroah-Hartman
2012-12-24  3:46       ` Woody Suwalski
2012-12-28 23:12         ` Woody Suwalski
2013-01-01 15:17         ` INVALID " Woody Suwalski
2013-01-02 13:41       ` Woody Suwalski
2013-01-12 13:16         ` Andreas Mohr
2013-01-12 16:54           ` Oliver Neukum
2013-01-12 17:38           ` Alan Stern
2013-01-16  4:26             ` Woody Suwalski
2013-01-16  8:25               ` Oliver Neukum
2013-01-16 15:00               ` Alan Stern
2013-01-17  2:25                 ` Woody Suwalski

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=20121224172838.162b3597@redhat.com \
    --to=mchehab@redhat.com \
    --cc=hans.verkuil@cisco.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=torvalds@linux-foundation.org \
    /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).