public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Dave Gordon <david.s.gordon@intel.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	John Harrison <John.C.Harrison@Intel.com>,
	Intel-GFX@Lists.FreeDesktop.Org
Subject: Re: [RFC, 1/4] drm/i915: Convert requests to use struct fence
Date: Fri, 17 Apr 2015 20:22:12 +0100	[thread overview]
Message-ID: <55315D64.5020300@intel.com> (raw)
In-Reply-To: <5523BD09.6030008@linux.intel.com>

On 07/04/15 12:18, Maarten Lankhorst wrote:
> Hey,
> 
> Op 07-04-15 om 12:59 schreef John Harrison:
>> On 07/04/2015 10:18, Maarten Lankhorst wrote:
>>> Hey,
>>>
>>> Op 20-03-15 om 18:48 schreef John.C.Harrison@Intel.com:
>>>> From: John Harrison <John.C.Harrison@Intel.com>
>>>>
>>>> There is a construct in the linux kernel called 'struct fence' that is intended
>>>> to keep track of work that is executed on hardware. I.e. it solves the basic
>>>> problem that the drivers 'struct drm_i915_gem_request' is trying to address. The
>>>> request structure does quite a lot more than simply track the execution progress
>>>> so is very definitely still required. However, the basic completion status side
>>>> could be updated to use the ready made fence implementation and gain all the
>>>> advantages that provides.
>>>>
>>>> This patch makes the first step of integrating a struct fence into the request.
>>>> It replaces the explicit reference count with that of the fence. It also
>>>> replaces the 'is completed' test with the fence's equivalent. Currently, that
>>>> simply chains on to the original request implementation. A future patch will
>>>> improve this.
>>>>
>>>> For: VIZ-5190
>>>> Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
>>>>
>>>> ---
>>>> drivers/gpu/drm/i915/i915_drv.h         |   37 +++++++++------------
>>>>   drivers/gpu/drm/i915/i915_gem.c         |   55 ++++++++++++++++++++++++++++---
>>>>   drivers/gpu/drm/i915/intel_lrc.c        |    1 +
>>>>   drivers/gpu/drm/i915/intel_ringbuffer.c |    1 +
>>>>   drivers/gpu/drm/i915/intel_ringbuffer.h |    3 ++
>>>>   5 files changed, 70 insertions(+), 27 deletions(-)

Since Maarten provided i915_gem_request_unreference__unlocked() in the
interval since this was first posted, you'll need to convert that too:

> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 4213dfb..97073fe 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2218,14 +2218,8 @@ void i915_gem_request_unreference_irq(struct drm_i915_gem_request *req);
>  static inline void
>  i915_gem_request_unreference__unlocked(struct drm_i915_gem_request *req)
>  {
> -       struct drm_device *dev;
> -
> -       if (!req)
> -               return;
> -
> -       dev = req->ring->dev;
> -       if (kref_put_mutex(&req->ref, i915_gem_request_free, &dev->struct_mutex))
> -               mutex_unlock(&dev->struct_mutex);
> +       if (req)
> +               fence_put_mutex(&req->fence, &req->ring->dev->struct_mutex);
>  }
>  static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,

... and here's the implementation of fence_put_mutex() ...

> diff --git a/include/linux/fence.h b/include/linux/fence.h
> index 39efee1..c4fbb25 100644
> --- a/include/linux/fence.h
> +++ b/include/linux/fence.h
> @@ -218,6 +218,24 @@ static inline void fence_put(struct fence *fence)
>                 kref_put(&fence->refcount, fence_release);
>  }
>  
> +/**
> + * fence_put_mutex - decrement refcount for object.
> + * @fence: object.
> + * @lock: lock to take in release case
> + *
> + * A version of fence_put() that doesn't require the caller to hold the
> + * associated lock already. If the refcount doesn't go to zero, the lock
> + * is not needed; if it does, the lock will automatically be acquired and
> + * released around the call to fence_release().
> + */
> +static inline void fence_put_mutex(struct fence *fence,
> +                                  struct mutex *lock)
> +{
> +       if (fence)
> +               if (kref_put_mutex(&fence->refcount, fence_release, lock))
> +                       mutex_unlock(lock);
> +}
> +
>  int fence_signal(struct fence *fence);
>  int fence_signal_locked(struct fence *fence);
>  signed long fence_default_wait(struct fence *fence, bool intr, signed long timeout);

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

  reply	other threads:[~2015-04-17 19:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20 17:48 [RFC 0/4] Convert requests to use struct fence John.C.Harrison
2015-03-20 17:48 ` [RFC 1/4] drm/i915: " John.C.Harrison
2015-04-07  9:18   ` [RFC, " Maarten Lankhorst
2015-04-07 10:59     ` John Harrison
2015-04-07 11:18       ` Maarten Lankhorst
2015-04-17 19:22         ` Dave Gordon [this message]
2015-04-20  5:13           ` Maarten Lankhorst
2015-03-20 17:48 ` [RFC 2/4] drm/i915: Removed now redudant parameter to i915_gem_request_completed() John.C.Harrison
2015-04-17 18:57   ` Dave Gordon
2015-03-20 17:48 ` [RFC 3/4] drm/i915: Interrupt driven fences John.C.Harrison
2015-03-20 21:11   ` Chris Wilson
2015-03-23  9:22     ` Daniel Vetter
2015-03-23 12:13       ` John Harrison
2015-03-26 13:22         ` Daniel Vetter
2015-03-26 17:27           ` Jesse Barnes
2015-03-27  8:24             ` Daniel Vetter
2015-03-20 17:48 ` [RFC 4/4] drm/i915: Updated request structure tracing John.C.Harrison

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=55315D64.5020300@intel.com \
    --to=david.s.gordon@intel.com \
    --cc=Intel-GFX@Lists.FreeDesktop.Org \
    --cc=John.C.Harrison@Intel.com \
    --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