All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports
@ 2018-11-27 16:36 Imre Deak
  2018-11-27 17:25 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Imre Deak @ 2018-11-27 16:36 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula

The requirement for the DDI port clock gating for a port in DSI mode is
the opposite wrt. the case when the port is in DDI mode: the clock
should be gated when the port is active and ungated when the port is
inactive. Note that we cannot simply keep the DDI clock gated when the
port will be only used in DSI mode: it must be gated/ungated at a
specific spot in the DSI enable/disable sequence.

Ensure the above for all ports of a DSI encoder, also adding a sanity
check that we haven't registered another encoder using the same port
(VBT should never allow this to happen).

Cc: Madhav Chauhan <madhav.chauhan@intel.com>
Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Clint Taylor <clinton.a.taylor@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 65 +++++++++++++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_dsi.h |  5 ++++
 2 files changed, 53 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index ad11540ac436..6d032a6be16c 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -28,6 +28,7 @@
 #include <drm/drm_scdc_helper.h>
 #include "i915_drv.h"
 #include "intel_drv.h"
+#include "intel_dsi.h"
 
 struct ddi_buf_trans {
 	u32 trans1;	/* balance leg enable, de-emph level */
@@ -2854,8 +2855,9 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
 {
 	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
 	u32 val;
-	enum port port = encoder->port;
-	bool clk_enabled;
+	enum port port;
+	u32 port_mask;
+	bool ddi_clk_needed;
 
 	/*
 	 * In case of DP MST, we sanitize the primary encoder only, not the
@@ -2864,9 +2866,6 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
 	if (encoder->type == INTEL_OUTPUT_DP_MST)
 		return;
 
-	val = I915_READ(DPCLKA_CFGCR0_ICL);
-	clk_enabled = !(val & icl_dpclka_cfgcr0_clk_off(dev_priv, port));
-
 	if (!encoder->base.crtc && intel_encoder_is_dp(encoder)) {
 		u8 pipe_mask;
 		bool is_mst;
@@ -2880,20 +2879,52 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
 			return;
 	}
 
-	if (clk_enabled == !!encoder->base.crtc)
-		return;
+	port_mask = BIT(encoder->port);
+	ddi_clk_needed = encoder->base.crtc;
 
-	/*
-	 * Punt on the case now where clock is disabled, but the encoder is
-	 * enabled, something else is really broken then.
-	 */
-	if (WARN_ON(!clk_enabled))
-		return;
+	if (encoder->type == INTEL_OUTPUT_DSI) {
+		struct intel_encoder *other_encoder;
 
-	DRM_NOTE("Port %c is disabled but it has a mapped PLL, unmap it\n",
-		 port_name(port));
-	val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
-	I915_WRITE(DPCLKA_CFGCR0_ICL, val);
+		port_mask = intel_dsi_encoder_ports(encoder);
+		/*
+		 * Sanity check that we haven't incorrectly registered another
+		 * encoder using any of the ports of this DSI encoder.
+		 */
+		for_each_intel_encoder(&dev_priv->drm, other_encoder) {
+			if (other_encoder == encoder)
+				continue;
+
+			if (WARN_ON(port_mask & BIT(other_encoder->port)))
+				return;
+		}
+		/*
+		 * DSI ports should have their DDI clock ungated when disabled
+		 * and gated when enabled.
+		 */
+		ddi_clk_needed = !encoder->base.crtc;
+	}
+
+	val = I915_READ(DPCLKA_CFGCR0_ICL);
+	for_each_port_masked(port, port_mask) {
+		bool ddi_clk_ungated = !(val &
+					 icl_dpclka_cfgcr0_clk_off(dev_priv,
+								   port));
+
+		if (ddi_clk_needed == ddi_clk_ungated)
+			continue;
+
+		/*
+		 * Punt on the case now where clock is gated, but it would
+		 * be needed by the port. Something else is really broken then.
+		 */
+		if (WARN_ON(ddi_clk_needed))
+			continue;
+
+		DRM_NOTE("Port %c is disabled/in DSI mode with an ungated DDI clock, gate it\n",
+			 port_name(port));
+		val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
+		I915_WRITE(DPCLKA_CFGCR0_ICL, val);
+	}
 }
 
 static void intel_ddi_clk_select(struct intel_encoder *encoder,
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index ee93137f4433..d968f1f13e09 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -146,6 +146,11 @@ static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
 	return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
 }
 
+static inline u16 intel_dsi_encoder_ports(struct intel_encoder *encoder)
+{
+	return enc_to_intel_dsi(&encoder->base)->ports;
+}
+
 /* intel_dsi.c */
 int intel_dsi_bitrate(const struct intel_dsi *intel_dsi);
 int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi);
-- 
2.13.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* ✓ Fi.CI.BAT: success for drm/i915/icl: Sanitize DDI port clock gating for DSI ports
  2018-11-27 16:36 [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports Imre Deak
@ 2018-11-27 17:25 ` Patchwork
  2018-11-27 22:02 ` ✓ Fi.CI.IGT: " Patchwork
  2018-11-29 14:05 ` [PATCH] " Jani Nikula
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2018-11-27 17:25 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/icl: Sanitize DDI port clock gating for DSI ports
URL   : https://patchwork.freedesktop.org/series/53093/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_5211 -> Patchwork_10914 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/53093/revisions/1/mbox/

== Known issues ==

  Here are the changes found in Patchwork_10914 that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_ctx_create@basic-files:
      fi-bsw-n3050:       PASS -> FAIL (fdo#108656)

    igt@i915_selftest@live_execlists:
      fi-apl-guc:         PASS -> INCOMPLETE (fdo#103927, fdo#108622)

    igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
      fi-byt-clapper:     PASS -> FAIL (fdo#103191, fdo#107362)

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-blb-e6850:       PASS -> INCOMPLETE (fdo#107718)

    
    ==== Possible fixes ====

    igt@i915_selftest@live_hangcheck:
      fi-cfl-8109u:       INCOMPLETE (fdo#106070) -> PASS

    igt@kms_frontbuffer_tracking@basic:
      fi-hsw-peppy:       DMESG-WARN (fdo#102614) -> PASS

    igt@kms_pipe_crc_basic@read-crc-pipe-a:
      fi-byt-clapper:     FAIL (fdo#107362) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
      fi-byt-clapper:     FAIL (fdo#103191, fdo#107362) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cfl-8109u:       DMESG-WARN (fdo#106107) -> PASS

    
  fdo#102614 https://bugs.freedesktop.org/show_bug.cgi?id=102614
  fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#106070 https://bugs.freedesktop.org/show_bug.cgi?id=106070
  fdo#106107 https://bugs.freedesktop.org/show_bug.cgi?id=106107
  fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
  fdo#107718 https://bugs.freedesktop.org/show_bug.cgi?id=107718
  fdo#108622 https://bugs.freedesktop.org/show_bug.cgi?id=108622
  fdo#108656 https://bugs.freedesktop.org/show_bug.cgi?id=108656


== Participating hosts (51 -> 45) ==

  Missing    (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-pnv-d510 


== Build changes ==

    * Linux: CI_DRM_5211 -> Patchwork_10914

  CI_DRM_5211: b6ba4ad91b7c6c4341c40a05b0326470e0c293cb @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4732: eae5c3587e56abc581af9b59060cd316df2caa08 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10914: 5819a00cb00ab2a888cbb96225bcf8e09c21f268 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

5819a00cb00a drm/i915/icl: Sanitize DDI port clock gating for DSI ports

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10914/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* ✓ Fi.CI.IGT: success for drm/i915/icl: Sanitize DDI port clock gating for DSI ports
  2018-11-27 16:36 [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports Imre Deak
  2018-11-27 17:25 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-11-27 22:02 ` Patchwork
  2018-11-29 14:05 ` [PATCH] " Jani Nikula
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2018-11-27 22:02 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/icl: Sanitize DDI port clock gating for DSI ports
URL   : https://patchwork.freedesktop.org/series/53093/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_5211_full -> Patchwork_10914_full =

== Summary - WARNING ==

  Minor unknown changes coming with Patchwork_10914_full need to be verified
  manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_10914_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

== Possible new issues ==

  Here are the unknown changes that may have been introduced in Patchwork_10914_full:

  === IGT changes ===

    ==== Warnings ====

    igt@kms_chv_cursor_fail@pipe-b-64x64-top-edge:
      shard-snb:          SKIP -> PASS

    igt@kms_frontbuffer_tracking@fbc-rgb565-draw-blt:
      shard-snb:          PASS -> SKIP +2

    igt@pm_rc6_residency@rc6-accuracy:
      shard-kbl:          SKIP -> PASS

    
== Known issues ==

  Here are the changes found in Patchwork_10914_full that come from known issues:

  === IGT changes ===

    ==== Issues hit ====

    igt@gem_ctx_isolation@vcs0-clean:
      shard-apl:          PASS -> INCOMPLETE ([fdo#103927])

    igt@gem_exec_schedule@pi-ringfull-blt:
      shard-skl:          NOTRUN -> FAIL ([fdo#103158])

    igt@gem_exec_schedule@pi-ringfull-vebox:
      {shard-iclb}:       NOTRUN -> FAIL ([fdo#103158])

    igt@gem_exec_suspend@basic-s3:
      shard-kbl:          PASS -> INCOMPLETE ([fdo#103665])

    igt@gem_ppgtt@blt-vs-render-ctxn:
      shard-skl:          PASS -> TIMEOUT ([fdo#108039])

    igt@gem_pwrite@stolen-uncached:
      shard-snb:          SKIP -> INCOMPLETE ([fdo#105411])

    igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-c:
      shard-skl:          NOTRUN -> DMESG-WARN ([fdo#107956])

    igt@kms_color@pipe-a-degamma:
      shard-skl:          PASS -> FAIL ([fdo#104782], [fdo#108145])

    igt@kms_cursor_crc@cursor-128x128-random:
      shard-apl:          PASS -> FAIL ([fdo#103232])

    igt@kms_cursor_crc@cursor-128x42-sliding:
      shard-glk:          PASS -> FAIL ([fdo#103232])

    igt@kms_cursor_crc@cursor-64x21-random:
      {shard-iclb}:       NOTRUN -> FAIL ([fdo#103232])

    igt@kms_draw_crc@draw-method-xrgb2101010-render-untiled:
      shard-skl:          PASS -> FAIL ([fdo#103184])

    igt@kms_flip@2x-flip-vs-expired-vblank:
      shard-hsw:          PASS -> FAIL ([fdo#102887])

    igt@kms_flip_tiling@flip-yf-tiled:
      shard-skl:          PASS -> FAIL ([fdo#108145])

    igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-render:
      shard-skl:          NOTRUN -> FAIL ([fdo#103167]) +2

    igt@kms_frontbuffer_tracking@psr-1p-primscrn-spr-indfb-draw-mmap-gtt:
      {shard-iclb}:       PASS -> FAIL ([fdo#103167]) +4

    igt@kms_plane@pixel-format-pipe-b-planes:
      shard-apl:          PASS -> FAIL ([fdo#103166]) +1

    igt@kms_plane@plane-position-covered-pipe-c-planes:
      {shard-iclb}:       NOTRUN -> FAIL ([fdo#103166])

    igt@kms_plane_alpha_blend@pipe-a-alpha-transparant-fb:
      shard-skl:          NOTRUN -> FAIL ([fdo#108145])

    igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
      shard-skl:          PASS -> FAIL ([fdo#107815])

    igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
      {shard-iclb}:       PASS -> FAIL ([fdo#103166]) +3

    igt@kms_plane_multiple@atomic-pipe-b-tiling-x:
      shard-glk:          PASS -> FAIL ([fdo#103166]) +1

    igt@kms_rmfb@rmfb-ioctl:
      shard-kbl:          PASS -> DMESG-WARN ([fdo#103558], [fdo#105602]) +20

    igt@pm_rpm@gem-execbuf:
      shard-skl:          PASS -> INCOMPLETE ([fdo#107803], [fdo#107807])

    igt@pm_rpm@gem-mmap-cpu:
      shard-skl:          PASS -> INCOMPLETE ([fdo#107807])

    igt@pm_rpm@system-suspend-modeset:
      shard-skl:          PASS -> INCOMPLETE ([fdo#104108], [fdo#107807])

    
    ==== Possible fixes ====

    igt@kms_busy@extended-pageflip-hang-newfb-render-b:
      shard-apl:          DMESG-WARN ([fdo#107956]) -> PASS

    igt@kms_color@pipe-a-legacy-gamma:
      shard-skl:          FAIL ([fdo#104782], [fdo#108145]) -> PASS

    igt@kms_cursor_legacy@cursora-vs-flipa-toggle:
      shard-glk:          DMESG-WARN ([fdo#105763], [fdo#106538]) -> PASS

    igt@kms_draw_crc@draw-method-rgb565-mmap-gtt-xtiled:
      shard-glk:          FAIL ([fdo#103184]) -> PASS

    igt@kms_flip@flip-vs-expired-vblank-interruptible:
      shard-apl:          FAIL ([fdo#102887], [fdo#105363]) -> PASS

    igt@kms_frontbuffer_tracking@psr-1p-primscrn-spr-indfb-draw-blt:
      {shard-iclb}:       FAIL ([fdo#103167]) -> PASS +5

    igt@kms_plane_multiple@atomic-pipe-a-tiling-yf:
      {shard-iclb}:       FAIL ([fdo#103166]) -> PASS

    igt@kms_setmode@basic:
      shard-apl:          FAIL ([fdo#99912]) -> PASS

    igt@pm_rpm@fences-dpms:
      shard-skl:          INCOMPLETE ([fdo#107807]) -> PASS +2

    
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
  fdo#103158 https://bugs.freedesktop.org/show_bug.cgi?id=103158
  fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103184 https://bugs.freedesktop.org/show_bug.cgi?id=103184
  fdo#103232 https://bugs.freedesktop.org/show_bug.cgi?id=103232
  fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
  fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
  fdo#104782 https://bugs.freedesktop.org/show_bug.cgi?id=104782
  fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
  fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
  fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
  fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
  fdo#106538 https://bugs.freedesktop.org/show_bug.cgi?id=106538
  fdo#107803 https://bugs.freedesktop.org/show_bug.cgi?id=107803
  fdo#107807 https://bugs.freedesktop.org/show_bug.cgi?id=107807
  fdo#107815 https://bugs.freedesktop.org/show_bug.cgi?id=107815
  fdo#107956 https://bugs.freedesktop.org/show_bug.cgi?id=107956
  fdo#108039 https://bugs.freedesktop.org/show_bug.cgi?id=108039
  fdo#108145 https://bugs.freedesktop.org/show_bug.cgi?id=108145
  fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912


== Participating hosts (7 -> 7) ==

  No changes in participating hosts


== Build changes ==

    * Linux: CI_DRM_5211 -> Patchwork_10914

  CI_DRM_5211: b6ba4ad91b7c6c4341c40a05b0326470e0c293cb @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4732: eae5c3587e56abc581af9b59060cd316df2caa08 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_10914: 5819a00cb00ab2a888cbb96225bcf8e09c21f268 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10914/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports
  2018-11-27 16:36 [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports Imre Deak
  2018-11-27 17:25 ` ✓ Fi.CI.BAT: success for " Patchwork
  2018-11-27 22:02 ` ✓ Fi.CI.IGT: " Patchwork
@ 2018-11-29 14:05 ` Jani Nikula
  2018-12-03 14:10   ` Jani Nikula
  2 siblings, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2018-11-29 14:05 UTC (permalink / raw)
  To: Imre Deak, intel-gfx

On Tue, 27 Nov 2018, Imre Deak <imre.deak@intel.com> wrote:
> The requirement for the DDI port clock gating for a port in DSI mode is
> the opposite wrt. the case when the port is in DDI mode: the clock
> should be gated when the port is active and ungated when the port is
> inactive. Note that we cannot simply keep the DDI clock gated when the
> port will be only used in DSI mode: it must be gated/ungated at a
> specific spot in the DSI enable/disable sequence.
>
> Ensure the above for all ports of a DSI encoder, also adding a sanity
> check that we haven't registered another encoder using the same port
> (VBT should never allow this to happen).
>
> Cc: Madhav Chauhan <madhav.chauhan@intel.com>
> Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Clint Taylor <clinton.a.taylor@intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_ddi.c | 65 +++++++++++++++++++++++++++++-----------
>  drivers/gpu/drm/i915/intel_dsi.h |  5 ++++
>  2 files changed, 53 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index ad11540ac436..6d032a6be16c 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -28,6 +28,7 @@
>  #include <drm/drm_scdc_helper.h>
>  #include "i915_drv.h"
>  #include "intel_drv.h"
> +#include "intel_dsi.h"
>  
>  struct ddi_buf_trans {
>  	u32 trans1;	/* balance leg enable, de-emph level */
> @@ -2854,8 +2855,9 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>  	u32 val;
> -	enum port port = encoder->port;
> -	bool clk_enabled;
> +	enum port port;
> +	u32 port_mask;
> +	bool ddi_clk_needed;
>  
>  	/*
>  	 * In case of DP MST, we sanitize the primary encoder only, not the
> @@ -2864,9 +2866,6 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
>  	if (encoder->type == INTEL_OUTPUT_DP_MST)
>  		return;
>  
> -	val = I915_READ(DPCLKA_CFGCR0_ICL);
> -	clk_enabled = !(val & icl_dpclka_cfgcr0_clk_off(dev_priv, port));
> -
>  	if (!encoder->base.crtc && intel_encoder_is_dp(encoder)) {
>  		u8 pipe_mask;
>  		bool is_mst;
> @@ -2880,20 +2879,52 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
>  			return;
>  	}
>  
> -	if (clk_enabled == !!encoder->base.crtc)
> -		return;
> +	port_mask = BIT(encoder->port);
> +	ddi_clk_needed = encoder->base.crtc;
>  
> -	/*
> -	 * Punt on the case now where clock is disabled, but the encoder is
> -	 * enabled, something else is really broken then.
> -	 */
> -	if (WARN_ON(!clk_enabled))
> -		return;
> +	if (encoder->type == INTEL_OUTPUT_DSI) {
> +		struct intel_encoder *other_encoder;
>  
> -	DRM_NOTE("Port %c is disabled but it has a mapped PLL, unmap it\n",
> -		 port_name(port));
> -	val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
> -	I915_WRITE(DPCLKA_CFGCR0_ICL, val);
> +		port_mask = intel_dsi_encoder_ports(encoder);
> +		/*
> +		 * Sanity check that we haven't incorrectly registered another
> +		 * encoder using any of the ports of this DSI encoder.
> +		 */
> +		for_each_intel_encoder(&dev_priv->drm, other_encoder) {
> +			if (other_encoder == encoder)
> +				continue;
> +
> +			if (WARN_ON(port_mask & BIT(other_encoder->port)))
> +				return;
> +		}
> +		/*
> +		 * DSI ports should have their DDI clock ungated when disabled
> +		 * and gated when enabled.
> +		 */
> +		ddi_clk_needed = !encoder->base.crtc;
> +	}
> +
> +	val = I915_READ(DPCLKA_CFGCR0_ICL);
> +	for_each_port_masked(port, port_mask) {
> +		bool ddi_clk_ungated = !(val &
> +					 icl_dpclka_cfgcr0_clk_off(dev_priv,
> +								   port));
> +
> +		if (ddi_clk_needed == ddi_clk_ungated)
> +			continue;
> +
> +		/*
> +		 * Punt on the case now where clock is gated, but it would
> +		 * be needed by the port. Something else is really broken then.
> +		 */
> +		if (WARN_ON(ddi_clk_needed))
> +			continue;
> +
> +		DRM_NOTE("Port %c is disabled/in DSI mode with an ungated DDI clock, gate it\n",
> +			 port_name(port));
> +		val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
> +		I915_WRITE(DPCLKA_CFGCR0_ICL, val);
> +	}
>  }
>  
>  static void intel_ddi_clk_select(struct intel_encoder *encoder,
> diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
> index ee93137f4433..d968f1f13e09 100644
> --- a/drivers/gpu/drm/i915/intel_dsi.h
> +++ b/drivers/gpu/drm/i915/intel_dsi.h
> @@ -146,6 +146,11 @@ static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
>  	return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
>  }
>  
> +static inline u16 intel_dsi_encoder_ports(struct intel_encoder *encoder)
> +{
> +	return enc_to_intel_dsi(&encoder->base)->ports;
> +}
> +
>  /* intel_dsi.c */
>  int intel_dsi_bitrate(const struct intel_dsi *intel_dsi);
>  int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi);

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports
  2018-11-29 14:05 ` [PATCH] " Jani Nikula
@ 2018-12-03 14:10   ` Jani Nikula
  0 siblings, 0 replies; 5+ messages in thread
From: Jani Nikula @ 2018-12-03 14:10 UTC (permalink / raw)
  To: Imre Deak, intel-gfx

On Thu, 29 Nov 2018, Jani Nikula <jani.nikula@intel.com> wrote:
> On Tue, 27 Nov 2018, Imre Deak <imre.deak@intel.com> wrote:
>> The requirement for the DDI port clock gating for a port in DSI mode is
>> the opposite wrt. the case when the port is in DDI mode: the clock
>> should be gated when the port is active and ungated when the port is
>> inactive. Note that we cannot simply keep the DDI clock gated when the
>> port will be only used in DSI mode: it must be gated/ungated at a
>> specific spot in the DSI enable/disable sequence.
>>
>> Ensure the above for all ports of a DSI encoder, also adding a sanity
>> check that we haven't registered another encoder using the same port
>> (VBT should never allow this to happen).
>>
>> Cc: Madhav Chauhan <madhav.chauhan@intel.com>
>> Cc: Vandita Kulkarni <vandita.kulkarni@intel.com>
>> Cc: Jani Nikula <jani.nikula@intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Cc: Clint Taylor <clinton.a.taylor@intel.com>
>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Thanks for the patch, pushed to dinq as part of [1].

BR,
Jani.


[1] https://patchwork.freedesktop.org/series/51011/


>
>> ---
>>  drivers/gpu/drm/i915/intel_ddi.c | 65 +++++++++++++++++++++++++++++-----------
>>  drivers/gpu/drm/i915/intel_dsi.h |  5 ++++
>>  2 files changed, 53 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
>> index ad11540ac436..6d032a6be16c 100644
>> --- a/drivers/gpu/drm/i915/intel_ddi.c
>> +++ b/drivers/gpu/drm/i915/intel_ddi.c
>> @@ -28,6 +28,7 @@
>>  #include <drm/drm_scdc_helper.h>
>>  #include "i915_drv.h"
>>  #include "intel_drv.h"
>> +#include "intel_dsi.h"
>>  
>>  struct ddi_buf_trans {
>>  	u32 trans1;	/* balance leg enable, de-emph level */
>> @@ -2854,8 +2855,9 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
>>  {
>>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>>  	u32 val;
>> -	enum port port = encoder->port;
>> -	bool clk_enabled;
>> +	enum port port;
>> +	u32 port_mask;
>> +	bool ddi_clk_needed;
>>  
>>  	/*
>>  	 * In case of DP MST, we sanitize the primary encoder only, not the
>> @@ -2864,9 +2866,6 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
>>  	if (encoder->type == INTEL_OUTPUT_DP_MST)
>>  		return;
>>  
>> -	val = I915_READ(DPCLKA_CFGCR0_ICL);
>> -	clk_enabled = !(val & icl_dpclka_cfgcr0_clk_off(dev_priv, port));
>> -
>>  	if (!encoder->base.crtc && intel_encoder_is_dp(encoder)) {
>>  		u8 pipe_mask;
>>  		bool is_mst;
>> @@ -2880,20 +2879,52 @@ void icl_sanitize_encoder_pll_mapping(struct intel_encoder *encoder)
>>  			return;
>>  	}
>>  
>> -	if (clk_enabled == !!encoder->base.crtc)
>> -		return;
>> +	port_mask = BIT(encoder->port);
>> +	ddi_clk_needed = encoder->base.crtc;
>>  
>> -	/*
>> -	 * Punt on the case now where clock is disabled, but the encoder is
>> -	 * enabled, something else is really broken then.
>> -	 */
>> -	if (WARN_ON(!clk_enabled))
>> -		return;
>> +	if (encoder->type == INTEL_OUTPUT_DSI) {
>> +		struct intel_encoder *other_encoder;
>>  
>> -	DRM_NOTE("Port %c is disabled but it has a mapped PLL, unmap it\n",
>> -		 port_name(port));
>> -	val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
>> -	I915_WRITE(DPCLKA_CFGCR0_ICL, val);
>> +		port_mask = intel_dsi_encoder_ports(encoder);
>> +		/*
>> +		 * Sanity check that we haven't incorrectly registered another
>> +		 * encoder using any of the ports of this DSI encoder.
>> +		 */
>> +		for_each_intel_encoder(&dev_priv->drm, other_encoder) {
>> +			if (other_encoder == encoder)
>> +				continue;
>> +
>> +			if (WARN_ON(port_mask & BIT(other_encoder->port)))
>> +				return;
>> +		}
>> +		/*
>> +		 * DSI ports should have their DDI clock ungated when disabled
>> +		 * and gated when enabled.
>> +		 */
>> +		ddi_clk_needed = !encoder->base.crtc;
>> +	}
>> +
>> +	val = I915_READ(DPCLKA_CFGCR0_ICL);
>> +	for_each_port_masked(port, port_mask) {
>> +		bool ddi_clk_ungated = !(val &
>> +					 icl_dpclka_cfgcr0_clk_off(dev_priv,
>> +								   port));
>> +
>> +		if (ddi_clk_needed == ddi_clk_ungated)
>> +			continue;
>> +
>> +		/*
>> +		 * Punt on the case now where clock is gated, but it would
>> +		 * be needed by the port. Something else is really broken then.
>> +		 */
>> +		if (WARN_ON(ddi_clk_needed))
>> +			continue;
>> +
>> +		DRM_NOTE("Port %c is disabled/in DSI mode with an ungated DDI clock, gate it\n",
>> +			 port_name(port));
>> +		val |= icl_dpclka_cfgcr0_clk_off(dev_priv, port);
>> +		I915_WRITE(DPCLKA_CFGCR0_ICL, val);
>> +	}
>>  }
>>  
>>  static void intel_ddi_clk_select(struct intel_encoder *encoder,
>> diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
>> index ee93137f4433..d968f1f13e09 100644
>> --- a/drivers/gpu/drm/i915/intel_dsi.h
>> +++ b/drivers/gpu/drm/i915/intel_dsi.h
>> @@ -146,6 +146,11 @@ static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
>>  	return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
>>  }
>>  
>> +static inline u16 intel_dsi_encoder_ports(struct intel_encoder *encoder)
>> +{
>> +	return enc_to_intel_dsi(&encoder->base)->ports;
>> +}
>> +
>>  /* intel_dsi.c */
>>  int intel_dsi_bitrate(const struct intel_dsi *intel_dsi);
>>  int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi);

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-03 14:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27 16:36 [PATCH] drm/i915/icl: Sanitize DDI port clock gating for DSI ports Imre Deak
2018-11-27 17:25 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-11-27 22:02 ` ✓ Fi.CI.IGT: " Patchwork
2018-11-29 14:05 ` [PATCH] " Jani Nikula
2018-12-03 14:10   ` Jani Nikula

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.