From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Rob Clark <robdclark@gmail.com>,
dri-devel@lists.freedesktop.org,
Matthew Brost <matthew.brost@intel.com>
Cc: "Tvrtko Ursulin" <tvrtko.ursulin@intel.com>,
"Rob Clark" <robdclark@chromium.org>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Matthew Auld" <matthew.auld@intel.com>,
"Andrzej Hajda" <andrzej.hajda@intel.com>,
"Niranjana Vishwanathapura" <niranjana.vishwanathapura@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Nirmoy Das" <nirmoy.das@intel.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
intel-gfx@lists.freedesktop.org,
"open list" <linux-kernel@vger.kernel.org>,
jason.ekstrand@collabora.com
Subject: Re: [PATCH] drm/i915: Move fd_install after last use of fence
Date: Mon, 6 Feb 2023 09:35:52 +0000 [thread overview]
Message-ID: <e2403d2c-b088-fb05-64a6-f933f12dfb40@linux.intel.com> (raw)
In-Reply-To: <CAF6AEGvanLri-+Z5KgmgSFX2ShB09T7X7wxcSQk_0JV7PKGRng@mail.gmail.com>
On 03/02/2023 18:15, Rob Clark wrote:
> On Fri, Feb 3, 2023 at 8:49 AM Rob Clark <robdclark@gmail.com> wrote:
>>
>> From: Rob Clark <robdclark@chromium.org>
>>
>> Because eb_composite_fence_create() drops the fence_array reference
>> after creation of the sync_file, only the sync_file holds a ref to the
>> fence. But fd_install() makes that reference visable to userspace, so
>> it must be the last thing we do with the fence.
>>
>
> Fixes: 00dae4d3d35d ("drm/i915: Implement SINGLE_TIMELINE with a syncobj (v4)")
This is correct and the fix looks good to me.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
CI is green so I will merge it, thanks again for a fix Rob!
Followup up question for Matthew Brost however is whether the composite
fence flow could be simplified. This block here comes late in
i915_gem_do_execbuffer and may mislead the user the composite fence is
held to the end of the function:
if (!out_fence && eb.composite_fence)
dma_fence_put(eb.composite_fence);
Question is would it work to remove the !out_fence condition from here,
and remove "consumption" of the reference from eb_composite_fence_create
success path.
Regards,
Tvrtko
>> Signed-off-by: Rob Clark <robdclark@chromium.org>
>> ---
>> drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
>> index f266b68cf012..0f2e056c02dd 100644
>> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
>> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
>> @@ -3476,38 +3476,38 @@ i915_gem_do_execbuffer(struct drm_device *dev,
>>
>> err_request:
>> eb_requests_get(&eb);
>> err = eb_requests_add(&eb, err);
>>
>> if (eb.fences)
>> signal_fence_array(&eb, eb.composite_fence ?
>> eb.composite_fence :
>> &eb.requests[0]->fence);
>>
>> + if (unlikely(eb.gem_context->syncobj)) {
>> + drm_syncobj_replace_fence(eb.gem_context->syncobj,
>> + eb.composite_fence ?
>> + eb.composite_fence :
>> + &eb.requests[0]->fence);
>> + }
>> +
>> if (out_fence) {
>> if (err == 0) {
>> fd_install(out_fence_fd, out_fence->file);
>> args->rsvd2 &= GENMASK_ULL(31, 0); /* keep in-fence */
>> args->rsvd2 |= (u64)out_fence_fd << 32;
>> out_fence_fd = -1;
>> } else {
>> fput(out_fence->file);
>> }
>> }
>>
>> - if (unlikely(eb.gem_context->syncobj)) {
>> - drm_syncobj_replace_fence(eb.gem_context->syncobj,
>> - eb.composite_fence ?
>> - eb.composite_fence :
>> - &eb.requests[0]->fence);
>> - }
>> -
>> if (!out_fence && eb.composite_fence)
>> dma_fence_put(eb.composite_fence);
>>
>> eb_requests_put(&eb);
>>
>> err_vma:
>> eb_release_vmas(&eb, true);
>> WARN_ON(err == -EDEADLK);
>> i915_gem_ww_ctx_fini(&eb.ww);
>>
>> --
>> 2.38.1
>>
prev parent reply other threads:[~2023-02-06 9:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-03 16:49 [PATCH] drm/i915: Move fd_install after last use of fence Rob Clark
2023-02-03 18:15 ` Rob Clark
2023-02-06 9:35 ` Tvrtko Ursulin [this message]
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=e2403d2c-b088-fb05-64a6-f933f12dfb40@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Jason@zx2c4.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jason.ekstrand@collabora.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=niranjana.vishwanathapura@intel.com \
--cc=nirmoy.das@intel.com \
--cc=robdclark@chromium.org \
--cc=robdclark@gmail.com \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tvrtko.ursulin@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