From patchwork Fri Sep 13 07:33:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Hogander, Jouni" X-Patchwork-Id: 13803039 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 E9D37FA3723 for ; Fri, 13 Sep 2024 07:34:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 95A9610E8E2; Fri, 13 Sep 2024 07:34:10 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="k8hw+cK0"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 44BA110E8E2 for ; Fri, 13 Sep 2024 07:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726212849; x=1757748849; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oOd3Xob06M3l1wXmapdCkkstP67YPErPNieKU3hsURo=; b=k8hw+cK06qzXwQPJafrQrHEMp+tJugGTtlrZn2jm93erlI2LilDN8hnw jWJTI/DKZhuRVMA0OpxmtyVDGcRi3baIHbQiaA4VUptNbP/Vz8frGKmEL EK+TyVXyrI51Qxy2ETQKI68zYVAUrTycmMhWj44+a00jzJCAHq4KsCV8L xhslBNFeloAKHju63x9WOTCSVD2mK9eJFTmbWguH8OK2ECReKdFt80yeB mZDNJOHuMERuE3Oe2l6He2iciufdPceP5ORMjmuqn2IG89VNIU6irb899 KzjR3y6HwIJL53K3r05fnpn8HG5NTusV5d4s0eGM7lidkBVm2BulWVM3y Q==; X-CSE-ConnectionGUID: 6m4ydndtSbWCE9+qK1rwhA== X-CSE-MsgGUID: vmNe49GKQVWvZ66vsH3kVQ== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24644228" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24644228" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2024 00:34:09 -0700 X-CSE-ConnectionGUID: TvLj9oqJSNOQrkAO3Zl12A== X-CSE-MsgGUID: YWaJ4GmBRwiYqsBaLwk3fw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="72745195" Received: from dneilan-mobl1.ger.corp.intel.com (HELO jhogande-mobl1..) ([10.245.245.104]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2024 00:34:08 -0700 From: =?utf-8?q?Jouni_H=C3=B6gander?= To: intel-gfx@lists.freedesktop.org Cc: ville.syrjala@linux.intel.com, =?utf-8?q?Jouni_H=C3=B6gander?= Subject: [PATCH 1/2] drm/i915/display: Add block_dc6_needed variable into intel_crtc Date: Fri, 13 Sep 2024 10:33:46 +0300 Message-Id: <20240913073347.3273589-2-jouni.hogander@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913073347.3273589-1-jouni.hogander@intel.com> References: <20240913073347.3273589-1-jouni.hogander@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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" We need to block DC6 entry in case of Panel Replay as enabling VBI doesn't prevent DC6 in case of Panel Replay. This causes problems if user-space is polling for vblank events. For this purpose add new block_dc6_needed variable into intel_crtc. Signed-off-by: Jouni Högander --- .../gpu/drm/i915/display/intel_display_irq.c | 28 +++++++++++++++++++ .../gpu/drm/i915/display/intel_display_irq.h | 3 ++ .../drm/i915/display/intel_display_types.h | 7 +++++ drivers/gpu/drm/i915/display/intel_psr.c | 7 +++++ 4 files changed, 45 insertions(+) diff --git a/drivers/gpu/drm/i915/display/intel_display_irq.c b/drivers/gpu/drm/i915/display/intel_display_irq.c index 8f13f148c73e3..7ff721bcec0d3 100644 --- a/drivers/gpu/drm/i915/display/intel_display_irq.c +++ b/drivers/gpu/drm/i915/display/intel_display_irq.c @@ -1361,6 +1361,34 @@ static bool gen11_dsi_configure_te(struct intel_crtc *intel_crtc, return true; } +/** + * block_dc6_on_vblank_get - get block DC6 entry reference + * + * @_crtc: drm crtc pointer + * + * This function is called from Panel Replay code when Panel Replay gets + * activated. Intention is to block DC6 entry when VBI is enabled and Panel + * Replay is active. + */ +void block_dc6_on_vblank_get(struct drm_crtc *_crtc) +{ + to_intel_crtc(_crtc)->block_dc6_needed++; +} + +/** + * block_dc6_on_vblank_put - free block DC6 entry reference + * + * @crtc: drm crtc pointer + * + * This function is called from Panel Replay code when Panel Replay is + * deactivated. Intention is to block DC6 entry when VBI is enabled and Panel + * Replay is active. + */ +void block_dc6_on_vblank_put(struct drm_crtc *crtc) +{ + to_intel_crtc(crtc)->block_dc6_needed--; +} + int bdw_enable_vblank(struct drm_crtc *_crtc) { struct intel_crtc *crtc = to_intel_crtc(_crtc); diff --git a/drivers/gpu/drm/i915/display/intel_display_irq.h b/drivers/gpu/drm/i915/display/intel_display_irq.h index 2a090dd6abd7c..fe3ada8f37283 100644 --- a/drivers/gpu/drm/i915/display/intel_display_irq.h +++ b/drivers/gpu/drm/i915/display/intel_display_irq.h @@ -77,6 +77,9 @@ void i965_pipestat_irq_handler(struct drm_i915_private *i915, u32 iir, u32 pipe_ void valleyview_pipestat_irq_handler(struct drm_i915_private *i915, u32 pipe_stats[I915_MAX_PIPES]); void i8xx_pipestat_irq_handler(struct drm_i915_private *i915, u16 iir, u32 pipe_stats[I915_MAX_PIPES]); +void block_dc6_on_vblank_get(struct drm_crtc *crtc); +void block_dc6_on_vblank_put(struct drm_crtc *crtc); + void intel_display_irq_init(struct drm_i915_private *i915); #endif /* __INTEL_DISPLAY_IRQ_H__ */ diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h index 000ab373c8879..df0c3eb750809 100644 --- a/drivers/gpu/drm/i915/display/intel_display_types.h +++ b/drivers/gpu/drm/i915/display/intel_display_types.h @@ -1413,6 +1413,13 @@ struct intel_crtc { #ifdef CONFIG_DEBUG_FS struct intel_pipe_crc pipe_crc; #endif + + /* + * We need to block DC6 entry in case of Panel Replay as enabling VBI doesn't + * prevent DC6 in case of Panel Replay. This causes problems if user-space is + * polling for vblank events. + */ + u8 block_dc6_needed; }; struct intel_plane { diff --git a/drivers/gpu/drm/i915/display/intel_psr.c b/drivers/gpu/drm/i915/display/intel_psr.c index 1a4ef231a53ca..f9e5177893c46 100644 --- a/drivers/gpu/drm/i915/display/intel_psr.c +++ b/drivers/gpu/drm/i915/display/intel_psr.c @@ -35,6 +35,7 @@ #include "intel_cursor_regs.h" #include "intel_ddi.h" #include "intel_de.h" +#include "intel_display_irq.h" #include "intel_display_types.h" #include "intel_dp.h" #include "intel_dp_aux.h" @@ -970,6 +971,9 @@ static void dg2_activate_panel_replay(struct intel_dp *intel_dp) val); } + if (intel_dp_is_edp(intel_dp)) + block_dc6_on_vblank_get(&intel_crtc_for_pipe(display, intel_dp->psr.pipe)->base); + intel_de_rmw(display, PSR2_MAN_TRK_CTL(display, intel_dp->psr.transcoder), 0, ADLP_PSR2_MAN_TRK_CTL_SF_CONTINUOS_FULL_FRAME); @@ -2005,6 +2009,9 @@ static void intel_psr_exit(struct intel_dp *intel_dp) } if (intel_dp->psr.panel_replay_enabled) { + if (intel_dp_is_edp(intel_dp)) + block_dc6_on_vblank_put(drm_crtc_from_index(display->drm, + intel_dp->psr.pipe)); intel_de_rmw(display, TRANS_DP2_CTL(intel_dp->psr.transcoder), TRANS_DP2_PANEL_REPLAY_ENABLE, 0); } else if (intel_dp->psr.sel_update_enabled) { From patchwork Fri Sep 13 07:33:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Hogander, Jouni" X-Patchwork-Id: 13803040 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 EB9BFEEE245 for ; Fri, 13 Sep 2024 07:34:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 911A310E9CA; Fri, 13 Sep 2024 07:34:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="dDEYYAVa"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id B9E2810E9CA for ; Fri, 13 Sep 2024 07:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726212852; x=1757748852; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3nhNOS9wiwv/lrTBlnOKyuR4z+aqZr9ErgKf+w+VUh0=; b=dDEYYAVatlp3yrxZvxe+d4v6MlhTzgrGnaEEiKGe59FtnB3aiUyMmkCP rDkSUD/TOvVDjPeKCP3HZPdXc4Ey1/gO0s/ADCX2WatdrH6rltSN7L3cD fxby1MvibfapVo51zgUOLeZHiNjXyxlJlvuc3dUq5lq4lYNIvY4u5bxyI RWNegvqgYt9NiVU/eLhyKpa4khNKJcptUaWJ0Q1QpmEYEfV8STDgdLF6J KgeZM825k+h2cyigCk7ezS/8xi7RiWGxND82VkXqI+2r3xj77H75PuS3S JIgL2L+a5L8NlS7alTDIJsre4V25UJIdnuG9RgP+3bqt1+zxP+/ALMugy w==; X-CSE-ConnectionGUID: fbqXfDrQQci1RKrVZeuUQA== X-CSE-MsgGUID: ADeXZfBoQPWz83RQOZ2n9g== X-IronPort-AV: E=McAfee;i="6700,10204,11193"; a="24644233" X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="24644233" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2024 00:34:11 -0700 X-CSE-ConnectionGUID: Mfmrl1B7QNecCgFnTJ/gqA== X-CSE-MsgGUID: 0Eg83sFRRmK2xOeQpbLGOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,225,1719903600"; d="scan'208";a="72745200" Received: from dneilan-mobl1.ger.corp.intel.com (HELO jhogande-mobl1..) ([10.245.245.104]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2024 00:34:11 -0700 From: =?utf-8?q?Jouni_H=C3=B6gander?= To: intel-gfx@lists.freedesktop.org Cc: ville.syrjala@linux.intel.com, =?utf-8?q?Jouni_H=C3=B6gander?= Subject: [PATCH 2/2] drm/i915/display: Prevent DC6 while vblank is enabled for Panel Replay Date: Fri, 13 Sep 2024 10:33:47 +0300 Message-Id: <20240913073347.3273589-3-jouni.hogander@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240913073347.3273589-1-jouni.hogander@intel.com> References: <20240913073347.3273589-1-jouni.hogander@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo 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" We need to block DC6 entry in case of Panel Replay as enabling VBI doesn't prevent DC6 in case of Panel Replay. This causes problems if user-space is polling for vblank events. Fix this by setting target DC state as DC_STATE_EN_UPTO_DC5 when both source and sink are supporting eDP Panel Replay and VBI is enabled. v2: - use READ_ONCE in intel_display_vblank_work - use DC_STATE_DISABLE instead of DC_STATE_EN_UPTO_DC6 - use intel_crtc->block_dc6_needed Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2296 Signed-off-by: Jouni Högander --- .../gpu/drm/i915/display/intel_display_core.h | 2 ++ .../gpu/drm/i915/display/intel_display_irq.c | 34 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_display_core.h b/drivers/gpu/drm/i915/display/intel_display_core.h index 0a711114ff2b4..0707bc2047931 100644 --- a/drivers/gpu/drm/i915/display/intel_display_core.h +++ b/drivers/gpu/drm/i915/display/intel_display_core.h @@ -457,6 +457,8 @@ struct intel_display { /* For i915gm/i945gm vblank irq workaround */ u8 vblank_enabled; + struct work_struct vblank_work; + u32 de_irq_mask[I915_MAX_PIPES]; u32 pipestat_irq_mask[I915_MAX_PIPES]; } irq; diff --git a/drivers/gpu/drm/i915/display/intel_display_irq.c b/drivers/gpu/drm/i915/display/intel_display_irq.c index 7ff721bcec0d3..7adcde5874601 100644 --- a/drivers/gpu/drm/i915/display/intel_display_irq.c +++ b/drivers/gpu/drm/i915/display/intel_display_irq.c @@ -1372,7 +1372,11 @@ static bool gen11_dsi_configure_te(struct intel_crtc *intel_crtc, */ void block_dc6_on_vblank_get(struct drm_crtc *_crtc) { - to_intel_crtc(_crtc)->block_dc6_needed++; + struct intel_crtc *crtc = to_intel_crtc(_crtc); + struct intel_display *display = to_intel_display(crtc); + + if (crtc->block_dc6_needed++ == 0) + schedule_work(&display->irq.vblank_work); } /** @@ -1389,16 +1393,38 @@ void block_dc6_on_vblank_put(struct drm_crtc *crtc) to_intel_crtc(crtc)->block_dc6_needed--; } +static void intel_display_vblank_work(struct work_struct *work) +{ + struct intel_display *display = + container_of(work, typeof(*display), irq.vblank_work); + struct drm_i915_private *i915 = to_i915(display->drm); + u8 vblank_enabled = READ_ONCE(display->irq.vblank_enabled); + + /* + * NOTE: intel_display_power_set_target_dc_state is used only by PSR + * code for DC3CO handling. DC3CO target state is currently disabled in + * PSR code. If DC3CO is taken into use we need take that into account + * here as well. + */ + intel_display_power_set_target_dc_state(i915, vblank_enabled ? DC_STATE_DISABLE : + DC_STATE_EN_UPTO_DC6); +} + int bdw_enable_vblank(struct drm_crtc *_crtc) { struct intel_crtc *crtc = to_intel_crtc(_crtc); + struct intel_display *display = to_intel_display(crtc); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); enum pipe pipe = crtc->pipe; unsigned long irqflags; + u8 block_dc6_needed = READ_ONCE(crtc->block_dc6_needed); if (gen11_dsi_configure_te(crtc, true)) return 0; + if (display->irq.vblank_enabled++ == 0 && block_dc6_needed) + schedule_work(&display->irq.vblank_work); + spin_lock_irqsave(&dev_priv->irq_lock, irqflags); bdw_enable_pipe_irq(dev_priv, pipe, GEN8_PIPE_VBLANK); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); @@ -1464,6 +1490,7 @@ void ilk_disable_vblank(struct drm_crtc *crtc) void bdw_disable_vblank(struct drm_crtc *_crtc) { struct intel_crtc *crtc = to_intel_crtc(_crtc); + struct intel_display *display = to_intel_display(crtc); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); enum pipe pipe = crtc->pipe; unsigned long irqflags; @@ -1474,6 +1501,9 @@ void bdw_disable_vblank(struct drm_crtc *_crtc) spin_lock_irqsave(&dev_priv->irq_lock, irqflags); bdw_disable_pipe_irq(dev_priv, pipe, GEN8_PIPE_VBLANK); spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); + + if (--display->irq.vblank_enabled == 0) + schedule_work(&display->irq.vblank_work); } void vlv_display_irq_reset(struct drm_i915_private *dev_priv) @@ -1899,4 +1929,6 @@ void intel_display_irq_init(struct drm_i915_private *i915) i915->display.irq.display_irqs_enabled = false; intel_hotplug_irq_init(i915); + + INIT_WORK(&i915->display.irq.vblank_work, intel_display_vblank_work); }