All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: airlied@gmail.com
Cc: Thomas Hellstrom <thellstrom@vmware.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 21/26] vmwgfx: Optimize the command submission resource list
Date: Tue,  4 Oct 2011 20:13:31 +0200	[thread overview]
Message-ID: <1317752016-2680-22-git-send-email-thellstrom@vmware.com> (raw)
In-Reply-To: <1317752016-2680-1-git-send-email-thellstrom@vmware.com>

Use a list for resources referenced during command submission, instead of
an array.
As long as we don't implement parallell command submission this works fine
and simplifies things a bit.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h      |    5 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c  |   50 ++++++++++++++----------------
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c |    1 +
 3 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index d8d6a86..75e6d10 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -81,7 +81,7 @@ struct vmw_resource {
 	bool avail;
 	void (*hw_destroy) (struct vmw_resource *res);
 	void (*res_free) (struct vmw_resource *res);
-	bool on_validate_list;
+	struct list_head validate_head;
 	struct list_head query_head; /* Protected by the cmdbuf mutex */
 	/* TODO is a generic snooper needed? */
 #if 0
@@ -155,8 +155,7 @@ struct vmw_sw_context{
 	uint32_t cur_val_buf;
 	uint32_t *cmd_bounce;
 	uint32_t cmd_bounce_size;
-	struct vmw_resource *resources[VMWGFX_MAX_VALIDATIONS];
-	uint32_t num_ref_resources;
+	struct list_head resource_list;
 	uint32_t fence_flags;
 	struct list_head query_list;
 	struct ttm_buffer_object *cur_query_bo;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index efa1d1c..dfd7fca 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -44,27 +44,16 @@ static int vmw_cmd_ok(struct vmw_private *dev_priv,
 	return 0;
 }
 
-static int vmw_resource_to_validate_list(struct vmw_sw_context *sw_context,
-					 struct vmw_resource **p_res)
+static void vmw_resource_to_validate_list(struct vmw_sw_context *sw_context,
+					  struct vmw_resource **p_res)
 {
-	int ret = 0;
 	struct vmw_resource *res = *p_res;
 
-	if (!res->on_validate_list) {
-		if (sw_context->num_ref_resources >= VMWGFX_MAX_VALIDATIONS) {
-			DRM_ERROR("Too many resources referenced in "
-				  "command stream.\n");
-			ret = -ENOMEM;
-			goto out;
-		}
-		sw_context->resources[sw_context->num_ref_resources++] = res;
-		res->on_validate_list = true;
-		return 0;
-	}
-
-out:
-	vmw_resource_unreference(p_res);
-	return ret;
+	if (list_empty(&res->validate_head)) {
+		list_add_tail(&res->validate_head, &sw_context->resource_list);
+		*p_res = NULL;
+	} else
+		vmw_resource_unreference(p_res);
 }
 
 /**
@@ -142,7 +131,9 @@ static int vmw_cmd_cid_check(struct vmw_private *dev_priv,
 	sw_context->last_cid = cmd->cid;
 	sw_context->cid_valid = true;
 	sw_context->cur_ctx = ctx;
-	return vmw_resource_to_validate_list(sw_context, &ctx);
+	vmw_resource_to_validate_list(sw_context, &ctx);
+
+	return 0;
 }
 
 static int vmw_cmd_sid_check(struct vmw_private *dev_priv,
@@ -179,7 +170,9 @@ static int vmw_cmd_sid_check(struct vmw_private *dev_priv,
 	*sid = sw_context->sid_translation;
 
 	res = &srf->res;
-	return vmw_resource_to_validate_list(sw_context, &res);
+	vmw_resource_to_validate_list(sw_context, &res);
+
+	return 0;
 }
 
 
@@ -388,7 +381,7 @@ static void vmw_query_bo_switch_commit(struct vmw_private *dev_priv,
 				 query_head) {
 		list_del_init(&ctx->query_head);
 
-		BUG_ON(!ctx->on_validate_list);
+		BUG_ON(list_empty(&ctx->validate_head));
 
 		ret = vmw_fifo_emit_dummy_query(dev_priv, ctx->id);
 
@@ -582,7 +575,9 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv,
 	vmw_dmabuf_unreference(&vmw_bo);
 
 	res = &srf->res;
-	return vmw_resource_to_validate_list(sw_context, &res);
+	vmw_resource_to_validate_list(sw_context, &res);
+
+	return 0;
 
 out_no_reloc:
 	vmw_dmabuf_unreference(&vmw_bo);
@@ -870,7 +865,7 @@ static void vmw_apply_relocations(struct vmw_sw_context *sw_context)
 static void vmw_clear_validations(struct vmw_sw_context *sw_context)
 {
 	struct ttm_validate_buffer *entry, *next;
-	uint32_t i = sw_context->num_ref_resources;
+	struct vmw_resource *res, *res_next;
 
 	/*
 	 * Drop references to DMA buffers held during command submission.
@@ -887,9 +882,10 @@ static void vmw_clear_validations(struct vmw_sw_context *sw_context)
 	/*
 	 * Drop references to resources held during command submission.
 	 */
-	while (i-- > 0) {
-		sw_context->resources[i]->on_validate_list = false;
-		vmw_resource_unreference(&sw_context->resources[i]);
+	list_for_each_entry_safe(res, res_next, &sw_context->resource_list,
+				 validate_head) {
+		list_del_init(&res->validate_head);
+		vmw_resource_unreference(&res);
 	}
 }
 
@@ -1066,9 +1062,9 @@ int vmw_execbuf_process(struct drm_file *file_priv,
 	sw_context->sid_valid = false;
 	sw_context->cur_reloc = 0;
 	sw_context->cur_val_buf = 0;
-	sw_context->num_ref_resources = 0;
 	sw_context->fence_flags = 0;
 	INIT_LIST_HEAD(&sw_context->query_list);
+	INIT_LIST_HEAD(&sw_context->resource_list);
 	sw_context->cur_query_bo = dev_priv->pinned_bo;
 	sw_context->cur_query_cid = dev_priv->query_cid;
 	sw_context->query_cid_valid = (dev_priv->pinned_bo != NULL);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 36c9d03..e0a4181 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -127,6 +127,7 @@ static int vmw_resource_init(struct vmw_private *dev_priv,
 	res->avail = false;
 	res->dev_priv = dev_priv;
 	INIT_LIST_HEAD(&res->query_head);
+	INIT_LIST_HEAD(&res->validate_head);
 	do {
 		if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0))
 			return -ENOMEM;
-- 
1.7.4.4

  parent reply	other threads:[~2011-10-04 18:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-04 18:13 [PATCH -next 00/26] vmwgfx updates v2 Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 01/26] ttm: export ttm_bo_create Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 02/26] vmwgfx: Update register files to latest from vmware-sdk Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 03/26] vmwgfx: Document vmw_fifo_reserve Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 04/26] vmwgfx: Add comments for buffer pinning code Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 05/26] vmwgfx: Make sure the reserved area is at the start of vram Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 06/26] vmwgfx: Some comments and BUG_ON Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 07/26] vmwgfx: Break out execbuf command processing Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 08/26] vmwgfx: Break out dirty submission code Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 09/26] vmwgfx: Expand the command checker to cover screen object commands Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 10/26] vmwgfx: Refactor common display unit functions to shared file Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 11/26] vmwgfx: Add dmabuf helper functions for pinning Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 12/26] vmwgfx: Add screen object support Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 13/26] vmwgfx: Require HWV8 for 3d support Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 14/26] vmwgfx: Drop 3D Legacy Display Unit support Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 15/26] vmwgfx: Place overlays in GMR area if we can Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 16/26] vmwgfx: Add present and readback ioctls Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 17/26] vmwgfx: Disallow user space to send present and readback commands Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 18/26] vmwgfx: minor dmabuf utilities cleanup Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 19/26] vmwgfx: Allow reference and unreference of NULL fence objects Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 20/26] vmwgfx: Fix up query processing Thomas Hellstrom
2011-10-04 18:13 ` Thomas Hellstrom [this message]
2011-10-04 18:13 ` [PATCH 22/26] vmwgfx: Make sure we always have a user-space handle to use for objects that are backing kms framebuffers Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 23/26] vmwgfx: Handle device surface memory limit Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 24/26] vmwgfx: Be more strict with fb depths when using screen objects Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 25/26] vmwgfx: Bump driver minor to advertise support for new ioctls Thomas Hellstrom
2011-10-04 18:13 ` [PATCH 26/26] vmwgfx: Minor cleanups Thomas Hellstrom

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=1317752016-2680-22-git-send-email-thellstrom@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.