All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel@daenzer.net>
To: Christopher James Halse Rogers
	<christopher.halse.rogers@canonical.com>,
	Lucas Stach <l.stach@pengutronix.de>,
	Daniel Vetter <daniel@ffwll.ch>
Cc: raof@ubuntu.com, dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT.
Date: Mon, 10 Apr 2017 17:51:21 +0900	[thread overview]
Message-ID: <8c9c3bbd-b036-238a-3a71-4303e45dbe0f@daenzer.net> (raw)
In-Reply-To: <CAPMmPEwd0ixvM8Tn8Yv3PrNfWk4Y0poW2AK09FgetJVSKY6ZRA@mail.gmail.com>

On 06/04/17 04:47 PM, Christopher James Halse Rogers wrote:
> On Wed, 5 Apr 2017 at 20:14 Lucas Stach <l.stach@pengutronix.de
> <mailto:l.stach@pengutronix.de>> wrote:
> 
>     Am Mittwoch, den 05.04.2017, 11:59 +0200 schrieb Daniel Vetter:
>     > On Wed, Apr 05, 2017 at 10:15:44AM +0200, Lucas Stach wrote:
>     > > Am Mittwoch, den 05.04.2017, 00:20 +0000 schrieb Christopher
>     James Halse
>     > > Rogers:
>     > > >
>     > > >
>     > > > On Tue, Apr 4, 2017 at 9:53 PM Daniel Vetter <daniel@ffwll.ch
>     <mailto:daniel@ffwll.ch>> wrote:
>     > > >
>     > > >         On Tue, Apr 4, 2017 at 12:43 PM, Lucas Stach
>     > > >         <l.stach@pengutronix.de
>     <mailto:l.stach@pengutronix.de>> wrote:
>     > > >         >> If I could guarantee that I'd only ever run on
>     > > >         4.13-or-later kernels
>     > > >         >> (I think that's when the previous patches will
>     land?), then
>     > > >         this would
>     > > >         >> indeed be mostly unnecessary. It would save me a
>     bunch of
>     > > >         addfb calls
>     > > >         >> that would predictably fail, but they're cheap.
>     > > >         >
>     > > >         > I don't think we ever had caps for "things are
>     working now,
>     > > >         as they are
>     > > >         > supposed to". i915 wasn't properly synchronizing on
>     foreign
>     > > >         fences for a
>     > > >         > long time, yet we didn't gain a cap for "cross
>     device sync
>     > > >         works now".
>     > > >         >
>     > > >         > If your distro use-case relies on those things
>     working it's
>     > > >         probably
>     > > >         > best to just backport the relevant fixes.
>     > > >
>     > > >         The even better solution for this is to push the backports
>     > > >         through
>     > > >         upstream -stable kernels. This stuff here is simple enough
>     > > >         that we can
>     > > >         do it. Same could have been done for the fairly minimal
>     > > >         fencing fixes
>     > > >         for i915 (at least some of them, the ones in the
>     page-flip).
>     > > >
>     > > >         Otherwise we'll end up with tons IM_NOT_BUGGY and
>     > > >         IM_SLIGHTLY_LESS_BUGGY and
>     > > >         IM_NOT_BUGGY_EXCEPT_THIS_BOTCHED_BACKPORT
>     > > >         flags where no one at all knows what they mean, usage
>     between
>     > > >         different drivers and different userspace is entirely
>     > > >         inconsistent and
>     > > >         they just all add to the confusion. They're just bugs,
>     lets
>     > > >         treat them
>     > > >         like that.
>     > > >
>     > > >
>     > > > It's not *quite* DRM_CAP_PRIME_SCANOUT_NOT_BUGGY - while the
>     relevant
>     > > > hardware allegedly supports it, nouveau/radeon/amdgpu don't do
>     scanout
>     > > > of GTT, so the lack of this cap indicates that there's no point in
>     > > > trying to call addfb2.
>     > > >
>     > > >
>     > > > But calling addfb2 and it failing is not expensive, so this is
>     rather
>     > > > niche.
>     > > >
>     > > >
>     > > > In practice I can just restrict attempting to scanout of imported
>     > > > buffers to i915, as that's the only driver that it'll work on.
>     By the
>     > > > time nouveau/radeon/amdgpu get patches to scanout of GTT the fixes
>     > > > should be old enough that I don't need to care about unfixed
>     kernels.
>     > > >
>     > > So given that most discreet hardware won't ever be able to
>     scanout from
>     > > GTT (latency and iso requirements will be hard to meet), can't
>     we just
>     > > fix the case of the broken prime sharing when migrating to VRAM?
>     > >
>     > > I'm thinking about attaching an exclusive fence to the dma-buf
>     when the
>     > > migration to VRAM happens, then when the GPU is done with the
>     buffer we
>     > > can either write back any changes to GTT, or just drop the fence
>     in case
>     > > the GPU didn't modify the buffer.
>     >
>     > We could, but someone needs to type the code for it. There's also the
>     > problem that you need to migrate back, and then doing all that behind
>     > userspaces back might not be the best idea.
> 
>     Drivers with separate VRAM and GTT are already doing a lot of migration
>     behind the userspaces back. The only issue with dma-buf migration to
>     VRAM is that you probably don't want to migrate the pages, but duplicate
>     them in VRAM, doubling memory consumption with possible OOM. But then
>     you could alloc the memory on addfb where you are able to return proper
>     errors.
> 
> 
> Hm. So, on a first inspection, this looks like something I could
> actually cook up.
> 
> Looking at amdgpu it seems like the thing to do would be to associate a
> shadow-bo in VRAM for the imported dma-buf in the addfb call, then
> pin-and-copy-to the shadow bo in the places where the bo is currently
> pinned.
> 
> Is this approach likely to be acceptable?

It would break e.g. with DRI2 flips, because they replace the screen
pixmap buffer with the buffer we're flipping to. If the app stops
flipping while such a shadow BO is being scanned out, later draws to the
screen pixmap won't become visible.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-04-10  8:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04  8:13 [PATCH] Tell userspace if scanning out of an imported PRIME buffer is safe raof
2017-04-04  8:13 ` [PATCH 1/2] drm: Add DRM_CAP_PRIME_SCANOUT raof
2017-04-04  8:31   ` Daniel Vetter
2017-04-04 10:11     ` Daniel Stone
2017-04-04 10:27     ` Christopher James Halse Rogers
2017-04-04 10:43       ` Lucas Stach
2017-04-04 11:53         ` Daniel Vetter
2017-04-05  0:20           ` Christopher James Halse Rogers
2017-04-05  6:27             ` Daniel Vetter
2017-04-05  6:52               ` Christopher James Halse Rogers
2017-04-05  8:15             ` Lucas Stach
2017-04-05  9:59               ` Daniel Vetter
2017-04-05 10:14                 ` Lucas Stach
2017-04-05 11:13                   ` Christopher James Halse Rogers
2017-04-05 11:21                     ` Christian König
2017-04-10  8:52                       ` Michel Dänzer
2017-04-10  9:03                         ` Christian König
2017-04-10 14:10                           ` Alex Deucher
2017-04-06  7:47                   ` Christopher James Halse Rogers
2017-04-10  8:51                     ` Michel Dänzer [this message]
2017-04-17  5:05                       ` Christopher James Halse Rogers
2017-04-17  6:41                         ` Michel Dänzer
2017-04-04 10:43       ` Daniel Stone
2017-04-04 11:15         ` Christian König
2017-04-04 11:32           ` Daniel Stone
2017-04-04 11:43             ` Christian König
2017-04-04  8:13 ` [PATCH 2/2] drm/i915: support DRIVER_PRIME_SCANOUT raof

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=8c9c3bbd-b036-238a-3a71-4303e45dbe0f@daenzer.net \
    --to=michel@daenzer.net \
    --cc=christopher.halse.rogers@canonical.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=l.stach@pengutronix.de \
    --cc=raof@ubuntu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.