All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Harrison <John.C.Harrison@Intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, Intel-GFX@Lists.FreeDesktop.Org
Subject: Re: [RFC] drm/i915: Add sync framework support to execbuff IOCTL
Date: Thu, 02 Jul 2015 16:43:12 +0100	[thread overview]
Message-ID: <55955C10.5000306@Intel.com> (raw)
In-Reply-To: <20150702132238.GY21398@nuc-i3427.alporthouse.com>

On 02/07/2015 14:22, Chris Wilson wrote:
> On Thu, Jul 02, 2015 at 02:01:56PM +0100, John Harrison wrote:
>> On 02/07/2015 12:54, Chris Wilson wrote:
>>> On Thu, Jul 02, 2015 at 12:09:59PM +0100, John.C.Harrison@Intel.com wrote:
>>>> From: John Harrison <John.C.Harrison@Intel.com>
>>>>
>>>> Various projects desire a mechanism for managing dependencies between
>>>> work items asynchronously. This can also include work items across
>>>> complete different and independent systems. For example, an
>>>> application wants to retreive a frame from a video in device,
>>>> using it for rendering on a GPU then send it to the video out device
>>>> for display all without having to stall waiting for completion along
>>>> the way. The sync framework allows this. It encapsulates
>>>> synchronisation events in file descriptors. The application can
>>>> request a sync point for the completion of each piece of work. Drivers
>>>> should also take sync points in with each new work request and not
>>>> schedule the work to start until the sync has been signalled.
>>>>
>>>> This patch adds sync framework support to the exec buffer IOCTL. A
>>>> sync point can be passed in to stall execution of the batch buffer
>>>> until signalled. And a sync point can be returned after each batch
>>>> buffer submission which will be signalled upon that batch buffer's
>>>> completion.
>>>>
>>>> At present, the input sync point is simply waited on synchronously
>>>> inside the exec buffer IOCTL call. Once the GPU scheduler arrives,
>>>> this will be handled asynchronously inside the scheduler and the IOCTL
>>>> can return without having to wait.
>>>>
>>>> Note also that the scheduler will re-order the execution of batch
>>>> buffers, e.g. because a batch buffer is stalled on a sync point and
>>>> cannot be submitted yet but other, independent, batch buffers are
>>>> being presented to the driver. This means that the timeline within the
>>>> sync points returned cannot be global to the engine. Instead they must
>>>> be kept per context per engine (the scheduler may not re-order batches
>>>> within a context). Hence the timeline cannot be based on the existing
>>>> seqno values but must be a new implementation.
>>> But there is nothing preventing assignment of the sync value on
>>> submission. Other than the debug .fence_value_str it's a private
>>> implementation detail, and the interface is solely through the fd and
>>> signalling.
>> No, it needs to be public from the moment of creation. The sync
>> framework API allows sync points to be combined together to create
>> fences that either merge multiple points on the same timeline or
>> amalgamate points across differing timelines. The merging part means
>> that the sync point must be capable of doing arithmetic comparisons
>> with other sync points from the instant it is returned to user land.
>> And those comparisons must not change in the future due to scheduler
>> re-ordering because by then it is too late to redo the test.
> You know that's not documented at all. The only information userspace
> gets is afaict
>
> struct sync_pt_info {
> 	__u32   len;
> 	char    obj_name[32];
> 	char    driver_name[32];
> 	__s32   status;
> 	__u64   timestamp_ns;
>
> 	__u8    driver_data[0];
> };
>
> There is a merge operation done by combining two fence into a new one.
> Merging is done by ordering the fences based on the context pointers and
> then by sync_pt->fence.seqno, not the private sync value.
>
> How does userspace try to order the fences other than as opaque fd? You
> actually mean driver_data is undefined ABI...
Hmm, something looks confused. Way back when (i.e. the shipping Android 
tree), the 'private' seqno value was very definitely being exposed in 
various ways but it looks like it has actually been superseded by the 
seqno value inside the (new) fence object that is inside the sync_pt. 
Despite that, there is still a 'compare' callback in the timeline_ops 
for doing comparisons between sync_pts based on their private 
implementation specific seqno. Although this is marked as 'required' it 
is not actually called anywhere anymore! So it looks like we can drop 
the 'private' seqno value completely and just use the fence version.

In my defense, this code is all coming from the Android tree and the 
port to the nightly was done by someone else. I hadn't realised that 
nightly had changed quite so significantly.

>>>   You could implement this as a secondary write to the HWS,
>>> assigning the sync_value to the sync_pt on submission and
>>> remove the request tracking, as when signalled you only need to compare
>>> the sync_value against the timeline value in the HWS.
>>>
>>> However, that equally applies to the existing request->seqno. That can
>>> also be assigned on submission so that it always an ordered timeline, and
>>> so can be used internally or externally.
>> One of the scheduler patches is to defer seqno assignment until
>> batch submission rather than do it at request creation (for
>> execbuffer requests). You still have a problem with pre-emption
>> though. A request that is pre-empted will get a new seqno assigned
>> when it is resubmitted so that the HWS page always sees ordered
>> values popping out. For internal requests, this is fine but for
>> external sync points that breaks the assumptions made by the
>> framework.
> I fail to see how. Nothing in uapi/sync.h says anything about the order
> of fences or gives any such guarantees. If the external callers only
> have access through the fd, there is no restriction that the timeline
> sync_pt->value must be set prior to submission.

As noted above, it looks like the new version of the sync framework now 
allocates its own context/value seqno pair internally at creation time. 
So all my comments really refer to that seqno inside the struct fence. 
It seems like a bad idea that we are trying to shoe horn another seqno 
value on top.

Back to the drawing board...


> -Chris
>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-07-02 15:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02 11:09 [RFC] drm/i915: Add sync framework support to execbuff IOCTL John.C.Harrison
2015-07-02 11:54 ` Chris Wilson
2015-07-02 12:02   ` Chris Wilson
2015-07-02 13:01   ` John Harrison
2015-07-02 13:22     ` Chris Wilson
2015-07-02 15:43       ` John Harrison [this message]
2015-07-02 15:55         ` Chris Wilson
2015-07-03 11:17           ` Tvrtko Ursulin
2015-07-06  9:29             ` Daniel Vetter
2015-07-06 12:58               ` John Harrison
2015-07-06 13:59                 ` Daniel Vetter
2015-07-06 14:26                   ` John Harrison
2015-07-06 14:41                     ` Daniel Vetter
2015-07-06 14:46                     ` Tvrtko Ursulin
2015-07-06 15:12                       ` Daniel Vetter
2015-07-06 15:21                         ` Tvrtko Ursulin
2015-07-06 15:37                           ` Daniel Vetter
2015-07-06 16:34                             ` Tvrtko Ursulin
2015-07-06 17:58                               ` Daniel Vetter
2015-07-07  9:15                 ` Tvrtko Ursulin
2015-07-29 21:19                   ` Jesse Barnes
2015-07-30 11:36                     ` John Harrison

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=55955C10.5000306@Intel.com \
    --to=john.c.harrison@intel.com \
    --cc=Intel-GFX@Lists.FreeDesktop.Org \
    --cc=chris@chris-wilson.co.uk \
    /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.