From: John Harrison <John.C.Harrison@Intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, Intel-GFX@Lists.FreeDesktop.Org
Subject: Re: [RFC 6/9] drm/i915: Add sync framework support to execbuff IOCTL
Date: Thu, 14 Jan 2016 11:47:17 +0000 [thread overview]
Message-ID: <56978AC5.10604@Intel.com> (raw)
In-Reply-To: <20160113184316.GA29867@nuc-i3427.alporthouse.com>
On 13/01/2016 18:43, Chris Wilson wrote:
> On Wed, Jan 13, 2016 at 05:57:32PM +0000, John.C.Harrison@Intel.com wrote:
>> static int
>> i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>> struct drm_file *file,
>> @@ -1428,6 +1465,17 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>> u32 dispatch_flags;
>> int ret, i;
>> bool need_relocs;
>> + int fd_fence_complete = -1;
>> + int fd_fence_wait = lower_32_bits(args->rsvd2);
>> + struct sync_fence *sync_fence;
>> +
>> + /*
>> + * Make sure an broken fence handle is not returned no matter
>> + * how early an error might be hit. Note that rsvd2 has been
>> + * saved away above because it is also an input parameter!
>> + */
>> + if (args->flags & I915_EXEC_CREATE_FENCE)
>> + args->rsvd2 = (__u64) -1;
> But you are not restoring the user input parameter upon an error path.
>
> Very simple example is the user trying to do a wait on a fence but is
> woken up by a signal and then tries to restart the syscall, the standard
> do {
> ret = ioctl(fd, request, arg);
> } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
> loop errors out with EINVAL on the second pass.
>
>> if (!i915_gem_check_execbuffer(args))
>> return -EINVAL;
>> @@ -1511,6 +1559,17 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>> dispatch_flags |= I915_DISPATCH_RS;
>> }
>>
>> + /*
>> + * Without a GPU scheduler, any fence waits must be done up front.
>> + */
>> + if (args->flags & I915_EXEC_WAIT_FENCE) {
>> + ret = i915_early_fence_wait(ring, fd_fence_wait);
>> + if (ret < 0)
>> + return ret;
>> +
>> + args->flags &= ~I915_EXEC_WAIT_FENCE;
>> + }
>> +
>> ret = i915_mutex_lock_interruptible(dev);
>> if (ret)
>> goto pre_mutex_err;
>> @@ -1695,13 +1754,41 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
>> i915_gem_context_reference(ctx);
>> params->ctx = ctx;
>>
>> + if (args->flags & I915_EXEC_CREATE_FENCE) {
>> + /*
>> + * Caller has requested a sync fence.
>> + * User interrupts will be enabled to make sure that
>> + * the timeline is signalled on completion.
>> + */
>> + ret = i915_create_sync_fence(params->request, &sync_fence,
>> + &fd_fence_complete);
>> + if (ret) {
>> + DRM_ERROR("Fence creation failed for ring %d, ctx %p\n",
>> + ring->id, ctx);
>> + goto err_batch_unpin;
>> + }
>> + }
>> +
>> ret = dev_priv->gt.execbuf_submit(params, args, &eb->vmas);
>> if (ret)
>> - goto err_batch_unpin;
>> + goto err_fence;
>>
>> /* the request owns the ref now */
>> i915_gem_context_unreference(ctx);
>>
>> + if (fd_fence_complete != -1) {
>> + /*
>> + * Install the fence into the pre-allocated file
>> + * descriptor to the fence object so that user land
>> + * can wait on it...
>> + */
>> + i915_install_sync_fence_fd(params->request,
>> + sync_fence, fd_fence_complete);
>> +
>> + /* Return the fence through the rsvd2 field */
>> + args->rsvd2 = (__u64) fd_fence_complete;
> Use the upper s32 for the output, so again you are not overwriting user
> state without good reason.
> -Chris
>
Makes sense. Will do.
Thanks,
John.
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-01-14 11:47 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 17:57 [RFC 0/9] Add native sync support to i915 driver John.C.Harrison
2016-01-13 17:57 ` [RFC 1/9] staging/android/sync: Support sync points created from dma-fences John.C.Harrison
2016-01-13 17:57 ` [RFC 2/9] staging/android/sync: add sync_fence_create_dma John.C.Harrison
2016-01-13 19:03 ` Gustavo Padovan
2016-01-13 17:57 ` [RFC 3/9] staging/android/sync: Move sync framework out of staging John.C.Harrison
2016-01-13 19:00 ` Gustavo Padovan
2016-01-14 11:31 ` John Harrison
2016-01-14 13:42 ` Gustavo Padovan
2016-01-14 14:19 ` John Harrison
2016-01-13 19:51 ` Gustavo Padovan
2016-01-14 4:55 ` Greg Kroah-Hartman
2016-01-13 17:57 ` [RFC 4/9] android/sync: Improved debug dump to dmesg John.C.Harrison
2016-01-13 17:57 ` [RFC 5/9] android/sync: Fix reversed sense of signaled fence John.C.Harrison
2016-01-13 17:57 ` [RFC 6/9] drm/i915: Add sync framework support to execbuff IOCTL John.C.Harrison
2016-01-13 18:43 ` Chris Wilson
2016-01-14 11:47 ` John Harrison [this message]
2016-01-14 12:07 ` Chris Wilson
2016-01-21 14:47 ` Maarten Lankhorst
2016-01-21 15:07 ` Chris Wilson
2016-01-13 17:57 ` [RFC 7/9] drm/i915: Add sync wait support to scheduler John.C.Harrison
2016-01-13 17:57 ` [RFC 8/9] drm/i915: Connecting execbuff fences " John.C.Harrison
2016-01-13 17:57 ` [RFC 9/9] drm/i915: Add sync support to the scheduler statistics and status dump John.C.Harrison
2016-01-19 16:04 ` [RFC] igt/gem_exec_fence: New test for sync/fence interface John.C.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=56978AC5.10604@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox