Correct sequencing of usage of DRM writeback connector

Daniel Vetter daniel at ffwll.ch
Mon Jun 17 15:16:36 UTC 2024


On Mon, Jun 17, 2024 at 01:41:59PM +0000, Hoosier, Matt wrote:
> Hi,
> 
> There is a discussion ongoing over in the compositor world about the implication of this cautionary wording found in the documentation for the DRM_MODE_CONNECTOR_WRITEBACK connectors:
> 
> >  *  "WRITEBACK_OUT_FENCE_PTR":
> >  *	Userspace can use this property to provide a pointer for the kernel to
> >  *	fill with a sync_file file descriptor, which will signal once the
> >  *	writeback is finished. The value should be the address of a 32-bit
> >  *	signed integer, cast to a u64.
> >  *	Userspace should wait for this fence to signal before making another
> >  *	commit affecting any of the same CRTCs, Planes or Connectors.
> >  *	**Failure to do so will result in undefined behaviour.**
> >  *	For this reason it is strongly recommended that all userspace
> >  *	applications making use of writeback connectors *always* retrieve an
> >  *	out-fence for the commit and use it appropriately.
> >  *	From userspace, this property will always read as zero.
> 
> The question is whether it's realistic to hope that a DRM writeback
> connector can produce results on every frame, and do so without dragging
> down the frame-rate for the connector.
> 
> The wording in the documentation above suggests that it is very likely
> the fence fd won't signal userspace until after the vblank following the
> scanout during which the writeback was applied (call that frame N). This
> would mean that the compositor driving the connector would typically be
> unable to legally queue a page flip for frame N+1.
> 
> Is this the right interpretation? Is the writeback hardware typically
> even designed with a streaming use-case in mind? Maybe it's just
> intended for occasional static screenshots.

So typically writeback hardware needs its separate crtc (at least the
examples I know of) and doesn't make a lot of guarantees that it's fast
enough for real time use. Since it's a separate crtc it shouldn't hold up
the main composition loop, and so this should be all fine.

If/when we have hardware and driver support where you can use the
writeback connector as a real-time streamout kind of thing, then we need
to change all this, because with the current implementation, there's
indeed the possibility that funny things can happen if you ignore the
notice (funny as in data corruption, not funny as the kernel crashes of
course).

If we already have devices where you can use writeback together with real
outputs, then I guess that counts as an oopsie :-/

Cheers, Sima
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list