From patchwork Mon May 2 20:41:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 12834706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8950AC433EF for ; Mon, 2 May 2022 20:40:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EDF3910E65B; Mon, 2 May 2022 20:40:40 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 84A4D10E65B for ; Mon, 2 May 2022 20:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651524039; x=1683060039; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=UD0Roz+JJhMkM/TvXZ8wJywDiuh41cckCrr7E1e1epI=; b=X7hfAzAVYhd/dNHSIIJ6XBbRP8c6XKuQsi2w/vrHWEiP92YQcp1RTUQj PCPoktH5cVtqVEyVsjsaLuejQtB57Xes6o/gZ4HGkv+GdSxbpydpeFDlY JuUlRjXJvDRTfcSJHbL0aNZ8ogjEntl093xEuEcTlNB5oKZI7zwgL65g7 MzxI6c9UOwYqa+cH14jMQ5CfkNCx8xjn5B9W1OP9FWobdFM7kUuIYORmJ wcEeHK+nuo+cFvU8HkoxlawbdMAPVgAW6sOLzyKDSjjDKTdCkhJlSiVnh rJvrGteFFEp6eTK23fnSPRO8kNOdKBKDJABF15814bXbv+l0BwizEXX4O w==; X-IronPort-AV: E=McAfee;i="6400,9594,10335"; a="247873036" X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="247873036" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 13:40:38 -0700 X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="690670554" Received: from unknown (HELO josouza-mobl2.fso.intel.com) ([10.230.18.139]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 13:40:37 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Mon, 2 May 2022 13:41:15 -0700 Message-Id: <20220502204117.32938-1-jose.souza@intel.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 1/3] drm/i915/display: Allow DRRS to be enabled during driver load X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" When driver takes over display from firmware it does some checks and if possible it tries to avoid a modeset to improve user boot experience. But even if DRRS is supported it was being left disabled as intel_crtc_copy_fastset() was overwritten new state with the old one (hardware readout). So here checking if platform has only one set of m_n registers that can change on the fly between high and low clock, if yes we can keep DRRS enabled. Cc: Vidya Srinivas Cc: Ville Syrjälä Signed-off-by: José Roberto de Souza --- drivers/gpu/drm/i915/display/intel_display.c | 7 ++++-- drivers/gpu/drm/i915/display/intel_drrs.c | 24 ++++++++++++++++++++ drivers/gpu/drm/i915/display/intel_drrs.h | 2 ++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 0decf3d242372..17d0cad9e1686 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -7086,8 +7086,11 @@ static void intel_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_stat */ new_crtc_state->fdi_m_n = old_crtc_state->fdi_m_n; new_crtc_state->dp_m_n = old_crtc_state->dp_m_n; - new_crtc_state->dp_m2_n2 = old_crtc_state->dp_m2_n2; - new_crtc_state->has_drrs = old_crtc_state->has_drrs; + + if (!intel_drrs_crtc_copy_fastset(old_crtc_state, new_crtc_state)) { + new_crtc_state->dp_m2_n2 = old_crtc_state->dp_m2_n2; + new_crtc_state->has_drrs = old_crtc_state->has_drrs; + } } static int intel_crtc_add_planes_to_state(struct intel_atomic_state *state, diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c b/drivers/gpu/drm/i915/display/intel_drrs.c index 166caf293f7bc..d266fad83a086 100644 --- a/drivers/gpu/drm/i915/display/intel_drrs.c +++ b/drivers/gpu/drm/i915/display/intel_drrs.c @@ -300,3 +300,27 @@ void intel_crtc_drrs_init(struct intel_crtc *crtc) mutex_init(&crtc->drrs.mutex); crtc->drrs.cpu_transcoder = INVALID_TRANSCODER; } + +/** + * intel_drrs_crtc_copy_fastset - Handles crtc state copy during fastsets when + * new state has DRRS. + * @old_crtc_state: old crtc state + * @new_crtc_state: new crtc state + * + * Handle crtc state copy during fastsets trying to keep DRRS enabled. + * That can be done in platforms that supports change the dp_m_n register on + * the fly between high and low clocks. + * + * Returns true if crtc copy was already handled otherwise returns false. + */ +bool intel_drrs_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_state, + struct intel_crtc_state *new_crtc_state) +{ + struct drm_i915_private *i915 = to_i915(old_crtc_state->uapi.crtc->dev); + + /* m2_n2 register needs to already be set */ + if (intel_cpu_transcoder_has_m2_n2(i915, new_crtc_state->cpu_transcoder)) + return false; + + return true; +} diff --git a/drivers/gpu/drm/i915/display/intel_drrs.h b/drivers/gpu/drm/i915/display/intel_drrs.h index 3ad1be1ad9c13..749ac717db063 100644 --- a/drivers/gpu/drm/i915/display/intel_drrs.h +++ b/drivers/gpu/drm/i915/display/intel_drrs.h @@ -24,5 +24,7 @@ void intel_drrs_invalidate(struct drm_i915_private *dev_priv, void intel_drrs_flush(struct drm_i915_private *dev_priv, unsigned int frontbuffer_bits); void intel_crtc_drrs_init(struct intel_crtc *crtc); +bool intel_drrs_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_state, + struct intel_crtc_state *new_crtc_state); #endif /* __INTEL_DRRS_H__ */ From patchwork Mon May 2 20:41:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 12834707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3EFACC433F5 for ; Mon, 2 May 2022 20:40:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D557410E66B; Mon, 2 May 2022 20:40:41 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6FEFB10E65B for ; Mon, 2 May 2022 20:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651524040; x=1683060040; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6r0JVEm97E0jHAoi13T87rQQoefTlX9huusCqBo66iw=; b=lx+cK2DmlO3GofH8SS4DegRDnidEYsJDzw/kFuqVLfTbz96fmarQnfUq MfH334EDfyWHuCSDr9pV69HIhZ/mhN1XKZ4wv7ZvNAOhJyhQMI/lwXIcc ulVJwugTUcxM0Ucj+kiAHsI+y+IYQvFjsghtLdl3XVhM9UrKAUEBM8OYW T0mcTOacPT7Wdx4dx8G9A+KmoWJKkfQPc5yiolruHLjX2MJfdBIw2uD/C 3dscRytw0KGqLFYbtgAPm34of768iFYmx5h9Jci/KU+sDuiZ79SRPhO+t 9andE2sJcn1V7599n/0XqVHFAGwD+tDOWFxQLemHANTYMYYQ9q0e9PCJs w==; X-IronPort-AV: E=McAfee;i="6400,9594,10335"; a="247873045" X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="247873045" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 13:40:40 -0700 X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="690670615" Received: from unknown (HELO josouza-mobl2.fso.intel.com) ([10.230.18.139]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 13:40:38 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Mon, 2 May 2022 13:41:16 -0700 Message-Id: <20220502204117.32938-2-jose.souza@intel.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220502204117.32938-1-jose.souza@intel.com> References: <20220502204117.32938-1-jose.souza@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 2/3] drm/i915/display/dp: Try to fallback to previous link config if modeset is not allowed X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" When an atomic commit has changes that allows it to go to a lower DP link configuration it will require a modeset but userspace might not want it, so it would not set the modeset allowed flag causing commit to fail. Here in such case it tries to keep previous and trained link configuration for the new state. Cc: Ville Syrjälä Signed-off-by: José Roberto de Souza --- drivers/gpu/drm/i915/display/intel_dp.c | 86 ++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index e4a79c11fd255..cc9be82e128f4 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -1596,6 +1596,16 @@ intel_dp_compute_link_config(struct intel_encoder *encoder, return ret; } + return 0; +} + +static void +intel_dp_print_link_config(struct intel_crtc_state *pipe_config) +{ + struct drm_i915_private *i915 = to_i915(pipe_config->uapi.crtc->dev); + const struct drm_display_mode *adjusted_mode = + &pipe_config->hw.adjusted_mode; + if (pipe_config->dsc.compression_enable) { drm_dbg_kms(&i915->drm, "DP lane count %d clock %d Input bpp %d Compressed bpp %d\n", @@ -1621,7 +1631,6 @@ intel_dp_compute_link_config(struct intel_encoder *encoder, intel_dp_max_data_rate(pipe_config->port_clock, pipe_config->lane_count)); } - return 0; } bool intel_dp_limited_color_range(const struct intel_crtc_state *crtc_state, @@ -1915,6 +1924,72 @@ static bool intel_dp_has_audio(struct intel_encoder *encoder, return intel_conn_state->force_audio == HDMI_AUDIO_ON; } +/* + * If modeset is not allowed it checks for link computed state and if different + * it checks if is possible to fallback to previous configuration. + * + * Returns 0 if modeset is allowed, link computed states matches or fallback is + * possible otherwise returns a errno. + */ +static int +intel_dp_compute_link_config_no_modeset_fallback(struct intel_crtc_state *crtc_state) +{ + struct intel_atomic_state *state = to_intel_atomic_state(crtc_state->uapi.state); + struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; + const struct intel_crtc_state *old_crtc_state; + int output_bpp, mode_rate, old_link_avail; + struct intel_crtc *crtc; + + if (state->base.allow_modeset) + return 0; + + crtc = to_intel_crtc(crtc_state->uapi.crtc); + old_crtc_state = intel_atomic_get_old_crtc_state(state, crtc); + + /* Check if both states matches */ + if (crtc_state->output_format == old_crtc_state->output_format && + crtc_state->port_clock == old_crtc_state->port_clock && + crtc_state->lane_count == old_crtc_state->lane_count && + crtc_state->pipe_bpp == old_crtc_state->pipe_bpp && + crtc_state->dsc.compression_enable == old_crtc_state->dsc.compression_enable && + crtc_state->dsc.compressed_bpp == old_crtc_state->dsc.compressed_bpp && + crtc_state->dsc.slice_count == old_crtc_state->dsc.slice_count && + crtc_state->bigjoiner_pipes == old_crtc_state->bigjoiner_pipes) + return 0; + + /* + * Modeset will be required if any of this changed, there is no way + * around it + */ + if (crtc_state->output_format != old_crtc_state->output_format || + crtc_state->bigjoiner_pipes != old_crtc_state->bigjoiner_pipes || + crtc_state->dsc.compression_enable != old_crtc_state->dsc.compression_enable) + return -EINVAL; + + /* TODO: Not supporting DSC fallback but it might be possible */ + if (crtc_state->dsc.compression_enable) + return -EINVAL; + + output_bpp = intel_dp_output_bpp(crtc_state->output_format, + old_crtc_state->pipe_bpp); + mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, + output_bpp); + + old_link_avail = intel_dp_max_data_rate(old_crtc_state->port_clock, + old_crtc_state->lane_count); + + /* Check if old link configuration has enough bandwidth for new mode */ + if (mode_rate > old_link_avail) + return -EINVAL; + + /* Fallback is possible */ + crtc_state->lane_count = old_crtc_state->lane_count; + crtc_state->pipe_bpp = old_crtc_state->pipe_bpp; + crtc_state->port_clock = old_crtc_state->port_clock; + + return 0; +} + static int intel_dp_compute_output_format(struct intel_encoder *encoder, struct intel_crtc_state *crtc_state, @@ -1950,8 +2025,17 @@ intel_dp_compute_output_format(struct intel_encoder *encoder, crtc_state->output_format = intel_dp_output_format(connector, true); ret = intel_dp_compute_link_config(encoder, crtc_state, conn_state, respect_downstream_limits); + if (ret) + return ret; } + ret = intel_dp_compute_link_config_no_modeset_fallback(crtc_state); + if (ret) + drm_dbg_kms(&i915->drm, "DP link configuration requires " + "changes but modeset is not allowed\n"); + + intel_dp_print_link_config(crtc_state); + return ret; } From patchwork Mon May 2 20:41:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 12834708 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBF4EC4332F for ; Mon, 2 May 2022 20:40:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3811210E6A3; Mon, 2 May 2022 20:40:44 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7F41610E796 for ; Mon, 2 May 2022 20:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651524042; x=1683060042; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/sOoEYRv69G4rT3LDs6U5b7a4o1iu5RE00o02Q76zIA=; b=ApRHyZZYAiAoU8MZTHZj0+LM81zb1AdDmClcy00k21ofM9/icGTT/0br qo6s4mY09fglQllgpb+MfIWjMuaJVWrdmQp6S2jqjKlYYZRKS0YgxJW1Y ucXnINjHjoATvOW8YK4k6ZzXz37BmwJ78HfdEFKw5VSyj5902+i5Sx7HO w5QGTUtIijuRQjHLaqo8Ydat71tyzYMUQRMM292LsNaW75lvodqV6CoPe vj9fikXuZlPHOTeIQ5Lk9K77f3NNaKDMqFYHNYaGmtlyx95EXPvVMGQT7 NSGRbFoExM+JKfdoHG7qzhf05MKxcCwS1bMGq5v3mEJ4QmoRtXxOhpKSy w==; X-IronPort-AV: E=McAfee;i="6400,9594,10335"; a="247873046" X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="247873046" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 13:40:42 -0700 X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="690670666" Received: from unknown (HELO josouza-mobl2.fso.intel.com) ([10.230.18.139]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 13:40:40 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Mon, 2 May 2022 13:41:17 -0700 Message-Id: <20220502204117.32938-3-jose.souza@intel.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220502204117.32938-1-jose.souza@intel.com> References: <20220502204117.32938-1-jose.souza@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH v2 3/3] drm/i915/display: Implement seamless mode switch X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sean Paul Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" So far the i915's DRRS feature was automatically changing between preferred panel mode and downclock mode based on idleness but ChromeOS compositor team is asking to be in control of the mode switch. So for certain types of content it can switch to a mode with a lower refresh rate without the user noticing a thing and saving more power. This seamless mode switch will be triggered when user-space dispatches an atomic commit with the new mode and clears the DRM_MODE_ATOMIC_ALLOW_MODESET flag. The main steps to acomplish that are: - as mode changed in atomic state drm_atomic_helper_check_modeset() will set mode_changed and it will trigger the crtc state computation so intel_dp_compute_config() will be called and dp_m_n will be computed for the new mode - then intel_dp_drrs_compute_config() will check for the necessary conditions to do a seamless mode switch, if possible crtc_state->seamless_mode_switch will be set and has_drrs will not be set, so i915 will not automatically switch between modes - then intel_crtc_compute_config() will call intel_crtc_compute_pixel_rate() that will take the hint that it is trying to do a seamless mode switch and set pixel_rate to the pixel_rate of the old state - then if nothing else changed in the state intel_crtc_check_fastset() will be able to set mode_changed to false and i915 can do fastset otherwise the commit will fail during the check phase - now on the atomic commit phase, intel_ddi_update_pipe_dp() will be called and will program the new dp_m_n - nothing else is different in the commit phase until the step to verify programmed state, the most important change here is that need to save the pixel_rate in DRRS global state as there is no other way to get that from hardware or atomic state v2: - not overwritten dp_m_n values in intel_crtc_copy_fastset() when doing a seamless_mode_switch Cc: Vidya Srinivas Cc: Sean Paul Cc: Ville Syrjälä Signed-off-by: José Roberto de Souza Tested-by: Vidya Srinivas --- drivers/gpu/drm/i915/display/intel_ddi.c | 10 +++ drivers/gpu/drm/i915/display/intel_display.c | 61 ++++++++++++++++--- .../drm/i915/display/intel_display_debugfs.c | 3 + .../drm/i915/display/intel_display_types.h | 3 + drivers/gpu/drm/i915/display/intel_dp.c | 56 ++++++++++++++--- drivers/gpu/drm/i915/display/intel_drrs.c | 38 +++++++++--- drivers/gpu/drm/i915/display/intel_drrs.h | 3 + 7 files changed, 151 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c index 9e6fa59eabba7..732e5d425412e 100644 --- a/drivers/gpu/drm/i915/display/intel_ddi.c +++ b/drivers/gpu/drm/i915/display/intel_ddi.c @@ -46,6 +46,7 @@ #include "intel_dp_link_training.h" #include "intel_dp_mst.h" #include "intel_dpio_phy.h" +#include "intel_drrs.h" #include "intel_dsi.h" #include "intel_fdi.h" #include "intel_fifo_underrun.h" @@ -3010,6 +3011,14 @@ static void intel_ddi_update_pipe_dp(struct intel_atomic_state *state, intel_backlight_update(state, encoder, crtc_state, conn_state); drm_connector_update_privacy_screen(conn_state); + + if (crtc_state->seamless_mode_switch) { + struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->uapi.crtc); + + intel_cpu_transcoder_set_m1_n1(intel_crtc, + crtc_state->cpu_transcoder, + &crtc_state->dp_m_n); + } } void intel_ddi_update_pipe(struct intel_atomic_state *state, @@ -3484,6 +3493,7 @@ static void intel_ddi_get_config(struct intel_encoder *encoder, intel_read_dp_sdp(encoder, pipe_config, DP_SDP_VSC); intel_psr_get_config(encoder, pipe_config); + intel_drrs_get_config(encoder, pipe_config); } void intel_ddi_get_clock(struct intel_encoder *encoder, diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c index 17d0cad9e1686..e54fbe3b1d394 100644 --- a/drivers/gpu/drm/i915/display/intel_display.c +++ b/drivers/gpu/drm/i915/display/intel_display.c @@ -2629,6 +2629,44 @@ static void intel_crtc_compute_pixel_rate(struct intel_crtc_state *crtc_state) else crtc_state->pixel_rate = ilk_pipe_pixel_rate(crtc_state); + + /* + * Do not change pixel_rate when doing seamless mode switch, otherwise + * it will change port_clock and other stuff that will need a modeset + * to be programmed + */ + if (crtc_state->seamless_mode_switch) { + struct intel_atomic_state *state = to_intel_atomic_state(crtc_state->uapi.state); + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); + const struct intel_crtc_state *old_crtc_state; + + old_crtc_state = intel_atomic_get_old_crtc_state(state, crtc); + + /* + * It can only seamless switch if pixel rate of the new mode is + * <= than old one, if not commit will fail with pixel_rate + * mismatch. + */ + if (crtc_state->pixel_rate < old_crtc_state->pixel_rate || + intel_fuzzy_clock_check(crtc_state->pixel_rate, + old_crtc_state->pixel_rate)) + crtc_state->pixel_rate = old_crtc_state->pixel_rate; + } +} + +static void intel_crtc_get_pixel_rate(struct intel_crtc_state *crtc_state) +{ + if (crtc_state->seamless_mode_switch) { + struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); + + mutex_lock(&crtc->drrs.mutex); + crtc_state->pixel_rate = crtc->drrs.seamless_mode_switch_pixel_rate; + mutex_unlock(&crtc->drrs.mutex); + + return; + } + + intel_crtc_compute_pixel_rate(crtc_state); } static void intel_bigjoiner_adjust_timings(const struct intel_crtc_state *crtc_state, @@ -2705,7 +2743,7 @@ static void intel_crtc_readout_derived_state(struct intel_crtc_state *crtc_state intel_bigjoiner_adjust_timings(crtc_state, pipe_mode); intel_mode_from_crtc_timings(pipe_mode, pipe_mode); - intel_crtc_compute_pixel_rate(crtc_state); + intel_crtc_get_pixel_rate(crtc_state); } static void intel_encoder_get_config(struct intel_encoder *encoder, @@ -6182,11 +6220,13 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config, PIPE_CONF_CHECK_I(lane_count); PIPE_CONF_CHECK_X(lane_lat_optim_mask); - if (DISPLAY_VER(dev_priv) >= 9 || IS_BROADWELL(dev_priv)) { - PIPE_CONF_CHECK_M_N_ALT(dp_m_n, dp_m2_n2); - } else { - PIPE_CONF_CHECK_M_N(dp_m_n); - PIPE_CONF_CHECK_M_N(dp_m2_n2); + if (!pipe_config->seamless_mode_switch) { + if (DISPLAY_VER(dev_priv) >= 9 || IS_BROADWELL(dev_priv)) { + PIPE_CONF_CHECK_M_N_ALT(dp_m_n, dp_m2_n2); + } else { + PIPE_CONF_CHECK_M_N(dp_m_n); + PIPE_CONF_CHECK_M_N(dp_m2_n2); + } } PIPE_CONF_CHECK_X(output_types); @@ -6348,8 +6388,10 @@ intel_pipe_config_compare(const struct intel_crtc_state *current_config, if (IS_G4X(dev_priv) || DISPLAY_VER(dev_priv) >= 5) PIPE_CONF_CHECK_I(pipe_bpp); - PIPE_CONF_CHECK_CLOCK_FUZZY(hw.pipe_mode.crtc_clock); - PIPE_CONF_CHECK_CLOCK_FUZZY(hw.adjusted_mode.crtc_clock); + if (!pipe_config->seamless_mode_switch) { + PIPE_CONF_CHECK_CLOCK_FUZZY(hw.pipe_mode.crtc_clock); + PIPE_CONF_CHECK_CLOCK_FUZZY(hw.adjusted_mode.crtc_clock); + } PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); PIPE_CONF_CHECK_I(min_voltage_level); @@ -7085,11 +7127,12 @@ static void intel_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_stat * FIXME: should really copy more fuzzy state here */ new_crtc_state->fdi_m_n = old_crtc_state->fdi_m_n; - new_crtc_state->dp_m_n = old_crtc_state->dp_m_n; if (!intel_drrs_crtc_copy_fastset(old_crtc_state, new_crtc_state)) { + new_crtc_state->dp_m_n = old_crtc_state->dp_m_n; new_crtc_state->dp_m2_n2 = old_crtc_state->dp_m2_n2; new_crtc_state->has_drrs = old_crtc_state->has_drrs; + new_crtc_state->seamless_mode_switch = old_crtc_state->seamless_mode_switch; } } diff --git a/drivers/gpu/drm/i915/display/intel_display_debugfs.c b/drivers/gpu/drm/i915/display/intel_display_debugfs.c index 452d773fd4e34..92099e1f0b23e 100644 --- a/drivers/gpu/drm/i915/display/intel_display_debugfs.c +++ b/drivers/gpu/drm/i915/display/intel_display_debugfs.c @@ -1108,6 +1108,9 @@ static int i915_drrs_status(struct seq_file *m, void *unused) crtc->drrs.refresh_rate == DRRS_REFRESH_RATE_LOW ? "low" : "high"); + seq_printf(m, "Seamless mode switch enabled: %s\n", + str_yes_no(crtc->drrs.seamless_mode_switch_pixel_rate)); + mutex_unlock(&crtc->drrs.mutex); } diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 408152f9f46a4..e290366adfc27 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -1057,6 +1057,7 @@ struct intel_crtc_state { /* m2_n2 for eDP downclock */ struct intel_link_m_n dp_m2_n2; bool has_drrs; + bool seamless_mode_switch; /* PSR is supported but might not be enabled due the lack of enabled planes */ bool has_psr; @@ -1314,6 +1315,8 @@ struct intel_crtc { unsigned int busy_frontbuffer_bits; enum transcoder cpu_transcoder; struct intel_link_m_n m_n, m2_n2; + /* Only used to verify if programmed state matches */ + unsigned int seamless_mode_switch_pixel_rate; } drrs; int scanline_offset; diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index cc9be82e128f4..691d362dde95e 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -1844,8 +1844,7 @@ static bool cpu_transcoder_has_drrs(struct drm_i915_private *i915, } static bool can_enable_drrs(struct intel_connector *connector, - const struct intel_crtc_state *pipe_config, - const struct drm_display_mode *downclock_mode) + const struct intel_crtc_state *pipe_config) { struct drm_i915_private *i915 = to_i915(connector->base.dev); @@ -1868,8 +1867,40 @@ static bool can_enable_drrs(struct intel_connector *connector, if (!cpu_transcoder_has_drrs(i915, pipe_config->cpu_transcoder)) return false; - return downclock_mode && - intel_panel_drrs_type(connector) == DRRS_TYPE_SEAMLESS; + return intel_panel_drrs_type(connector) == DRRS_TYPE_SEAMLESS; +} + +static bool can_seamless_switch_mode(struct intel_crtc_state *pipe_config) +{ + struct drm_i915_private *i915 = to_i915(pipe_config->uapi.crtc->dev); + const struct intel_crtc_state *old_pipe_config; + struct intel_atomic_state *state; + struct intel_crtc *intel_crtc; + + /* Only supported in platforms that can switch m_n on the fly */ + if (intel_cpu_transcoder_has_m2_n2(i915, pipe_config->cpu_transcoder)) + return false; + + state = to_intel_atomic_state(pipe_config->uapi.state); + if (state->base.allow_modeset) + return false; + + intel_crtc = to_intel_crtc(pipe_config->uapi.crtc); + old_pipe_config = intel_atomic_get_old_crtc_state(state, intel_crtc); + if (drm_mode_equal(&old_pipe_config->hw.adjusted_mode, + &pipe_config->hw.adjusted_mode)) + return false; + + /* Only clock can change */ + if (!drm_mode_match(&old_pipe_config->hw.adjusted_mode, + &pipe_config->hw.adjusted_mode, + DRM_MODE_MATCH_TIMINGS | + DRM_MODE_MATCH_FLAGS | + DRM_MODE_MATCH_3D_FLAGS | + DRM_MODE_MATCH_ASPECT_RATIO)) + return false; + + return true; } static void @@ -1882,12 +1913,17 @@ intel_dp_drrs_compute_config(struct intel_connector *connector, intel_panel_downclock_mode(connector, &pipe_config->hw.adjusted_mode); int pixel_clock; - if (!can_enable_drrs(connector, pipe_config, downclock_mode)) { - if (intel_cpu_transcoder_has_m2_n2(i915, pipe_config->cpu_transcoder)) - intel_zero_m_n(&pipe_config->dp_m2_n2); + if (!can_enable_drrs(connector, pipe_config)) + goto not_supported; + + if (can_seamless_switch_mode(pipe_config)) { + pipe_config->seamless_mode_switch = true; return; } + if (!downclock_mode) + goto not_supported; + if (IS_IRONLAKE(i915) || IS_SANDYBRIDGE(i915) || IS_IVYBRIDGE(i915)) pipe_config->msa_timing_delay = i915->vbt.edp.drrs_msa_timing_delay; @@ -1904,6 +1940,12 @@ intel_dp_drrs_compute_config(struct intel_connector *connector, /* FIXME: abstract this better */ if (pipe_config->splitter.enable) pipe_config->dp_m2_n2.data_m *= pipe_config->splitter.link_count; + + return; + +not_supported: + if (intel_cpu_transcoder_has_m2_n2(i915, pipe_config->cpu_transcoder)) + intel_zero_m_n(&pipe_config->dp_m2_n2); } static bool intel_dp_has_audio(struct intel_encoder *encoder, diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c b/drivers/gpu/drm/i915/display/intel_drrs.c index d266fad83a086..ffd51d2f5998d 100644 --- a/drivers/gpu/drm/i915/display/intel_drrs.c +++ b/drivers/gpu/drm/i915/display/intel_drrs.c @@ -144,16 +144,19 @@ void intel_drrs_activate(const struct intel_crtc_state *crtc_state) { struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc); + mutex_lock(&crtc->drrs.mutex); + + crtc->drrs.seamless_mode_switch_pixel_rate = crtc_state->seamless_mode_switch ? + crtc_state->pixel_rate : 0; + if (!crtc_state->has_drrs) - return; + goto unlock; if (!crtc_state->hw.active) - return; + goto unlock; if (intel_crtc_is_bigjoiner_slave(crtc_state)) - return; - - mutex_lock(&crtc->drrs.mutex); + goto unlock; crtc->drrs.cpu_transcoder = crtc_state->cpu_transcoder; crtc->drrs.m_n = crtc_state->dp_m_n; @@ -163,6 +166,7 @@ void intel_drrs_activate(const struct intel_crtc_state *crtc_state) intel_drrs_schedule_work(crtc); +unlock: mutex_unlock(&crtc->drrs.mutex); } @@ -176,7 +180,7 @@ void intel_drrs_deactivate(const struct intel_crtc_state *old_crtc_state) { struct intel_crtc *crtc = to_intel_crtc(old_crtc_state->uapi.crtc); - if (!old_crtc_state->has_drrs) + if (!old_crtc_state->has_drrs && !old_crtc_state->seamless_mode_switch) return; if (!old_crtc_state->hw.active) @@ -187,12 +191,14 @@ void intel_drrs_deactivate(const struct intel_crtc_state *old_crtc_state) mutex_lock(&crtc->drrs.mutex); - if (intel_drrs_is_active(crtc)) + if (intel_drrs_is_active(crtc) && + old_crtc_state->seamless_mode_switch == 0) intel_drrs_set_state(crtc, DRRS_REFRESH_RATE_HIGH); crtc->drrs.cpu_transcoder = INVALID_TRANSCODER; crtc->drrs.frontbuffer_bits = 0; crtc->drrs.busy_frontbuffer_bits = 0; + crtc->drrs.seamless_mode_switch_pixel_rate = 0; mutex_unlock(&crtc->drrs.mutex); @@ -322,5 +328,23 @@ bool intel_drrs_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_state, if (intel_cpu_transcoder_has_m2_n2(i915, new_crtc_state->cpu_transcoder)) return false; + if (!new_crtc_state->seamless_mode_switch) + new_crtc_state->dp_m_n = old_crtc_state->dp_m_n; + return true; } + +void intel_drrs_get_config(struct intel_encoder *encoder, + struct intel_crtc_state *pipe_config) +{ + struct intel_crtc *crtc; + + crtc = to_intel_crtc(pipe_config->uapi.crtc); + + mutex_lock(&crtc->drrs.mutex); + + pipe_config->seamless_mode_switch = crtc->drrs.seamless_mode_switch_pixel_rate; + pipe_config->has_drrs = intel_drrs_is_active(crtc); + + mutex_unlock(&crtc->drrs.mutex); +} diff --git a/drivers/gpu/drm/i915/display/intel_drrs.h b/drivers/gpu/drm/i915/display/intel_drrs.h index 749ac717db063..a100023658a5a 100644 --- a/drivers/gpu/drm/i915/display/intel_drrs.h +++ b/drivers/gpu/drm/i915/display/intel_drrs.h @@ -14,6 +14,7 @@ struct intel_atomic_state; struct intel_crtc; struct intel_crtc_state; struct intel_connector; +struct intel_encoder; const char *intel_drrs_type_str(enum drrs_type drrs_type); bool intel_drrs_is_active(struct intel_crtc *crtc); @@ -26,5 +27,7 @@ void intel_drrs_flush(struct drm_i915_private *dev_priv, void intel_crtc_drrs_init(struct intel_crtc *crtc); bool intel_drrs_crtc_copy_fastset(const struct intel_crtc_state *old_crtc_state, struct intel_crtc_state *new_crtc_state); +void intel_drrs_get_config(struct intel_encoder *encoder, + struct intel_crtc_state *pipe_config); #endif /* __INTEL_DRRS_H__ */