All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: airlied@gmail.com
Cc: airlied@redhat.com, Thomas Hellstrom <thellstrom@vmware.com>,
	dri-devel@lists.freedesktop.org
Subject: [PATCH 7/9] drm/vmwgfx: Treat out-of-range initial width and height as host errors
Date: Thu,  9 Feb 2012 16:56:47 +0100	[thread overview]
Message-ID: <1328803009-2847-8-git-send-email-thellstrom@vmware.com> (raw)
In-Reply-To: <1328803009-2847-1-git-send-email-thellstrom@vmware.com>

And assign the initial width and height to the minimum in that case.
Strange values (-1) from these registers have been reported by users.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 1227232..f076f66 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -395,7 +395,9 @@ void vmw_3d_resource_dec(struct vmw_private *dev_priv,
  * Sets the initial_[width|height] fields on the given vmw_private.
  *
  * It does so by reading SVGA_REG_[WIDTH|HEIGHT] regs and then
- * capping the value to fb_max_[width|height] fields and the
+ * clamping the value to fb_max_[width|height] fields and the
+ * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
+ * If the values appear to be invalid, set them to
  * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
  */
 static void vmw_get_initial_size(struct vmw_private *dev_priv)
@@ -407,10 +409,18 @@ static void vmw_get_initial_size(struct vmw_private *dev_priv)
 	height = vmw_read(dev_priv, SVGA_REG_HEIGHT);
 
 	width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH);
-	width = min_t(uint32_t, width, dev_priv->fb_max_width);
-
 	height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT);
-	height = min_t(uint32_t, height, dev_priv->fb_max_height);
+
+	if (width > dev_priv->fb_max_width ||
+	    height > dev_priv->fb_max_height) {
+
+		/*
+		 * This is a host error and shouldn't occur.
+		 */
+
+		width = VMW_MIN_INITIAL_WIDTH;
+		height = VMW_MIN_INITIAL_HEIGHT;
+	}
 
 	dev_priv->initial_width = width;
 	dev_priv->initial_height = height;
-- 
1.7.4.4

  parent reply	other threads:[~2012-02-09 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09 15:56 [PATCH -next 0/0] vmwgfx updates Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 1/9] vmwgfx: Rework fence event action Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 2/9] vmwgfx: Clean up pending event references to struct drm_file objects on close Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 3/9] vmwgfx: Make it possible to get fence from execbuf Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 4/9] vmwgfx: Pipe fence out of screen object dirty functions Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 5/9] vmwgfx: Add page flip support Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 6/9] vmwgfx: Pick up the initial size from the width and height regs Thomas Hellstrom
2012-02-09 15:56 ` Thomas Hellstrom [this message]
2012-02-09 15:56 ` [PATCH 8/9] vmwgfx: Move function declaration to correct header Thomas Hellstrom
2012-02-09 15:56 ` [PATCH 9/9] drm/vmwgfx: Bump driver minor Thomas Hellstrom
2012-02-09 15:58 ` [PATCH -next 0/0] vmwgfx updates 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=1328803009-2847-8-git-send-email-thellstrom@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.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.