From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 01/12] drm/i915: Remove kref from i915_sw_fence
Date: Fri, 12 May 2017 15:13:30 +0300 [thread overview]
Message-ID: <87bmqyl1cl.fsf@gaia.fi.intel.com> (raw)
In-Reply-To: <20170511195922.15844-1-chris@chris-wilson.co.uk>
Chris Wilson <chris@chris-wilson.co.uk> writes:
> My original intention was for i915_sw_fence to be the base class and
> provide the reference count for the container. This was from starting
> with a design to handle async_work. In practice, for i915 we embed
> fences into structs which have their own independent reference counting,
> making the i915_sw_fence.kref duplicitous. If we remove the kref, we
> remove the i915_sw_fence's ability to free itself and its independence,
> it can only exist within a container and must be supplied with a
> callback to handle its release.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/i915_sw_fence.c | 55 ++++++++----------------------------
> drivers/gpu/drm/i915/i915_sw_fence.h | 1 -
> 2 files changed, 11 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence.c b/drivers/gpu/drm/i915/i915_sw_fence.c
> index a277f8eb7beb..a0a690d6627e 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence.c
> +++ b/drivers/gpu/drm/i915/i915_sw_fence.c
> @@ -120,34 +120,6 @@ void i915_sw_fence_fini(struct i915_sw_fence *fence)
> }
> #endif
>
> -static void i915_sw_fence_release(struct kref *kref)
> -{
> - struct i915_sw_fence *fence = container_of(kref, typeof(*fence), kref);
> -
> - WARN_ON(atomic_read(&fence->pending) > 0);
> - debug_fence_destroy(fence);
> -
> - if (fence->flags & I915_SW_FENCE_MASK) {
> - __i915_sw_fence_notify(fence, FENCE_FREE);
> - } else {
> - i915_sw_fence_fini(fence);
> - kfree(fence);
> - }
> -}
> -
> -static void i915_sw_fence_put(struct i915_sw_fence *fence)
> -{
> - debug_fence_assert(fence);
> - kref_put(&fence->kref, i915_sw_fence_release);
> -}
> -
> -static struct i915_sw_fence *i915_sw_fence_get(struct i915_sw_fence *fence)
> -{
> - debug_fence_assert(fence);
> - kref_get(&fence->kref);
> - return fence;
> -}
> -
> static void __i915_sw_fence_wake_up_all(struct i915_sw_fence *fence,
> struct list_head *continuation)
> {
> @@ -202,13 +174,15 @@ static void __i915_sw_fence_complete(struct i915_sw_fence *fence,
>
> debug_fence_set_state(fence, DEBUG_FENCE_IDLE, DEBUG_FENCE_NOTIFY);
>
> - if (fence->flags & I915_SW_FENCE_MASK &&
> - __i915_sw_fence_notify(fence, FENCE_COMPLETE) != NOTIFY_DONE)
> + if (__i915_sw_fence_notify(fence, FENCE_COMPLETE) != NOTIFY_DONE)
> return;
>
> debug_fence_set_state(fence, DEBUG_FENCE_NOTIFY, DEBUG_FENCE_IDLE);
>
> __i915_sw_fence_wake_up_all(fence, continuation);
> +
> + debug_fence_destroy(fence);
> + __i915_sw_fence_notify(fence, FENCE_FREE);
> }
>
> static void i915_sw_fence_complete(struct i915_sw_fence *fence)
> @@ -232,33 +206,26 @@ void __i915_sw_fence_init(struct i915_sw_fence *fence,
> const char *name,
> struct lock_class_key *key)
> {
> - BUG_ON((unsigned long)fn & ~I915_SW_FENCE_MASK);
> + BUG_ON(!fn || (unsigned long)fn & ~I915_SW_FENCE_MASK);
>
> debug_fence_init(fence);
>
> __init_waitqueue_head(&fence->wait, name, key);
> - kref_init(&fence->kref);
> atomic_set(&fence->pending, 1);
> fence->flags = (unsigned long)fn;
> }
>
> -static void __i915_sw_fence_commit(struct i915_sw_fence *fence)
> -{
> - i915_sw_fence_complete(fence);
> - i915_sw_fence_put(fence);
> -}
> -
> void i915_sw_fence_commit(struct i915_sw_fence *fence)
> {
> debug_fence_activate(fence);
> - __i915_sw_fence_commit(fence);
> + i915_sw_fence_complete(fence);
> }
>
> static int i915_sw_fence_wake(wait_queue_t *wq, unsigned mode, int flags, void *key)
> {
> list_del(&wq->task_list);
> __i915_sw_fence_complete(wq->private, key);
> - i915_sw_fence_put(wq->private);
> +
> if (wq->flags & I915_SW_FENCE_FLAG_ALLOC)
> kfree(wq);
> return 0;
> @@ -353,7 +320,7 @@ static int __i915_sw_fence_await_sw_fence(struct i915_sw_fence *fence,
> INIT_LIST_HEAD(&wq->task_list);
> wq->flags = pending;
> wq->func = i915_sw_fence_wake;
> - wq->private = i915_sw_fence_get(fence);
> + wq->private = fence;
>
> i915_sw_fence_await(fence);
>
> @@ -402,7 +369,7 @@ static void timer_i915_sw_fence_wake(unsigned long data)
> dma_fence_put(cb->dma);
> cb->dma = NULL;
>
> - __i915_sw_fence_commit(cb->fence);
> + i915_sw_fence_complete(cb->fence);
> cb->timer.function = NULL;
> }
>
> @@ -413,7 +380,7 @@ static void dma_i915_sw_fence_wake(struct dma_fence *dma,
>
> del_timer_sync(&cb->timer);
> if (cb->timer.function)
> - __i915_sw_fence_commit(cb->fence);
> + i915_sw_fence_complete(cb->fence);
> dma_fence_put(cb->dma);
>
> kfree(cb);
> @@ -440,7 +407,7 @@ int i915_sw_fence_await_dma_fence(struct i915_sw_fence *fence,
> return dma_fence_wait(dma, false);
> }
>
> - cb->fence = i915_sw_fence_get(fence);
> + cb->fence = fence;
> i915_sw_fence_await(fence);
>
> cb->dma = NULL;
> diff --git a/drivers/gpu/drm/i915/i915_sw_fence.h b/drivers/gpu/drm/i915/i915_sw_fence.h
> index d31cefbbcc04..1d3b6051daaf 100644
> --- a/drivers/gpu/drm/i915/i915_sw_fence.h
> +++ b/drivers/gpu/drm/i915/i915_sw_fence.h
> @@ -23,7 +23,6 @@ struct reservation_object;
> struct i915_sw_fence {
> wait_queue_head_t wait;
> unsigned long flags;
> - struct kref kref;
> atomic_t pending;
> };
>
> --
> 2.11.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-05-12 12:13 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-11 19:59 [PATCH 01/12] drm/i915: Remove kref from i915_sw_fence Chris Wilson
2017-05-11 19:59 ` [PATCH 02/12] drm/i915: Import the kfence selftests for i915_sw_fence Chris Wilson
2017-05-15 10:52 ` [PATCH v2] " Chris Wilson
2017-05-16 8:55 ` Chris Wilson
2017-05-16 9:15 ` Mika Kuoppala
2017-05-16 14:49 ` Mika Kuoppala
2017-05-11 19:59 ` [PATCH 03/12] drm/i915: Make ptr_unpack_bits() more function-like Chris Wilson
2017-05-11 19:59 ` [PATCH 04/12] drm/i915: Redefine ptr_pack_bits() and friends Chris Wilson
2017-05-11 19:59 ` [PATCH 05/12] drm/i915/execlists: Pack the count into the low bits of the port.request Chris Wilson
2017-05-11 19:59 ` [PATCH 06/12] drm/i915: Don't mark an execlists context-switch when idle Chris Wilson
2017-05-11 19:59 ` [PATCH 07/12] drm/i915: Use a define for the default priority [0] Chris Wilson
2017-05-12 8:02 ` Mika Kuoppala
2017-05-11 19:59 ` [PATCH 08/12] drm/i915: Split execlist priority queue into rbtree + linked list Chris Wilson
2017-05-15 11:45 ` Tvrtko Ursulin
2017-05-15 12:26 ` Chris Wilson
2017-05-15 12:56 ` [PATCH v2] " Chris Wilson
2017-05-15 13:27 ` Chris Wilson
2017-05-15 13:29 ` [PATCH v3] " Chris Wilson
2017-05-15 14:51 ` Michał Winiarski
2017-05-16 7:55 ` Tvrtko Ursulin
2017-05-11 19:59 ` [PATCH 09/12] drm/i915: Create a kmem_cache to allocate struct i915_priolist from Chris Wilson
2017-05-16 7:57 ` Tvrtko Ursulin
2017-05-11 19:59 ` [PATCH 10/12] drm/i915/execlists: Reduce lock contention between schedule/submit_request Chris Wilson
2017-05-15 10:51 ` Tvrtko Ursulin
2017-05-15 10:55 ` Chris Wilson
2017-05-15 11:46 ` Tvrtko Ursulin
2017-05-11 19:59 ` [PATCH 11/12] drm/i915: Stop inlining the execlists IRQ handler Chris Wilson
2017-05-11 19:59 ` [PATCH 12/12] drm/i915: Don't force serialisation on marking up execlists irq posted Chris Wilson
2017-05-12 7:16 ` Mika Kuoppala
2017-05-15 10:33 ` Tvrtko Ursulin
2017-05-11 20:17 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Remove kref from i915_sw_fence Patchwork
2017-05-12 7:43 ` [PATCH 01/12] " Mika Kuoppala
2017-05-12 8:19 ` Chris Wilson
2017-05-12 12:13 ` Mika Kuoppala [this message]
2017-05-15 11:47 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Remove kref from i915_sw_fence (rev2) Patchwork
2017-05-15 14:01 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Remove kref from i915_sw_fence (rev4) 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=87bmqyl1cl.fsf@gaia.fi.intel.com \
--to=mika.kuoppala@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.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