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 18/26] vmwgfx: minor dmabuf utilities cleanup
Date: Tue,  4 Oct 2011 20:13:28 +0200	[thread overview]
Message-ID: <1317752016-2680-19-git-send-email-thellstrom@vmware.com> (raw)
In-Reply-To: <1317752016-2680-1-git-send-email-thellstrom@vmware.com>

Add / fix some function comments.
Don't move out an fbdev framebuffer when unused. Just unpin.
Only have a single function that computes a SVGAGuestPtr from the buffer's
current placement, and make it more versatile by accepting a
struct ttm_buffer_object

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c  |   86 +++++++++++++------------------
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h     |    9 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c      |    3 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c |   10 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c    |    2 +-
 5 files changed, 45 insertions(+), 65 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index 5668ad9..7f744a8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -32,10 +32,16 @@
 
 
 /**
- * Validate a buffer to placement.
+ * vmw_dmabuf_to_placement - Validate a buffer to placement.
  *
- * May only be called by the current master as this function takes the
- * its lock in write mode.
+ * @dev_priv:  Driver private.
+ * @buf:  DMA buffer to move.
+ * @pin:  Pin buffer if true.
+ * @interruptible:  Use interruptible wait.
+ *
+ * May only be called by the current master since it assumes that the
+ * master lock is the current master's lock.
+ * This function takes the master's lock in write mode.
  *
  * Returns
  *  -ERESTARTSYS if interrupted by a signal.
@@ -67,10 +73,11 @@ err:
 }
 
 /**
- * Move a buffer to vram or gmr.
+ * vmw_dmabuf_to_vram_or_gmr - Move a buffer to vram or gmr.
  *
- * May only be called by the current master as this function takes the
- * its lock in write mode.
+ * May only be called by the current master since it assumes that the
+ * master lock is the current master's lock.
+ * This function takes the master's lock in write mode.
  *
  * @dev_priv:  Driver private.
  * @buf:  DMA buffer to move.
@@ -134,10 +141,11 @@ err:
 }
 
 /**
- * Move a buffer to vram.
+ * vmw_dmabuf_to_vram - Move a buffer to vram.
  *
- * May only be called by the current master as this function takes the
- * its lock in write mode.
+ * May only be called by the current master since it assumes that the
+ * master lock is the current master's lock.
+ * This function takes the master's lock in write mode.
  *
  * @dev_priv:  Driver private.
  * @buf:  DMA buffer to move.
@@ -164,10 +172,11 @@ int vmw_dmabuf_to_vram(struct vmw_private *dev_priv,
 }
 
 /**
- * Move a buffer to start of vram.
+ * vmw_dmabuf_to_start_of_vram - Move a buffer to start of vram.
  *
- * May only be called by the current master as this function takes the
- * its lock in write mode.
+ * May only be called by the current master since it assumes that the
+ * master lock is the current master's lock.
+ * This function takes the master's lock in write mode.
  *
  * @dev_priv:  Driver private.
  * @buf:  DMA buffer to move.
@@ -219,11 +228,13 @@ err_unlock:
 	return ret;
 }
 
+
 /**
- * Unpin the buffer given buffer, does not move the buffer.
+ * vmw_dmabuf_upin - Unpin the buffer given buffer, does not move the buffer.
  *
- * May only be called by the current master as this function takes the
- * its lock in write mode.
+ * May only be called by the current master since it assumes that the
+ * master lock is the current master's lock.
+ * This function takes the master's lock in write mode.
  *
  * @dev_priv:  Driver private.
  * @buf:  DMA buffer to unpin.
@@ -246,47 +257,22 @@ int vmw_dmabuf_unpin(struct vmw_private *dev_priv,
 				       interruptible);
 }
 
+
 /**
- * Move a buffer to system memory, does not pin the buffer.
- *
- * May only be called by the current master as this function takes the
- * its lock in write mode.
- *
- * @dev_priv:  Driver private.
- * @buf:  DMA buffer to move.
- * @interruptible:  Use interruptible wait.
+ * vmw_bo_get_guest_ptr - Get the guest ptr representing the current placement
+ * of a buffer.
  *
- * Returns
- * -ERESTARTSYS if interrupted by a signal.
+ * @bo: Pointer to a struct ttm_buffer_object. Must be pinned or reserved.
+ * @ptr: SVGAGuestPtr returning the result.
  */
-int vmw_dmabuf_to_system(struct vmw_private *dev_priv,
-			 struct vmw_dma_buffer *buf,
-			 bool interruptible)
-{
-	return vmw_dmabuf_to_placement(dev_priv, buf,
-				       &vmw_sys_placement,
-				       interruptible);
-}
-
-void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf,
-			      uint32_t *gmrId, uint32_t *offset)
-{
-	if (buf->base.mem.mem_type == TTM_PL_VRAM) {
-		*gmrId = SVGA_GMR_FRAMEBUFFER;
-		*offset = buf->base.offset;
-	} else {
-		*gmrId = buf->base.mem.start;
-		*offset = 0;
-	}
-}
-
-void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf, SVGAGuestPtr *ptr)
+void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *bo,
+			  SVGAGuestPtr *ptr)
 {
-	if (buf->base.mem.mem_type == TTM_PL_VRAM) {
+	if (bo->mem.mem_type == TTM_PL_VRAM) {
 		ptr->gmrId = SVGA_GMR_FRAMEBUFFER;
-		ptr->offset = buf->base.offset;
+		ptr->offset = bo->offset;
 	} else {
-		ptr->gmrId = buf->base.mem.start;
+		ptr->gmrId = bo->mem.start;
 		ptr->offset = 0;
 	}
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index fc0e3bc..b22b96a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -416,13 +416,8 @@ extern int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,
 extern int vmw_dmabuf_unpin(struct vmw_private *vmw_priv,
 			    struct vmw_dma_buffer *bo,
 			    bool interruptible);
-extern int vmw_dmabuf_to_system(struct vmw_private *vmw_priv,
-				struct vmw_dma_buffer *bo,
-				bool interruptible);
-extern void vmw_dmabuf_get_id_offset(struct vmw_dma_buffer *buf,
-				     uint32_t *gmrId, uint32_t *offset);
-extern void vmw_dmabuf_get_guest_ptr(struct vmw_dma_buffer *buf,
-				     SVGAGuestPtr *ptr);
+extern void vmw_bo_get_guest_ptr(const struct ttm_buffer_object *buf,
+				 SVGAGuestPtr *ptr);
 
 /**
  * Misc Ioctl functionality - vmwgfx_ioctl.c
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 191f1b2..070797b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -613,8 +613,7 @@ int vmw_fb_off(struct vmw_private *vmw_priv)
 	par->bo_ptr = NULL;
 	ttm_bo_kunmap(&par->map);
 
-	/* move this to system instead of just unpinning it */
-	vmw_dmabuf_to_system(vmw_priv, par->vmw_bo, false);
+	vmw_dmabuf_unpin(vmw_priv, par->vmw_bo, false);
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
index 29481e1..14399ee 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c
@@ -99,9 +99,9 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
 {
 	struct vmw_escape_video_flush *flush;
 	size_t fifo_size;
-	uint32_t gmrId, offset;
 	bool have_so = dev_priv->sou_priv ? true : false;
 	int i, num_items;
+	SVGAGuestPtr ptr;
 
 	struct {
 		struct vmw_escape_header escape;
@@ -141,12 +141,12 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
 	for (i = 0; i < num_items; i++)
 		items[i].registerId = i;
 
-	vmw_dmabuf_get_id_offset(buf, &gmrId, &offset);
-	offset += arg->offset;
+	vmw_bo_get_guest_ptr(&buf->base, &ptr);
+	ptr.offset += arg->offset;
 
 	items[SVGA_VIDEO_ENABLED].value     = true;
 	items[SVGA_VIDEO_FLAGS].value       = arg->flags;
-	items[SVGA_VIDEO_DATA_OFFSET].value = offset;
+	items[SVGA_VIDEO_DATA_OFFSET].value = ptr.offset;
 	items[SVGA_VIDEO_FORMAT].value      = arg->format;
 	items[SVGA_VIDEO_COLORKEY].value    = arg->color_key;
 	items[SVGA_VIDEO_SIZE].value        = arg->size;
@@ -164,7 +164,7 @@ static int vmw_overlay_send_put(struct vmw_private *dev_priv,
 	items[SVGA_VIDEO_PITCH_2].value     = arg->pitch[1];
 	items[SVGA_VIDEO_PITCH_3].value     = arg->pitch[2];
 	if (have_so) {
-		items[SVGA_VIDEO_DATA_GMRID].value    = gmrId;
+		items[SVGA_VIDEO_DATA_GMRID].value    = ptr.gmrId;
 		items[SVGA_VIDEO_DST_SCREEN_ID].value = SVGA_ID_INVALID;
 	}
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index e74b8e3..347e406 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -168,7 +168,7 @@ static int vmw_sou_fifo_create(struct vmw_private *dev_priv,
 	cmd->obj.root.y = y;
 
 	/* Ok to assume that buffer is pinned in vram */
-	vmw_dmabuf_get_guest_ptr(sou->buffer, &cmd->obj.backingStore.ptr);
+	vmw_bo_get_guest_ptr(&sou->buffer->base, &cmd->obj.backingStore.ptr);
 	cmd->obj.backingStore.pitch = mode->hdisplay * 4;
 
 	vmw_fifo_commit(dev_priv, fifo_size);
-- 
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 ` Thomas Hellstrom [this message]
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 ` [PATCH 21/26] vmwgfx: Optimize the command submission resource list Thomas Hellstrom
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-19-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.