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 07/13] drm/vmwgfx: Reserve first part of VRAM for framebuffer.
Date: Tue, 27 Apr 2010 19:45:39 +0200	[thread overview]
Message-ID: <1272390345-3655-8-git-send-email-thellstrom@vmware.com> (raw)
In-Reply-To: <1272390345-3655-7-git-send-email-thellstrom@vmware.com>

The host may be touching this part of VRAM at modesetting,
even if we never use it ourselves, since we blit screen updates from 3D
surfaces. Make sure no DMA buffers are placed in this part of VRAM.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |   39 +++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 9d0defa..c1a7fd5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -30,6 +30,8 @@
 /* Might need a hrtimer here? */
 #define VMWGFX_PRESENT_RATE ((HZ / 60 > 0) ? HZ / 60 : 1)
 
+static int vmw_surface_dmabuf_pin(struct vmw_framebuffer *vfb);
+static int vmw_surface_dmabuf_unpin(struct vmw_framebuffer *vfb);
 
 void vmw_display_unit_cleanup(struct vmw_display_unit *du)
 {
@@ -326,6 +328,7 @@ int vmw_framebuffer_create_handle(struct drm_framebuffer *fb,
 struct vmw_framebuffer_surface {
 	struct vmw_framebuffer base;
 	struct vmw_surface *surface;
+	struct vmw_dma_buffer *buffer;
 	struct delayed_work d_work;
 	struct mutex work_lock;
 	bool present_fs;
@@ -500,8 +503,8 @@ int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
 	vfbs->base.base.depth = 24;
 	vfbs->base.base.width = width;
 	vfbs->base.base.height = height;
-	vfbs->base.pin = NULL;
-	vfbs->base.unpin = NULL;
+	vfbs->base.pin = &vmw_surface_dmabuf_pin;
+	vfbs->base.unpin = &vmw_surface_dmabuf_unpin;
 	vfbs->surface = surface;
 	mutex_init(&vfbs->work_lock);
 	INIT_DELAYED_WORK(&vfbs->d_work, &vmw_framebuffer_present_fs_callback);
@@ -589,6 +592,38 @@ static struct drm_framebuffer_funcs vmw_framebuffer_dmabuf_funcs = {
 	.create_handle = vmw_framebuffer_create_handle,
 };
 
+static int vmw_surface_dmabuf_pin(struct vmw_framebuffer *vfb)
+{
+	struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
+	struct vmw_framebuffer_surface *vfbs =
+		vmw_framebuffer_to_vfbs(&vfb->base);
+	unsigned long size = vfbs->base.base.pitch * vfbs->base.base.height;
+	int ret;
+
+	vfbs->buffer = kzalloc(sizeof(*vfbs->buffer), GFP_KERNEL);
+
+	vmw_overlay_pause_all(dev_priv);
+	ret = vmw_dmabuf_init(dev_priv, vfbs->buffer, size,
+			       &vmw_vram_ne_placement,
+			       false, &vmw_dmabuf_bo_free);
+	vmw_overlay_resume_all(dev_priv);
+
+	return ret;
+}
+
+static int vmw_surface_dmabuf_unpin(struct vmw_framebuffer *vfb)
+{
+	struct ttm_buffer_object *bo;
+	struct vmw_framebuffer_surface *vfbs =
+		vmw_framebuffer_to_vfbs(&vfb->base);
+
+	bo = &vfbs->buffer->base;
+	ttm_bo_unref(&bo);
+	vfbs->buffer = NULL;
+
+	return 0;
+}
+
 static int vmw_framebuffer_dmabuf_pin(struct vmw_framebuffer *vfb)
 {
 	struct vmw_private *dev_priv = vmw_priv(vfb->base.dev);
-- 
1.6.2.5

  reply	other threads:[~2010-04-27 17:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27 17:45 [PATCH 0/13] vmwgfx update Thomas Hellstrom
2010-04-27 17:45 ` [PATCH 01/13] drm/vmwgfx: Assume larger framebuffer max size Thomas Hellstrom
2010-04-27 17:45   ` [PATCH 02/13] drm/vmwgfx: Fix single framebuffer detection Thomas Hellstrom
2010-04-27 17:45     ` [PATCH 03/13] drm/vmwgfx: Make sure to unpin old and pin new framebuffer Thomas Hellstrom
2010-04-27 17:45       ` [PATCH 04/13] drm/vmwgfx: Add kernel throttling support. Bump minor Thomas Hellstrom
2010-04-27 17:45         ` [PATCH 05/13] drm/vmwgfx: Get connector status from detection function Thomas Hellstrom
2010-04-27 17:45           ` [PATCH 06/13] drm/vmwgfx: Support older hardware Thomas Hellstrom
2010-04-27 17:45             ` Thomas Hellstrom [this message]
2010-04-27 17:45               ` [PATCH 08/13] drm/vmwgfx: Remove duplicate member from struct vmw_legacy_display_unit Thomas Hellstrom
2010-04-27 17:45                 ` [PATCH 09/13] drm/vmwgfx: Don't use SVGA_REG_ENABLE in modesetting code Thomas Hellstrom
2010-04-27 17:45                   ` [PATCH 10/13] drm/vmwgfx: Some modesetting cleanups and fixes Thomas Hellstrom
2010-04-27 17:45                     ` [PATCH 11/13] drm/vmwgfx: Unpause overlay on update Thomas Hellstrom
2010-04-27 17:45                       ` [PATCH 12/13] drm/vmwgfx: Print warnings in kernel log about bo pinning that fails Thomas Hellstrom
2010-04-27 17:45                         ` [PATCH 13/13] drm/vmwgfx: Remove some leftover debug messages Thomas Hellstrom
2010-04-28  8:49     ` [PATCH 02/13] drm/vmwgfx: Fix single framebuffer detection Paulius Zaleckas
  -- strict thread matches above, loose matches on Subject: below --
2010-05-28  9:21 [PATCH 0/13] vmwgfx update V2 Thomas Hellstrom
2010-05-28  9:21 ` [PATCH 01/13] drm/vmwgfx: Assume larger framebuffer max size Thomas Hellstrom
2010-05-28  9:21   ` [PATCH 02/13] drm/vmwgfx: Fix single framebuffer detection Thomas Hellstrom
2010-05-28  9:21     ` [PATCH 03/13] drm/vmwgfx: Make sure to unpin old and pin new framebuffer Thomas Hellstrom
2010-05-28  9:21       ` [PATCH 04/13] drm/vmwgfx: Add kernel throttling support. Bump minor Thomas Hellstrom
2010-05-28  9:21         ` [PATCH 05/13] drm/vmwgfx: Get connector status from detection function Thomas Hellstrom
2010-05-28  9:21           ` [PATCH 06/13] drm/vmwgfx: Support older hardware Thomas Hellstrom
2010-05-28  9:22             ` [PATCH 07/13] drm/vmwgfx: Reserve first part of VRAM for framebuffer 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=1272390345-3655-8-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.