From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH] drm/i915: Use dma_resv_iter for waiting in i915_gem_object_wait_reservation.
Date: Thu, 14 Oct 2021 09:37:48 +0100 [thread overview]
Message-ID: <8625e3ca-57f8-e387-1742-808e3599786f@linux.intel.com> (raw)
In-Reply-To: <20211013104123.1877827-1-maarten.lankhorst@linux.intel.com>
On 13/10/2021 11:41, Maarten Lankhorst wrote:
> No memory should be allocated when calling i915_gem_object_wait,
> because it may be called to idle a BO when evicting memory.
>
> Fix this by using dma_resv_iter helpers to call
> i915_gem_object_wait_fence() on each fence, which cleans up the code a lot.
> Also remove dma_resv_prune, it's questionably.
>
> This will result in the following lockdep splat.
<snip>
> @@ -37,56 +36,17 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
> unsigned int flags,
> long timeout)
> {
> - struct dma_fence *excl;
> - bool prune_fences = false;
> -
> - if (flags & I915_WAIT_ALL) {
> - struct dma_fence **shared;
> - unsigned int count, i;
> - int ret;
> + struct dma_resv_iter cursor;
> + struct dma_fence *fence;
>
> - ret = dma_resv_get_fences(resv, &excl, &count, &shared);
> - if (ret)
> - return ret;
> -
> - for (i = 0; i < count; i++) {
> - timeout = i915_gem_object_wait_fence(shared[i],
> - flags, timeout);
> - if (timeout < 0)
> - break;
> + dma_resv_iter_begin(&cursor, resv, flags & I915_WAIT_ALL);
> + dma_resv_for_each_fence_unlocked(&cursor, fence) {
>
> - dma_fence_put(shared[i]);
> - }
> -
> - for (; i < count; i++)
> - dma_fence_put(shared[i]);
> - kfree(shared);
> -
> - /*
> - * If both shared fences and an exclusive fence exist,
> - * then by construction the shared fences must be later
> - * than the exclusive fence. If we successfully wait for
> - * all the shared fences, we know that the exclusive fence
> - * must all be signaled. If all the shared fences are
> - * signaled, we can prune the array and recover the
> - * floating references on the fences/requests.
> - */
> - prune_fences = count && timeout >= 0;
> - } else {
> - excl = dma_resv_get_excl_unlocked(resv);
> + timeout = i915_gem_object_wait_fence(fence, flags, timeout);
> + if (timeout <= 0)
> + break;
You have another change in behaviour here, well a bug really. When
userspace passes in zero timeout you fail to report activity in other
than the first fence.
Regards,
Tvrtko
next prev parent reply other threads:[~2021-10-14 8:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-13 10:41 [Intel-gfx] [PATCH] drm/i915: Use dma_resv_iter for waiting in i915_gem_object_wait_reservation Maarten Lankhorst
2021-10-13 10:58 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for " Patchwork
2021-10-13 11:18 ` [Intel-gfx] [PATCH] " Maarten Lankhorst
2021-10-13 12:32 ` Maarten Lankhorst
2021-10-13 14:00 ` Daniel Vetter
2021-10-13 15:37 ` Tvrtko Ursulin
2021-10-13 16:17 ` Daniel Vetter
2021-10-14 7:30 ` Tvrtko Ursulin
2021-10-13 16:41 ` Maarten Lankhorst
2021-10-13 13:45 ` kernel test robot
2021-10-13 15:15 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915: Use dma_resv_iter for waiting in i915_gem_object_wait_reservation. (rev3) Patchwork
2021-10-13 19:31 ` [Intel-gfx] [PATCH] drm/i915: Use dma_resv_iter for waiting in i915_gem_object_wait_reservation kernel test robot
2021-10-14 8:37 ` Tvrtko Ursulin [this message]
2021-10-14 12:05 ` Maarten Lankhorst
2021-10-14 13:25 ` Tvrtko Ursulin
2021-10-14 13:45 ` Maarten Lankhorst
2021-10-14 13:56 ` Tvrtko Ursulin
2021-10-18 11:07 ` Maarten Lankhorst
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=8625e3ca-57f8-e387-1742-808e3599786f@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.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