From patchwork Fri Mar 29 12:00:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10876941 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 E9B3D14DE for ; Fri, 29 Mar 2019 12:02:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D88352878E for ; Fri, 29 Mar 2019 12:02:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CCD8A28E95; Fri, 29 Mar 2019 12:02:45 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 783DC2878E for ; Fri, 29 Mar 2019 12:02:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7BB436E8CB; Fri, 29 Mar 2019 12:02:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id E49F86E8CB; Fri, 29 Mar 2019 12:02:43 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id r4so2277129wrq.8; Fri, 29 Mar 2019 05:02:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=703QKedBOeWIgxMRfdFecHCrgtlU1SMQHBooug10jcY=; b=SigddgontqR8oK31e/ajDGXfDHaEMqtEGwlE6IA3AiZQ7uKhwWcFQN+NAgatpvm81a Axxj9USqZUDnCwjM2M6KRqBbMl5M85JbvYyeRNwwYOKoA1GZtWAFUx1DY1tCar6tkAdG DcDDOYagM1WozeT+tD0OEBOfFrEo5u5NroNsbHxjMJM/6fDu9Dl13gHuOirdX8e7F+0x MMxmPt23yvd3RzPQMn154v+R7U0XHIfpy2cm+Un5kngEzJyoirVaL2ATNtNTDaReoWgm l2O32jQSMOE6Wi0m72rvcIjuvP8lzwTIWvmNQJuzZJ8juWLFCKf6MqjshaQn1vkwHMLF LXXw== X-Gm-Message-State: APjAAAVs3BpXPimVcNl4cYcptW7q5Tj03c8xSLjM8RE3d+c/cTSHjVIL GmZdtwpMdLHVFE+guDUqYIfxNaXG X-Google-Smtp-Source: APXvYqz00ZXd7KuO5Pz7mDRbR9hyFNZGgZQzR19Q19t5B8MOBXqIblBT1RD8HODtq6zJChKCeNGh6w== X-Received: by 2002:adf:cf0c:: with SMTP id o12mr12339579wrj.16.1553860902264; Fri, 29 Mar 2019 05:01:42 -0700 (PDT) Received: from twisty.cin.medizin.uni-tuebingen.de ([2a01:c22:d02f:4b00:e9fd:d3f1:412c:598a]) by smtp.gmail.com with ESMTPSA id z8sm1839358wrh.80.2019.03.29.05.01.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Mar 2019 05:01:41 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 1/5] drm/amd/display: Update VRR state earlier in atomic_commit_tail. Date: Fri, 29 Mar 2019 13:00:53 +0100 Message-Id: <20190329120057.1472-2-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190329120057.1472-1-mario.kleiner.de@gmail.com> References: <20190329120057.1472-1-mario.kleiner.de@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=703QKedBOeWIgxMRfdFecHCrgtlU1SMQHBooug10jcY=; b=PXZX+/AI9wrSGJYsZhO4JGwJ4LWICvILPeptSS9ddQ6zbsEw/dkYC/t8zU0n+I1Nt0 rg6TvOE9vFJHKrYAExDhWv877hwQ0qBg7UYM69fAIhYwexNCj9mfZ/gbMokep6XkCxcs e7kMzdr0Uj+rhepAgQYckBW3Sm1syJ4yuVZCFPeT6fdOJqhDIBMRLl8hDg6FeH0E3JGU 70yvJ5Fshjzm2lozq0NPZBHO+NNBE9qDeJtH1VFZjsECVZutABGz3za7fnPACHiusCKp cS4hRdjF11YD7n2OWi1UZ4Bd2BIf2rXtHFiGntNyyi6W4S/Ntn4Fc4GUAM9NM58dFIxe uRuw== 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: nicholas.kazlauskas@amd.com, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We need the VRR active/inactive state info earlier in the commit sequence, so VRR related setup functions like amdgpu_dm_handle_vrr_transition() know the final VRR state when they need to do their hw setup work. Split update_freesync_state_on_stream() into an early part, that can run at the beginning of commit tail before the vrr transition handling, and a late part that must run after vrr transition handling inside the commit planes code for enabled crtc's. Suggested by Nicholas Kazlauskas. Signed-off-by: Mario Kleiner Reviewed-by: Nicholas Kazlauskas --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 61 ++++++++++++++----- 1 file changed, 46 insertions(+), 15 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 7d1c782072ee..6528258f8975 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4645,7 +4645,6 @@ static void update_freesync_state_on_stream( { struct mod_vrr_params vrr_params = new_crtc_state->vrr_params; struct dc_info_packet vrr_infopacket = {0}; - struct mod_freesync_config config = new_crtc_state->freesync_config; if (!new_stream) return; @@ -4658,20 +4657,6 @@ static void update_freesync_state_on_stream( if (!new_stream->timing.h_total || !new_stream->timing.v_total) return; - if (new_crtc_state->vrr_supported && - config.min_refresh_in_uhz && - config.max_refresh_in_uhz) { - config.state = new_crtc_state->base.vrr_enabled ? - VRR_STATE_ACTIVE_VARIABLE : - VRR_STATE_INACTIVE; - } else { - config.state = VRR_STATE_UNSUPPORTED; - } - - mod_freesync_build_vrr_params(dm->freesync_module, - new_stream, - &config, &vrr_params); - if (surface) { mod_freesync_handle_preflip( dm->freesync_module, @@ -4712,6 +4697,46 @@ static void update_freesync_state_on_stream( (int)vrr_params.state); } +static void pre_update_freesync_state_on_stream( + struct amdgpu_display_manager *dm, + struct dm_crtc_state *new_crtc_state) +{ + struct dc_stream_state *new_stream = new_crtc_state->stream; + struct mod_vrr_params vrr_params = new_crtc_state->vrr_params; + struct mod_freesync_config config = new_crtc_state->freesync_config; + + if (!new_stream) + return; + + /* + * TODO: Determine why min/max totals and vrefresh can be 0 here. + * For now it's sufficient to just guard against these conditions. + */ + if (!new_stream->timing.h_total || !new_stream->timing.v_total) + return; + + if (new_crtc_state->vrr_supported && + config.min_refresh_in_uhz && + config.max_refresh_in_uhz) { + config.state = new_crtc_state->base.vrr_enabled ? + VRR_STATE_ACTIVE_VARIABLE : + VRR_STATE_INACTIVE; + } else { + config.state = VRR_STATE_UNSUPPORTED; + } + + mod_freesync_build_vrr_params(dm->freesync_module, + new_stream, + &config, &vrr_params); + + new_crtc_state->freesync_timing_changed |= + (memcmp(&new_crtc_state->vrr_params.adjust, + &vrr_params.adjust, + sizeof(vrr_params.adjust)) != 0); + + new_crtc_state->vrr_params = vrr_params; +} + static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, struct dc_state *dc_state, struct drm_device *dev, @@ -5233,6 +5258,12 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) mutex_unlock(&dm->dc_lock); } + /* Update freesync state before amdgpu_dm_handle_vrr_transition(). */ + for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) { + dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); + pre_update_freesync_state_on_stream(dm, dm_new_crtc_state); + } + for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { /*