From patchwork Mon Mar 27 22:17:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinclair Yeh X-Patchwork-Id: 9647611 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B282E601D7 for ; Mon, 27 Mar 2017 22:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A540925D9E for ; Mon, 27 Mar 2017 22:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A4BF27F07; Mon, 27 Mar 2017 22:19:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 389DE25D9E for ; Mon, 27 Mar 2017 22:19:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77A556E385; Mon, 27 Mar 2017 22:19:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EX13-EDG-OU-002.vmware.com (ex13-edg-ou-002.vmware.com [208.91.0.190]) by gabe.freedesktop.org (Postfix) with ESMTPS id 19CCF6E385 for ; Mon, 27 Mar 2017 22:19:55 +0000 (UTC) Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Mon, 27 Mar 2017 15:19:00 -0700 Received: from vmware.com (unknown [10.16.254.220]) by sc9-mailhost3.vmware.com (Postfix) with SMTP id 7D9674043D; Mon, 27 Mar 2017 15:19:40 -0700 (PDT) Received: by vmware.com (sSMTP sendmail emulation); Mon, 27 Mar 2017 15:19:37 -0700 From: Sinclair Yeh To: Subject: [PATCH 9/9] drm/vmwgfx: Properly check display/scanout surface size Date: Mon, 27 Mar 2017 15:17:59 -0700 Message-ID: <1490653079-45042-10-git-send-email-syeh@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490653079-45042-1-git-send-email-syeh@vmware.com> References: <1490653079-45042-1-git-send-email-syeh@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: syeh@vmware.com does not designate permitted sender hosts) Cc: thellstrom@vmware.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The scanout surface size is the smaller of max texture size and max STDU size. Signed-off-by: Sinclair Yeh Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +++ drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 16 +++++++++++++++- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 881ffd4..9b0bf2c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2218,7 +2218,10 @@ int vmw_du_connector_fill_modes(struct drm_connector *connector, if (dev_priv->active_display_unit == vmw_du_screen_target) { max_width = min(max_width, dev_priv->stdu_max_width); + max_width = min(max_width, dev_priv->texture_max_width); + max_height = min(max_height, dev_priv->stdu_max_height); + max_height = min(max_height, dev_priv->texture_max_height); } /* Add preferred mode */ diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index ce1191a..6ae2042 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -1602,7 +1602,21 @@ int vmw_kms_stdu_init_display(struct vmw_private *dev_priv) dev_priv->active_display_unit = vmw_du_screen_target; - if (!(dev_priv->capabilities & SVGA_CAP_3D)) { + if (dev_priv->capabilities & SVGA_CAP_3D) { + /* + * For 3D VMs, display (scanout) buffer size is the smaller of + * max texture and max STDU + */ + uint32_t max_width, max_height; + + max_width = min(dev_priv->texture_max_width, + dev_priv->stdu_max_width); + max_height = min(dev_priv->texture_max_height, + dev_priv->stdu_max_height); + + dev->mode_config.max_width = max_width; + dev->mode_config.max_height = max_height; + } else { /* * Given various display aspect ratios, there's no way to * estimate these using prim_bb_mem. So just set these to diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c index 6abcf82..41b9d20 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c @@ -1479,10 +1479,24 @@ int vmw_surface_gb_priv_define(struct drm_device *dev, *srf_out = NULL; if (for_scanout) { + uint32_t max_width, max_height; + if (!svga3dsurface_is_screen_target_format(format)) { DRM_ERROR("Invalid Screen Target surface format."); return -EINVAL; } + + max_width = min(dev_priv->texture_max_width, + dev_priv->stdu_max_width); + max_height = min(dev_priv->texture_max_height, + dev_priv->stdu_max_height); + + if (size.width > max_width || size.height > max_height) { + DRM_ERROR("%ux%u\n, exeeds max surface size %ux%u", + size.width, size.height, + max_width, max_height); + return -EINVAL; + } } else { const struct svga3d_surface_desc *desc;