Skip to content

Commit 0c1b174

Browse files
deepak-rawatthomashvmw
authored andcommitted
drm/vmwgfx: limit screen size to stdu_max during check_modeset
For STDU individual screen target size is limited by SVGA_REG_SCREENTARGET_MAX_WIDTH/HEIGHT registers so add that limit during atomic check_modeset. An additional limit is placed in the update_layout ioctl to avoid requesting layouts that current user-space typically can't support. Also modified the comments to reflect current limitation on topology. Signed-off-by: Deepak Rawat <drawat@vmware.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
1 parent bfc8882 commit 0c1b174

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,21 +1512,19 @@ static int vmw_kms_check_display_memory(struct drm_device *dev,
15121512
struct drm_rect *rects)
15131513
{
15141514
struct vmw_private *dev_priv = vmw_priv(dev);
1515-
struct drm_mode_config *mode_config = &dev->mode_config;
15161515
struct drm_rect bounding_box = {0};
15171516
u64 total_pixels = 0, pixel_mem, bb_mem;
15181517
int i;
15191518

15201519
for (i = 0; i < num_rects; i++) {
15211520
/*
1522-
* Currently this check is limiting the topology within max
1523-
* texture/screentarget size. This should change in future when
1524-
* user-space support multiple fb with topology.
1521+
* For STDU only individual screen (screen target) is limited by
1522+
* SCREENTARGET_MAX_WIDTH/HEIGHT registers.
15251523
*/
1526-
if (rects[i].x1 < 0 || rects[i].y1 < 0 ||
1527-
rects[i].x2 > mode_config->max_width ||
1528-
rects[i].y2 > mode_config->max_height) {
1529-
DRM_ERROR("Invalid GUI layout.\n");
1524+
if (dev_priv->active_display_unit == vmw_du_screen_target &&
1525+
(drm_rect_width(&rects[i]) > dev_priv->stdu_max_width ||
1526+
drm_rect_height(&rects[i]) > dev_priv->stdu_max_height)) {
1527+
DRM_ERROR("Screen size not supported.\n");
15301528
return -EINVAL;
15311529
}
15321530

@@ -2376,6 +2374,7 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
23762374
struct drm_file *file_priv)
23772375
{
23782376
struct vmw_private *dev_priv = vmw_priv(dev);
2377+
struct drm_mode_config *mode_config = &dev->mode_config;
23792378
struct drm_vmw_update_layout_arg *arg =
23802379
(struct drm_vmw_update_layout_arg *)data;
23812380
void __user *user_rects;
@@ -2421,6 +2420,21 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
24212420
drm_rects[i].y1 = curr_rect.y;
24222421
drm_rects[i].x2 = curr_rect.x + curr_rect.w;
24232422
drm_rects[i].y2 = curr_rect.y + curr_rect.h;
2423+
2424+
/*
2425+
* Currently this check is limiting the topology within
2426+
* mode_config->max (which actually is max texture size
2427+
* supported by virtual device). This limit is here to address
2428+
* window managers that create a big framebuffer for whole
2429+
* topology.
2430+
*/
2431+
if (drm_rects[i].x1 < 0 || drm_rects[i].y1 < 0 ||
2432+
drm_rects[i].x2 > mode_config->max_width ||
2433+
drm_rects[i].y2 > mode_config->max_height) {
2434+
DRM_ERROR("Invalid GUI layout.\n");
2435+
ret = -EINVAL;
2436+
goto out_free;
2437+
}
24242438
}
24252439

24262440
ret = vmw_kms_check_display_memory(dev, arg->num_outputs, drm_rects);

0 commit comments

Comments
 (0)