From patchwork Thu Sep 13 11:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10599321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB90714BD for ; Thu, 13 Sep 2018 11:59:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA592AA0A for ; Thu, 13 Sep 2018 11:59:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C02E72AA28; Thu, 13 Sep 2018 11:59:24 +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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,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 61D312AA0A for ; Thu, 13 Sep 2018 11:59:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6DAF96E675; Thu, 13 Sep 2018 11:59:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680040.outbound.protection.outlook.com [40.107.68.40]) by gabe.freedesktop.org (Postfix) with ESMTPS id 145AC6E66E for ; Thu, 13 Sep 2018 11:59:18 +0000 (UTC) Received: from fedoratest.localdomain (155.4.205.56) by SN6PR05MB4589.namprd05.prod.outlook.com (2603:10b6:805:38::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.11; Thu, 13 Sep 2018 11:59:14 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org, linux-graphics-maintainer@vmware.com Subject: [PATCH -fixes 2/5] drm/vmwgfx: limit screen size to stdu_max during check_modeset Date: Thu, 13 Sep 2018 13:58:34 +0200 Message-Id: <20180913115837.7746-2-thellstrom@vmware.com> X-Mailer: git-send-email 2.19.0.rc1 In-Reply-To: <20180913115837.7746-1-thellstrom@vmware.com> References: <20180913115837.7746-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: PR0P264CA0003.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100::15) To SN6PR05MB4589.namprd05.prod.outlook.com (2603:10b6:805:38::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb469e09-270c-4a1c-8f9a-08d6197053c1 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN6PR05MB4589; X-Microsoft-Exchange-Diagnostics: 1; SN6PR05MB4589; 3:8TTv8KZIT84HdGDnPflO+u94BH8gsI6VxhOblt9qouZqGmQFil1N2P3/4E3wd9FD7omER0d4h4+F5ebBsJbZbXXXCow1+LTEgLXZOiKhltu5rI1mIrOv/rhDKDKl91JbUmb7tbTTe2tA7gPtEJlT4p6BDhgCYrYpRa5uyk4S5gLyUYFIzV655021acYmXg+Lte2+pV2EX8yEIYwomOVvoFgz1LySpFaCbYyrCU5oh+borsdmEeY/1Hu/zm3n2KSD; 25:Fc4XDPtfsCdN511PcAT/PljUiK4efVVfqyMi3tSp8Ro5WgduX4HSVfd9Levzao4laQiBqtJr9mVMA20fM/cQgPzKY5zLBE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qxuPmJweaf3sRFy+0KiaOaX1y9Xvmk9yLdAak6WUnfRT12KeCydBmN3MvYm14hw0YHnqjA5hrr0zhrfLaWGSD+qmS457uM4n+qznQVpaaQSSyAr2i5SOzsh4hBqf0P18+j7D8apXngGun9XaOlYxVEe4IZGnac9ub72fXCQ0WJXu0=; 4:3L5KdLUreLIyghkf8js4IQhQU48bzKG43JOu6dBlGa19hjBgqeqmAXR//wgow+k8UEfbh6MkGIfsXrRJpIGMdh/ioYriT2lzMBOXBXhDq/ZmvdBi8aJJLTdTL9APruA4pYdPmwnnXqny8d8xJCLIDco0ZDgmOtRWcl+ywsUi4X1KHsH1MxXscSNzq2+V6ohnLY3fxDyRd41HeEz9+Zd475og1eUrNWKC+ycGhGbWU0iLr2jxYVIqlNIwhcwAldqQqJB4g7hQAzFeDOj0OxjnGZY07BnTmQPsNDxmzrUeB6f8+Ajs2LHr3GNRgGEvBiOA X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(10201501046)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(201708071742011)(7699050); SRVR:SN6PR05MB4589; BCL:0; PCL:0; RULEID:; SRVR:SN6PR05MB4589; X-Forefront-PRVS: 07943272E1 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(376002)(39860400002)(136003)(366004)(346002)(199004)(189003)(2906002)(6512007)(81156014)(5660300001)(386003)(106356001)(105586002)(6506007)(53936002)(2870700001)(26005)(6666003)(107886003)(6636002)(97736004)(36756003)(16526019)(51416003)(186003)(486006)(76176011)(11346002)(50466002)(81166006)(52116002)(956004)(8676002)(446003)(476003)(6486002)(48376002)(478600001)(316002)(2616005)(68736007)(66066001)(305945005)(4326008)(14444005)(1076002)(50226002)(47776003)(8936002)(86362001)(6116002)(7736002)(54906003)(3846002)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR05MB4589; H:fedoratest.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN6PR05MB4589; 23:p8fBfHIa2PavdOmPMntIfTkO5aw4Oy1c15o/h1yGG?= eaBt39M5mBNOunosq638fo+X9iiCNBs//WWz/zqTgHLLhZHdnXudM9LHisQbGKCENUB3NCOQjAbiCInS3kjKedpJV7l+XkzshxM5uXjkrpGNChBU1kLcOgRIkNfGEwVin41L1i44J3PHW8vSfz35lim1tp4CLKf+sL4xp5W5Q/hSKNt5UdCp/daFaZM9I3Irxg/RDwxiAdQJOTnJjVchkpAXZ+2doQH82fqTs+B3l23mlhpHDA+9Ce2cn0QXPfCVB6KuLWkAQbMcbd3sXbxKcwmyyyOCyLFyeiri+rlFNb2PUeSHMz8EBlfTCh5MtVbX5VjT5LQaMOWHIkKIXkc7D9lQ3s2Hmf9wGz9iVnIjAkX0bzOg92+zuRq6CrbUtmqiAeW253L4N7lWoe6ZuZNiBpBinKeI1tkvcmT3e3ORcEQ87XE5CTpCEaQZVhsg6sgeaiF1V23XfQtGh2flfwj/9LtpClmhsNH4QVvcpS0wt7Ftb3jYYyRbIZFMKjkxg6netbT1iPCqOnAvsd9E1vsVsvE+fOEkPSvG1jpSnHHLWJUds8/PgEKvM59gYYvE7WO565EDdOgHAfkjqb8IV7ejNUWP2K7A7wdyP9r9s+GQCWL23tR0wZgtpummpri6wXzYsD7CLakExB/g6YwS22NHLH0jKQwZpL1xqP8yst32OTVVXuOq1ksIMYojaFIZLFPUGqpRQ4IR9yVd/EqnttwrPt9w3ICxCtM/ubOq6WttQ1hRpaCUYngYaj24x+kd3VGe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t/zEgdo8CphwmAhHF4kMCcQtIj6Mu0YrYZop2ibZ4ZpoeS6ivsXjCp0lbOjRM7R/I78vRVBfixWBAJTP8fguF4mcpLJrOyYe0RTbNkwGcP36oJ465s95GBBQMha3wjMtugKb92i7P4/7XaL8QHBQKchbm/HSf5Vf0VEA/wz2UNKPGm+Xnnw6tDW2HOE8ch+6CIbQQxlRkeSbVssRLLcnl6GywUlsJxQrsQX7dwdaX+3Ewe76DZCiNMy4aa7xngBMW0BMgVamnr/r4AkCF/bY2WA==; 5:X/P3OEnf20aPfLaKywGe9gL7JrEEmVB6b30lQKDoCuwsURUCCT0zsr4aZ9Zf6t/x+a4vYbMBT16SeaexSLChG2nPdrkoPuGtJdnCWRZIpms7r3/VFgVpDndq+djYKx8FrjJIHPE3Z02WWBVcO1an2fRXe3Xh1YarXulIkkRhzoo=; 7:rUeAbUr1XaDWxF8mbAU2xnl+26kU9xzqYPErcINoqn5gTzXbnYmO8rSzCTqKnPd7XQiTDgLhoG5O/fgl3n1cy8N1i8UIyHrQ//oU1GaxFVJ2TziL9kbMnIQQobhqezmHQ/YmhciXvrS6ESdCc4DQpdCD/1IlokaR0EXSWr/fDXvekUjVhlw6Q17/iXflqCdzKwCl/TfMzIW+YZM+98P+v+PvIkTW5Z2Ns3BUIKlhyeRYoaNR8lawBsRvMC43JwL3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SN6PR05MB4589; 20:JfTImTMii9TA2/5k9Ld8UtmFMxksQMjOR8LctCTA7FeCHZE7LvEtuSUG4Ph/VskSIrZ1uoLWAXpuvGen3QMgbcm8pgVl8Xneftk52hQ6pC/2+FLy9c49ZymABHXsC0QWCe3E4tOkkNUbTxXqxIHLAxkTFCagPmqOIel5sSIdWe0= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2018 11:59:14.1332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb469e09-270c-4a1c-8f9a-08d6197053c1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR05MB4589 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pv-drivers@vmware.com, Thomas Hellstrom , Deepak Rawat Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Deepak Rawat 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 Reviewed-by: Sinclair Yeh Reviewed-by: Thomas Hellstrom Signed-off-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 30 +++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 636b962849c8..12a41b039167 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -1512,21 +1512,19 @@ static int vmw_kms_check_display_memory(struct drm_device *dev, struct drm_rect *rects) { struct vmw_private *dev_priv = vmw_priv(dev); - struct drm_mode_config *mode_config = &dev->mode_config; struct drm_rect bounding_box = {0}; u64 total_pixels = 0, pixel_mem, bb_mem; int i; for (i = 0; i < num_rects; i++) { /* - * Currently this check is limiting the topology within max - * texture/screentarget size. This should change in future when - * user-space support multiple fb with topology. + * For STDU only individual screen (screen target) is limited by + * SCREENTARGET_MAX_WIDTH/HEIGHT registers. */ - if (rects[i].x1 < 0 || rects[i].y1 < 0 || - rects[i].x2 > mode_config->max_width || - rects[i].y2 > mode_config->max_height) { - DRM_ERROR("Invalid GUI layout.\n"); + if (dev_priv->active_display_unit == vmw_du_screen_target && + (drm_rect_width(&rects[i]) > dev_priv->stdu_max_width || + drm_rect_height(&rects[i]) > dev_priv->stdu_max_height)) { + DRM_ERROR("Screen size not supported.\n"); return -EINVAL; } @@ -2376,6 +2374,7 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct vmw_private *dev_priv = vmw_priv(dev); + struct drm_mode_config *mode_config = &dev->mode_config; struct drm_vmw_update_layout_arg *arg = (struct drm_vmw_update_layout_arg *)data; void __user *user_rects; @@ -2421,6 +2420,21 @@ int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, drm_rects[i].y1 = curr_rect.y; drm_rects[i].x2 = curr_rect.x + curr_rect.w; drm_rects[i].y2 = curr_rect.y + curr_rect.h; + + /* + * Currently this check is limiting the topology within + * mode_config->max (which actually is max texture size + * supported by virtual device). This limit is here to address + * window managers that create a big framebuffer for whole + * topology. + */ + if (drm_rects[i].x1 < 0 || drm_rects[i].y1 < 0 || + drm_rects[i].x2 > mode_config->max_width || + drm_rects[i].y2 > mode_config->max_height) { + DRM_ERROR("Invalid GUI layout.\n"); + ret = -EINVAL; + goto out_free; + } } ret = vmw_kms_check_display_memory(dev, arg->num_outputs, drm_rects);