From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: intel-gfx@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
chris@chris-wilson.co.uk
Subject: [PATCH 2/5] dma-buf: fix busy wait for new shared fences
Date: Mon, 5 Aug 2019 17:45:51 +0200 [thread overview]
Message-ID: <20190805154554.3476-2-christian.koenig@amd.com> (raw)
In-Reply-To: <20190805154554.3476-1-christian.koenig@amd.com>
When reservation_object_add_shared_fence is replacing an old fence with a new
one we should not drop the old one before the new one is in place.
Otherwise other cores can busy wait for the new one to appear.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/dma-buf/reservation.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
index c71b85c8c159..d59207ca72d2 100644
--- a/drivers/dma-buf/reservation.c
+++ b/drivers/dma-buf/reservation.c
@@ -196,6 +196,7 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
struct dma_fence *fence)
{
struct reservation_object_list *fobj;
+ struct dma_fence *old;
unsigned int i, count;
dma_fence_get(fence);
@@ -209,18 +210,16 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
write_seqcount_begin(&obj->seq);
for (i = 0; i < count; ++i) {
- struct dma_fence *old_fence;
- old_fence = rcu_dereference_protected(fobj->shared[i],
- reservation_object_held(obj));
- if (old_fence->context == fence->context ||
- dma_fence_is_signaled(old_fence)) {
- dma_fence_put(old_fence);
+ old = rcu_dereference_protected(fobj->shared[i],
+ reservation_object_held(obj));
+ if (old->context == fence->context ||
+ dma_fence_is_signaled(old))
goto replace;
- }
}
BUG_ON(fobj->shared_count >= fobj->shared_max);
+ old = NULL;
count++;
replace:
@@ -230,6 +229,7 @@ void reservation_object_add_shared_fence(struct reservation_object *obj,
write_seqcount_end(&obj->seq);
preempt_enable();
+ dma_fence_put(old);
}
EXPORT_SYMBOL(reservation_object_add_shared_fence);
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2019-08-05 15:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 15:45 [PATCH 1/5] drm/i915: stop pruning reservation object after wait Christian König
2019-08-05 15:45 ` Christian König [this message]
2019-08-05 15:45 ` [PATCH 3/5] dma-buf: further relax reservation_object_add_shared_fence Christian König
2019-08-05 15:45 ` [PATCH 4/5] dma-buf: simplify reservation_object_get_fences_rcu a bit Christian König
2019-08-05 15:45 ` [PATCH 5/5] dma-buf: nuke reservation_object seq number Christian König
2019-08-05 16:07 ` Chris Wilson
2019-08-05 16:41 ` Daniel Vetter
2019-08-05 15:58 ` [PATCH 1/5] drm/i915: stop pruning reservation object after wait Chris Wilson
2019-08-05 16:54 ` Chris Wilson
2019-08-06 8:05 ` Christian König
2019-08-09 13:01 ` ✗ Fi.CI.BAT: failure for series starting with [1/5] " 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=20190805154554.3476-2-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=chris@chris-wilson.co.uk \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
/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