ksummit.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Jonathan Corbet <corbet@lwn.net>, ksummit@lists.linux.dev
Subject: Re: [MAINTAINER SUMMIT] User-space requirements for accelerator drivers
Date: Sat, 11 Sep 2021 02:38:11 +0200	[thread overview]
Message-ID: <20210911023811.74b82f10@coco.lan> (raw)
In-Reply-To: <YTvuYmqLESpGvXD7@pendragon.ideasonboard.com>

Em Sat, 11 Sep 2021 02:46:42 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> Hi Mauro,
> 
> On Sat, Sep 11, 2021 at 12:52:14AM +0200, Mauro Carvalho Chehab wrote:
> > Em Fri, 10 Sep 2021 15:00:58 -0600 Jonathan Corbet escreveu:
> >   
> > > There has been a regular disagreement in recent years about whether
> > > drivers for accelerators (such as for the Habana Gaudi device) should be
> > > subject to the same requirements as GPU drivers when it comes to the
> > > availability of a free implementation of the user-space side.  It flared
> > > up again recently:
> > > 
> > >    https://lwn.net/Articles/867168/
> > > 
> > > Happily, the Habana situation in particular seems to be resolving
> > > itself:
> > > 
> > >    https://lwn.net/ml/linux-kernel/CAFCwf119s7iXk+qpwoVPnRtOGcxeuZb3rnihf6NWWoVT-4ODHA@mail.gmail.com/
> > > 
> > > But even there it is clear that the fundamental question has not yet
> > > been resolved.
> > > 
> > > This seems like the sort of question that the maintainer summit exists
> > > to address.  Specifically, we could discuss:
> > > 
> > >  - Under which circumstances should the kernel community require the
> > >    existence of freely licensed user-space code that exercises all
> > >    functionalities of a proposed kernel driver or feature?
> > > 
> > >  - Are there internal kernel interfaces, such as DMA-BUF or P2PDMA, that
> > >    are only available to drivers with a free user-space implementation?
> > >    Do we need an EXPORT_SYMBOL_USERSPACE_GPL()?
> > > 
> > >  - What constitutes an acceptable user-space implementation in cases
> > >    where these restrictions apply?
> > > 
> > > I suspect that more clarity (and fewer arguments) on these questions
> > > would be welcome both within and beyond the development community.  
> > 
> > The media subsystem also has this sort of issues: there are several
> > drivers there to support hardware accelerators for video encoders and 
> > decoders. In the case of media, usually devices with such hardware have
> > an Image Signal Processor, where the codec runs on some firmware.
> > 
> > On media, enforcing userspace to always be open source would
> > have been very bad, as it would prevent several videoconferencing 
> > software to exist on Linux.  
> 
> Could you elaborate on which software you're thinking of ? And maybe
> which driver(s) you're thinking about ?

I'm referring to tools like v4l2-compliance, qv4l2 and other tools
we maintain at v4l-utils tree.

> > Also, there are several such codec hardware that only exists on 
> > embedded hardware that already depends on proprietary software 
> > to run.
> > 
> > So, a policy like that would make more damage than good.  
> 
> I wonder if there's some sort of misunderstanding. We're not talking
> about requiring *all* userspace to be open, but about requiring the
> existence of *one* open userspace as an acceptance criteria for merging
> drivers.

Something like EXPORT_SYMBOL_USERSPACE_GPL() implies that any
userspace app using such symbols would be GPL'd.

> 
> > What we do, instead, is to try to enforce that the userspace API to
> > be fully documented in a way that open source software can exist.
> > 
> > This is easier said than done, but we have some compliance tools
> > that we use, in order to help to validate the uAPI implementations.  
> 
> I won't comment on the codec side as there are people more knowledgeable
> than me in that area, but on the camera side, my analysis of the
> situation is different than yours. The vast majority of drivers only use
> standard parts of the V4L2 and MC APIs. For those, we do have plenty of
> existing open userspace, as well as compliance tools as you mentioned
> (some drivers also expose custom controls, but that's a very small API
> footprint and they are documented well enough to be usable by any
> application).

Yes, that's my view too. We used to have problems in the past with
some proprietary fourccs, but I guess the problematic ones were
either removed (because there was no upstream driver) or documented.

> The possibly problematic case is mostly about ISP drivers. For those,
> the userspace API is more complex, with lots of device-specific
> elements. The first ISP that received kernel support was the OMAP3 ISP,
> and the driver has custom ioctls. Requiring an open userspace may indeed
> have delayed the driver from being merged. However, for that particular
> device, we had a public datasheet that documented the ISP,

Yes, but afterwards, other ISP drivers got added. I don't think they
all have public datasheets. 

> which we
> could consider as an alternative to the open userspace implementation
> (a topic worth discussing I believe).

Yeah, a public datasheet sounds an interesting requirement. It offers
a problem, though: maybe some details could be missed on it, which
would prevent any real open source userspace development.

> Even if we had considered the
> public datasheet to not be enough, I think we would have eventually got
> an open userspace anyway (based on my internal knowledge of the Nokia
> team working on this project).

Yes.

> More recently, we have two ISP drivers that got merged, for the Rockchip
> RK3399 ISP and the Intel IPU3. Those drivers differ from all previous
> drivers in the sense that the device is configured through a blob of
> parameters passed by userspace to the kernel, written to registers by
> the driver in the Rockchip case, and passed to the ISP firmware in the
> Intel case. We have for both drivers a header file that describes the
> layout of those blobs as C structures, but I can tell with first hand
> experience working on an open userspace implementation that at least in
> the Intel case that's not enough to use the ISP.

Yeah, I was afraid that this would end happening some day. Not too big
harm, though, as IPU3 is under staging. We should enforce it to be
be supported at libcamera or to have some other open source application
before moving it out of staging.

> There's also an ISP driver for Raspberry Pi that is currently out of
> tree and that we'll try to upstream, and for that one we have an open
> userspace already (there's actually no closed userspace, kudos to
> Raspberry Pi for doing the right thing, I'd like to see more vendors
> following that great lead).
> 
> Finally, having spent the last 2 years and a half working on an open
> userspace camera stack (libcamera) that exercise the V4L2 and MC APIs, I
> was quite horrified to find out how some parts of those APIs are pretty
> badly designed. I'm not just blaming others here, this includes APIs
> that I have designed myself. They have been tested at the time with test
> applications (either extending tools such as v4l2-ctl, or writing
> dedicated tested tools for the API), but failed me when exercised in
> real use cases. In retrospect I shouldn't have been surprised,
> developing a test application that exercises the API in the way it was
> designed as opposed to the way a real use case would need it can only
> lead to problems. I think that requiring an open implementation of a
> real use case, not just a test tool, would be a very good practice for
> new APIs or extensions or existing APIs.

I remember that, during OMAP3 development, I required several times
to have an userspace app/lib before merging it upstream (somewhat
similar to libcamera goals). 

On that time, we didn't have staging yet. So, when Nokia ended with
MeeGo development, I opted to merge what we had so far to support
OMAP3 even without having an open source counterpart, as there
were already some public documentation that seemed to help someone
to write userspace tools in the future.

Thanks,
Mauro

  reply	other threads:[~2021-09-11  0:38 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 21:00 [MAINTAINER SUMMIT] User-space requirements for accelerator drivers Jonathan Corbet
2021-09-10 21:32 ` Josh Triplett
2021-09-13 13:50   ` Christian Brauner
2021-09-13 13:57     ` Daniel Vetter
2021-09-14  2:07       ` Laurent Pinchart
2021-09-14 14:40   ` Jani Nikula
2021-09-14 14:45     ` Geert Uytterhoeven
2021-09-14 14:59       ` Jani Nikula
2021-09-14 15:10         ` Geert Uytterhoeven
2021-09-10 21:51 ` James Bottomley
2021-09-10 21:59   ` Alexandre Belloni
2021-09-10 22:35     ` James Bottomley
2021-09-11 14:51       ` Jonathan Corbet
2021-09-11 15:24         ` James Bottomley
2021-09-11 21:52           ` Laurent Pinchart
2021-09-14 13:22             ` Johannes Berg
2021-09-11  0:08   ` Laurent Pinchart
2021-09-10 22:52 ` Mauro Carvalho Chehab
2021-09-10 23:45   ` Josh Triplett
2021-09-10 23:48     ` Dave Hansen
2021-09-11  0:13       ` Laurent Pinchart
2021-09-10 23:55     ` Thomas Gleixner
2021-09-11  0:20       ` Laurent Pinchart
2021-09-11 14:20         ` Steven Rostedt
2021-09-11 22:08           ` Laurent Pinchart
2021-09-11 22:42             ` Steven Rostedt
2021-09-11 23:10               ` Laurent Pinchart
2021-09-13 11:10               ` Mark Brown
2021-09-11 22:51           ` Mauro Carvalho Chehab
2021-09-11 23:22           ` Mauro Carvalho Chehab
2021-09-11 10:31       ` Leon Romanovsky
2021-09-11 11:41         ` Laurent Pinchart
2021-09-11 12:04           ` Leon Romanovsky
2021-09-11 22:04             ` Laurent Pinchart
2021-09-12  4:27               ` Leon Romanovsky
2021-09-12  7:26                 ` Greg KH
2021-09-12  8:29                   ` Leon Romanovsky
2021-09-12 13:25                     ` Greg KH
2021-09-12 14:15                       ` Leon Romanovsky
2021-09-12 14:34                         ` Greg KH
2021-09-12 16:41                           ` Laurent Pinchart
2021-09-12 20:35                           ` Dave Airlie
2021-09-12 20:41                           ` Dave Airlie
2021-09-12 20:49                             ` Daniel Vetter
2021-09-12 21:12                               ` Dave Airlie
2021-09-12 22:51                                 ` Linus Walleij
2021-09-12 23:15                                   ` Dave Airlie
2021-09-13 13:20                                   ` Arnd Bergmann
2021-09-13 13:54                                     ` Daniel Vetter
2021-09-13 22:04                                       ` Arnd Bergmann
2021-09-13 23:33                                         ` Dave Airlie
2021-09-14  9:08                                           ` Arnd Bergmann
2021-09-14  9:23                                             ` Daniel Vetter
2021-09-14 10:47                                               ` Laurent Pinchart
2021-09-14 12:58                                               ` Arnd Bergmann
2021-09-14 19:45                                                 ` Daniel Vetter
2021-09-14 15:43                                             ` Luck, Tony
2021-09-13 14:52                                     ` James Bottomley
2021-09-14 13:07                                     ` Linus Walleij
2021-09-13 14:03                           ` Mark Brown
2021-09-12 15:55                       ` Laurent Pinchart
2021-09-12 16:43                         ` James Bottomley
2021-09-12 16:58                           ` Laurent Pinchart
2021-09-12 17:08                             ` James Bottomley
2021-09-12 19:52                   ` Dave Airlie
2021-09-12  7:46                 ` Mauro Carvalho Chehab
2021-09-12  8:00                   ` Leon Romanovsky
2021-09-12 14:53                     ` Laurent Pinchart
2021-09-12 15:41                       ` Mauro Carvalho Chehab
2021-09-10 23:46   ` Laurent Pinchart
2021-09-11  0:38     ` Mauro Carvalho Chehab [this message]
2021-09-11  9:27       ` Laurent Pinchart
2021-09-11 22:33         ` Mauro Carvalho Chehab
2021-09-13 12:04         ` Mark Brown
2021-09-12 19:13 ` Dave Airlie
2021-09-12 19:48   ` Laurent Pinchart
2021-09-13  2:26     ` Dave Airlie

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=20210911023811.74b82f10@coco.lan \
    --to=mchehab@kernel.org \
    --cc=corbet@lwn.net \
    --cc=ksummit@lists.linux.dev \
    --cc=laurent.pinchart@ideasonboard.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).