From patchwork Mon Sep 10 17:28:03 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: 10594623 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 E537F920 for ; Mon, 10 Sep 2018 17:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD5BB2932E for ; Mon, 10 Sep 2018 17:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C144929338; Mon, 10 Sep 2018 17:28:52 +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=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 2217B2932E for ; Mon, 10 Sep 2018 17:28:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 552F86E09E; Mon, 10 Sep 2018 17:28:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0604.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::604]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04CE76E09E for ; Mon, 10 Sep 2018 17:28:50 +0000 (UTC) Received: from e114479-lin.cambridge.arm.com (217.140.106.53) by DB6PR0802MB2552.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.18; Mon, 10 Sep 2018 17:28:43 +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 v3] drm: Fix crtc color management when doing suspend/resume Date: Mon, 10 Sep 2018 18:28:03 +0100 Message-Id: <20180910172803.18057-1-alexandru-cosmin.gheorghe@arm.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-Originating-IP: [217.140.106.53] X-ClientProxiedBy: MWHPR0201CA0097.namprd02.prod.outlook.com (2603:10b6:301:75::38) To DB6PR0802MB2552.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a59c68df-9ab2-4660-3833-08d61742dd79 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:DB6PR0802MB2552; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2552; 3:bM0St9iitLx2+Tpwhk+BE0BKMY17++Dj3ztfoCyCrvf9Ja79pIKJ7SDNFRLxFZruvC6tIyyTjOGA+agotxa4Mx3Mr9rcuUZV/jtmX63jW+z0PhOkfq7uvyWEml5nJXhOIJdvVRtB9pMZb9CGvlK2QSBY8OXbq7lAb6OW87NehnkSEGSoDfFdZGgNeTUNOC4t4aHUiwW/DSgm7DrqYAF+zzAZzRq7JqOYwkbFcI63RveqMEhW7uMl58uEn7zbacV3; 25:XxP7fT15vEaWVOJroN+yrV1XFUqnwZTZ95np3w5ec6q+9VZsxh3zan+mB3axDnxTuPrGIa3vuxGDu70jAhneizWGhMo9xudY4XLa3iOosCDTa+zEL05EOehUbKUkrSwfJbbsVB6YCIbCo/dvOI7kvg9F0aUgK0e9Pz8dLRCwmgGkCyFGGlrJSKzPe8fz/07n4q4nezPoGr7Qsj3TcFpbOqYDGGnwOtTzV02/6LT0CsB9GaWL013cv7okmzNx/IeGcI5hF5aEVmpRZvvuw+uBqL056SUArQDHSlHmKWDkfQU8RjUIC3cUJiWmiYPP/nfzbo5VlrZEXtcdm9gHX77Png==; 31:Lv+YmFgvSlrmeAgAyQYq1fB+YvF9sVwYJmNJ8mwcPEAVdwf1h1CX1pOgXXE4W7WXRywOBkMWR5KZQFnvDq9ajhexd42wXfi/ebZZLiApPb95yy0hqxsy/cTYjR6lbfASwNJkZ9lZzhyjtXC4Owi86lM+dyoComGqlrK4brljeCUKhfvRkSi/Oaob20dttePoF20XeTBvs7uY6i696hxOpqI1ER7MRfYiPWxk7l9EGW0= X-MS-TrafficTypeDiagnostic: DB6PR0802MB2552: NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; DB6PR0802MB2552; 20:upRrMwNPdVk968RoPbX9XPAoRHz+ismZnJh19Di/fDXbpHB2SbY0DgFfVMkQtnigocHz1ktrYk/3J2RhFB4Z13Bwj5dejkxfO9njtGRPoj1QOnG6VJjV8PaZitZmKFq8g7hnJX7RgwVVm3HvKlsKLVoR4bZWVixpGJtqM9JuucIb53/GV1YBx2Z1ExoDumhUtcTAJ8GPiWxfP+MGM4LIaL63N//jljOgO7Qn1rZW7DC5PTzdVv4FwRfrrUY4ZjJpuF8kZeGbcxr3IrMo4KMWdyxPNyMxudzcYtI9ow/SatTES4+MCjCcKA54/5pP4jAHltPIdtur6Vpf8SSK1Te4MnPePm2z2qKJev+pgr2ndgyg8uQcUCvMWEUx4xK4cvWjkaZSfJ7kLRejL7EFH+bftJjENsrrAI1R7cy0w16PGak=; 4:2CCRIb6AACL8NRqQ3bboyCnGbccuMDVatccTsxkt44JSV63dNicghxe+P+0iRiDpixmvOGDW9vrllbpANQC6hLFFHj9wkVKQQ1rPndc+NaAf5wARKvOLCFaDA2oeX8lXETrvLXpPO6l0rWMIWYQWvKcQh8+ztPIqnAyKJbI9YlbGFHrjqDmMR4DXkbhhfw+df3n+608LGgIPW+s6ozsRStiaTWLeXIrSwj/7QtgNoQ3Vd7atkWccva1OqZ4IVUNkgxsGKpiORLed57hXtJSjUGkEjVB1X/x2T1rnYr0nfFRCkBDkqZVXQXMaBGae+k8Dsi1e3+vp/AbkmP2vM7IkQRBrCcCp2V6oQiTunSZrhvE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(823301075)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050); SRVR:DB6PR0802MB2552; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0802MB2552; X-Forefront-PRVS: 07915F544A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(376002)(396003)(39860400002)(366004)(346002)(199004)(189003)(478600001)(72206003)(1076002)(68736007)(476003)(956004)(2616005)(50226002)(486006)(25786009)(4326008)(81156014)(6116002)(386003)(16526019)(3846002)(186003)(81166006)(26005)(8936002)(86362001)(36756003)(97736004)(8676002)(6636002)(105586002)(6666003)(305945005)(7736002)(106356001)(5660300001)(66066001)(47776003)(23676004)(53936002)(7696005)(14444005)(15650500001)(2870700001)(2906002)(316002)(52116002)(6486002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0802MB2552; H:e114479-lin.cambridge.arm.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDB6PR0802MB2552=3B23=3AzpNVp?= =?utf-8?q?dCfZStZsE4Di3WNs4LhX6hOHNNS7qW9qWsPxIGszLuVYsFQM3MyoI+PhnrBFQTdmY?= =?utf-8?q?VFwFPDt1ndSR9vVnXPv47Zj0h3R8Z6GuKwLhNb0n3zaCBZI+C4lfhlfdXZ5vpm9+g?= =?utf-8?q?sx7vUThQu9z9K39N+3IGkr912+RuFt33ekgBxNqATRSdlRB6bympeIxhsrq/L1XVo?= =?utf-8?q?kJgS7BTRZMfvoiCD7lfI4bdb/6XYyQz9IA8p/SVV3WDWOVdlZcdLo0vThfrSjCIcs?= =?utf-8?q?RUv5wo50xSdJVQgn584kLt/MvF36Rn/2uI/Z2rGDaj24DQpESGX3JFtyWK2dn96HH?= =?utf-8?q?O+5ky1ZMp81hysdi4jMG9H36a7PgrS9ZNCQ6l58vMpq11Ia9w0ouvC4GJZdFDsiti?= =?utf-8?q?GwGhLc/j3FqZVKRDLt9L5kDpme+JpDCkUW+Ibe+RLDktp4wvzxqCfeTB5DvIv2ibR?= =?utf-8?q?UeY9Bfzc/dqcNN6ra0wL2gorksfzZEY9A76PTSY54+NxpZlE5QPfFD0vbXNVEgm3B?= =?utf-8?q?IsV16xJeZrE3tGDgZ9VpSSFcNT82NP0pdaZeieM3JSDWw8mJi7+hhJ+bQSb1RWYGX?= =?utf-8?q?Xgq1YaabyQlypB9MlSUMbou755BApAkRsZdYbdnVb5l23YYomA1vAS8sG4PO99Kyo?= =?utf-8?q?F53w9DOK63F3rQMmUY5Nj20bNwQVl0zpWbQAp+KpK247ld+wS61g71mF3NqPbqbJ+?= =?utf-8?q?ubpRwPa5mtImQGxOwU290mVLcRlm3X/nf8RjqguTuHWEcxnhohHgIQnWxwSR6km3Q?= =?utf-8?q?miwgIc5fLO+X0IgnoLzyBYwLP+P0pZ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KgR9sn4leecnBw50xueAxDQoowpExIVkWa1ypLj1PhaXe/48BCONoV9BLxHs1AZLnQfXyTY77GfZaQVtcRb+/RXoQ75IeglYzy9WM4fcOoO6JOOntqQb7a7LaYKGoHjimy/TAiNJeO7yAJ+vfW6tB31qJEe7jgHSVUuoe5XeYiwEvTOKzi56rwZV3gOshKtHg6Jp54FkVLfsu9WRnPvPiImU/+EGPxAqF8WFa7YGRpJmMid1kH+Z4A==; 5:3S78mZyo9tMsBCD0zHhHVCBOwzhNVw3/2D2I1ZhWkCPYEQGdkS15+Dm7estElEWBuRUMt98zd8qZevNY3gBfPJyVwoxICVrpZZ6mqz9VkMdbHbBCzIL5yhQpN2H5m7Ta8LkesOu+Y0LgxxGk8zE5hMSEa0bSefjMnUSXn0LPaOI=; 7:581qIRutzcqct9rvCeoA5sicQzp6W+68VY7gkiuVA8cUN66zznQyckZZdkIqQQ+RkMs9dsLNJXTcgE6CaFl5uX63/PVVdVz5a+p89fInbB1tdxa9vfdR/hSOiCVBh9AkfVheM8dV5GK35qiZGYV6eermk5zgjEGWxhOtZEKKt+IfvJjOUFf9fIi54jtCNymMD4EtV9Hwbsdt+G615eDipPFW6+0s9Ci7Sb5j2ooirfeEnsTYYZZkU1PoN0iMCN5w SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2018 17:28:43.6654 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a59c68df-9ab2-4660-3833-08d61742dd79 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2552 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. All current drivers that use color_mgmt_changed, either call directly drm_atomic_helper_check_modeset or they use drm_atomic_helper_check which calls drm_atomic_helper_check_modeset, so 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. Changes since v3: - Rebased v2 on top of drm-misc-next and fix conflicts introduced by the move of drm_atomic_crtc_set_property in drm_atomic_uapi.c. Signed-off-by: Alexandru Gheorghe Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/drm_atomic_helper.c | 8 +++++++- drivers/gpu/drm/drm_atomic_uapi.c | 12 +++--------- drivers/gpu/drm/drm_fb_helper.c | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 3cf1aa132778..53e60daa1bb6 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -612,6 +612,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); @@ -3948,7 +3955,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_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 26690a664ec6..686da206427e 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -434,29 +434,23 @@ static 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_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 73cf10adebbf..a53e169e6824 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);