From patchwork Tue Jul 3 19:14:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10505001 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 CE2C160225 for ; Tue, 3 Jul 2018 19:16:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B78E528B5A for ; Tue, 3 Jul 2018 19:16:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABC0428BDD; Tue, 3 Jul 2018 19:16:53 +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 543FD28B5A for ; Tue, 3 Jul 2018 19:16:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66C4A6E8CA; Tue, 3 Jul 2018 19:16:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710056.outbound.protection.outlook.com [40.107.71.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id F11466E8C1 for ; Tue, 3 Jul 2018 19:16:33 +0000 (UTC) Received: from fedoratest.localdomain (155.4.205.56) by DM6PR05MB4587.namprd05.prod.outlook.com (2603:10b6:5:9f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.11; Tue, 3 Jul 2018 19:16:31 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH -next 05/15] drm/vmwgfx: Fix atomic mode set check Date: Tue, 3 Jul 2018 21:14:50 +0200 Message-Id: <20180703191500.2374-6-thellstrom@vmware.com> X-Mailer: git-send-email 2.18.0.rc1 In-Reply-To: <20180703191500.2374-1-thellstrom@vmware.com> References: <20180703191500.2374-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: DM5PR21CA0042.namprd21.prod.outlook.com (2603:10b6:3:ed::28) To DM6PR05MB4587.namprd05.prod.outlook.com (2603:10b6:5:9f::24) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 03a639a0-9841-4b23-74ed-08d5e1197c6e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DM6PR05MB4587; X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4587; 3:uTNCNFY7/Adq5FF+5ocYINhjuN2eMV4TSiEosSwG4OyL6g+bMzfdyb0ti1DmLVQf6CjPu0A2gKdzTcuns8mTwCQ/qH/TdZSZ1Am4oLM27x0tlZQYIfzHg7T2vL3KRdDK+HD8luSP8m/JtFjN6cMAQEShCy0fCTGMaHJ+Y1Itnxptm3gRzCsc1zYvxESU/BDUqIc5wderazl2zBffzO0pcxSynZj/Y6tgYd+xmTB+RxQtDwb8lt3Y4meP5MTx/hyU; 25:wFIxcZDh+ApBx+aai2XQBkkOLLL8dtq+9HT6iyzuaC67K3h/xYTM+Ep+keG8eU5ZFsXP+5ZvRRDmzBK6EoE5tPiNmuQog4JagYL63AAobxBkfIQOHJZUElPeIa1xupQvvBfNbtR+7Ge4u9t+u1WlS3roDdscZRf0HJ5MrV+/v47Jt+SSDoLdCipiZDXOfGYilolVbi1J4kyFDRcOn+R2c8AitpiyCKtRYS5Q8nz82DlWDOP354Vza35cYkgAgSz8Zu4k3L71hcjfNkby3RjwaoKwGauzOoRzaa3es6WCNhm8LmpsYc/5/cn1bRpb8xv46pNG0RQUQFyC0n28suefrQ==; 31:hjTW/jRou4mKoNkfW4K6YV0xQ5s5CTtxcWwREdxGE1IGWRyRFwt34bb80IgiIX+7qsEC5MHImaTEkVAjpJrffdGxL4FuUCsoxmjr62c8X/bcdS6ZclYmYQpFWKSanPz7Wi1c2yUgGVyAf0Q3/OYuPvr+UlZjdyO93oGTEMi6+G71FZvnYfJ2/SFs5Pxi+VobEu9UVAHh/duJbxqvY+fdSz2ncZT8eNPpCrR9AUIQ15I= X-MS-TrafficTypeDiagnostic: DM6PR05MB4587: X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4587; 20:iuGzhVVWTVR+AMakEROSDghp908NReWWoEg2Ni7kiJuVeA/0n3Z6DJ+ZvouQGs6mqIbWiLuvA60LAWhTjyLACPJi4I3K/hmjyzrsWMb42lHuYaIJS1jissZxsewiLpNDhDd43WoVNXQHyR47K/Jq9TDEh6gYUDltnV/f31FCa8OiHsn3GwLzCU+eyjOzrCSNcIfWPMuTnClA4EHJB/FjXz5J40APGfyN25XrnP99sfQFi2TYf06y7dTzViCKQthXyAO4HZHNYKbyCpe2Dob5Iyj+PomKLXBcqyJSN+jQFN/aS4MQXTWVO2lkD7KzXJWARiQt5odUQWdB/6kBPmKEUbtuuXQiUEH3z9e2D7syR0DVdv75IF9yPCtd19u8VLuSWC5NTdL3741AhdPs61towVxobtScjFUuTmMI1E7uv93gC4BXsef+AnM8PG9ATambyt5KfGfVNK9Y26l52V7O5al7//frA7vkR0ee8Pp7z7WG4qf0TmWeiJ1jOXSFlAC8; 4:rz7aRK9X80RKrqpgcIlCQtCnihV20g1UY/ggpdEUIMkAmQPl4AOHkIIlMEivA8sxDWnt1V07jNC5E7qLfu5rT0EF+wvuCamO0kcCUjmB6esY0arZ/6T2nfkLJVfoiIqmM1q0s6bAFCFgAmQTG9aAWgr8xyvgKG0Wa04ltPY3dTDTqeKaa/0W+y16ejAvM86E3JiXwSmgYJQrfZ8cNSepvKahhHTZiK+SDhh19QFZKmYVMe8OWE1SWYI401qGSZ2p/zYQkPwPf0a68msbLME0RsO1SRcAtTCi4rwYEyILLsY0Q8AHsVQmyQ/SO6hLoqlP 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)(8121501046)(5005006)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DM6PR05MB4587; BCL:0; PCL:0; RULEID:; SRVR:DM6PR05MB4587; X-Forefront-PRVS: 0722981D2A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(366004)(39860400002)(396003)(376002)(346002)(199004)(189003)(2361001)(53936002)(76176011)(68736007)(52116002)(51416003)(47776003)(26005)(2351001)(50226002)(16526019)(97736004)(86362001)(386003)(2906002)(6506007)(66066001)(186003)(316002)(16586007)(48376002)(446003)(6486002)(50466002)(54906003)(14444005)(11346002)(2616005)(1076002)(956004)(6116002)(6512007)(476003)(81166006)(8676002)(81156014)(36756003)(3846002)(5660300001)(486006)(107886003)(106356001)(305945005)(25786009)(7736002)(4326008)(478600001)(6916009)(105586002)(6666003)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR05MB4587; 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; DM6PR05MB4587; 23:Pq5MpG9J0+shMOOSdU32L22IqWcSCnDzjSzCL4aYz?= =?us-ascii?Q?CXKxyAgH52z08+ywgJGc32IXLBRpHOxESwPNR0iMxLRgEqC+U4tdZE966grU?= =?us-ascii?Q?DwJVdfvaaARqJyvfdGviJQNFNUzWh4h0ND13kKKpx5053OkWxQa2psdIKmyR?= =?us-ascii?Q?2w552FjCGDJK8Bnr4uODESCa7jMY3wdqQuWksxlwsiLcGGuN3MnSKN6yqlTh?= =?us-ascii?Q?ZihKaMkezlQB9ZKnt9/+zrFV0SuL0iEn6wRe0CQpam5dsEF9XzTsaA1CqC3A?= =?us-ascii?Q?QpOMkkiExhq/CgjUTvNgFNd8JMN1Y0LltncU87Yrl+YxLd+FBA5jbMhI3va9?= =?us-ascii?Q?oJPckVCaDdGHTQHX1cNFKmp84azj4TyLOBdj0nIOEpq2CW/1b546lKD8vVVY?= =?us-ascii?Q?l9g21y6tufXUOwrAg6UjL/3Q3+jmLGtxaOOmn4mDAlJTbb2Ngug72/GHKfbT?= =?us-ascii?Q?OB1Fczfe7LIClGLVQ6UibMYjflTtOm0IETSYdU0UXmgGuAmKclyLXDoLGPCR?= =?us-ascii?Q?5AKP0o41DrAfRyC5ZdlX8KrcA5fZIK69SMfkJTjQrmz6w5NkqR4/L/S5/OIY?= =?us-ascii?Q?DADLRnSLDmw4ihoL/U2Lg7Ac0fTUkEKVv+LOT6USY6S+FdMMqn4odkqI2scv?= =?us-ascii?Q?5EDJLHN+KVeD6jK/ZBg79ZQbxZiF5XZRLqbvJDTPH9iXq0shMmlwj1iLpSwV?= =?us-ascii?Q?YKX6W4/zE2CglIb5b4I6HIGXw4JWhMldjQi4tuEQzkUus7vY+MvKGTWRTBMK?= =?us-ascii?Q?s2HrfjLFbDBWFrBcz26cPCm+qh8NFWaImm/JdmId+Kx+x29Lqi9UmXfCmJcx?= =?us-ascii?Q?SdXUMZgtaF+tPqiVQvgdW14eSAgEkc3rQuh2ODXADrF+dSytkvfMReZyCneU?= =?us-ascii?Q?AZoTl21jv+CRRT3bz3+nfVr/WMl7TpAyxU8CAepuylhDuMnihxZ1ZtwD051H?= =?us-ascii?Q?xfmyYNwJfIDCIrsIi+BGn6Z6dTG1DRhzHirNN6CRFUmMeQxzSrmoKDWwM/20?= =?us-ascii?Q?8RDEWAUQXW5277fut57HBmp1eUM5YPPG74y4v1V+JEyzjREuU/m+EYPm71cp?= =?us-ascii?Q?oLdjnyifoHTjWak622C3UKTwOFU0Waspxn1trlfEglG0N21cEHJUqbnmnSrt?= =?us-ascii?Q?GKgibq6RJ5O+xlngpFaYJgicdNUQzenqfEnT6Jn1o0t1FyS4Nn9Qy2hGM3wH?= =?us-ascii?Q?EWpUw5tP0gvvU4FquWeBsY1uURiJ8YbZ5+tPfz0Yd9rOhdrAd/DmfNxCjUMt?= =?us-ascii?Q?N2N0vGFQ2VO7eSBUr8nKSmZzZF3j10mVe6JgS+WyUPsgTVpwTGIcBhwEyq+V?= =?us-ascii?B?QT09?= X-Microsoft-Antispam-Message-Info: SFggwf/ETPr2xfQNKZxncqpd8rIt2FYZiN7qo1LbOz2L2yviXf0jzg1jc+ssXrO2nJ/d5J7arIpVeKkBR6jYofSuqV+ROZo7qJoG1YGzVnj8k238sOjGP64JQ9uM27aZWXS7CeAa6ws2IcWidFmrvJ3wVrkFUw6EmQcCA9F+93kahRvZWSwPdHjUAGiyk/J2qokyFlqxJGM87m4xA9wBAg1YYQyPDMb3/3VmTULNwwC4C/MkRpNfDd2WGACjoH+4/Yc96MBXQiYOEsBKO/FXWztIQKevL6RKupJmgPGWiThXZV8a1m52PQ7tQyMocFGNsa5FB2jZeFISeZw/oEE+f0stKO0IjLQX1V1r7MeTSaE= X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4587; 6:FBEquQKlJ+EOakF5PRi20xmRRVf2U+JOZzJEbuW5SylDBCpM4Ly4/YeIieW3FAx3HoyjT+0aXG9m9buVAVD8vXen39gjrVb/k+yHpEnQKHwWKDtMb8TjEZ2rj507tkNCqvdOqcJ45OIVxE3LY4X3cg719M47fwcLH+GuuOTJaLJaKTxztLQn1z2bPRJlmBQF8AbuZFCmwwahs77KZnSVzJO1yOknNVmNiNocI87l6pb0bR+uqVKi1Q92TRb5t0K4huPoYOvxmWgpaaij1oz7BPaA5LtmPivWgOCVNXkVYWXZPvlSVdbkjps9XHTiIN5T0ZejzwFBcpPDZcuj1tCipLzMXps6fJ+fXmRTSLaOX223i89T0PFQ0LwxXI+viC9HokmEloTrABwnOHhEswbch0RkPxzF/6MhcJdhPJE8RqZ8seo57l8vV+7w1YQuGJKTkKThJKZnMTf9e4kQ2jBT4g==; 5:4S8HAODwhEWxineyNRZmbf1aG0pB6pJErEWgljLapV3nxv+zaOG3FGokkRidazngiOOR421Iiakry7UsDY/oSC+6yT3DcrsHYkHKnuZ30c3MiGIHmHFEWR5ysGFcHnlGFN0i1dSWZ513dvkbyLRUM4krLxmVJd38Cm5wv4qZNMg=; 24:4n8HdUPAkvzCc1jlMil52gxDg96rgC0yPsyyWx1iJi3hYQOvFJDiZMCVxFURmsY1x0/Dk6plyzLwPx2rLY8Yv5bb8MogfKzNXe1tFJq1Dlc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4587; 7:yY8fua/83KyGmasduaed28xWt5r9+jEU56hyJ4HetoevArhx/E5ELV6pgANANKguK20/0aiiWwOCLry0FmtvErvLloRNT9AzMpt4HGt/nKNkLlvA+LicSqaQxMw4J7T8slWHhLITmKOZ70BF4lAvcVTm/MASZYb9bs97CPB739gA/BeyajxC9CfheScy0oV4y3gRZh1QNygsEb879xcq5k9cbpy0iwyjl8m+mjFNPx1lTtmBpt82+Wxgr4zKvDoY; 20:/MIsbX2yIEb3OSHELkm/gXCfa6KEvqzNL1APp7dti3PYzNMBdHqZue946ZBgbnTqyvQXAz6JuRYrj4ia6Cxc6jYkqXor6k3plyE+jnZkVaWo3l6U4mOIcU2y5WXIZ1W0R1QjV7cskpCiEedkCwvElb/8wwEqQAosWnyX27CB23o= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jul 2018 19:16:31.2533 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 03a639a0-9841-4b23-74ed-08d5e1197c6e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB4587 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: Thomas Hellstrom , linux-graphics-maintainer@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Sinclair Yeh vmw_kms_atomic_check_modeset() is currently checking config using the legacy state, which is updated after a commit has happened. This means vmw_kms_atomic_check_modeset() will reject an invalid config on the next update rather than the current one. Fix this by using the new states for config checking Signed-off-by: Sinclair Yeh Reviewed-by: Deepak Rawat Signed-off-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 40 +++++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index e7a7a2e73bbf..6b8541f9215d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -1526,33 +1526,45 @@ static int vmw_kms_atomic_check_modeset(struct drm_device *dev, struct drm_atomic_state *state) { - struct drm_crtc_state *crtc_state; + struct drm_crtc_state *new_crtc_state; + struct drm_plane_state *new_plane_state; + struct drm_plane *plane; struct drm_crtc *crtc; struct vmw_private *dev_priv = vmw_priv(dev); - int i; + int i, ret, cpp = 0; - for_each_new_crtc_in_state(state, crtc, crtc_state, i) { - unsigned long requested_bb_mem = 0; + ret = drm_atomic_helper_check(dev, state); - if (dev_priv->active_display_unit == vmw_du_screen_target) { - struct drm_plane *plane = crtc->primary; - struct drm_plane_state *plane_state; + /* If this is not a STDU, then no more checking is necessary */ + if (ret || dev_priv->active_display_unit != vmw_du_screen_target) + return ret; - plane_state = drm_atomic_get_new_plane_state(state, plane); + for_each_new_plane_in_state(state, plane, new_plane_state, i) { + if (new_plane_state->fb) { + int current_cpp = new_plane_state->fb->pitches[0] / + new_plane_state->fb->width; - if (plane_state && plane_state->fb) { - int cpp = plane_state->fb->format->cpp[0]; + if (cpp == 0) + cpp = current_cpp; + else if (current_cpp != cpp) + return -EINVAL; + } + } - requested_bb_mem += crtc->mode.hdisplay * cpp * - crtc->mode.vdisplay; - } + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { + unsigned long requested_bb_mem = 0; + + if (drm_atomic_crtc_needs_modeset(new_crtc_state)) { + requested_bb_mem += new_crtc_state->mode.hdisplay * + new_crtc_state->mode.vdisplay * + cpp; if (requested_bb_mem > dev_priv->prim_bb_mem) return -EINVAL; } } - return drm_atomic_helper_check(dev, state); + return ret; } static const struct drm_mode_config_funcs vmw_kms_funcs = {