From patchwork Fri Feb 10 16:26:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harry Wentland X-Patchwork-Id: 9567091 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 024F3601EA for ; Fri, 10 Feb 2017 16:27:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E436E26E4D for ; Fri, 10 Feb 2017 16:27:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D912427F4B; Fri, 10 Feb 2017 16:27:19 +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.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 35E9426E4D for ; Fri, 10 Feb 2017 16:27:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9391189C27; Fri, 10 Feb 2017 16:26:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0054.outbound.protection.outlook.com [104.47.38.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id EBFB389C27; Fri, 10 Feb 2017 16:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=VbXcc/2EpPHx7ibbzccGWNXqwfwDHLiWM+aCdOL1vMQ=; b=dyk5m4nrWL3CIbwxC2RwYjlbbVDdp3fkZNyxblVlHwT140MVvkJkaty2lZ40qEb15M7XCFNdB4Zx2hPfJaT6Fp3YleukRgRdeltht9g6SoVijkE2w9ZagBetgrpMh31FIAb5U/lBRJBXwhV7hN3Wfd+kuOYfZPCACQje1bz8YSY= Received: from BY2PR12CA0018.namprd12.prod.outlook.com (10.160.121.28) by BY2PR12MB0244.namprd12.prod.outlook.com (10.162.83.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Fri, 10 Feb 2017 16:26:54 +0000 Received: from DM3NAM03FT032.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::201) by BY2PR12CA0018.outlook.office365.com (2a01:111:e400:2c84::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16 via Frontend Transport; Fri, 10 Feb 2017 16:26:53 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT032.mail.protection.outlook.com (10.152.82.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.904.16 via Frontend Transport; Fri, 10 Feb 2017 16:26:53 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 10 Feb 2017 10:26:52 -0600 Received: from hwentlanhp.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.319.2; Fri, 10 Feb 2017 11:26:51 -0500 From: Harry Wentland To: , , , Subject: [PATCH 7/8] drm/amd/display: Refactor headless to use atomic commit. Date: Fri, 10 Feb 2017 11:26:29 -0500 Message-ID: <20170210162630.18157-8-harry.wentland@amd.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170210162630.18157-1-harry.wentland@amd.com> References: <20170210162630.18157-1-harry.wentland@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39850400002)(39840400002)(39860400002)(39410400002)(39450400003)(2980300002)(428002)(189002)(199003)(356003)(4326007)(68736007)(2906002)(39060400001)(38730400002)(50466002)(53936002)(101416001)(305945005)(33646002)(54906002)(86362001)(77096006)(2201001)(189998001)(48376002)(47776003)(81156014)(81166006)(626004)(106466001)(2950100002)(105586002)(8676002)(1076002)(50226002)(5003940100001)(92566002)(5660300001)(97736004)(53416004)(8936002)(5890100001)(36756003)(50986999)(76176999)(6666003)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0244; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT032; 1:2RZn6EKVsRXa3YSea/qwd+uqY0LnyEl/OObN4lxWkQYfKaSeLEJDtnY98Gs3kdebcRcQh/8IO0s4meGkEun56dmoGVIEkYf1lbCdEXE8DNnn6Cld5nyjJ52nxw/IbTASVLbjr3NlzPMtbLFf4Y4J/KAgky3ndRGxdPsjNmWLZRO6leRp8y0mw5vjyTnunu1IrggrA3NPQrJNxQMCJF3mjrsgS6NHT9+AD6KjjtOKpvPdYPVw9rMhxtfC2cfeEhVTb/ZMzhEFnA+bUrBf/lv+3WGxuVeWGpa030znR7UVZVbPQjaQqqn7+tRgnUGJKrzkPLgOyIQGlhtdYQn3vH6Kb0sD8h97QLylfwziUjwdotBEbfki52L2GIU0cWJ4we26osTQXw++ncILqZAZowqhCNJ80vAAr0GpphXbyLlP4AHToOSm/RyqzqEkba2wKoyTAndmjylL+U4e22GvWw7X/A== X-MS-Office365-Filtering-Correlation-Id: 4342e4fd-e6d4-4945-d8a5-08d451d19fb9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR12MB0244; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0244; 3:bznnrtuPFMoZfM/8zEkB8af/kHj5YQbq0ih9b40OY/aHSm+g9xvmlIObGaN+wC29iRXkmwSdbq1unnwBt9cdFJnzTWqXeOfjvKvxUUs/nZxQvEgGyGvAH+XN/y3TWNsRXHpLsGd7o8d1+Sju5kyWCq9myxhpyRq0nxU4gDUaFzmL3F5rJ0jwz+evHWyol9O4HK2SNwhf27fwlrCOMmtWNUudqDW/0DIjOK1gsjFcOMOcsUIVP2L4htSIKocaNVmaba78k0cQBuev5mjaY2VO9483sFIp3UlY5WXcezrVyUSh8R5n555DkDe/vNl5sL+5khZpkriUjciSxZzyd6vW6N146KzKRu3p8YLSQeNx3evqH8y/S+gjBZb+OKj0O1ub; 25:vwXRZqjWRPJRhDQ5u1hFsHROq8NAs1zJoD4Ibu8JIzau2Wfg/HWg+LVdABR+8vV3xsWlN7THjvbOuI3WWgnXNwM8WduOSXpHCwJuIddiS1mwlf/sMnElPgSQM+Fl9pgplhbv/CDM6OJ+osZdyxF+NOKXQUrPB3xjrRuXnIOGMA+zKngrnmMbHh/Y+hEMJQ0G3a9qieNdNX9r8ibqngTW6DbZD88+NBWoDhuier2/HqSJyirLAX4LjWgSdE6I9P+vee8pej8GEHsbRQtdUuYgOCWdqBz04oniRXXLRiRT9XBDhSqX3vPWddexkHJkjNyqBoBp4TzCzLDwB/Davbe/mg61qefrrK9st/V8Fs1YdMN6qqE4+kzDceOgWzKTIs6BMc5CiycEthmVg/faw79BVRjf8In678VJjEyJs16MR44sg0FDyH1JyujYzm3iA23sF6eCKZvLFU2Z6G45xTV1sQ== X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0244; 31:VcTcLhv0h/+XyH7R2Sbn97GnUiZpLYsjighNcG8r6DZ8pUXpQxGmahrwMbg6AglrdmAW+kW1IBOce1Dq4LECTJFwkl1ysgGldGecGd6LuzTlwmmeVBOwF/+oLAm21EhVmgj8QrXH0k4wurl2QrZWmWiOu2W4tCp0vtWenCmdef+AvJjLfmt7uVjCZUyQlhfqhXk4ozPONaGAcn1YcBKMdNLCx/A7OKy8XV8PtREP3qDAHi9X3onQrc1bNtGreWbfD+ziB2gFFFsKcQcyKtZHIQ==; 20:0M4yF+/hQUYDkdudltysSuNb7SqMmPYZ4XJ3jdI6mNBR+XbQHwBKk1/XxCI3GQ8p8wTNWmIUId6hhKWpIJbuVPdf2ufFr0YmAKuxKr7+X6zeT5/qRx5SW++t3jPKsEb2Bb5lSgVjsxUDmHXLT2sTzwMcXFtC5etWU0QO2rXa9795nel1g1nQGXHZnJszK4kuv8zJ7fVTUNaMx7hV2cHZ7IlFO2xG2LBZ0njFWccizUbwoizIcqvnb9f0OyqZEmcSsFc95Zajz4dc+0IA0kjcIxn89p/r26ugZffbJY/LO1mL6+vY6RGPYsJvNIWXzG/OTqca631UZ671xG3SqxPoaAYKyo/Akn4f//8LqMT4Fkr4AbTCx7f5FcRS85ENdSNe7eBJTifJ8ddYC3bJILp7wz/aZSX7oOHNMxZ5JZ7AWjP2GEFbBNnvcIFzFSlavFcHZdwGOEk3VfF49LlmLBZoQ7McYMZdlhq15tnMY0AnzXksRNA9KXl5XbMxihmNv0MI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13018025)(5005006)(8121501046)(13016025)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123564025)(20161123562025)(20161123558025)(6072148); SRVR:BY2PR12MB0244; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0244; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0244; 4:zGTSaRiJytGZW5UOpQz6D5JBaylyqkMOgQJF6gbKupR3eY8k9GCOFiFSsAOhOGQUCKkTaYvxGjSagE130qoxKb/qQSTuc5qctwlCgu5TWI2Or0C9F7x/YOwbOdX2GgSOD+ACA+VL0+IVxWrEoLzSQbu8p6IhhRGKmhTCvI9nWJ1gL+f2/w8CFr+pZOeIGJnm6q3hgqKtpNBuawkfUhE3G2bYPHFbjKK26cgMr6jUYpkvAvg4mMpVx3dFZnBRt3sHbiZ09dNsxa+7RpOhWatMkruFLEYuxX86mBqRH3/IePPCEqgFmdvvcI3DcAkslDAl/vDI8VTYdLcEWUL7U2KwhPUDeEGpWzuAyyT9LN7r1JSqDIjJnlOfwjr45X+MxMbnzSSHi7lhX8ohgzWiD4ijhWgpGCpz5IHKlFbA9DAID9e9DfQ3BXq3GBHvKfn4etow54SU3hPHHKXtHPusjXY6hPghffeMk/6H2Il8+pZtUMsut0iI+4HnhudkYrXYo6ZPKV9RDEMBLaYsJ6JuFxBBHA9msj9EbSyO91K4eV+6h92/6o5lVfA2ijb6Bxft0qi6drjbFzn2wsM11G6Xu5CMr03RuQpYZI1+CHNykyuMCSjsunubtQGHH8cpVQSQK+jSyg9wyzPCxvfpKKxp6aLVQtTGg63GzkvxRXB8qZeePHxkll8HCAWBp/7UiIxvSIOwcymNo95grq86A0aUkYj1mw== X-Forefront-PRVS: 0214EB3F68 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR12MB0244; 23:cpFPg8nYRZ72I0lwHRsju+aljSq555o+XlIexD5td?= =?us-ascii?Q?kyOqTX02+85q0O1vuCd2aAvRA/oSZEaE5Ij5p+FDKQ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y2Z+o3WbRS8TV4e82o4nAc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0244; 7:HDHM2OvcW8c/1cwQHgQMvVngxz97ZlcZ4Tjlyt9GXqAbcGtlnf5Eo1qqF5DmSJQDkFEByttxBiwO7FMnqWmfdAZHv5G5h7YXBvw5lE6NIhmiocXMGpASZJFUQ1hvePDMkAUxba80RBC+I8EZq3AHaObhevBrRx+PAdCGKq3GHrfm0m/oIjkDCpIxZfrVWyndcdfs+tWF8+MDe0N+gmLA4AW/gzK5u56MCyuK/0tEEjHqRyovI9Q4x7Q0Hll1Qmbx3mXpk/azUudSSxbdKGlY8QGTNeBxBafHL8HlZMw1VpYMd/TlITxUE4PramYYZm9ILjIWK3Br+Ne/ezdXGzf4246+g0E67EhltrCzV/LDKbCyQ/rQHM4VqDnTq2ajy98kbi5JaF2u35g8VeD0Fp8vxwmYmn517kbcOlNHhlmGZ13FWrp6Y0KmdGof4u70woZEd9Dx/e6DfXlYCO1Y5ac0X+7BHqCl4s9ZMmyJ5SgLHKOAszvD/XLc5jFkyAGvYnDs5jGD6wFStVBJzKbNJV66cA==; 20:EoLkbHH/vPYdp+gqVju6gYQ+yu1pJd7F3Zr2W6vS/l82DflTwyJXvNSV7yvuPidSipUKsyno9mdn5aj6F4+QDXjXkG55VbICDstcaWBzuzteEP4w6bzXk0nhEoIxOr3QZxNp/ZeZMKNq3VPjLwOhWnGXrCN9DMiV1pUH596rxbhlT+2ktA46Q3bY3lMX8fF2nZdOQbXdLIx+BT7+0lA/lFIE5jPLsOxNMNqat5hYbT3Vk85Qo/BeDZulzIAGwXyr X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2017 16:26:53.3979 (UTC) X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0244 Cc: dri-devel@lists.freedesktop.org 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 From: Andrey Grodzovsky Headless mode set needs to be synchronized against outstanding nonblocking commits. This achieved by building atomic state and commiting it. Change-Id: Ie5e778afb33dd5c303a169216a7bb8c2d857037e Signed-off-by: Andrey Grodzovsky --- .../drm/amd/display/amdgpu_dm/amdgpu_dm_types.c | 140 +++++++++------------ 1 file changed, 61 insertions(+), 79 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c index 93cc3d128a11..69c85ef63c4b 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_types.c @@ -2802,6 +2802,65 @@ void amdgpu_dm_atomic_commit_tail( /* Release old FB */ drm_atomic_helper_cleanup_planes(dev, state); } + + +static int dm_force_atomic_commit(struct drm_connector *connector) +{ + int ret = 0; + struct drm_device *ddev = connector->dev; + struct drm_atomic_state *state = drm_atomic_state_alloc(ddev); + struct amdgpu_crtc *disconnected_acrtc = to_amdgpu_crtc(connector->encoder->crtc); + struct drm_plane *plane = disconnected_acrtc->base.primary; + struct drm_connector_state *conn_state; + struct drm_crtc_state *crtc_state; + struct drm_plane_state *plane_state; + + if (!state) + return ENOMEM; + + state->acquire_ctx = ddev->mode_config.acquire_ctx; + + /* Construct an atomic state to restore previous display setting */ + + /* + * Attach connectors to drm_atomic_state + */ + conn_state = drm_atomic_get_connector_state(state, connector); + + ret = PTR_ERR_OR_ZERO(conn_state); + if (ret) + goto err; + + /* Attach crtc to drm_atomic_state*/ + crtc_state = drm_atomic_get_crtc_state(state, &disconnected_acrtc->base); + + ret = PTR_ERR_OR_ZERO(crtc_state); + if (ret) + goto err; + + /* force a restore */ + crtc_state->mode_changed = true; + + /* Attach plane to drm_atomic_state */ + plane_state = drm_atomic_get_plane_state(state, plane); + + ret = PTR_ERR_OR_ZERO(plane_state); + if (ret) + goto err; + + + /* Call commit internally with the state we just constructed */ + ret = drm_atomic_commit(state); + if (!ret) + return 0; + +err: + DRM_ERROR("Restoring old state failed with %i\n", ret); + drm_atomic_state_put(state); + + return ret; +} + /* * This functions handle all cases when set mode does not come upon hotplug. * This include when the same display is unplugged then plugged back into the @@ -2809,15 +2868,8 @@ void amdgpu_dm_atomic_commit_tail( */ void dm_restore_drm_connector_state(struct drm_device *dev, struct drm_connector *connector) { - struct drm_crtc *crtc; - struct amdgpu_device *adev = dev->dev_private; - struct dc *dc = adev->dm.dc; struct amdgpu_connector *aconnector = to_amdgpu_connector(connector); struct amdgpu_crtc *disconnected_acrtc; - const struct dc_sink *sink; - const struct dc_stream *commit_streams[MAX_STREAMS]; - const struct dc_stream *current_stream; - uint32_t commit_streams_count = 0; if (!aconnector->dc_sink || !connector->state || !connector->encoder) return; @@ -2827,83 +2879,13 @@ void dm_restore_drm_connector_state(struct drm_device *dev, struct drm_connector if (!disconnected_acrtc || !disconnected_acrtc->stream) return; - sink = disconnected_acrtc->stream->sink; - /* * If the previous sink is not released and different from the current, * we deduce we are in a state where we can not rely on usermode call * to turn on the display, so we do it here */ - if (sink != aconnector->dc_sink) { - struct dm_connector_state *dm_state = - to_dm_connector_state(aconnector->base.state); - - struct dc_stream *new_stream = - create_stream_for_sink( - aconnector, - &disconnected_acrtc->base.state->mode, - dm_state); - - DRM_INFO("Headless hotplug, restoring connector state\n"); - /* - * we evade vblanks and pflips on crtc that - * should be changed - */ - manage_dm_interrupts(adev, disconnected_acrtc, false); - /* this is the update mode case */ - - current_stream = disconnected_acrtc->stream; - - disconnected_acrtc->stream = new_stream; - disconnected_acrtc->enabled = true; - disconnected_acrtc->hw_mode = disconnected_acrtc->base.state->mode; - - commit_streams_count = 0; - - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc); - - if (acrtc->stream) { - commit_streams[commit_streams_count] = acrtc->stream; - ++commit_streams_count; - } - } - - /* DC is optimized not to do anything if 'streams' didn't change. */ - if (!dc_commit_streams(dc, commit_streams, - commit_streams_count)) { - DRM_INFO("Failed to restore connector state!\n"); - dc_stream_release(disconnected_acrtc->stream); - disconnected_acrtc->stream = current_stream; - manage_dm_interrupts(adev, disconnected_acrtc, true); - return; - } - - if (adev->dm.freesync_module) { - mod_freesync_remove_stream(adev->dm.freesync_module, - current_stream); - - mod_freesync_add_stream(adev->dm.freesync_module, - new_stream, &aconnector->caps); - } - - list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { - struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc); - - if (acrtc->stream != NULL) { - acrtc->otg_inst = - dc_stream_get_status(acrtc->stream)->primary_otg_inst; - } - } - - dc_stream_release(current_stream); - - dm_dc_surface_commit(dc, &disconnected_acrtc->base); - - manage_dm_interrupts(adev, disconnected_acrtc, true); - dm_crtc_cursor_reset(&disconnected_acrtc->base); - - } + if (disconnected_acrtc->stream->sink != aconnector->dc_sink) + dm_force_atomic_commit(&aconnector->base); } static uint32_t add_val_sets_surface(