public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <mripard@redhat.com>
To: nicolas.dufresne@collabora.corp-partner.google.com
Cc: "Laurent Pinchart" <laurent.pinchart@ideasonboard.com>,
	"Bryan O'Donoghue" <bryan.odonoghue@linaro.org>,
	"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Benjamin Gaignard" <benjamin.gaignard@collabora.com>,
	"Brian Starkey" <Brian.Starkey@arm.com>,
	"John Stultz" <jstultz@google.com>,
	"T.J. Mercier" <tjmercier@google.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Lennart Poettering" <mzxreary@0pointer.de>,
	"Robert Mader" <robert.mader@collabora.com>,
	"Sebastien Bacher" <sebastien.bacher@canonical.com>,
	"Linux Media Mailing List" <linux-media@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	linaro-mm-sig@lists.linaro.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Milan Zamazal" <mzamazal@redhat.com>,
	"Andrey Konovalov" <andrey.konovalov.ynk@gmail.com>
Subject: Re: Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ?
Date: Tue, 21 May 2024 10:43:34 +0200	[thread overview]
Message-ID: <20240521-thick-messy-lemur-c8cebe@houat> (raw)
In-Reply-To: <08b882dd036367c4d78a5b33f5d11cdb347823bb.camel@collabora.corp-partner.google.com>

[-- Attachment #1: Type: text/plain, Size: 4904 bytes --]

On Thu, May 16, 2024 at 01:11:51PM GMT, nicolas.dufresne@collabora.corp-partner.google.com wrote:
> Le jeudi 16 mai 2024 à 14:27 +0300, Laurent Pinchart a écrit :
> > Hi Nicolas,
> > 
> > On Wed, May 15, 2024 at 01:43:58PM -0400, nicolas.dufresne@collabora.corp-partner.google.com wrote:
> > > Le mardi 14 mai 2024 à 23:42 +0300, Laurent Pinchart a écrit :
> > > > > You'll hit the same limitation as we hit in GStreamer, which is that KMS driver
> > > > > only offer allocation for render buffers and most of them are missing allocators
> > > > > for YUV buffers, even though they can import in these formats. (kms allocators,
> > > > > except dumb, which has other issues, are format aware).
> > > > 
> > > > My experience on Arm platforms is that the KMS drivers offer allocation
> > > > for scanout buffers, not render buffers, and mostly using the dumb
> > > > allocator API. If the KMS device can scan out YUV natively, YUV buffer
> > > > allocation should be supported. Am I missing something here ?
> > > 
> > > There is two APIs, Dumb is the legacy allocation API, only used by display
> > 
> > Is it legacy only ? I understand the dumb buffers API to be officially
> > supported, to allocate scanout buffers suitable for software rendering.
> > 
> > > drivers indeed, and the API does not include a pixel format or a modifier. The
> > > allocation of YUV buffer has been made through a small hack, 
> > > 
> > >   bpp = number of bits per component (of luma plane if multiple planes)
> > >   width = width
> > >   height = height * X
> > > 
> > > Where X will vary, "3 / 2" is used for 420 subsampling, "2" for 422 and "3" for
> > > 444. It is far from idea, requires deep knowledge of each formats in the
> > > application
> > 
> > I'm not sure I see that as an issue, but our experiences and uses cases
> > may vary :-)
> 
> Its extra burden, and does not scale to all available pixel formats. My reply
> was for readers education as I feel like a lot of linux-media dev don't have a
> clue of what is going on at the rendering side. This ensure a minimum knowledge
> to everyone commenting.
> 
> And yes, within the GFX community, Dumb allocation is to be killed and
> replacement completely in the future, it simply does not have a complete
> replacement yet.
> 
> > 
> > > and cannot allocate each planes seperatly.
> > 
> > For semi-planar or planar formats, unless I'm mistaken, you can either
> > allocate a single buffer and use it with appropriate offsets when
> > constructing your framebuffer (with DRM_IOCTL_MODE_ADDFB2), or allocate
> > one buffer per plane.
> 
> We have use cases were single allocation is undesirable, but I don't really feel
> like this is important enough for me to type this explanation. Ping me if you
> care.
> > 
> > > The second is to use the driver specific allocation API. This is then abstracted
> > > by GBM. This allows allocating render buffers with notably modifiers and/or use
> > > cases. But no support for YUV formats or multi-planar formats.
> > 
> > GBM is the way to go for render buffers indeed. It has been designed
> > with only graphics buffer management use cases in mind, so it's
> > unfortunately not an option as a generic allocator, at least in its
> > current form.
> > 
> 
> What I perhaps should have highlighted that is that all these allocators in the
> GFX (called DRM, but meh) subsystem abstract away some deep knowledge of the HW
> requirements. Heaps are lower level APIs that assume that userspace have this
> knowledge. The Android and ChromeOS solution is to take the implementation from
> the kernel and move it into userspace, see minigbm from chromeos, or gralloc
> from Android. As these two projects are device centric, they are not usable on
> generic Linux. Heaps might have some future, but not without other piece of the
> puzzle.
> 
> To come back to you wanting heaps in libcamera, because it makes them better for
> rendered or display. Well today this is a lie you make to yourself, because this
> is just a tiny bit of the puzzle, it is pure luck if you allocate dmabuf is
> usable but a foreign device. At the end of the day, this is just a fallback to
> satisfy that application are not forced to allocate that memory in libcamera.

I mean, it's pure luck, but can you point to any platform supported
upstream where it wouldn't work?

> Thus, I strongly recommend the udmabuf in the short term. Finally, moving to
> heaps when the reported issue is resolved, as then it gives more options and
> reduce the number of layers.

udmabuf wouldn't work with any platform without an IOMMU. We have plenty
of those.

All things considered, while I agree that it isn't the ideal solution,
we really don't have a better (ie, works on a larger set of platforms)
solution at the moment or in the next 5 years.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

  reply	other threads:[~2024-05-21  8:43 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 11:49 Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ? Hans de Goede
2024-05-06 12:05 ` Maxime Ripard
2024-05-06 12:11   ` Hans de Goede
2024-05-06 13:38   ` Daniel Vetter
2024-05-06 14:01     ` Hans de Goede
2024-05-07 11:15       ` Daniel Vetter
2024-05-08  5:46         ` Daniel Stone
2024-05-08  8:33           ` Daniel Vetter
2024-05-08  8:38             ` Daniel Stone
2024-05-08 15:49               ` Daniel Vetter
2024-05-09  9:23                 ` Daniel Stone
2024-05-16 10:18                   ` Daniel Vetter
2024-05-13 13:51                 ` Simon Ser
2024-05-16 10:13                   ` Daniel Vetter
2024-05-07 13:34       ` Dmitry Baryshkov
2024-05-07 18:59     ` Laurent Pinchart
2024-05-22 13:34     ` Maxime Ripard
2024-05-23  9:41       ` Daniel Vetter
2024-05-07 13:32 ` Dmitry Baryshkov
2024-05-07 14:34   ` Hans de Goede
2024-05-07 15:09     ` Dmitry Baryshkov
2024-05-07 15:15       ` Bryan O'Donoghue
2024-05-07 15:19         ` Dmitry Baryshkov
2024-05-07 18:40           ` Laurent Pinchart
2024-05-07 19:59             ` Dmitry Baryshkov
2024-05-07 20:15               ` Laurent Pinchart
2024-05-08  8:39               ` Daniel Vetter
2024-05-08 21:54                 ` Laurent Pinchart
2024-05-13  8:39               ` Maxime Ripard
2024-05-07 17:36         ` Daniel Vetter
2024-05-07 18:36           ` Laurent Pinchart
2024-05-07 20:07             ` Nicolas Dufresne
2024-05-08  8:36               ` Daniel Vetter
2024-05-08 21:51                 ` Laurent Pinchart
2024-05-08 21:52                   ` Laurent Pinchart
2024-05-13  8:29                 ` Maxime Ripard
2024-05-13  8:34                   ` Laurent Pinchart
2024-05-13 15:10                     ` Nicolas Dufresne
2024-05-14 20:42                       ` Laurent Pinchart
2024-05-15 17:43                         ` nicolas.dufresne
2024-05-16 11:27                           ` Laurent Pinchart
2024-05-16 17:11                             ` nicolas.dufresne
2024-05-21  8:43                               ` Maxime Ripard [this message]
2024-05-21 14:18                                 ` nicolas.dufresne
2024-05-16  7:00                         ` Simon Ser
2024-05-16 11:20                           ` Laurent Pinchart
2024-05-22 13:02                             ` Nicolas Dufresne
2024-05-13 13:42                   ` Nicolas Dufresne
2024-05-13 13:51                     ` Maxime Ripard
2024-05-13 15:06                       ` Nicolas Dufresne
2024-05-14 20:45                         ` Laurent Pinchart
2024-05-14 20:52                           ` Nicolas Dufresne

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=20240521-thick-messy-lemur-c8cebe@houat \
    --to=mripard@redhat.com \
    --cc=Brian.Starkey@arm.com \
    --cc=andrey.konovalov.ynk@gmail.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=bryan.odonoghue@linaro.org \
    --cc=christian.koenig@amd.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hdegoede@redhat.com \
    --cc=jstultz@google.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mzamazal@redhat.com \
    --cc=mzxreary@0pointer.de \
    --cc=nicolas.dufresne@collabora.corp-partner.google.com \
    --cc=robert.mader@collabora.com \
    --cc=sebastien.bacher@canonical.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tjmercier@google.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