[RFC v2 0/8] drm: explicit fencing support

classic Classic list List threaded Threaded
47 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Daniel Vetter
On Thu, Apr 28, 2016 at 7:55 PM, Gustavo Padovan
<[hidden email]> wrote:

> 2016-04-28 Ville Syrjälä <[hidden email]>:
>
>> On Thu, Apr 28, 2016 at 07:43:16PM +0200, Daniel Vetter wrote:
>> > On Thu, Apr 28, 2016 at 6:56 PM, Ville Syrjälä
>> > <[hidden email]> wrote:
>> > >>  - better for tracing, can identify the buffer/fence promptly
>> > >
>> > > Can fences be reused somehow while still attached to a plane, or ever?
>> > > That might cause some oddness if you, say, leave a fence attached to one
>> > > plane and then do a modeset on another crtc perhaps which needs to turn
>> > > the first crtc off+on to reconfigure something.
>> >
>> > Fences auto-disappear of course and don't stick around when you
>> > duplicate the drm_plane_state again. I still don't really get the real
>> > concerns though ...
>>
>> Properties that magically change values shouldn't exist IMO. I guess if
>> you could have write-only properties or something it migth be sensible?
>
> We can just not return FENCE_FD on get_props, that would make it
> write-only.

We do actually return a value for get_props, but it's -1 which for fds
means "no fd". That's to make sure userspace can save&restore any prop
without causing harm.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Ville Syrjälä-2
In reply to this post by Ville Syrjälä-2
On Thu, Apr 28, 2016 at 07:56:19PM +0300, Ville Syrjälä wrote:

> On Thu, Apr 28, 2016 at 11:36:44AM -0300, Gustavo Padovan wrote:
> > 2016-04-27 Daniel Stone <[hidden email]>:
> >
> > > Hi,
> > >
> > > On 26 April 2016 at 21:48, Greg Hackmann <[hidden email]> wrote:
> > > > On 04/26/2016 01:05 PM, Daniel Vetter wrote:
> > > >> On Tue, Apr 26, 2016 at 09:55:06PM +0300, Ville Syrjälä wrote:
> > > >>> What are they doing that can't stuff the fences into an array
> > > >>> instead of props?
> > > >>
> > > >> The hw composer interface is one in-fence per plane. That's really the
> > > >> major reason why the kernel interface is built to match. And I really
> > > >> don't think we should diverge just because we have a slight different
> > > >> color preference ;-)
> > > >
> > > > The relationship between layers and fences is only fuzzy and indirect
> > > > though.  The relationship is really between the buffer you're displaying on
> > > > that layer, and the fence representing the work done to render into that
> > > > buffer.  SurfaceFlinger just happens to bundle them together inside the same
> > > > struct hwc_layer_1 as an API convenience.
> > >
> > > Right, and when using implicit fencing, this comes as a plane
> > > property, by virtue of plane -> fb -> buffer -> fence.
> > >
> > > > Which is kind of splitting hairs as long as you have a 1-to-1 relationship
> > > > between layers and DRM planes.  But that's not always the case.
> > >
> > > Can you please elaborate?
> > >
> > > > A (per-CRTC?) array of fences would be more flexible.  And even in the cases
> > > > where you could make a 1-to-1 mapping between planes and fences, it's not
> > > > that much more work for userspace to assemble those fences into an array
> > > > anyway.
> > >
> > > As Ville says, I don't want to go down the path of scheduling CRTC
> > > updates separately, because that breaks MST pretty badly. If you don't
> > > want your updates to display atomically, then don't schedule them
> > > atomically ... ? That's the only reason I can see for making fencing
> > > per-CRTC, rather than just a pile of unassociated fences appended to
> > > the request. Per-CRTC fences also forces userspace to merge fences
> > > before submission when using multiple planes per CRTC, which is pretty
> > > punitive.
> > >
> > > I think having it semantically attached to the plane is a little bit
> > > nicer for tracing (why was this request delayed? -> a fence -> which
> > > buffer was that fence for?) at a glance. Also the 'pile of appended
> > > fences' model is a bit awkward for more generic userspace, which
> > > creates a libdrm request and builds it (add a plane, try it out, wind
> > > back) incrementally. Using properties makes that really easy, but
> > > without properties, we'd have to add separate codepaths - and thus
> > > separate ABI, which complicates distribution - to libdrm to account
> > > for a separate plane array which shares a cursor with the properties.
> > > So for that reason if none other, I'd really prefer not to go down
> > > that route.
> >
> > I also agree to have it as FENCE_FD prop on the plane. Summarizing the
> > arguments on this thread, they are:
>
> Your "summary" forgot to include any counter arguments.
>
> >
> >  - implicit fences also needs one fence per plane/fb, so it will be good to    
> >    match with that.                                                            
>
> We would actually need a fence per object rather than per fb.

I guess you could overcome this by automagically creating a merged fence
for a multi-obj fb?

--
Ville Syrjälä
Intel OTC
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Daniel Vetter
On Thu, Apr 28, 2016 at 8:17 PM, Ville Syrjälä
<[hidden email]> wrote:
>> >  - implicit fences also needs one fence per plane/fb, so it will be good to
>> >    match with that.
>>
>> We would actually need a fence per object rather than per fb.
>
> I guess you could overcome this by automagically creating a merged fence
> for a multi-obj fb?

Yeah, and the android hwc does this for you already. You get passed a
surface (or whatever it's called exactly) plus a fence, and the
surface contains the gralloc/native buffer thing, which would contain
multiple dma-buf handles if your hw does planar stuff that way.

I think everyone else who wants explicit fencing will go with the same
or similar model, so it's just about implicit fencing. And there we
can easily construct the fence_collection from a drm_framebuffer
ourselves with a small helper in each driver (or shared one in cma,
although cma doesn't yet grok reserverations/implicitly attached
fences).
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Rob Clark
In reply to this post by Daniel Vetter
On Wed, Apr 27, 2016 at 2:39 AM, Daniel Vetter <[hidden email]> wrote:

> On Tue, Apr 26, 2016 at 01:48:02PM -0700, Greg Hackmann wrote:
>> On 04/26/2016 01:05 PM, Daniel Vetter wrote:
>> >On Tue, Apr 26, 2016 at 09:55:06PM +0300, Ville Syrjälä wrote:
>> >>On Tue, Apr 26, 2016 at 08:23:46PM +0200, Daniel Vetter wrote:
>> >>>On Tue, Apr 26, 2016 at 08:40:45PM +0300, Ville Syrjälä wrote:
>> >>>But really the reason for per-plane is hw composer from
>> >>>Android. I don't see any point in designing an api that's needlessly
>> >>>different from what the main user expects (even if it may be silly).
>> >>
>> >>What are they doing that can't stuff the fences into an array
>> >>instead of props?
>> >
>> >The hw composer interface is one in-fence per plane. That's really the
>> >major reason why the kernel interface is built to match. And I really
>> >don't think we should diverge just because we have a slight different
>> >color preference ;-)
>> >
>> >As long as you end up with a pile of fences somehow it'll work.
>> >-Daniel
>> >
>>
>> The relationship between layers and fences is only fuzzy and indirect
>> though.  The relationship is really between the buffer you're displaying on
>> that layer, and the fence representing the work done to render into that
>> buffer.  SurfaceFlinger just happens to bundle them together inside the same
>> struct hwc_layer_1 as an API convenience.
>>
>> Which is kind of splitting hairs as long as you have a 1-to-1 relationship
>> between layers and DRM planes.  But that's not always the case.
>>
>> A (per-CRTC?) array of fences would be more flexible.  And even in the cases
>> where you could make a 1-to-1 mapping between planes and fences, it's not
>> that much more work for userspace to assemble those fences into an array
>> anyway.
>
> I'm ok with an array too if that's what you folks prefer (it's meant to be
> used by you after all). I just don't want just 1 fence for the entire op,
> forcing userspace to first merge them all together. That seems silly.

I was kinda more a fan of array too, if for no other reason that to be
consistent w/ how out-fences work.  (And using property just for
in-fence seemed slightly weird/abusive to me)

> One side-effect of that is that we'd also have to rework all the internal
> bits and move fences around in atomic. Which means change a pile of
> drivers. Not sure that's worth it, but I'd be ok either way really.

hmm, well we could keep the array per-plane (and if one layer is using
multiple planes, just list the same fd multiple times).. then it
mostly comes down to changes in the ioctl fxn itself.

BR,
-R


> -Daniel
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> dri-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Daniel Stone
Hi,

On 28 April 2016 at 23:28, Rob Clark <[hidden email]> wrote:

> On Wed, Apr 27, 2016 at 2:39 AM, Daniel Vetter <[hidden email]> wrote:
>> On Tue, Apr 26, 2016 at 01:48:02PM -0700, Greg Hackmann wrote:
>>> A (per-CRTC?) array of fences would be more flexible.  And even in the cases
>>> where you could make a 1-to-1 mapping between planes and fences, it's not
>>> that much more work for userspace to assemble those fences into an array
>>> anyway.
>>
>> I'm ok with an array too if that's what you folks prefer (it's meant to be
>> used by you after all). I just don't want just 1 fence for the entire op,
>> forcing userspace to first merge them all together. That seems silly.
>
> I was kinda more a fan of array too, if for no other reason that to be
> consistent w/ how out-fences work.  (And using property just for
> in-fence seemed slightly weird/abusive to me)

I don't think it's really useful to look for much consistency between
the two, beyond the name. I'm more concerned with consistency between
in-fences and the implicit fences on buffers/FBs, and between
out-fences and the page_flip_events.

>> One side-effect of that is that we'd also have to rework all the internal
>> bits and move fences around in atomic. Which means change a pile of
>> drivers. Not sure that's worth it, but I'd be ok either way really.
>
> hmm, well we could keep the array per-plane (and if one layer is using
> multiple planes, just list the same fd multiple times).. then it
> mostly comes down to changes in the ioctl fxn itself.

... and new API in libdrm, which is going to be a serious #ifdef and
distribution pain. The core property API has been available since
2.4.62 last June, but for this we'd have to write the code, wait for
the kernel code, wait for HWC, get everything together, and then merge
and release. That gives minimum one year of libdrm releases which have
had atomic but not in-fence API support, if we're adding a new array.
And I just don't really see what it buys us, apart from the need for
the core atomic_get_property helper to statically return -1 when
requesting FENCE_FD.

Cheers,
Daniel
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Greg Hackmann
In reply to this post by Daniel Vetter
On 04/26/2016 11:39 PM, Daniel Vetter wrote:

>> A (per-CRTC?) array of fences would be more flexible.  And even in the cases
>> where you could make a 1-to-1 mapping between planes and fences, it's not
>> that much more work for userspace to assemble those fences into an array
>> anyway.
>
> I'm ok with an array too if that's what you folks prefer (it's meant to be
> used by you after all). I just don't want just 1 fence for the entire op,
> forcing userspace to first merge them all together. That seems silly.
>
> One side-effect of that is that we'd also have to rework all the internal
> bits and move fences around in atomic. Which means change a pile of
> drivers. Not sure that's worth it, but I'd be ok either way really.
> -Daniel
>

It's not a strong preference on my end.  The 1:1 plane-to-layer mapping
breaks down somewhat on hardware where you need to split large
hwcomposer layers across multiple DRM planes.

That said, you can force that case to fit by just dup()ing the fence a
bunch of times or arbitrarily picking one of the planes to assign the
fence to.  Either is kludgey, but I can't argue it's kludgey enough to
justify refactoring a bunch of existing driver code.
Reply | Threaded
Open this post in threaded view
|

Re: [RFC v2 5/8] drm/fence: add in-fences support

Rob Clark
In reply to this post by Daniel Stone
On Fri, Apr 29, 2016 at 3:48 AM, Daniel Stone <[hidden email]> wrote:

> Hi,
>
> On 28 April 2016 at 23:28, Rob Clark <[hidden email]> wrote:
>> On Wed, Apr 27, 2016 at 2:39 AM, Daniel Vetter <[hidden email]> wrote:
>>> On Tue, Apr 26, 2016 at 01:48:02PM -0700, Greg Hackmann wrote:
>>>> A (per-CRTC?) array of fences would be more flexible.  And even in the cases
>>>> where you could make a 1-to-1 mapping between planes and fences, it's not
>>>> that much more work for userspace to assemble those fences into an array
>>>> anyway.
>>>
>>> I'm ok with an array too if that's what you folks prefer (it's meant to be
>>> used by you after all). I just don't want just 1 fence for the entire op,
>>> forcing userspace to first merge them all together. That seems silly.
>>
>> I was kinda more a fan of array too, if for no other reason that to be
>> consistent w/ how out-fences work.  (And using property just for
>> in-fence seemed slightly weird/abusive to me)
>
> I don't think it's really useful to look for much consistency between
> the two, beyond the name. I'm more concerned with consistency between
> in-fences and the implicit fences on buffers/FBs, and between
> out-fences and the page_flip_events.
>
>>> One side-effect of that is that we'd also have to rework all the internal
>>> bits and move fences around in atomic. Which means change a pile of
>>> drivers. Not sure that's worth it, but I'd be ok either way really.
>>
>> hmm, well we could keep the array per-plane (and if one layer is using
>> multiple planes, just list the same fd multiple times).. then it
>> mostly comes down to changes in the ioctl fxn itself.
>
> ... and new API in libdrm, which is going to be a serious #ifdef and
> distribution pain. The core property API has been available since
> 2.4.62 last June, but for this we'd have to write the code, wait for
> the kernel code, wait for HWC, get everything together, and then merge
> and release. That gives minimum one year of libdrm releases which have
> had atomic but not in-fence API support, if we're adding a new array.
> And I just don't really see what it buys us, apart from the need for
> the core atomic_get_property helper to statically return -1 when
> requesting FENCE_FD.

don't we have the same issue for out-fences anyway?

ofc, I suspect we could handle making fences look like properties in
userspace in libdrm (at least if there was a sane way that libdrm
could track and eventually close() old out-fence fd's).  I'm not
entirely sure this matters, I mean how do we make implicit vs explicit
fencing transparent to the compositor and the proto between
compositor<->app?

Admittedly I haven't given *too* much thought yet about the
implications to libdrm and it's users, but it seems like we need to
make a v2 API rev anyway for out-fences, and the compositor is going
to need different codepaths for explicit vs implicit (if it supports
both).  So I don't think in-fences as something other than property
really costs us anything additional?

(Unless there is some sane reason to have an intermediate state w/
in-fences but pageflip events instead of out-fences?  But that seems
odd..)

BR,
-R


> Cheers,
> Daniel
123