From patchwork Mon Sep 24 18:15:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kazlauskas, Nicholas" X-Patchwork-Id: 10612781 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 0C9C2157B for ; Mon, 24 Sep 2018 18:17:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE8F0296A8 for ; Mon, 24 Sep 2018 18:17:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1CC62A2C7; Mon, 24 Sep 2018 18:17:02 +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 08DF0296A8 for ; Mon, 24 Sep 2018 18:17:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A27866E31A; Mon, 24 Sep 2018 18:17:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0065.outbound.protection.outlook.com [104.47.32.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE7A46E29B; Mon, 24 Sep 2018 18:16:58 +0000 (UTC) Received: from DM5PR12CA0056.namprd12.prod.outlook.com (2603:10b6:3:103::18) by BLUPR12MB0419.namprd12.prod.outlook.com (2a01:111:e400:516c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1143.17; Mon, 24 Sep 2018 18:16:55 +0000 Received: from CO1NAM03FT042.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by DM5PR12CA0056.outlook.office365.com (2603:10b6:3:103::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1164.20 via Frontend Transport; Mon, 24 Sep 2018 18:16:55 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT042.mail.protection.outlook.com (10.152.81.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.1185.13 via Frontend Transport; Mon, 24 Sep 2018 18:16:54 +0000 Received: from kazbox.amd.com (10.180.168.240) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.389.1; Mon, 24 Sep 2018 13:16:45 -0500 From: Nicholas Kazlauskas To: , Subject: [PATCH v2 3/3] drm/amd/display: Set FreeSync state using DRM VRR properties Date: Mon, 24 Sep 2018 14:15:37 -0400 Message-ID: <20180924181537.12092-4-nicholas.kazlauskas@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180924181537.12092-1-nicholas.kazlauskas@amd.com> References: <20180924181537.12092-1-nicholas.kazlauskas@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)(39860400002)(346002)(396003)(136003)(376002)(2980300002)(428003)(199004)(189003)(26005)(72206003)(77096007)(486006)(8936002)(110136005)(54906003)(104016004)(47776003)(53936002)(478600001)(44832011)(305945005)(50226002)(36756003)(7696005)(426003)(356003)(4326008)(51416003)(11346002)(2906002)(446003)(126002)(76176011)(48376002)(97736004)(186003)(476003)(336012)(8676002)(81156014)(50466002)(81166006)(2616005)(5024004)(14444005)(53416004)(5660300001)(6666003)(217873002)(68736007)(105586002)(106466001)(86362001)(16586007)(1076002)(316002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0419; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; A:1; MX:1; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT042; 1:pU8x3dNz3f9JF3ma/VGIrew+xYo+6p4o8llsEi/8GJHcJg2J/2niOrYCFkSqVHt2nkM5hEAWhdZxgAjt+R00jDnWCSIN/lXxlBw57Lo8AFwXJIkvhQAw0SjHpkXlATHG X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 67f7bbf0-e554-4064-c253-08d62249e895 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060); SRVR:BLUPR12MB0419; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0419; 3:B3/iCSeS6y10tK6v7mIGWziOK2+77790prEOc5mp+uj45F9xQOselmMJMLO0bF97iyyo5RjiJ/TnA8wbi/7s22UwWZL4v93Ql1IGRADM7IIs21JhAnn8eH7KNYr6XaUkX2p+0XHNJKgSUbvtrFho0lp72F+SRqJxvaMaig32kT4/0J+fd6r7hanMJuCOJZ90gkb24AE5LQnDXanepWgBY3/yD2YuXentql6zn5qJq9TsnR1ddIv5uuB6XT8hq7m8P9w21/qw5GRxXoqfpkFBkLdPpfP3dQwkdIyFGpaA9VgLgJe3DIifBdYVwGthaqloNrvOuwQPvuxvKvXz37OPRu1s6pmQdPWyBFNN+uyznig=; 25:Rko3MvjYXS45SgLc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C7pHGUbcMHSXsIvRg8tTDTc8lOofv7q+Tdo+5DpxZWk6mK3jspZQ7HRzN8 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93003095)(3231355)(944501410)(52105095)(3002001)(6055026)(149066)(150027)(6041310)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:BLUPR12MB0419; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0419; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0419; 4:jmtcY9hCzi9Ew6nKNSriI08ASedOAlVBh3oJ4yjKrg9u0M4ta3/oo8FzVcVNcEKn74ASkJYWv1YL2DKwn6R/djtUpsmCTsX9sOWST4es11jfyRwO7WfDs962XZwjNwIeCrMr8HekywWc9vHoQXSF6e78MLIjAZGs8Kp5HDGEOcaOFe7cCD/+QFwLA1n17o7DdcI5+e33C4WLEFOc81szsPZpTdiwvk+0H/iLqZqf09TOI8fvYYbMxY4RAeJ+5Si5CPKRThfgyanpDICWCH+ieK47dxp0oGF39YsY3KPCpHmEoFZLq8ZczuLSCzLpDqvV X-Forefront-PRVS: 0805EC9467 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR12MB0419; 23:aHb+eo2Tnx9hSgh5Y8xUr9voN4zPbIeOEL9QNIYo5?= 0xP+E1Cu1WRkL9Y8nBFQPa3B7+2WG3Ods8VKqQ8uPeUOandTs8px87XILrye1AwaGj294A4T3cUAzxMsbDwesyY6JRsbv1AGOU5K0+OUXEvLPwxZ2pxw9b9ybM2DuOmUlFg8/YP8ALiyS1HfBOAFLmejqB8ZSDuHY2EEXZCuVHpQarS9TYa1OugXD7eDGNxWeEmegF3Ogk/PefmFqs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iep93NZOXtywNcj0r1wYl0fq/vOMCwyHKTc+gr7yXoHn/rNd0w8AjP5ja3pqYX6ZwOcG+3ZeTcbPF0oP/z/8cpIpOgNWZcbycwTjkJcvALENLVr7um/Esdlg/boe3lsh1d04/jL1dvabOpv4/+h0b1FS/J18EOTyYFk352tod6vfhp7uVi SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0419; 20:rIQmirvPzOmuH57e8UfRVKGktkTne8Z48Olm4ddTFClDu8Eh6gagpTm+hDijzcQ44eOLlidyZNuAPELMhYZtK1RCcvye6Kd9OjXBvRhN8Gmjil91Z2Q5IknZlVwmjRG6rJazaCYQ7+ZXO178rPEuRcsQNFiljkz/rfMv3FuLTgcH2W8NpRWaC6kgq1bhJQU5OjUGB1UnJ4xXtEQhkJSZz/Rwc0BMQklWgdunc/I+qQGIeGIocimVJIc5qkyBhGo4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2018 18:16:54.6152 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67f7bbf0-e554-4064-c253-08d62249e895 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=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0419 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: nicolai.haehnle@amd.com, michel@daenzer.net, Christian.Koenig@amd.com, manasi.d.navare@intel.com, Alexander.Deucher@amd.com, Nicholas Kazlauskas , Marek.Olsak@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The AMDGPU specific FreeSync properties and IOCTLs are dropped from amdgpu_dm in favor of the DRM variable refresh properties. The AMDGPU connector properties freesync_capable and freesync_enabled are mostly direct mappings to the DRM variable_refresh_capable and variable_refresh_enabled. The AMDGPU CRTC freesync_enabled property requires special care to handle correctly. The DRM variable_refresh property is a content hint to the driver which is independent from actual hardware variable refresh capability and user configuration. To handle changes with this property it was easier to drop the forced modeset on variable refresh change. This patch now performs the required stream updates when planes are attached *or* flipped. This is done for a few reasons: (1) VRR stream updates can be done in the fast update path (2) amdgpu_dm_atomic_check would have had to been hacked apart to check desired variable refresh state and capability before the CRTC disable pass. (3) Performing VRR stream updates on-flip is needed for enabling BTR support. FreeSync state on the stream is now tracked and compared to the previous packet sent to the hardware. It's worth noting that the current implementation treats variable_refresh_enabled as a strict requirement for sending the VRR enable *or* disable packet. Signed-off-by: Nicholas Kazlauskas --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 232 +++++++++--------- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 +- 2 files changed, 121 insertions(+), 117 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 6c849e055038..0fddc2e66f49 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1683,72 +1683,6 @@ static void dm_bandwidth_update(struct amdgpu_device *adev) /* TODO: implement later */ } -static int amdgpu_notify_freesync(struct drm_device *dev, void *data, - struct drm_file *filp) -{ - struct drm_atomic_state *state; - struct drm_modeset_acquire_ctx ctx; - struct drm_crtc *crtc; - struct drm_connector *connector; - struct drm_connector_state *old_con_state, *new_con_state; - int ret = 0; - uint8_t i; - bool enable = false; - - drm_modeset_acquire_init(&ctx, 0); - - state = drm_atomic_state_alloc(dev); - if (!state) { - ret = -ENOMEM; - goto out; - } - state->acquire_ctx = &ctx; - -retry: - drm_for_each_crtc(crtc, dev) { - ret = drm_atomic_add_affected_connectors(state, crtc); - if (ret) - goto fail; - - /* TODO rework amdgpu_dm_commit_planes so we don't need this */ - ret = drm_atomic_add_affected_planes(state, crtc); - if (ret) - goto fail; - } - - for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) { - struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state); - struct drm_crtc_state *new_crtc_state; - struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc); - struct dm_crtc_state *dm_new_crtc_state; - - if (!acrtc) { - ASSERT(0); - continue; - } - - new_crtc_state = drm_atomic_get_new_crtc_state(state, &acrtc->base); - dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); - - dm_new_crtc_state->freesync_enabled = enable; - } - - ret = drm_atomic_commit(state); - -fail: - if (ret == -EDEADLK) { - drm_atomic_state_clear(state); - drm_modeset_backoff(&ctx); - goto retry; - } - - drm_atomic_state_put(state); - -out: - drm_modeset_drop_locks(&ctx); - drm_modeset_acquire_fini(&ctx); - return ret; -} static const struct amdgpu_display_funcs dm_display_funcs = { .bandwidth_update = dm_bandwidth_update, /* called unconditionally */ @@ -1762,7 +1696,6 @@ static const struct amdgpu_display_funcs dm_display_funcs = { dm_crtc_get_scanoutpos,/* called unconditionally */ .add_encoder = NULL, /* VBIOS parsing. DAL does it. */ .add_connector = NULL, /* VBIOS parsing. DAL does it. */ - .notify_freesync = amdgpu_notify_freesync, }; @@ -2645,7 +2578,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, update_stream_signal(stream); - if (dm_state && dm_state->freesync_capable) + if (dm_state && dm_state->base.variable_refresh_capable) stream->ignore_msa_timing_param = true; finish: if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL) @@ -2713,9 +2646,10 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc) dc_stream_retain(state->stream); } + state->freesync_enabled = cur->freesync_enabled; + state->freesync_config = cur->freesync_config; state->adjust = cur->adjust; state->vrr_infopacket = cur->vrr_infopacket; - state->freesync_enabled = cur->freesync_enabled; /* TODO Duplicate dc_stream after objects are stream object is flattened */ @@ -2933,9 +2867,6 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector) __drm_atomic_helper_connector_duplicate_state(connector, &new_state->base); - new_state->freesync_capable = state->freesync_capable; - new_state->freesync_enable = state->freesync_enable; - return &new_state->base; } @@ -3681,6 +3612,11 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, adev->mode_info.underscan_vborder_property, 0); + if (connector_type == DRM_MODE_CONNECTOR_HDMIA || + connector_type == DRM_MODE_CONNECTOR_DisplayPort) { + drm_connector_attach_variable_refresh_properties( + &aconnector->base); + } } static int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap, @@ -4057,6 +3993,63 @@ static void prepare_flip_isr(struct amdgpu_crtc *acrtc) acrtc->crtc_id); } +static void update_freesync_state_on_stream( + struct amdgpu_display_manager *dm, + struct dm_crtc_state *new_crtc_state, + struct dc_stream_state *new_stream) +{ + struct mod_vrr_params vrr = {0}; + struct dc_info_packet vrr_infopacket = {0}; + struct mod_freesync_config config = new_crtc_state->freesync_config; + + if (!new_stream) + return; + + if (new_crtc_state->freesync_enabled) { + config.state = new_crtc_state->base.variable_refresh ? + VRR_STATE_ACTIVE_VARIABLE : + VRR_STATE_INACTIVE; + } + + mod_freesync_build_vrr_params(dm->freesync_module, + new_stream, + &config, &vrr); + + mod_freesync_build_vrr_infopacket( + dm->freesync_module, + new_stream, + &vrr, + &vrr_infopacket); + + new_crtc_state->freesync_timing_changed = + (memcmp(&new_crtc_state->adjust, + &vrr.adjust, + sizeof(vrr.adjust)) != 0); + + new_crtc_state->freesync_vrr_info_changed = + (memcmp(&new_crtc_state->vrr_infopacket, + &vrr_infopacket, + sizeof(vrr_infopacket)) != 0); + + new_crtc_state->adjust = vrr.adjust; + new_crtc_state->vrr_infopacket = vrr_infopacket; + + new_stream->adjust = new_crtc_state->adjust; + new_stream->vrr_infopacket = vrr_infopacket; + + if (new_crtc_state->freesync_vrr_info_changed) + DRM_DEBUG_KMS("Freesync VRR info changed: crtc_id=%d wanted=%d actual=%d", + (int)new_crtc_state->base.crtc->base.id, + (int)new_crtc_state->base.variable_refresh, + (int)vrr.state); + + if (new_crtc_state->freesync_timing_changed) + DRM_DEBUG_KMS("Freesync timing changed: crtc_id=%d min=%d max=%d\n", + (int)new_crtc_state->base.crtc->base.id, + (int)vrr.adjust.v_total_min, + (int)vrr.adjust.v_total_max); +} + /* * Executes flip * @@ -4078,6 +4071,7 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc, struct dc_flip_addrs addr = { {0} }; /* TODO eliminate or rename surface_update */ struct dc_surface_update surface_updates[1] = { {0} }; + struct dc_stream_update stream_update = {0}; struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state); @@ -4137,11 +4131,21 @@ static void amdgpu_dm_do_flip(struct drm_crtc *crtc, surface_updates->surface = dc_stream_get_status(acrtc_state->stream)->plane_states[0]; surface_updates->flip_addr = &addr; + if (acrtc_state->stream) { + if (acrtc_state->freesync_timing_changed) + stream_update.adjust = + &acrtc_state->stream->adjust; + + if (acrtc_state->freesync_vrr_info_changed) + stream_update.vrr_infopacket = + &acrtc_state->stream->vrr_infopacket; + } + dc_commit_updates_for_stream(adev->dm.dc, surface_updates, 1, acrtc_state->stream, - NULL, + &stream_update, &surface_updates->surface, state); @@ -4201,10 +4205,10 @@ static bool commit_planes_to_stream( stream_update->dst = dc_stream->dst; stream_update->out_transfer_func = dc_stream->out_transfer_func; - if (dm_new_crtc_state->freesync_enabled != dm_old_crtc_state->freesync_enabled) { + if (dm_new_crtc_state->freesync_vrr_info_changed) stream_update->vrr_infopacket = &dc_stream->vrr_infopacket; + if (dm_new_crtc_state->freesync_timing_changed) stream_update->adjust = &dc_stream->adjust; - } for (i = 0; i < new_plane_count; i++) { updates[i].surface = plane_states[i]; @@ -4341,9 +4345,6 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, spin_unlock_irqrestore(&pcrtc->dev->event_lock, flags); } - dc_stream_attach->adjust = acrtc_state->adjust; - dc_stream_attach->vrr_infopacket = acrtc_state->vrr_infopacket; - if (false == commit_planes_to_stream(dm->dc, plane_states_constructed, planes_count, @@ -4515,6 +4516,17 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) } } + /* Handle freesync changes. */ + for_each_new_crtc_in_state(state, crtc, new_crtc_state, j) { + if (!new_crtc_state->active) + continue; + + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); + + update_freesync_state_on_stream(dm, + dm_new_crtc_state, dm_new_crtc_state->stream); + } + /* Handle scaling and underscan changes*/ for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) { struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state); @@ -4547,9 +4559,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) WARN_ON(!status); WARN_ON(!status->plane_count); - dm_new_crtc_state->stream->adjust = dm_new_crtc_state->adjust; - dm_new_crtc_state->stream->vrr_infopacket = dm_new_crtc_state->vrr_infopacket; - /*TODO How it works with MPO ?*/ if (!commit_planes_to_stream( dm->dc, @@ -4767,20 +4776,19 @@ static int do_aquire_global_lock(struct drm_device *dev, return ret < 0 ? ret : 0; } -void set_freesync_on_stream(struct amdgpu_display_manager *dm, - struct dm_crtc_state *new_crtc_state, - struct dm_connector_state *new_con_state, - struct dc_stream_state *new_stream) +static void get_freesync_config_for_crtc( + struct dm_crtc_state *new_crtc_state, + struct dm_connector_state *new_con_state) { struct mod_freesync_config config = {0}; - struct mod_vrr_params vrr = {0}; - struct dc_info_packet vrr_infopacket = {0}; struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(new_con_state->base.connector); - if (new_con_state->freesync_capable && - new_con_state->freesync_enable) { - config.state = new_crtc_state->freesync_enabled ? + new_crtc_state->freesync_enabled = false; + + if (new_con_state->base.variable_refresh_capable && + new_con_state->base.variable_refresh_enabled) { + config.state = new_crtc_state->base.variable_refresh ? VRR_STATE_ACTIVE_VARIABLE : VRR_STATE_INACTIVE; config.min_refresh_in_uhz = @@ -4788,19 +4796,20 @@ void set_freesync_on_stream(struct amdgpu_display_manager *dm, config.max_refresh_in_uhz = aconnector->max_vfreq * 1000000; config.vsif_supported = true; - } - mod_freesync_build_vrr_params(dm->freesync_module, - new_stream, - &config, &vrr); + new_crtc_state->freesync_enabled = true; + } - mod_freesync_build_vrr_infopacket(dm->freesync_module, - new_stream, - &vrr, - &vrr_infopacket); + new_crtc_state->freesync_config = config; +} - new_crtc_state->adjust = vrr.adjust; - new_crtc_state->vrr_infopacket = vrr_infopacket; +static void reset_freesync_config_for_crtc( + struct dm_crtc_state *new_crtc_state) +{ + memset(&new_crtc_state->adjust, 0, + sizeof(new_crtc_state->adjust)); + memset(&new_crtc_state->vrr_infopacket, 0, + sizeof(new_crtc_state->vrr_infopacket)); } static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, @@ -4875,9 +4884,6 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, break; } - set_freesync_on_stream(dm, dm_new_crtc_state, - dm_new_conn_state, new_stream); - if (dc_is_stream_unchanged(new_stream, dm_old_crtc_state->stream) && dc_is_stream_scaling_unchanged(new_stream, dm_old_crtc_state->stream)) { new_crtc_state->mode_changed = false; @@ -4886,9 +4892,6 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, } } - if (dm_old_crtc_state->freesync_enabled != dm_new_crtc_state->freesync_enabled) - new_crtc_state->mode_changed = true; - if (!drm_atomic_crtc_needs_modeset(new_crtc_state)) goto next_crtc; @@ -4925,6 +4928,8 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, dc_stream_release(dm_old_crtc_state->stream); dm_new_crtc_state->stream = NULL; + reset_freesync_config_for_crtc(dm_new_crtc_state); + *lock_and_validation_needed = true; } else {/* Add stream for any updated/enabled CRTC */ @@ -5002,7 +5007,8 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, amdgpu_dm_set_ctm(dm_new_crtc_state); } - + /* Update Freesync settings. */ + get_freesync_config_for_crtc(dm_new_crtc_state, dm_new_conn_state); } return ret; @@ -5267,12 +5273,9 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, goto fail; for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { - struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); - struct dm_crtc_state *dm_old_crtc_state = to_dm_crtc_state(old_crtc_state); - if (!drm_atomic_crtc_needs_modeset(new_crtc_state) && !new_crtc_state->color_mgmt_changed && - (dm_old_crtc_state->freesync_enabled == dm_new_crtc_state->freesync_enabled)) + !new_crtc_state->variable_refresh_changed) continue; if (!new_crtc_state->enable) @@ -5434,6 +5437,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, return; } + connector->state->variable_refresh_capable = false; + if (!edid) { dm_con_state = to_dm_connector_state(connector->state); @@ -5441,8 +5446,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->max_vfreq = 0; amdgpu_dm_connector->pixel_clock_mhz = 0; - dm_con_state->freesync_capable = false; - dm_con_state->freesync_enable = false; return; } @@ -5466,7 +5469,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector); } } - dm_con_state->freesync_capable = false; if (edid_check_required == true && (edid->version > 1 || (edid->version == 1 && edid->revision > 1))) { for (i = 0; i < 4; i++) { @@ -5498,7 +5500,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10) { - dm_con_state->freesync_capable = true; + connector->state->variable_refresh_capable = true; } } } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index d4f1bdf93207..debde9899ba7 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -187,7 +187,11 @@ struct dm_crtc_state { int crc_skip_count; bool crc_enabled; + bool freesync_timing_changed; + bool freesync_vrr_info_changed; + bool freesync_enabled; + struct mod_freesync_config freesync_config; struct dc_crtc_timing_adjust adjust; struct dc_info_packet vrr_infopacket; }; @@ -209,8 +213,6 @@ struct dm_connector_state { uint8_t underscan_vborder; uint8_t underscan_hborder; bool underscan_enable; - bool freesync_enable; - bool freesync_capable; }; #define to_dm_connector_state(x)\