From patchwork Tue Aug 28 15:33:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandru-Cosmin Gheorghe X-Patchwork-Id: 10578717 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 2556D920 for ; Tue, 28 Aug 2018 15:33:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1541A2A598 for ; Tue, 28 Aug 2018 15:33:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08C862A5BE; Tue, 28 Aug 2018 15:33:41 +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 902C82A598 for ; Tue, 28 Aug 2018 15:33:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AE3AA6E382; Tue, 28 Aug 2018 15:33:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00088.outbound.protection.outlook.com [40.107.0.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC81E6E382 for ; Tue, 28 Aug 2018 15:33:36 +0000 (UTC) Received: from e114479-lin.cambridge.arm.com (217.140.106.49) by DB6PR0802MB2550.eurprd08.prod.outlook.com (2603:10a6:4:a1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.13; Tue, 28 Aug 2018 15:33:34 +0000 From: Alexandru Gheorghe To: seanpaul@chromium.org, maarten.lankhorst@linux.intel.com, liviu.dudau@arm.com, brian.starkey@arm.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, gustavo@padovan.org, ayan.halder@arm.com Subject: [PATCH v2] drm: Fix crtc color management when doing suspend/resume Date: Tue, 28 Aug 2018 16:33:20 +0100 Message-Id: <20180828153320.4725-1-alexandru-cosmin.gheorghe@arm.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-Originating-IP: [217.140.106.49] X-ClientProxiedBy: AM5P190CA0031.EURP190.PROD.OUTLOOK.COM (2603:10a6:206:14::44) To DB6PR0802MB2550.eurprd08.prod.outlook.com (2603:10a6:4:a1::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c847b0b5-3504-4c2b-e5fe-08d60cfb9dea X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0802MB2550; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 3:k0flfGkBtRPcW7YDR4cChtdhjRJkb32Ds93ms0Mk4xQd+SUlEVr2lGDokBxwz5GLcigYkXuSQS+WoOhvlCOqKYynljM7+6M5Kvwg5s/bTEsLj4IzHHe0Hrahz7JV6vs2jSqp2PpgH6MJZzqDn68x5nGtNPwNMn8CTZ0eyrCLjlBHk0XJmxDcvEX/tbO26GfS+G7KCb/RvIxI36G/EesKz53AxDYfFirdrkuMiMSiteyh75NF+178ikufNYr9UKai; 25:dI97L7R+Wmeq8Qrt0Z3CQiCBhBPfORDgbNHWU8W9J41G+Tnk+/Jteet5/H+o2CP2mZ351DasPTPIRT0RPCUMHbGUPiB1WRbpVtkDgo8t5qwJGBCYnMscFTuvilI78vgO88kMXVT61+7nwoKeev/bcEiUJBS868mzZiAknmLumk4TzBm7dWhQxtCr/PVHgp/4nvfAgh1c3AqQ8rGHh4UPYUCGpJ8WdbU4UumXBwU4uXI2scLUFrheH+oR35LnZ2OoXK4DRSzbhnkYjGlKzf9NLJDE2JsPrAi9x/KShdU8XT7VbbKCMX3JsH46seOGKzS3QUatY9CcWW70JTInI58KqQ==; 31:eHzQ7UM085hOokwiL0/Yoy3dGAPMUYrfohEswE05u7irvXcrl7QcdMqcZjc3T+GCDaPOFOp8RYONgPpB7iSc09KO+lKZYgHhNSNCMXExLipQoIqnyswrOLn/EJ21cSkt6ahF/hTGkxHqQkThMpvr9ccIzot9D+TAdQu4kbMqXsj7MK5uqngD+vFj1Yvvp2NTAKXw2nSdDNPcV2q06GFXpRzVv3cq/Dy6kO0iCf8181c= X-MS-TrafficTypeDiagnostic: DB6PR0802MB2550: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 20:rMGQ6UtLH68YOingPS6flDQWtI4AiTl6XZgat+Hz9i/aMRiWBiRbg5oWbQ/hqgTUHwPX9W6tgYb+Yr94TIx0nzhWgN5FufRqS8twoNYNKVywAiFjSanSbeFgmbrEGefmJEvUUXQqSQhJXzvCW/1+2i6YSuREpkLl2sJj735mTaPBVZEvCylktHerYrJJidVsU4FAAlWsW7DKGxtmeyBGtzuzjf3ICBghqMzhT5RtsUjDiYdvskvE4ta32m5R/upg+960UXgdzqUrZVbSA9lJjQArmg99EgNjrXI14wz/RtuuyjTIi6j0f6XlybFFq0tAUAnQt1OAL454JS6Hw2RPKkLJziUWjm5WhZ3rn6MY1zzx1D2T7gzb65qBN6mumCfS5oJ6FUvrstU/Qw4xR+gkMIacq5ZYES1eX23/N4Hyf0I=; 4:UPlHj5KhMBfNaIyUuLFTihsFuOnOx5DXF6/dOeJXBGE3DMd/slD82gmF4LcmTHmmw4rYQsEcxwzKq/EXb+JqbJpqfVWHzmhDhJooe3FYDzJekt/C65EknymHwVjB7LWA8OxX+aqoO/lA9F4S7QpR1wNdhIZj9LWDwaejMlascfilWB/p+eybjXcCUsZ/W8GqCs4DHVvFMFgVDo0w8VQZiQYdQFMe7J/f85t64kfcI17EtoilLkaX7mC69shlbqDSCsTUoS9sCv5crhbtYkAaPs9IUS2H+Pz7upIPZ5Xyzz5N8vmRnsmM7LhPp0ojYOKr X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); 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)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(201708071742011)(7699016); SRVR:DB6PR0802MB2550; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2550; X-Forefront-PRVS: 077884B8B5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(39860400002)(136003)(396003)(189003)(199004)(386003)(26005)(16526019)(186003)(4326008)(14444005)(25786009)(86362001)(5660300001)(575784001)(50466002)(316002)(16586007)(6636002)(6666003)(2616005)(956004)(486006)(48376002)(476003)(81156014)(81166006)(15650500001)(97736004)(2906002)(8676002)(7736002)(8936002)(47776003)(68736007)(50226002)(3846002)(51416003)(53936002)(478600001)(7696005)(52116002)(72206003)(105586002)(106356001)(6486002)(36756003)(66066001)(1076002)(6116002)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2550; H:e114479-lin.cambridge.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0802MB2550; 23:Fa1SZHmljQpbGF5rVqdXS2vcD5Qu8TKP3c1ceU5?= tqFg/Xr83ESQLgl3MjU2gzZgCWHlDiOSuFCasIbohahx00KVrAcHhjZrmwZ8yIU6v8yFYwIMQQtJKvLlO01qPYbaaxADAJjEzhygZZ1utHE7E5VhKY/jVvDd5BqSilLxms84wFefmel9D5mE6CmpaQ/Gs6EhGASd2s5/gvka5L+AEe+CFxY5Wk0LFoFbpccluMzL0fJg80Mq+WIAQPye9NUaARtkyrh4T3k6aDRizdxs0hk6AcKmjtC0Lfcb4wgycCtM3fqJ/qlJIORTKRVHOyMsaNoJRGMju0SXEX/EhJ6QOohubHX+4gAwQ32SNbdeBiBKY16fVj+vuy9sZ493m+oqhhmeY+aSEjsw/NDaMiVZZO+39JcQZoJERGpz0efcn2mIiTe1I3QpNNQBVe8ZjdHbhczeTQUTSxeC9iQ6ofqm6wlODi+hcIyy17S4fspzByPVxgl5jnYWkLFUQnJYMiL/ORF7T1w6YHYgKRgb5ol2BGSMubGlSoTEuhunj7m4A+PpknkdeF7xcegYuKyX9KSK2j+50SOzPz9Kxl2/vQZoGZq1MdFcNT/EqK+E7VSXaqsXxIoQYUQReGGK2dsGIUkVQg3Hc6FaFG8r60Da7W6iEGXQ1AJUXppUFRLBaOvD+4Z+6lNW3T1+IlAEnFsH2pNnKFXHeCOeyBOxGu5cQQ50GTMtHpAZE8SbcEyYSNCgFdxyTGUeDUQAtRtitSayMWhjFbhCxUyB9IXoSYNFdzDEjXlPqL2H1rRYp4a0cpvmICh865K3Gfp/zmPhvvOcOOeMt90u8rJQU8NcySkDlLDS/i2bamMU84XNfpV2dKoXlapMONxUAF+nTKywO72xxbmhmPf9UtZr4hh49PTIfIKL6lkltoP8ET0t06WrbvgMCKs0H55u8fhJxI1qc5zy9WiEZDbXUm23iu1Rj8aUaBB7ERhN8j8+wmEDIZhZgOpaHmdvt7x/3Vk1u28kdtQphnJHIb7ARyvINyn3poXvUpB1cLrhctJgNilZGqDWAXl2dpJHWXIsDzsxyjpYen8KXI5dstXxqY3ECCPTzQpYly/+GW7F2aoiDYhYIaSjSQL9NhJn3Vo+C4OBE/JpKmfI/xPpKWXOsfWCbXxaEi0qXwNIodqA0xeU03bCVIju8XHhH/aX/s3vWRz+FuO12CcooVdby X-Microsoft-Antispam-Message-Info: avIp91i0AiByx/UrG9iJfhyHKluB0cK8n7giGc+tUaTGwX+njsviTDTKc0+JLxgPCJXzjrYRex5A7iwFk71a6tMHpwywnukf4SSz6a3ftq/ZEk1aHWuG4L4v7aVVuPpvwUmZl0gd9eW+OwdYwB5WZ1vYzcQjwh5OeuQSPuyCpbHZ1+MDG/3l3eZVPHcso415gQti3LFzcf5EuffTj2aTr+CEf1+r4xotSeDRe6cCEO/Jx4nB9KPFLEQyh2H7joKAjayr6klGlXkwD9Uj97A9tJC60nAnErov18KBqbGtpfqU/nu723SVxEo7btvjQ2ZvkASeGQ0EkIXzzuLG8L+/MLH1xmHjZotHfPJ1YJ/DqsI= X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2550; 6:2awDgqOW6NXiox9nIiw96BCr58mrrleespN2LFIzU8IlafCJQJhVVsdTcNb8iZjY3hQMLWJfg3uWOTsv4DvGP4BoDTwH1hOfOJMZcmX/lgwSMSEBRkG3JWlcSz1voBVhnkZlgayN13ttMvQPg8I9ogp4T2GnhydmSVyiH3671mRx8WboG8EJZ4tULt8RWCCszKGlhnvcYMfN91bQLzmLUNs0alPc5aq5CkT+rkahPtc0NArec889Cu1FkamTY34dWPtCT+punYVmEj7AUm0zat2NSED93UA9WE45V484cHfJ8YqShSbIicxFFshJepaxfcS0agLS3q3hj5GmjXxXyphZhK2AoMxzMREXg9wUa9FJYnOcUgHSdGv3xLAzOP3u8HiiTEjl3F1yRz6fddVEZh6ttdgc6TINX9V+yPNgbb5w7R9MBP9wm+KLXARNXy10efwoBPd45fkFsgdeuH90bQ==; 5:FFge/RllHpxbOaPelvJWfimDotDOSgrv49Aq9RKXiCWq6BZle4tSM6458QUqAtHWIL4R5QOR8lTHCyd6ljzfWlasyh70r/9Tb/3//24iHuDUAisYDGoJocIFpPV8U+R8RPXRbERxvaPzRTZxpuIRiVbgcoHQ7eaxsEk+LVRHGIc=; 7:iilIcyDP2wQsn7WTCNMzLzBOZ1hp2GHlwVDdi3ETnjjGyuvTTWIdSyIfYvPjvZLV7U04z7NZKR8UmSEE81I0sM0gwZDPZ6GtR+eE1EvTCgbsb8o0X9AecGGv8aPGSnXfeEHbf7+rdCKxtbVIrxiKjUlCzNBLJTz1t49U2TJTUSkdfVRdllDVWS6ivzgvq6lXwc7qBy9LNk0t7EVkogccXi+DPEdgeiGnIK6EPH+Edf3l9x3NHH/dJfrxys3+6KDU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2018 15:33:34.1082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c847b0b5-3504-4c2b-e5fe-08d60cfb9dea X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2550 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: nd@arm.com, Alexandru Gheorghe Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When doing suspend/resume drivers usually use the drm_atomic_helper_suspend/drm_atomic_helper_resume pair for saving the state and then re-comitting it. The problem is that drm_crtc_state has a bool field called color_mgmt_changed, which mali-dp and other drivers uses it to detect if coefficients need to be reprogrammed, but that never happens because the saved state has color_mgmt_changed set to 0. Fix that by setting color_mgmt_changed to true in drm_atomic_helper_check_modeset when at least one of gamma_lut, degamma_lut, ctm is different between the new and the old crtc state. Also, this makes unnecessary the setting of color_mgmt_changed in places where gamma_lut/degamma_lut/ctm are set in the new crtc_state. Changes since v2: - Instead of setting color_mgmt_changed in commit_duplicated_set just set it in check_modeset and clean up other place where it was set, suggested by Maarten Lankhorst. Signed-off-by: Alexandru Gheorghe Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_atomic.c | 12 +++--------- drivers/gpu/drm/drm_atomic_helper.c | 8 +++++++- drivers/gpu/drm/drm_fb_helper.c | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index d0478abc01bd..9bcada3c299e 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -554,29 +554,23 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, drm_property_blob_put(mode); return ret; } else if (property == config->degamma_lut_property) { - ret = drm_atomic_replace_property_blob_from_id(dev, + return drm_atomic_replace_property_blob_from_id(dev, &state->degamma_lut, val, -1, sizeof(struct drm_color_lut), &replaced); - state->color_mgmt_changed |= replaced; - return ret; } else if (property == config->ctm_property) { - ret = drm_atomic_replace_property_blob_from_id(dev, + return drm_atomic_replace_property_blob_from_id(dev, &state->ctm, val, sizeof(struct drm_color_ctm), -1, &replaced); - state->color_mgmt_changed |= replaced; - return ret; } else if (property == config->gamma_lut_property) { - ret = drm_atomic_replace_property_blob_from_id(dev, + return drm_atomic_replace_property_blob_from_id(dev, &state->gamma_lut, val, -1, sizeof(struct drm_color_lut), &replaced); - state->color_mgmt_changed |= replaced; - return ret; } else if (property == config->prop_out_fence_ptr) { s32 __user *fence_ptr = u64_to_user_ptr(val); diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 2c23a48482da..fe22e1ad468a 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -611,6 +611,13 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, return -EINVAL; } + if (new_crtc_state->degamma_lut != old_crtc_state->degamma_lut || + new_crtc_state->ctm != old_crtc_state->ctm || + new_crtc_state->gamma_lut != old_crtc_state->gamma_lut) { + DRM_DEBUG_ATOMIC("[CRTC:%d:%s] color management changed\n", + crtc->base.id, crtc->name); + new_crtc_state->color_mgmt_changed = true; + } } ret = handle_conflicting_encoders(state, false); @@ -3947,7 +3954,6 @@ int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, replaced = drm_property_replace_blob(&crtc_state->degamma_lut, NULL); replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL); replaced |= drm_property_replace_blob(&crtc_state->gamma_lut, blob); - crtc_state->color_mgmt_changed |= replaced; ret = drm_atomic_commit(state); diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 4b0dd20bccb8..8541e95a5410 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1442,7 +1442,6 @@ static int setcmap_atomic(struct fb_cmap *cmap, struct fb_info *info) replaced |= drm_property_replace_blob(&crtc_state->ctm, NULL); replaced |= drm_property_replace_blob(&crtc_state->gamma_lut, gamma_lut); - crtc_state->color_mgmt_changed |= replaced; } ret = drm_atomic_commit(state);