diff options
| author | Thomas Hellstrom <thellstrom@vmware.com> | 2012-02-09 10:56:47 -0500 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2012-02-13 07:01:36 -0500 |
| commit | 67d4a87b0a6bf7225aacc2c14e3542ec2f6b803f (patch) | |
| tree | 2055686de4dad4e38d8a74d4bf743e5a3afb71ea /drivers/gpu/drm/vmwgfx | |
| parent | eb4f923b1ceac8a618469c51ff249bd89bc0dfa4 (diff) | |
drm/vmwgfx: Treat out-of-range initial width and height as host errors
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>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx')
| -rw-r--r-- | 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 12272329d91..f076f66b115 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, | |||
| 395 | * Sets the initial_[width|height] fields on the given vmw_private. | 395 | * Sets the initial_[width|height] fields on the given vmw_private. |
| 396 | * | 396 | * |
| 397 | * It does so by reading SVGA_REG_[WIDTH|HEIGHT] regs and then | 397 | * It does so by reading SVGA_REG_[WIDTH|HEIGHT] regs and then |
| 398 | * capping the value to fb_max_[width|height] fields and the | 398 | * clamping the value to fb_max_[width|height] fields and the |
| 399 | * VMW_MIN_INITIAL_[WIDTH|HEIGHT]. | ||
| 400 | * If the values appear to be invalid, set them to | ||
| 399 | * VMW_MIN_INITIAL_[WIDTH|HEIGHT]. | 401 | * VMW_MIN_INITIAL_[WIDTH|HEIGHT]. |
| 400 | */ | 402 | */ |
| 401 | static void vmw_get_initial_size(struct vmw_private *dev_priv) | 403 | 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) | |||
| 407 | height = vmw_read(dev_priv, SVGA_REG_HEIGHT); | 409 | height = vmw_read(dev_priv, SVGA_REG_HEIGHT); |
| 408 | 410 | ||
| 409 | width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH); | 411 | width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH); |
| 410 | width = min_t(uint32_t, width, dev_priv->fb_max_width); | ||
| 411 | |||
| 412 | height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT); | 412 | height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT); |
| 413 | height = min_t(uint32_t, height, dev_priv->fb_max_height); | 413 | |
| 414 | if (width > dev_priv->fb_max_width || | ||
| 415 | height > dev_priv->fb_max_height) { | ||
| 416 | |||
| 417 | /* | ||
| 418 | * This is a host error and shouldn't occur. | ||
| 419 | */ | ||
| 420 | |||
| 421 | width = VMW_MIN_INITIAL_WIDTH; | ||
| 422 | height = VMW_MIN_INITIAL_HEIGHT; | ||
| 423 | } | ||
| 414 | 424 | ||
| 415 | dev_priv->initial_width = width; | 425 | dev_priv->initial_width = width; |
| 416 | dev_priv->initial_height = height; | 426 | dev_priv->initial_height = height; |
