public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Koenig, Christian" <Christian.Koenig@amd.com>
To: Lionel Landwerlin <lionel.g.landwerlin@intel.com>,
	Chris Wilson <chris@chris-wilson.co.uk>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH v6 07/11] drm/i915: add syncobj timeline support
Date: Mon, 15 Jul 2019 11:30:35 +0000	[thread overview]
Message-ID: <c80f9545-45f5-5e90-e80b-9f370f5ec33b@amd.com> (raw)
In-Reply-To: <53ed8376-aea4-3730-ee51-24981464e25e@intel.com>

Hi Lionel,

sorry for the delayed response, I'm just back from vacation.

Am 03.07.19 um 11:17 schrieb Lionel Landwerlin:
> On 03/07/2019 11:56, Chris Wilson wrote:
>> Quoting Lionel Landwerlin (2019-07-01 12:34:33)
>>> +               syncobj = drm_syncobj_find(eb->file, 
>>> user_fence.handle);
>>> +               if (!syncobj) {
>>> +                       DRM_DEBUG("Invalid syncobj handle provided\n");
>>> +                       err = -EINVAL;
>>> +                       goto err;
>>> +               }
>>> +
>>> +               if (user_fence.flags & I915_EXEC_FENCE_WAIT) {
>>> +                       fence = drm_syncobj_fence_get(syncobj);
>>> +                       if (!fence) {
>>> +                               DRM_DEBUG("Syncobj handle has no 
>>> fence\n");
>>> +                               drm_syncobj_put(syncobj);
>>> +                               err = -EINVAL;
>>> +                               goto err;
>>> +                       }
>>> +
>>> +                       err = dma_fence_chain_find_seqno(&fence, 
>>> point);
>> I'm very dubious about chain_find_seqno().
>>
>> It returns -EINVAL if the point is older than the first in the chain --
>> it is in an unknown state, but may be signaled since we remove signaled
>> links from the chain. If we are waiting for an already signaled syncpt,
>> we should not be erring out!
>
>
> You're right, I got this wrong.
>
> We can get fence = NULL if the point is already signaled.
>
> The easiest would be to skip it from the list, or add the stub fence.
>
>
> I guess the CTS got lucky that it always got the point needed before 
> it was garbage collected...

The topmost point is never garbage collected. So IIRC the check is 
actually correct and you should never get NULL here.

>>
>> Do we allow later requests to insert earlier syncpt into the chain? If
>> so, then the request we wait on here may be woefully inaccurate and
>> quite easily lead to cycles in the fence tree. We have no way of
>> resolving such deadlocks -- we would have to treat this fence as a
>> foreign fence and install a backup timer. Alternatively, we only allow
>> this to return the exact fence for a syncpt, and proxies for the rest.
>
>
> Adding points < latest added point is forbidden.
>
> I wish we enforced it a bit more than what's currently done in 
> drm_syncobj_add_point().
>
> In my view we should :
>
>     - lock the syncobj in get_timeline_fence_array() do the sanity 
> check there.
>
>     - keep the lock until we add the point to the timeline
>
>     - unlock once added
>
>
> That way we would ensure that the application cannot generate invalid 
> timelines and error out if it does.
>
> We could do the same for host signaling in 
> drm_syncobj_timeline_signal_ioctl/drm_syncobj_transfer_to_timeline 
> (there the locking a lot shorter).
>
> That requires holding the lock for longer than maybe other driver 
> would prefer.
>
>
> Ccing Christian who can tell whether that's out of question for AMD.

Yeah, adding the lock was the only other option I could see as well, but 
we intentionally decided against that.

Since we have multiple out sync objects we would need to use a ww_mutex 
as lock here.

That in turn would result in a another rather complicated dance for 
deadlock avoidance. Something which each driver would have to implement 
correctly.

That doesn't sounds like a good idea to me just to improve error checking.

As long as it is only in the same process userspace could check that as 
well before doing the submission.

Regards,
Christian.



>
>
> Cheers,
>
>
> -Lionel
>
>
>>> +                       if (err || !fence) {
>>> +                               DRM_DEBUG("Syncobj handle missing 
>>> requested point\n");
>>> +                               drm_syncobj_put(syncobj);
>>> +                               err = err != 0 ? err : -EINVAL;
>>> +                               goto err;
>>> +                       }
>>> +               }
>>> +
>>> +               /*
>>> +                * For timeline syncobjs we need to preallocate 
>>> chains for
>>> +                * later signaling.
>>> +                */
>>> +               if (point != 0 && user_fence.flags & 
>>> I915_EXEC_FENCE_SIGNAL) {
>>> +                       fences[n].chain_fence =
>>> + kmalloc(sizeof(*fences[n].chain_fence),
>>> +                                       GFP_KERNEL);
>>> +                       if (!fences[n].chain_fence) {
>>> +                               dma_fence_put(fence);
>>> +                               drm_syncobj_put(syncobj);
>>> +                               err = -ENOMEM;
>>> +                               DRM_DEBUG("Unable to alloc 
>>> chain_fence\n");
>>> +                               goto err;
>>> +                       }
>> What happens if we later try to insert two fences for the same syncpt?
>> Should we not reserve the slot in the chain to reject duplicates?
>> -Chris
>>
>

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

  reply	other threads:[~2019-07-15 11:30 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 11:34 [PATCH v6 00/11] drm/i915: Vulkan performance query support Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 01/11] drm/i915/perf: add missing delay for OA muxes configuration Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 02/11] drm/i915/perf: introduce a versioning of the i915-perf uapi Lionel Landwerlin
2019-07-01 12:45   ` Chris Wilson
2019-07-01 11:34 ` [PATCH v6 03/11] drm/i915/perf: allow for CS OA configs to be created lazily Lionel Landwerlin
2019-07-01 13:06   ` Chris Wilson
2019-07-01 13:45     ` Lionel Landwerlin
2019-07-01 15:09   ` Chris Wilson
2019-07-09  6:47     ` Lionel Landwerlin
2019-07-09  8:31       ` Chris Wilson
2019-07-09  8:30   ` Chris Wilson
2019-07-01 11:34 ` [PATCH v6 04/11] drm/i915: enumerate scratch fields Lionel Landwerlin
2019-07-01 12:07   ` Chris Wilson
2019-07-01 11:34 ` [PATCH v6 05/11] drm/i915/perf: implement active wait for noa configurations Lionel Landwerlin
2019-07-01 12:43   ` Chris Wilson
2019-07-01 13:10     ` Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 06/11] drm/i915: introduce a mechanism to extend execbuf2 Lionel Landwerlin
2019-07-01 15:17   ` Chris Wilson
2019-07-02 11:36     ` Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 07/11] drm/i915: add syncobj timeline support Lionel Landwerlin
2019-07-01 13:13   ` Chris Wilson
2019-07-01 13:15     ` Lionel Landwerlin
2019-07-01 13:18   ` Chris Wilson
2019-07-01 13:22     ` Lionel Landwerlin
2019-07-03  8:56   ` Chris Wilson
2019-07-03  9:17     ` Lionel Landwerlin
2019-07-15 11:30       ` Koenig, Christian [this message]
2019-07-16  8:17         ` Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 08/11] drm/i915: add a new perf configuration execbuf parameter Lionel Landwerlin
2019-07-01 12:05   ` Chris Wilson
2019-07-01 12:14     ` Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 09/11] drm/i915/perf: allow holding preemption on filtered ctx Lionel Landwerlin
2019-07-01 12:03   ` Chris Wilson
2019-07-01 12:10     ` Lionel Landwerlin
2019-07-01 14:37       ` Chris Wilson
2019-07-09  9:18         ` Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 10/11] drm/i915/perf: execute OA configuration from command stream Lionel Landwerlin
2019-07-01 13:32   ` Chris Wilson
2019-07-01 13:42     ` Lionel Landwerlin
2019-07-01 11:34 ` [PATCH v6 11/11] drm/i915: add support for perf configuration queries Lionel Landwerlin
2019-07-01 13:08 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Vulkan performance query support (rev6) Patchwork
2019-07-01 13:14 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-07-01 13:38 ` ✓ Fi.CI.BAT: success " Patchwork
2019-07-02 18:02 ` ✗ Fi.CI.IGT: failure " Patchwork

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=c80f9545-45f5-5e90-e80b-9f370f5ec33b@amd.com \
    --to=christian.koenig@amd.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=lionel.g.landwerlin@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox