Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 08/12] drm/i915/guc: Cache the client mapping
Date: Thu, 3 Nov 2016 16:37:24 +0000	[thread overview]
Message-ID: <1232ee71-389f-059e-df9e-8ae586c3b8b9@linux.intel.com> (raw)
In-Reply-To: <20161102175051.29163-9-chris@chris-wilson.co.uk>


On 02/11/2016 17:50, Chris Wilson wrote:
> Use i915_gem_object_pin_map() for the guc client's lifetime to replace
> the peristent kmap + frequent kmap_atomic with a permanent vmapping.
> This avoids taking the obj->mm.lock mutex whilst inside irq context
> later.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/i915_guc_submission.c | 38 +++++++++++++++---------------
>  drivers/gpu/drm/i915/intel_guc.h           |  2 +-
>  2 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
> index b31573a825fa..bab0c2fc3bce 100644
> --- a/drivers/gpu/drm/i915/i915_guc_submission.c
> +++ b/drivers/gpu/drm/i915/i915_guc_submission.c
> @@ -220,7 +220,7 @@ static int guc_update_doorbell_id(struct intel_guc *guc,
>  	struct guc_context_desc desc;
>  	size_t len;
>
> -	doorbell = client->client_base + client->doorbell_offset;
> +	doorbell = client->vaddr + client->doorbell_offset;
>
>  	if (client->doorbell_id != GUC_INVALID_DOORBELL_ID &&
>  	    test_bit(client->doorbell_id, doorbell_bitmap)) {
> @@ -326,7 +326,7 @@ static void guc_proc_desc_init(struct intel_guc *guc,
>  {
>  	struct guc_process_desc *desc;
>
> -	desc = client->client_base + client->proc_desc_offset;
> +	desc = client->vaddr + client->proc_desc_offset;
>
>  	memset(desc, 0, sizeof(*desc));
>
> @@ -413,8 +413,8 @@ static void guc_ctx_desc_init(struct intel_guc *guc,
>  	gfx_addr = i915_ggtt_offset(client->vma);
>  	desc.db_trigger_phy = sg_dma_address(client->vma->pages->sgl) +
>  				client->doorbell_offset;
> -	desc.db_trigger_cpu = (uintptr_t)client->client_base +
> -				client->doorbell_offset;
> +	desc.db_trigger_cpu =
> +		(uintptr_t)client->vaddr + client->doorbell_offset;
>  	desc.db_trigger_uk = gfx_addr + client->doorbell_offset;
>  	desc.process_desc = gfx_addr + client->proc_desc_offset;
>  	desc.wq_addr = gfx_addr + client->wq_offset;
> @@ -465,7 +465,7 @@ int i915_guc_wq_reserve(struct drm_i915_gem_request *request)
>  {
>  	const size_t wqi_size = sizeof(struct guc_wq_item);
>  	struct i915_guc_client *gc = request->i915->guc.execbuf_client;
> -	struct guc_process_desc *desc = gc->client_base + gc->proc_desc_offset;
> +	struct guc_process_desc *desc = gc->vaddr + gc->proc_desc_offset;
>  	u32 freespace;
>  	int ret;
>
> @@ -506,10 +506,9 @@ static void guc_wq_item_append(struct i915_guc_client *gc,
>  	struct intel_engine_cs *engine = rq->engine;
>  	struct guc_process_desc *desc;
>  	struct guc_wq_item *wqi;
> -	void *base;
> -	u32 freespace, tail, wq_off, wq_page;
> +	u32 freespace, tail, wq_off;
>
> -	desc = gc->client_base + gc->proc_desc_offset;
> +	desc = gc->vaddr + gc->proc_desc_offset;
>
>  	/* Free space is guaranteed, see i915_guc_wq_reserve() above */
>  	freespace = CIRC_SPACE(gc->wq_tail, desc->head, gc->wq_size);
> @@ -539,10 +538,7 @@ static void guc_wq_item_append(struct i915_guc_client *gc,
>  	gc->wq_rsvd -= wqi_size;
>
>  	/* WQ starts from the page after doorbell / process_desc */
> -	wq_page = (wq_off + GUC_DB_SIZE) >> PAGE_SHIFT;
> -	wq_off &= PAGE_SIZE - 1;
> -	base = kmap_atomic(i915_gem_object_get_page(gc->vma->obj, wq_page));
> -	wqi = (struct guc_wq_item *)((char *)base + wq_off);
> +	wqi = gc->vaddr + wq_off + GUC_DB_SIZE;
>
>  	/* Now fill in the 4-word work queue item */
>  	wqi->header = WQ_TYPE_INORDER |
> @@ -555,8 +551,6 @@ static void guc_wq_item_append(struct i915_guc_client *gc,
>
>  	wqi->ring_tail = tail << WQ_RING_TAIL_SHIFT;
>  	wqi->fence_id = rq->global_seqno;
> -
> -	kunmap_atomic(base);
>  }
>
>  static int guc_ring_doorbell(struct i915_guc_client *gc)
> @@ -566,7 +560,7 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
>  	union guc_doorbell_qw *db;
>  	int attempt = 2, ret = -EAGAIN;
>
> -	desc = gc->client_base + gc->proc_desc_offset;
> +	desc = gc->vaddr + gc->proc_desc_offset;
>
>  	/* Update the tail so it is visible to GuC */
>  	desc->tail = gc->wq_tail;
> @@ -582,7 +576,7 @@ static int guc_ring_doorbell(struct i915_guc_client *gc)
>  		db_exc.cookie = 1;
>
>  	/* pointer of current doorbell cacheline */
> -	db = gc->client_base + gc->doorbell_offset;
> +	db = gc->vaddr + gc->doorbell_offset;
>
>  	while (attempt--) {
>  		/* lets ring the doorbell */
> @@ -729,14 +723,14 @@ guc_client_free(struct drm_i915_private *dev_priv,
>  	 * Be sure to drop any locks
>  	 */
>
> -	if (client->client_base) {
> +	if (client->vaddr) {
>  		/*
>  		 * If we got as far as setting up a doorbell, make sure we
>  		 * shut it down before unmapping & deallocating the memory.
>  		 */
>  		guc_disable_doorbell(guc, client);
>
> -		kunmap(kmap_to_page(client->client_base));
> +		i915_gem_object_unpin_map(client->vma->obj);
>  	}
>
>  	i915_vma_unpin_and_release(&client->vma);
> @@ -825,6 +819,7 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
>  	struct i915_guc_client *client;
>  	struct intel_guc *guc = &dev_priv->guc;
>  	struct i915_vma *vma;
> +	void *vaddr;
>  	uint16_t db_id;
>
>  	client = kzalloc(sizeof(*client), GFP_KERNEL);
> @@ -851,7 +846,12 @@ guc_client_alloc(struct drm_i915_private *dev_priv,
>
>  	/* We'll keep just the first (doorbell/proc) page permanently kmap'd. */
>  	client->vma = vma;
> -	client->client_base = kmap(i915_vma_first_page(vma));
> +
> +	vaddr = i915_gem_object_pin_map(vma->obj, I915_MAP_WB);
> +	if (IS_ERR(vaddr))
> +		goto err;
> +
> +	client->vaddr = vaddr;
>
>  	spin_lock_init(&client->wq_lock);
>  	client->wq_offset = GUC_DB_SIZE;
> diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
> index 49ced0bad0f5..0053258e03d3 100644
> --- a/drivers/gpu/drm/i915/intel_guc.h
> +++ b/drivers/gpu/drm/i915/intel_guc.h
> @@ -64,7 +64,7 @@ struct drm_i915_gem_request;
>   */
>  struct i915_guc_client {
>  	struct i915_vma *vma;
> -	void *client_base;		/* first page (only) of above	*/
> +	void *vaddr;
>  	struct i915_gem_context *owner;
>  	struct intel_guc *guc;
>
>

Looks OK, I thought we've done this months ago. :)

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

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

  reply	other threads:[~2016-11-03 16:37 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-02 17:50 Trivial priority scheduler Chris Wilson
2016-11-02 17:50 ` [PATCH 01/12] drm/i915: Split request submit/execute phase into two Chris Wilson
2016-11-03 10:35   ` Tvrtko Ursulin
2016-11-02 17:50 ` [PATCH 02/12] drm/i915: Defer transfer onto execution timeline to actual hw submission Chris Wilson
2016-11-03 10:34   ` Tvrtko Ursulin
2016-11-03 10:51     ` Chris Wilson
2016-11-03 11:27       ` Chris Wilson
2016-11-02 17:50 ` [PATCH 03/12] drm/i915: Remove engine->execlist_lock Chris Wilson
2016-11-03 10:47   ` Tvrtko Ursulin
2016-11-03 12:28     ` Chris Wilson
2016-11-03 13:31       ` Tvrtko Ursulin
2016-11-02 17:50 ` [PATCH 04/12] drm/i915/scheduler: Signal the arrival of a new request Chris Wilson
2016-11-03 10:49   ` Tvrtko Ursulin
2016-11-02 17:50 ` [PATCH 05/12] drm/i915/scheduler: Record all dependencies upon request construction Chris Wilson
2016-11-03 11:03   ` Tvrtko Ursulin
2016-11-03 11:55     ` Chris Wilson
2016-11-04 14:44       ` Tvrtko Ursulin
2016-11-04 15:11         ` Chris Wilson
2016-11-07  9:12           ` Tvrtko Ursulin
2016-11-07  9:30             ` Chris Wilson
2016-11-07 13:30               ` Tvrtko Ursulin
2016-11-07 13:39                 ` Chris Wilson
2016-11-07 13:42                   ` Tvrtko Ursulin
2016-11-02 17:50 ` [PATCH 06/12] drm/i915/scheduler: Execute requests in order of priorities Chris Wilson
2016-11-03 16:21   ` Tvrtko Ursulin
2016-11-03 17:44     ` Chris Wilson
2016-11-03 19:47     ` Chris Wilson
2016-11-04  9:20       ` Chris Wilson
2016-11-02 17:50 ` [PATCH 07/12] drm/i915/scheduler: Boost priorities for flips Chris Wilson
2016-11-03 16:29   ` Tvrtko Ursulin
2016-11-03 16:54     ` Chris Wilson
2016-11-02 17:50 ` [PATCH 08/12] drm/i915/guc: Cache the client mapping Chris Wilson
2016-11-03 16:37   ` Tvrtko Ursulin [this message]
2016-11-03 20:01     ` Chris Wilson
2016-11-02 17:50 ` [PATCH 09/12] HACK drm/i915/scheduler: emulate a scheduler for guc Chris Wilson
2016-11-03 13:17   ` Tvrtko Ursulin
2016-11-02 17:50 ` [PATCH 10/12] drm/i915/scheduler: Support user-defined priorities Chris Wilson
2016-11-02 17:50 ` [PATCH 11/12] drm/i915: Enable userspace to opt-out of implicit fencing Chris Wilson
2016-11-02 17:50 ` [PATCH 12/12] drm/i915: Support explicit fencing for execbuf Chris Wilson
2016-11-02 18:45 ` ✓ Fi.CI.BAT: success for series starting with [01/12] drm/i915: Split request submit/execute phase into two 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=1232ee71-389f-059e-df9e-8ae586c3b8b9@linux.intel.com \
    --to=tvrtko.ursulin@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