All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD
@ 2017-01-27  9:39 Imre Deak
  2017-01-27  9:39   ` Imre Deak
                   ` (4 more replies)
  0 siblings, 5 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter

This patchset attempts to fix the sporadic LSPCON resume time failures
reported by CI. The first two patches are the actual fix (for stable)
the other two is cleanup and refactoring.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Imre Deak (4):
  drm/i915/gen9+: Enable hotplug detection early
  drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  drm/i915/lspcon: Remove DPCD compare based resume time workaround
  drm/i915/gen5+,pch: Enable hotplug detection early

 drivers/gpu/drm/i915/i915_irq.c     | 146 ++++++++++++++++++++++++------------
 drivers/gpu/drm/i915/intel_dp.c     |   4 +-
 drivers/gpu/drm/i915/intel_drv.h    |   3 +-
 drivers/gpu/drm/i915/intel_lspcon.c |  18 +----
 4 files changed, 107 insertions(+), 64 deletions(-)

-- 
2.5.0

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

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

* [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
  2017-01-27  9:39 [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD Imre Deak
@ 2017-01-27  9:39   ` Imre Deak
  2017-01-27  9:39   ` Imre Deak
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx
  Cc: Shashank Sharma, Jani Nikula, Ville Syrjälä,
	Daniel Vetter, stable

For LSPCON resume time initialization we need to sample the
corresponding pin's HPD level, but this is only available when HPD
detection is enabled. Currently we enable detection only when enabling
HPD interrupts which is too late, so bring the enabling of detection
earlier.

This is needed by the next patch.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
 1 file changed, 51 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 8440d8b..6daf522 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
 }
 
+static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
+{
+	u32 hotplug;
+
+	/* Enable digital hotplug on the PCH */
+	hotplug = I915_READ(PCH_PORT_HOTPLUG);
+	hotplug |= PORTA_HOTPLUG_ENABLE |
+		   PORTB_HOTPLUG_ENABLE |
+		   PORTC_HOTPLUG_ENABLE |
+		   PORTD_HOTPLUG_ENABLE;
+	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
+
+	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
+	hotplug |= PORTE_HOTPLUG_ENABLE;
+	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
+}
+
 static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
-	u32 hotplug_irqs, hotplug, enabled_irqs;
+	u32 hotplug_irqs, enabled_irqs;
 
 	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
 	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
 
 	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
 
-	/* Enable digital hotplug on the PCH */
-	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
-		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
-	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
-
-	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
-	hotplug |= PORTE_HOTPLUG_ENABLE;
-	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
+	spt_hpd_detection_setup(dev_priv);
 }
 
 static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
@@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	ibx_hpd_irq_setup(dev_priv);
 }
 
-static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
+static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
+					     u32 enabled_irqs)
 {
-	u32 hotplug_irqs, hotplug, enabled_irqs;
-
-	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
-	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
-
-	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
+	u32 hotplug;
 
 	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
-		PORTA_HOTPLUG_ENABLE;
+	hotplug |= PORTA_HOTPLUG_ENABLE |
+		   PORTB_HOTPLUG_ENABLE |
+		   PORTC_HOTPLUG_ENABLE;
 
 	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
 		      hotplug, enabled_irqs);
@@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	 * For BXT invert bit has to be set based on AOB design
 	 * for HPD detection logic, update it based on VBT fields.
 	 */
-
 	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
 	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
 		hotplug |= BXT_DDIA_HPD_INVERT;
@@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
 }
 
+static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
+{
+	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
+}
+
+static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
+{
+	u32 hotplug_irqs, enabled_irqs;
+
+	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
+	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
+
+	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
+
+	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
+}
+
 static void ibx_irq_postinstall(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
@@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
 
 	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
 	I915_WRITE(SDEIMR, ~mask);
+
+	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
+	    HAS_PCH_LPT(dev_priv))
+		; /* TODO: Enable HPD detection on older PCH platforms too */
+	else
+		spt_hpd_detection_setup(dev_priv);
 }
 
 static void gen5_gt_irq_postinstall(struct drm_device *dev)
@@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
 
 	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
 	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
+
+	if (IS_GEN9_LP(dev_priv))
+		bxt_hpd_detection_setup(dev_priv);
 }
 
 static int gen8_irq_postinstall(struct drm_device *dev)
-- 
2.5.0


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

* [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
@ 2017-01-27  9:39   ` Imre Deak
  0 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, stable

For LSPCON resume time initialization we need to sample the
corresponding pin's HPD level, but this is only available when HPD
detection is enabled. Currently we enable detection only when enabling
HPD interrupts which is too late, so bring the enabling of detection
earlier.

This is needed by the next patch.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
 1 file changed, 51 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 8440d8b..6daf522 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
 }
 
+static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
+{
+	u32 hotplug;
+
+	/* Enable digital hotplug on the PCH */
+	hotplug = I915_READ(PCH_PORT_HOTPLUG);
+	hotplug |= PORTA_HOTPLUG_ENABLE |
+		   PORTB_HOTPLUG_ENABLE |
+		   PORTC_HOTPLUG_ENABLE |
+		   PORTD_HOTPLUG_ENABLE;
+	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
+
+	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
+	hotplug |= PORTE_HOTPLUG_ENABLE;
+	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
+}
+
 static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
-	u32 hotplug_irqs, hotplug, enabled_irqs;
+	u32 hotplug_irqs, enabled_irqs;
 
 	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
 	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
 
 	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
 
-	/* Enable digital hotplug on the PCH */
-	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
-		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
-	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
-
-	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
-	hotplug |= PORTE_HOTPLUG_ENABLE;
-	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
+	spt_hpd_detection_setup(dev_priv);
 }
 
 static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
@@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	ibx_hpd_irq_setup(dev_priv);
 }
 
-static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
+static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
+					     u32 enabled_irqs)
 {
-	u32 hotplug_irqs, hotplug, enabled_irqs;
-
-	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
-	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
-
-	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
+	u32 hotplug;
 
 	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
-		PORTA_HOTPLUG_ENABLE;
+	hotplug |= PORTA_HOTPLUG_ENABLE |
+		   PORTB_HOTPLUG_ENABLE |
+		   PORTC_HOTPLUG_ENABLE;
 
 	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
 		      hotplug, enabled_irqs);
@@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	 * For BXT invert bit has to be set based on AOB design
 	 * for HPD detection logic, update it based on VBT fields.
 	 */
-
 	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
 	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
 		hotplug |= BXT_DDIA_HPD_INVERT;
@@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
 }
 
+static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
+{
+	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
+}
+
+static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
+{
+	u32 hotplug_irqs, enabled_irqs;
+
+	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
+	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
+
+	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
+
+	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
+}
+
 static void ibx_irq_postinstall(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
@@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
 
 	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
 	I915_WRITE(SDEIMR, ~mask);
+
+	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
+	    HAS_PCH_LPT(dev_priv))
+		; /* TODO: Enable HPD detection on older PCH platforms too */
+	else
+		spt_hpd_detection_setup(dev_priv);
 }
 
 static void gen5_gt_irq_postinstall(struct drm_device *dev)
@@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
 
 	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
 	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
+
+	if (IS_GEN9_LP(dev_priv))
+		bxt_hpd_detection_setup(dev_priv);
 }
 
 static int gen8_irq_postinstall(struct drm_device *dev)
-- 
2.5.0

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

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

* [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  2017-01-27  9:39 [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD Imre Deak
@ 2017-01-27  9:39   ` Imre Deak
  2017-01-27  9:39   ` Imre Deak
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx
  Cc: Shashank Sharma, Jani Nikula, Ville Syrjälä,
	Daniel Vetter, stable

During system resume time initialization the HPD level on LSPCON ports
can stay low for an extended amount of time, leading to failed AUX
transfers and LSPCON initialization. Fix this by waiting for HPD to get
asserted.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
 drivers/gpu/drm/i915/intel_drv.h    | 2 ++
 drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index e0f9b9e..a7785ce 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
  *
  * Return %true if @port is connected, %false otherwise.
  */
-static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
-					 struct intel_digital_port *port)
+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
+				  struct intel_digital_port *port)
 {
 	if (HAS_PCH_IBX(dev_priv))
 		return ibx_digital_port_connected(dev_priv, port);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b71fece..b9cde11 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
 bool intel_dp_read_desc(struct intel_dp *intel_dp);
 int intel_dp_link_required(int pixel_clock, int bpp);
 int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
+				  struct intel_digital_port *port);
 
 /* intel_dp_aux_backlight.c */
 int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
index f6d4e69..c300647 100644
--- a/drivers/gpu/drm/i915/intel_lspcon.c
+++ b/drivers/gpu/drm/i915/intel_lspcon.c
@@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
 static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
 {
 	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
+	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
+	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
 	unsigned long start = jiffies;
 
 	if (!lspcon->desc_valid)
@@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
 		if (!__intel_dp_read_desc(intel_dp, &desc))
 			return;
 
-		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
+		if (intel_digital_port_connected(dev_priv, dig_port) &&
+		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
 			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
 				      jiffies_to_msecs(jiffies - start));
 			return;
-- 
2.5.0


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

* [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
@ 2017-01-27  9:39   ` Imre Deak
  0 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter, stable

During system resume time initialization the HPD level on LSPCON ports
can stay low for an extended amount of time, leading to failed AUX
transfers and LSPCON initialization. Fix this by waiting for HPD to get
asserted.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: <stable@vger.kernel.org> # v4.9+
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
 drivers/gpu/drm/i915/intel_drv.h    | 2 ++
 drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index e0f9b9e..a7785ce 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
  *
  * Return %true if @port is connected, %false otherwise.
  */
-static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
-					 struct intel_digital_port *port)
+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
+				  struct intel_digital_port *port)
 {
 	if (HAS_PCH_IBX(dev_priv))
 		return ibx_digital_port_connected(dev_priv, port);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b71fece..b9cde11 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
 bool intel_dp_read_desc(struct intel_dp *intel_dp);
 int intel_dp_link_required(int pixel_clock, int bpp);
 int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
+				  struct intel_digital_port *port);
 
 /* intel_dp_aux_backlight.c */
 int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
index f6d4e69..c300647 100644
--- a/drivers/gpu/drm/i915/intel_lspcon.c
+++ b/drivers/gpu/drm/i915/intel_lspcon.c
@@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
 static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
 {
 	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
+	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
+	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
 	unsigned long start = jiffies;
 
 	if (!lspcon->desc_valid)
@@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
 		if (!__intel_dp_read_desc(intel_dp, &desc))
 			return;
 
-		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
+		if (intel_digital_port_connected(dev_priv, dig_port) &&
+		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
 			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
 				      jiffies_to_msecs(jiffies - start));
 			return;
-- 
2.5.0

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

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

* [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround
  2017-01-27  9:39 [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD Imre Deak
  2017-01-27  9:39   ` Imre Deak
  2017-01-27  9:39   ` Imre Deak
@ 2017-01-27  9:39 ` Imre Deak
  2017-01-28  5:06   ` Sharma, Shashank
  2017-01-27  9:39 ` [PATCH 4/4] drm/i915/gen5+, pch: Enable hotplug detection early Imre Deak
  2017-01-27 11:24 ` ✓ Fi.CI.BAT: success for drm/i915/lspcon: Fix resume time init due to low HPD Patchwork
  4 siblings, 1 reply; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter

This effectively reverts
commit 489375c866c111f16cea93b2467ebe59c9022cc7
Author: Imre Deak <imre.deak@intel.com>
Date:   Mon Oct 24 19:33:31 2016 +0300

    drm/i915/lspcon: Add workaround for resuming in PCON mode

The workaround was added without considering that HPD is low during
the failed AUX transfers the WA fixed. Since the previous patch we
wait for HPD to get asserted. My tests also show that this happens
_after_ the DPCD reads start to return correct values. This
suggests that we don't need this WA any more, let's try to remove
it to reduce the clutter.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/intel_drv.h    |  1 -
 drivers/gpu/drm/i915/intel_lspcon.c | 17 ++---------------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b9cde11..b2882ff 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -989,7 +989,6 @@ struct intel_dp {
 struct intel_lspcon {
 	bool active;
 	enum drm_lspcon_mode mode;
-	bool desc_valid;
 };
 
 struct intel_digital_port {
diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
index c300647..71cbe9c 100644
--- a/drivers/gpu/drm/i915/intel_lspcon.c
+++ b/drivers/gpu/drm/i915/intel_lspcon.c
@@ -162,21 +162,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
 	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
 	unsigned long start = jiffies;
 
-	if (!lspcon->desc_valid)
-		return;
-
 	while (1) {
-		struct intel_dp_desc desc;
-
-		/*
-		 * The w/a only applies in PCON mode and we don't expect any
-		 * AUX errors.
-		 */
-		if (!__intel_dp_read_desc(intel_dp, &desc))
-			return;
-
-		if (intel_digital_port_connected(dev_priv, dig_port) &&
-		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
+		if (intel_digital_port_connected(dev_priv, dig_port)) {
 			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
 				      jiffies_to_msecs(jiffies - start));
 			return;
@@ -253,7 +240,7 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
 		return false;
 	}
 
-	lspcon->desc_valid = intel_dp_read_desc(dp);
+	intel_dp_read_desc(dp);
 
 	DRM_DEBUG_KMS("Success: LSPCON init\n");
 	return true;
-- 
2.5.0

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

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

* [PATCH 4/4] drm/i915/gen5+, pch: Enable hotplug detection early
  2017-01-27  9:39 [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD Imre Deak
                   ` (2 preceding siblings ...)
  2017-01-27  9:39 ` [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround Imre Deak
@ 2017-01-27  9:39 ` Imre Deak
  2017-01-28  5:09   ` Sharma, Shashank
  2017-01-27 11:24 ` ✓ Fi.CI.BAT: success for drm/i915/lspcon: Fix resume time init due to low HPD Patchwork
  4 siblings, 1 reply; 29+ messages in thread
From: Imre Deak @ 2017-01-27  9:39 UTC (permalink / raw)
  To: intel-gfx; +Cc: Daniel Vetter

To be consistent with the recent change to enable hotplug detection
early on GEN9 platforms do the same on all non-GMCH platforms starting
from GEN5. On GMCH platforms enabling detection without interrupts isn't
trivial, since AUX and HPD have a shared interrupt line. It could be
done there too by using a SW interrupt mask, but I punt on that for now.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/i915/i915_irq.c | 79 ++++++++++++++++++++++++++---------------
 1 file changed, 50 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6daf522..88c10b1 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -3109,9 +3109,34 @@ static u32 intel_hpd_enabled_irqs(struct drm_i915_private *dev_priv,
 	return enabled_irqs;
 }
 
+static void ibx_hpd_detection_setup(struct drm_i915_private *dev_priv)
+{
+	u32 hotplug;
+
+	/*
+	 * Enable digital hotplug on the PCH, and configure the DP short pulse
+	 * duration to 2ms (which is the minimum in the Display Port spec).
+	 * The pulse duration bits are reserved on LPT+.
+	 */
+	hotplug = I915_READ(PCH_PORT_HOTPLUG);
+	hotplug &= ~(PORTB_PULSE_DURATION_MASK |
+		     PORTC_PULSE_DURATION_MASK |
+		     PORTD_PULSE_DURATION_MASK);
+	hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms;
+	hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
+	hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
+	/*
+	 * When CPU and PCH are on the same package, port A
+	 * HPD must be enabled in both north and south.
+	 */
+	if (HAS_PCH_LPT_LP(dev_priv))
+		hotplug |= PORTA_HOTPLUG_ENABLE;
+	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
+}
+
 static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
-	u32 hotplug_irqs, hotplug, enabled_irqs;
+	u32 hotplug_irqs, enabled_irqs;
 
 	if (HAS_PCH_IBX(dev_priv)) {
 		hotplug_irqs = SDE_HOTPLUG_MASK;
@@ -3123,23 +3148,7 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
 
 	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
 
-	/*
-	 * Enable digital hotplug on the PCH, and configure the DP short pulse
-	 * duration to 2ms (which is the minimum in the Display Port spec).
-	 * The pulse duration bits are reserved on LPT+.
-	 */
-	hotplug = I915_READ(PCH_PORT_HOTPLUG);
-	hotplug &= ~(PORTD_PULSE_DURATION_MASK|PORTC_PULSE_DURATION_MASK|PORTB_PULSE_DURATION_MASK);
-	hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
-	hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
-	hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms;
-	/*
-	 * When CPU and PCH are on the same package, port A
-	 * HPD must be enabled in both north and south.
-	 */
-	if (HAS_PCH_LPT_LP(dev_priv))
-		hotplug |= PORTA_HOTPLUG_ENABLE;
-	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
+	ibx_hpd_detection_setup(dev_priv);
 }
 
 static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
@@ -3171,9 +3180,25 @@ static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
 	spt_hpd_detection_setup(dev_priv);
 }
 
+static void ilk_hpd_detection_setup(struct drm_i915_private *dev_priv)
+{
+	u32 hotplug;
+
+	/*
+	 * Enable digital hotplug on the CPU, and configure the DP short pulse
+	 * duration to 2ms (which is the minimum in the Display Port spec)
+	 * The pulse duration bits are reserved on HSW+.
+	 */
+	hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL);
+	hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK;
+	hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE |
+		   DIGITAL_PORTA_PULSE_DURATION_2ms;
+	I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug);
+}
+
 static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
 {
-	u32 hotplug_irqs, hotplug, enabled_irqs;
+	u32 hotplug_irqs, enabled_irqs;
 
 	if (INTEL_GEN(dev_priv) >= 8) {
 		hotplug_irqs = GEN8_PORT_DP_A_HOTPLUG;
@@ -3192,15 +3217,7 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
 		ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs);
 	}
 
-	/*
-	 * Enable digital hotplug on the CPU, and configure the DP short pulse
-	 * duration to 2ms (which is the minimum in the Display Port spec)
-	 * The pulse duration bits are reserved on HSW+.
-	 */
-	hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL);
-	hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK;
-	hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE | DIGITAL_PORTA_PULSE_DURATION_2ms;
-	I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug);
+	ilk_hpd_detection_setup(dev_priv);
 
 	ibx_hpd_irq_setup(dev_priv);
 }
@@ -3271,7 +3288,7 @@ static void ibx_irq_postinstall(struct drm_device *dev)
 
 	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
 	    HAS_PCH_LPT(dev_priv))
-		; /* TODO: Enable HPD detection on older PCH platforms too */
+		ibx_hpd_detection_setup(dev_priv);
 	else
 		spt_hpd_detection_setup(dev_priv);
 }
@@ -3348,6 +3365,8 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
 
 	gen5_gt_irq_postinstall(dev);
 
+	ilk_hpd_detection_setup(dev_priv);
+
 	ibx_irq_postinstall(dev);
 
 	if (IS_IRONLAKE_M(dev_priv)) {
@@ -3488,6 +3507,8 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
 
 	if (IS_GEN9_LP(dev_priv))
 		bxt_hpd_detection_setup(dev_priv);
+	else if (IS_BROADWELL(dev_priv))
+		ilk_hpd_detection_setup(dev_priv);
 }
 
 static int gen8_irq_postinstall(struct drm_device *dev)
-- 
2.5.0

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

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

* ✓ Fi.CI.BAT: success for drm/i915/lspcon: Fix resume time init due to low HPD
  2017-01-27  9:39 [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD Imre Deak
                   ` (3 preceding siblings ...)
  2017-01-27  9:39 ` [PATCH 4/4] drm/i915/gen5+, pch: Enable hotplug detection early Imre Deak
@ 2017-01-27 11:24 ` Patchwork
  2017-02-06 14:46   ` Imre Deak
  4 siblings, 1 reply; 29+ messages in thread
From: Patchwork @ 2017-01-27 11:24 UTC (permalink / raw)
  To: Imre Deak; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/lspcon: Fix resume time init due to low HPD
URL   : https://patchwork.freedesktop.org/series/18656/
State : success

== Summary ==

Series 18656v1 drm/i915/lspcon: Fix resume time init due to low HPD
https://patchwork.freedesktop.org/api/1.0/series/18656/revisions/1/mbox/


fi-bdw-5557u     total:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14 
fi-bsw-n3050     total:247  pass:208  dwarn:0   dfail:0   fail:0   skip:39 
fi-bxt-j4205     total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
fi-bxt-t5700     total:79   pass:66   dwarn:0   dfail:0   fail:0   skip:12 
fi-byt-j1900     total:247  pass:220  dwarn:0   dfail:0   fail:0   skip:27 
fi-byt-n2820     total:247  pass:216  dwarn:0   dfail:0   fail:0   skip:31 
fi-hsw-4770      total:247  pass:228  dwarn:0   dfail:0   fail:0   skip:19 
fi-hsw-4770r     total:247  pass:228  dwarn:0   dfail:0   fail:0   skip:19 
fi-ivb-3520m     total:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
fi-ivb-3770      total:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
fi-kbl-7500u     total:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6260u     total:247  pass:234  dwarn:0   dfail:0   fail:0   skip:13 
fi-skl-6700hq    total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20 
fi-skl-6700k     total:247  pass:222  dwarn:4   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:247  pass:234  dwarn:0   dfail:0   fail:0   skip:13 
fi-snb-2520m     total:247  pass:216  dwarn:0   dfail:0   fail:0   skip:31 
fi-snb-2600      total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32 

93cbdef9696bcaa1279ae05c418b2794b71c2398 drm-tip: 2017y-01m-27d-09h-55m-16s UTC integration manifest
910551d drm/i915/gen5+, pch: Enable hotplug detection early
4fbb08f drm/i915/lspcon: Remove DPCD compare based resume time workaround
bd5876e drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
d4c554d drm/i915/gen9+: Enable hotplug detection early

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3620/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
  2017-01-27  9:39   ` Imre Deak
@ 2017-01-28  4:54     ` Sharma, Shashank
  -1 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-28  4:54 UTC (permalink / raw)
  To: Imre Deak, intel-gfx
  Cc: Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

Regards

Shashank


On 1/27/2017 3:09 PM, Imre Deak wrote:
> For LSPCON resume time initialization we need to sample the
> corresponding pin's HPD level, but this is only available when HPD
> detection is enabled. Currently we enable detection only when enabling
> HPD interrupts which is too late, so bring the enabling of detection
> earlier.
>
> This is needed by the next patch.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v4.9+
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
>   1 file changed, 51 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 8440d8b..6daf522 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>   }
>   
> +static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> +{
> +	u32 hotplug;
> +
> +	/* Enable digital hotplug on the PCH */
> +	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> +	hotplug |= PORTA_HOTPLUG_ENABLE |
> +		   PORTB_HOTPLUG_ENABLE |
> +		   PORTC_HOTPLUG_ENABLE |
> +		   PORTD_HOTPLUG_ENABLE;
> +	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> +
> +	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> +	hotplug |= PORTE_HOTPLUG_ENABLE;
> +	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> +}
> +
>   static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   {
> -	u32 hotplug_irqs, hotplug, enabled_irqs;
> +	u32 hotplug_irqs, enabled_irqs;
>   
>   	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
>   	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
>   
>   	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
>   
> -	/* Enable digital hotplug on the PCH */
> -	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> -	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
> -		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
> -	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> -
> -	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> -	hotplug |= PORTE_HOTPLUG_ENABLE;
> -	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> +	spt_hpd_detection_setup(dev_priv);
>   }
>   
>   static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
> @@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	ibx_hpd_irq_setup(dev_priv);
>   }
>   
> -static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> +static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
> +					     u32 enabled_irqs)
>   {
> -	u32 hotplug_irqs, hotplug, enabled_irqs;
> -
> -	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> -	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> -
> -	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> +	u32 hotplug;
>   
>   	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> -	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
> -		PORTA_HOTPLUG_ENABLE;
> +	hotplug |= PORTA_HOTPLUG_ENABLE |
> +		   PORTB_HOTPLUG_ENABLE |
> +		   PORTC_HOTPLUG_ENABLE;
>   
>   	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
>   		      hotplug, enabled_irqs);
> @@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	 * For BXT invert bit has to be set based on AOB design
>   	 * for HPD detection logic, update it based on VBT fields.
>   	 */
> -
>   	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
>   	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
>   		hotplug |= BXT_DDIA_HPD_INVERT;
> @@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>   }
>   
> +static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> +{
> +	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
Do we need another layer of internal function ? Why cant the content of 
__bxt_hpd_detection_setup be here, just
like spd_hpd_detection_setup, as they both are static to the file ?
> +}
> +
> +static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> +{
> +	u32 hotplug_irqs, enabled_irqs;
> +
> +	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> +	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> +
> +	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> +
> +	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
> +}
> +
>   static void ibx_irq_postinstall(struct drm_device *dev)
>   {
>   	struct drm_i915_private *dev_priv = to_i915(dev);
> @@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
>   
>   	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
>   	I915_WRITE(SDEIMR, ~mask);
> +
> +	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
> +	    HAS_PCH_LPT(dev_priv))
> +		; /* TODO: Enable HPD detection on older PCH platforms too */
> +	else
> +		spt_hpd_detection_setup(dev_priv);
>   }
>   
>   static void gen5_gt_irq_postinstall(struct drm_device *dev)
> @@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
>   
>   	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
>   	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
> +
> +	if (IS_GEN9_LP(dev_priv))
I have not done the delta analysis between hotplug interrupts, but this 
will be true for GLK too.
Should we bother ?

- Shashank
> +		bxt_hpd_detection_setup(dev_priv);
>   }
>   
>   static int gen8_irq_postinstall(struct drm_device *dev)


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

* Re: [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
@ 2017-01-28  4:54     ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-28  4:54 UTC (permalink / raw)
  To: Imre Deak, intel-gfx; +Cc: Daniel Vetter, stable

Regards

Shashank


On 1/27/2017 3:09 PM, Imre Deak wrote:
> For LSPCON resume time initialization we need to sample the
> corresponding pin's HPD level, but this is only available when HPD
> detection is enabled. Currently we enable detection only when enabling
> HPD interrupts which is too late, so bring the enabling of detection
> earlier.
>
> This is needed by the next patch.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v4.9+
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
>   1 file changed, 51 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 8440d8b..6daf522 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>   }
>   
> +static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> +{
> +	u32 hotplug;
> +
> +	/* Enable digital hotplug on the PCH */
> +	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> +	hotplug |= PORTA_HOTPLUG_ENABLE |
> +		   PORTB_HOTPLUG_ENABLE |
> +		   PORTC_HOTPLUG_ENABLE |
> +		   PORTD_HOTPLUG_ENABLE;
> +	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> +
> +	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> +	hotplug |= PORTE_HOTPLUG_ENABLE;
> +	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> +}
> +
>   static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   {
> -	u32 hotplug_irqs, hotplug, enabled_irqs;
> +	u32 hotplug_irqs, enabled_irqs;
>   
>   	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
>   	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
>   
>   	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
>   
> -	/* Enable digital hotplug on the PCH */
> -	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> -	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
> -		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
> -	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> -
> -	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> -	hotplug |= PORTE_HOTPLUG_ENABLE;
> -	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> +	spt_hpd_detection_setup(dev_priv);
>   }
>   
>   static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
> @@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	ibx_hpd_irq_setup(dev_priv);
>   }
>   
> -static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> +static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
> +					     u32 enabled_irqs)
>   {
> -	u32 hotplug_irqs, hotplug, enabled_irqs;
> -
> -	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> -	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> -
> -	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> +	u32 hotplug;
>   
>   	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> -	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
> -		PORTA_HOTPLUG_ENABLE;
> +	hotplug |= PORTA_HOTPLUG_ENABLE |
> +		   PORTB_HOTPLUG_ENABLE |
> +		   PORTC_HOTPLUG_ENABLE;
>   
>   	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
>   		      hotplug, enabled_irqs);
> @@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	 * For BXT invert bit has to be set based on AOB design
>   	 * for HPD detection logic, update it based on VBT fields.
>   	 */
> -
>   	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
>   	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
>   		hotplug |= BXT_DDIA_HPD_INVERT;
> @@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>   }
>   
> +static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> +{
> +	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
Do we need another layer of internal function ? Why cant the content of 
__bxt_hpd_detection_setup be here, just
like spd_hpd_detection_setup, as they both are static to the file ?
> +}
> +
> +static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> +{
> +	u32 hotplug_irqs, enabled_irqs;
> +
> +	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> +	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> +
> +	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> +
> +	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
> +}
> +
>   static void ibx_irq_postinstall(struct drm_device *dev)
>   {
>   	struct drm_i915_private *dev_priv = to_i915(dev);
> @@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
>   
>   	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
>   	I915_WRITE(SDEIMR, ~mask);
> +
> +	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
> +	    HAS_PCH_LPT(dev_priv))
> +		; /* TODO: Enable HPD detection on older PCH platforms too */
> +	else
> +		spt_hpd_detection_setup(dev_priv);
>   }
>   
>   static void gen5_gt_irq_postinstall(struct drm_device *dev)
> @@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
>   
>   	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
>   	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
> +
> +	if (IS_GEN9_LP(dev_priv))
I have not done the delta analysis between hotplug interrupts, but this 
will be true for GLK too.
Should we bother ?

- Shashank
> +		bxt_hpd_detection_setup(dev_priv);
>   }
>   
>   static int gen8_irq_postinstall(struct drm_device *dev)

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

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  2017-01-27  9:39   ` Imre Deak
@ 2017-01-28  5:02     ` Sharma, Shashank
  -1 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-28  5:02 UTC (permalink / raw)
  To: Imre Deak, intel-gfx
  Cc: Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

Regards

Shashank


On 1/27/2017 3:09 PM, Imre Deak wrote:
> During system resume time initialization the HPD level on LSPCON ports
> can stay low for an extended amount of time, leading to failed AUX
> transfers and LSPCON initialization. Fix this by waiting for HPD to get
> asserted.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v4.9+
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>   drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
>   drivers/gpu/drm/i915/intel_drv.h    | 2 ++
>   drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
>   3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index e0f9b9e..a7785ce 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
>    *
>    * Return %true if @port is connected, %false otherwise.
>    */
> -static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> -					 struct intel_digital_port *port)
> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> +				  struct intel_digital_port *port)
>   {
>   	if (HAS_PCH_IBX(dev_priv))
>   		return ibx_digital_port_connected(dev_priv, port);
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index b71fece..b9cde11 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
>   bool intel_dp_read_desc(struct intel_dp *intel_dp);
>   int intel_dp_link_required(int pixel_clock, int bpp);
>   int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> +				  struct intel_digital_port *port);
>   
>   /* intel_dp_aux_backlight.c */
>   int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> index f6d4e69..c300647 100644
> --- a/drivers/gpu/drm/i915/intel_lspcon.c
> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
> @@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
>   static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>   {
>   	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
> +	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
> +	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>   	unsigned long start = jiffies;
>   
>   	if (!lspcon->desc_valid)
> @@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>   		if (!__intel_dp_read_desc(intel_dp, &desc))
>   			return;
>   
> -		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> +		if (intel_digital_port_connected(dev_priv, dig_port) &&
when in PCON mode, live_status is always up for LSPCON port, so this 
check will be always true, isn't it ?
- Shashank
> +		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>   				      jiffies_to_msecs(jiffies - start));
>   			return;


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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
@ 2017-01-28  5:02     ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-28  5:02 UTC (permalink / raw)
  To: Imre Deak, intel-gfx; +Cc: Daniel Vetter, stable

Regards

Shashank


On 1/27/2017 3:09 PM, Imre Deak wrote:
> During system resume time initialization the HPD level on LSPCON ports
> can stay low for an extended amount of time, leading to failed AUX
> transfers and LSPCON initialization. Fix this by waiting for HPD to get
> asserted.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v4.9+
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>   drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
>   drivers/gpu/drm/i915/intel_drv.h    | 2 ++
>   drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
>   3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index e0f9b9e..a7785ce 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
>    *
>    * Return %true if @port is connected, %false otherwise.
>    */
> -static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> -					 struct intel_digital_port *port)
> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> +				  struct intel_digital_port *port)
>   {
>   	if (HAS_PCH_IBX(dev_priv))
>   		return ibx_digital_port_connected(dev_priv, port);
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index b71fece..b9cde11 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
>   bool intel_dp_read_desc(struct intel_dp *intel_dp);
>   int intel_dp_link_required(int pixel_clock, int bpp);
>   int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> +				  struct intel_digital_port *port);
>   
>   /* intel_dp_aux_backlight.c */
>   int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> index f6d4e69..c300647 100644
> --- a/drivers/gpu/drm/i915/intel_lspcon.c
> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
> @@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
>   static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>   {
>   	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
> +	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
> +	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>   	unsigned long start = jiffies;
>   
>   	if (!lspcon->desc_valid)
> @@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>   		if (!__intel_dp_read_desc(intel_dp, &desc))
>   			return;
>   
> -		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> +		if (intel_digital_port_connected(dev_priv, dig_port) &&
when in PCON mode, live_status is always up for LSPCON port, so this 
check will be always true, isn't it ?
- Shashank
> +		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>   				      jiffies_to_msecs(jiffies - start));
>   			return;

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

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

* Re: [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround
  2017-01-27  9:39 ` [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround Imre Deak
@ 2017-01-28  5:06   ` Sharma, Shashank
  2017-01-28  8:19     ` Imre Deak
  0 siblings, 1 reply; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-28  5:06 UTC (permalink / raw)
  To: Imre Deak, intel-gfx; +Cc: Daniel Vetter

Regards

Shashank


On 1/27/2017 3:09 PM, Imre Deak wrote:
> This effectively reverts
> commit 489375c866c111f16cea93b2467ebe59c9022cc7
> Author: Imre Deak <imre.deak@intel.com>
> Date:   Mon Oct 24 19:33:31 2016 +0300
>
>      drm/i915/lspcon: Add workaround for resuming in PCON mode
>
> The workaround was added without considering that HPD is low during
> the failed AUX transfers the WA fixed. Since the previous patch we
> wait for HPD to get asserted. My tests also show that this happens
> _after_ the DPCD reads start to return correct values. This
> suggests that we don't need this WA any more, let's try to remove
> it to reduce the clutter.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>   drivers/gpu/drm/i915/intel_drv.h    |  1 -
>   drivers/gpu/drm/i915/intel_lspcon.c | 17 ++---------------
>   2 files changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index b9cde11..b2882ff 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -989,7 +989,6 @@ struct intel_dp {
>   struct intel_lspcon {
>   	bool active;
>   	enum drm_lspcon_mode mode;
> -	bool desc_valid;
>   };
>   
>   struct intel_digital_port {
> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> index c300647..71cbe9c 100644
> --- a/drivers/gpu/drm/i915/intel_lspcon.c
> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
> @@ -162,21 +162,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>   	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>   	unsigned long start = jiffies;
>   
> -	if (!lspcon->desc_valid)
> -		return;
> -
>   	while (1) {
> -		struct intel_dp_desc desc;
> -
> -		/*
> -		 * The w/a only applies in PCON mode and we don't expect any
> -		 * AUX errors.
> -		 */
> -		if (!__intel_dp_read_desc(intel_dp, &desc))
> -			return;
> -
> -		if (intel_digital_port_connected(dev_priv, dig_port) &&
> -		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> +		if (intel_digital_port_connected(dev_priv, dig_port)) {
Again, does it matter, as in PCON mode live_status will be always true ?
- Shashank
>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>   				      jiffies_to_msecs(jiffies - start));
>   			return;
> @@ -253,7 +240,7 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
>   		return false;
>   	}
>   
> -	lspcon->desc_valid = intel_dp_read_desc(dp);
> +	intel_dp_read_desc(dp);
>   
>   	DRM_DEBUG_KMS("Success: LSPCON init\n");
>   	return true;

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

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

* Re: [PATCH 4/4] drm/i915/gen5+, pch: Enable hotplug detection early
  2017-01-27  9:39 ` [PATCH 4/4] drm/i915/gen5+, pch: Enable hotplug detection early Imre Deak
@ 2017-01-28  5:09   ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-28  5:09 UTC (permalink / raw)
  To: Imre Deak, intel-gfx; +Cc: Daniel Vetter

Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>

Regards
Shashank
On 1/27/2017 3:09 PM, Imre Deak wrote:
> To be consistent with the recent change to enable hotplug detection
> early on GEN9 platforms do the same on all non-GMCH platforms starting
> from GEN5. On GMCH platforms enabling detection without interrupts isn't
> trivial, since AUX and HPD have a shared interrupt line. It could be
> done there too by using a SW interrupt mask, but I punt on that for now.
>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_irq.c | 79 ++++++++++++++++++++++++++---------------
>   1 file changed, 50 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 6daf522..88c10b1 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -3109,9 +3109,34 @@ static u32 intel_hpd_enabled_irqs(struct drm_i915_private *dev_priv,
>   	return enabled_irqs;
>   }
>   
> +static void ibx_hpd_detection_setup(struct drm_i915_private *dev_priv)
> +{
> +	u32 hotplug;
> +
> +	/*
> +	 * Enable digital hotplug on the PCH, and configure the DP short pulse
> +	 * duration to 2ms (which is the minimum in the Display Port spec).
> +	 * The pulse duration bits are reserved on LPT+.
> +	 */
> +	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> +	hotplug &= ~(PORTB_PULSE_DURATION_MASK |
> +		     PORTC_PULSE_DURATION_MASK |
> +		     PORTD_PULSE_DURATION_MASK);
> +	hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms;
> +	hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
> +	hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
> +	/*
> +	 * When CPU and PCH are on the same package, port A
> +	 * HPD must be enabled in both north and south.
> +	 */
> +	if (HAS_PCH_LPT_LP(dev_priv))
> +		hotplug |= PORTA_HOTPLUG_ENABLE;
> +	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> +}
> +
>   static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   {
> -	u32 hotplug_irqs, hotplug, enabled_irqs;
> +	u32 hotplug_irqs, enabled_irqs;
>   
>   	if (HAS_PCH_IBX(dev_priv)) {
>   		hotplug_irqs = SDE_HOTPLUG_MASK;
> @@ -3123,23 +3148,7 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   
>   	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
>   
> -	/*
> -	 * Enable digital hotplug on the PCH, and configure the DP short pulse
> -	 * duration to 2ms (which is the minimum in the Display Port spec).
> -	 * The pulse duration bits are reserved on LPT+.
> -	 */
> -	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> -	hotplug &= ~(PORTD_PULSE_DURATION_MASK|PORTC_PULSE_DURATION_MASK|PORTB_PULSE_DURATION_MASK);
> -	hotplug |= PORTD_HOTPLUG_ENABLE | PORTD_PULSE_DURATION_2ms;
> -	hotplug |= PORTC_HOTPLUG_ENABLE | PORTC_PULSE_DURATION_2ms;
> -	hotplug |= PORTB_HOTPLUG_ENABLE | PORTB_PULSE_DURATION_2ms;
> -	/*
> -	 * When CPU and PCH are on the same package, port A
> -	 * HPD must be enabled in both north and south.
> -	 */
> -	if (HAS_PCH_LPT_LP(dev_priv))
> -		hotplug |= PORTA_HOTPLUG_ENABLE;
> -	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> +	ibx_hpd_detection_setup(dev_priv);
>   }
>   
>   static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> @@ -3171,9 +3180,25 @@ static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   	spt_hpd_detection_setup(dev_priv);
>   }
>   
> +static void ilk_hpd_detection_setup(struct drm_i915_private *dev_priv)
> +{
> +	u32 hotplug;
> +
> +	/*
> +	 * Enable digital hotplug on the CPU, and configure the DP short pulse
> +	 * duration to 2ms (which is the minimum in the Display Port spec)
> +	 * The pulse duration bits are reserved on HSW+.
> +	 */
> +	hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL);
> +	hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK;
> +	hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE |
> +		   DIGITAL_PORTA_PULSE_DURATION_2ms;
> +	I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug);
> +}
> +
>   static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   {
> -	u32 hotplug_irqs, hotplug, enabled_irqs;
> +	u32 hotplug_irqs, enabled_irqs;
>   
>   	if (INTEL_GEN(dev_priv) >= 8) {
>   		hotplug_irqs = GEN8_PORT_DP_A_HOTPLUG;
> @@ -3192,15 +3217,7 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>   		ilk_update_display_irq(dev_priv, hotplug_irqs, enabled_irqs);
>   	}
>   
> -	/*
> -	 * Enable digital hotplug on the CPU, and configure the DP short pulse
> -	 * duration to 2ms (which is the minimum in the Display Port spec)
> -	 * The pulse duration bits are reserved on HSW+.
> -	 */
> -	hotplug = I915_READ(DIGITAL_PORT_HOTPLUG_CNTRL);
> -	hotplug &= ~DIGITAL_PORTA_PULSE_DURATION_MASK;
> -	hotplug |= DIGITAL_PORTA_HOTPLUG_ENABLE | DIGITAL_PORTA_PULSE_DURATION_2ms;
> -	I915_WRITE(DIGITAL_PORT_HOTPLUG_CNTRL, hotplug);
> +	ilk_hpd_detection_setup(dev_priv);
>   
>   	ibx_hpd_irq_setup(dev_priv);
>   }
> @@ -3271,7 +3288,7 @@ static void ibx_irq_postinstall(struct drm_device *dev)
>   
>   	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
>   	    HAS_PCH_LPT(dev_priv))
> -		; /* TODO: Enable HPD detection on older PCH platforms too */
> +		ibx_hpd_detection_setup(dev_priv);
>   	else
>   		spt_hpd_detection_setup(dev_priv);
>   }
> @@ -3348,6 +3365,8 @@ static int ironlake_irq_postinstall(struct drm_device *dev)
>   
>   	gen5_gt_irq_postinstall(dev);
>   
> +	ilk_hpd_detection_setup(dev_priv);
> +
>   	ibx_irq_postinstall(dev);
>   
>   	if (IS_IRONLAKE_M(dev_priv)) {
> @@ -3488,6 +3507,8 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
>   
>   	if (IS_GEN9_LP(dev_priv))
>   		bxt_hpd_detection_setup(dev_priv);
> +	else if (IS_BROADWELL(dev_priv))
> +		ilk_hpd_detection_setup(dev_priv);
>   }
>   
>   static int gen8_irq_postinstall(struct drm_device *dev)

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

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

* Re: [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
  2017-01-28  4:54     ` Sharma, Shashank
@ 2017-01-28  7:54       ` Imre Deak
  -1 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-28  7:54 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

On Sat, Jan 28, 2017 at 10:24:19AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/27/2017 3:09 PM, Imre Deak wrote:
> >For LSPCON resume time initialization we need to sample the
> >corresponding pin's HPD level, but this is only available when HPD
> >detection is enabled. Currently we enable detection only when enabling
> >HPD interrupts which is too late, so bring the enabling of detection
> >earlier.
> >
> >This is needed by the next patch.
> >
> >Cc: Shashank Sharma <shashank.sharma@intel.com>
> >Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>
> >Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >Cc: <stable@vger.kernel.org> # v4.9+
> >Signed-off-by: Imre Deak <imre.deak@intel.com>
> >---
> >  drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
> >  1 file changed, 51 insertions(+), 20 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> >index 8440d8b..6daf522 100644
> >--- a/drivers/gpu/drm/i915/i915_irq.c
> >+++ b/drivers/gpu/drm/i915/i915_irq.c
> >@@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >  }
> >+static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> >+{
> >+	u32 hotplug;
> >+
> >+	/* Enable digital hotplug on the PCH */
> >+	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> >+	hotplug |= PORTA_HOTPLUG_ENABLE |
> >+		   PORTB_HOTPLUG_ENABLE |
> >+		   PORTC_HOTPLUG_ENABLE |
> >+		   PORTD_HOTPLUG_ENABLE;
> >+	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >+
> >+	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> >+	hotplug |= PORTE_HOTPLUG_ENABLE;
> >+	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> >+}
> >+
> >  static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  {
> >-	u32 hotplug_irqs, hotplug, enabled_irqs;
> >+	u32 hotplug_irqs, enabled_irqs;
> >  	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
> >  	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
> >  	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
> >-	/* Enable digital hotplug on the PCH */
> >-	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> >-	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
> >-		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
> >-	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >-
> >-	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> >-	hotplug |= PORTE_HOTPLUG_ENABLE;
> >-	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> >+	spt_hpd_detection_setup(dev_priv);
> >  }
> >  static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >@@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	ibx_hpd_irq_setup(dev_priv);
> >  }
> >-static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >+static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
> >+					     u32 enabled_irqs)
> >  {
> >-	u32 hotplug_irqs, hotplug, enabled_irqs;
> >-
> >-	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> >-	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> >-
> >-	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> >+	u32 hotplug;
> >  	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> >-	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
> >-		PORTA_HOTPLUG_ENABLE;
> >+	hotplug |= PORTA_HOTPLUG_ENABLE |
> >+		   PORTB_HOTPLUG_ENABLE |
> >+		   PORTC_HOTPLUG_ENABLE;
> >  	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
> >  		      hotplug, enabled_irqs);
> >@@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	 * For BXT invert bit has to be set based on AOB design
> >  	 * for HPD detection logic, update it based on VBT fields.
> >  	 */
> >-
> >  	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
> >  	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
> >  		hotplug |= BXT_DDIA_HPD_INVERT;
> >@@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >  }
> >+static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> >+{
> >+	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
> Do we need another layer of internal function ? Why cant the content of
> __bxt_hpd_detection_setup be here, just
> like spd_hpd_detection_setup, as they both are static to the file ?

The port configuration is platform specific and so I wanted to keep it
close to where the rest of HPD setup is done. The caller of
bxt_hpd_detection_setup() only cares about enabling detection on _all_
ports as the other *_hpd_detection_setup() helpers.

> >+}
> >+
> >+static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >+{
> >+	u32 hotplug_irqs, enabled_irqs;
> >+
> >+	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> >+	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> >+
> >+	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> >+
> >+	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
> >+}
> >+
> >  static void ibx_irq_postinstall(struct drm_device *dev)
> >  {
> >  	struct drm_i915_private *dev_priv = to_i915(dev);
> >@@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
> >  	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
> >  	I915_WRITE(SDEIMR, ~mask);
> >+
> >+	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
> >+	    HAS_PCH_LPT(dev_priv))
> >+		; /* TODO: Enable HPD detection on older PCH platforms too */
> >+	else
> >+		spt_hpd_detection_setup(dev_priv);
> >  }
> >  static void gen5_gt_irq_postinstall(struct drm_device *dev)
> >@@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
> >  	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
> >  	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
> >+
> >+	if (IS_GEN9_LP(dev_priv))
> I have not done the delta analysis between hotplug interrupts, but this will
> be true for GLK too.
> Should we bother ?

The GLK HPD detection setup and interrupt setup and handling is the same as
on BXT. See bxt_hpd_irq_setup() and bxt_hpd_irq_handler() that are
called on GLK as well.

> 
> - Shashank
> >+		bxt_hpd_detection_setup(dev_priv);
> >  }
> >  static int gen8_irq_postinstall(struct drm_device *dev)
> 

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

* Re: [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
@ 2017-01-28  7:54       ` Imre Deak
  0 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-28  7:54 UTC (permalink / raw)
  To: Sharma, Shashank; +Cc: Daniel Vetter, intel-gfx, stable

On Sat, Jan 28, 2017 at 10:24:19AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/27/2017 3:09 PM, Imre Deak wrote:
> >For LSPCON resume time initialization we need to sample the
> >corresponding pin's HPD level, but this is only available when HPD
> >detection is enabled. Currently we enable detection only when enabling
> >HPD interrupts which is too late, so bring the enabling of detection
> >earlier.
> >
> >This is needed by the next patch.
> >
> >Cc: Shashank Sharma <shashank.sharma@intel.com>
> >Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >Cc: <stable@vger.kernel.org> # v4.9+
> >Signed-off-by: Imre Deak <imre.deak@intel.com>
> >---
> >  drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
> >  1 file changed, 51 insertions(+), 20 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> >index 8440d8b..6daf522 100644
> >--- a/drivers/gpu/drm/i915/i915_irq.c
> >+++ b/drivers/gpu/drm/i915/i915_irq.c
> >@@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >  }
> >+static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> >+{
> >+	u32 hotplug;
> >+
> >+	/* Enable digital hotplug on the PCH */
> >+	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> >+	hotplug |= PORTA_HOTPLUG_ENABLE |
> >+		   PORTB_HOTPLUG_ENABLE |
> >+		   PORTC_HOTPLUG_ENABLE |
> >+		   PORTD_HOTPLUG_ENABLE;
> >+	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >+
> >+	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> >+	hotplug |= PORTE_HOTPLUG_ENABLE;
> >+	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> >+}
> >+
> >  static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  {
> >-	u32 hotplug_irqs, hotplug, enabled_irqs;
> >+	u32 hotplug_irqs, enabled_irqs;
> >  	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
> >  	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
> >  	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
> >-	/* Enable digital hotplug on the PCH */
> >-	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> >-	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
> >-		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
> >-	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >-
> >-	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
> >-	hotplug |= PORTE_HOTPLUG_ENABLE;
> >-	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
> >+	spt_hpd_detection_setup(dev_priv);
> >  }
> >  static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >@@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	ibx_hpd_irq_setup(dev_priv);
> >  }
> >-static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >+static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
> >+					     u32 enabled_irqs)
> >  {
> >-	u32 hotplug_irqs, hotplug, enabled_irqs;
> >-
> >-	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> >-	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> >-
> >-	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> >+	u32 hotplug;
> >  	hotplug = I915_READ(PCH_PORT_HOTPLUG);
> >-	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
> >-		PORTA_HOTPLUG_ENABLE;
> >+	hotplug |= PORTA_HOTPLUG_ENABLE |
> >+		   PORTB_HOTPLUG_ENABLE |
> >+		   PORTC_HOTPLUG_ENABLE;
> >  	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
> >  		      hotplug, enabled_irqs);
> >@@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	 * For BXT invert bit has to be set based on AOB design
> >  	 * for HPD detection logic, update it based on VBT fields.
> >  	 */
> >-
> >  	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
> >  	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
> >  		hotplug |= BXT_DDIA_HPD_INVERT;
> >@@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >  	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
> >  }
> >+static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
> >+{
> >+	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
> Do we need another layer of internal function ? Why cant the content of
> __bxt_hpd_detection_setup be here, just
> like spd_hpd_detection_setup, as they both are static to the file ?

The port configuration is platform specific and so I wanted to keep it
close to where the rest of HPD setup is done. The caller of
bxt_hpd_detection_setup() only cares about enabling detection on _all_
ports as the other *_hpd_detection_setup() helpers.

> >+}
> >+
> >+static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
> >+{
> >+	u32 hotplug_irqs, enabled_irqs;
> >+
> >+	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
> >+	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
> >+
> >+	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
> >+
> >+	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
> >+}
> >+
> >  static void ibx_irq_postinstall(struct drm_device *dev)
> >  {
> >  	struct drm_i915_private *dev_priv = to_i915(dev);
> >@@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
> >  	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
> >  	I915_WRITE(SDEIMR, ~mask);
> >+
> >+	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
> >+	    HAS_PCH_LPT(dev_priv))
> >+		; /* TODO: Enable HPD detection on older PCH platforms too */
> >+	else
> >+		spt_hpd_detection_setup(dev_priv);
> >  }
> >  static void gen5_gt_irq_postinstall(struct drm_device *dev)
> >@@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
> >  	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
> >  	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
> >+
> >+	if (IS_GEN9_LP(dev_priv))
> I have not done the delta analysis between hotplug interrupts, but this will
> be true for GLK too.
> Should we bother ?

The GLK HPD detection setup and interrupt setup and handling is the same as
on BXT. See bxt_hpd_irq_setup() and bxt_hpd_irq_handler() that are
called on GLK as well.

> 
> - Shashank
> >+		bxt_hpd_detection_setup(dev_priv);
> >  }
> >  static int gen8_irq_postinstall(struct drm_device *dev)
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  2017-01-28  5:02     ` Sharma, Shashank
@ 2017-01-28  8:17       ` Imre Deak
  -1 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-28  8:17 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/27/2017 3:09 PM, Imre Deak wrote:
> >During system resume time initialization the HPD level on LSPCON ports
> >can stay low for an extended amount of time, leading to failed AUX
> >transfers and LSPCON initialization. Fix this by waiting for HPD to get
> >asserted.
> >
> >Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
> >Cc: Shashank Sharma <shashank.sharma@intel.com>
> >Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>
> >Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >Cc: <stable@vger.kernel.org> # v4.9+
> >Signed-off-by: Imre Deak <imre.deak@intel.com>
> >---
> >  drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
> >  drivers/gpu/drm/i915/intel_drv.h    | 2 ++
> >  drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
> >  3 files changed, 8 insertions(+), 3 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >index e0f9b9e..a7785ce 100644
> >--- a/drivers/gpu/drm/i915/intel_dp.c
> >+++ b/drivers/gpu/drm/i915/intel_dp.c
> >@@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
> >   *
> >   * Return %true if @port is connected, %false otherwise.
> >   */
> >-static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >-					 struct intel_digital_port *port)
> >+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >+				  struct intel_digital_port *port)
> >  {
> >  	if (HAS_PCH_IBX(dev_priv))
> >  		return ibx_digital_port_connected(dev_priv, port);
> >diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> >index b71fece..b9cde11 100644
> >--- a/drivers/gpu/drm/i915/intel_drv.h
> >+++ b/drivers/gpu/drm/i915/intel_drv.h
> >@@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
> >  bool intel_dp_read_desc(struct intel_dp *intel_dp);
> >  int intel_dp_link_required(int pixel_clock, int bpp);
> >  int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
> >+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >+				  struct intel_digital_port *port);
> >  /* intel_dp_aux_backlight.c */
> >  int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
> >diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> >index f6d4e69..c300647 100644
> >--- a/drivers/gpu/drm/i915/intel_lspcon.c
> >+++ b/drivers/gpu/drm/i915/intel_lspcon.c
> >@@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
> >  static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >  {
> >  	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
> >+	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
> >+	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
> >  	unsigned long start = jiffies;
> >  	if (!lspcon->desc_valid)
> >@@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >  		if (!__intel_dp_read_desc(intel_dp, &desc))
> >  			return;
> >-		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >+		if (intel_digital_port_connected(dev_priv, dig_port) &&
> when in PCON mode, live_status is always up for LSPCON port, so this check
> will be always true, isn't it ?

Not at least in case of the MegaChips LSPCON I've seen, there it takes a
while for HPD to get asserted. And while it's not asserted AUX
transactions will either:
- return garbage in case of native AUX transactions
- hang the chip/FW until next cold reboot in case of I2C-over-AUX
  transactions
- simply not get a reply if the chip/FW initialization has reached a
  certain phase

Based on the DP specification the sink/branch device is not required to
respond in case the HPD is not asserted, so the 3rd scenario is
compliant, but the first two are not.

In PCON mode after initialization and HPD getting asserted, HPD will
stay asserted except for the short pulses signaling an output
connect/disconnect.

--Imre

> - Shashank
> >+		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >  			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
> >  				      jiffies_to_msecs(jiffies - start));
> >  			return;
> 

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
@ 2017-01-28  8:17       ` Imre Deak
  0 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-28  8:17 UTC (permalink / raw)
  To: Sharma, Shashank; +Cc: Daniel Vetter, intel-gfx, stable

On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/27/2017 3:09 PM, Imre Deak wrote:
> >During system resume time initialization the HPD level on LSPCON ports
> >can stay low for an extended amount of time, leading to failed AUX
> >transfers and LSPCON initialization. Fix this by waiting for HPD to get
> >asserted.
> >
> >Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
> >Cc: Shashank Sharma <shashank.sharma@intel.com>
> >Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >Cc: <stable@vger.kernel.org> # v4.9+
> >Signed-off-by: Imre Deak <imre.deak@intel.com>
> >---
> >  drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
> >  drivers/gpu/drm/i915/intel_drv.h    | 2 ++
> >  drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
> >  3 files changed, 8 insertions(+), 3 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >index e0f9b9e..a7785ce 100644
> >--- a/drivers/gpu/drm/i915/intel_dp.c
> >+++ b/drivers/gpu/drm/i915/intel_dp.c
> >@@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
> >   *
> >   * Return %true if @port is connected, %false otherwise.
> >   */
> >-static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >-					 struct intel_digital_port *port)
> >+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >+				  struct intel_digital_port *port)
> >  {
> >  	if (HAS_PCH_IBX(dev_priv))
> >  		return ibx_digital_port_connected(dev_priv, port);
> >diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> >index b71fece..b9cde11 100644
> >--- a/drivers/gpu/drm/i915/intel_drv.h
> >+++ b/drivers/gpu/drm/i915/intel_drv.h
> >@@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
> >  bool intel_dp_read_desc(struct intel_dp *intel_dp);
> >  int intel_dp_link_required(int pixel_clock, int bpp);
> >  int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
> >+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >+				  struct intel_digital_port *port);
> >  /* intel_dp_aux_backlight.c */
> >  int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
> >diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> >index f6d4e69..c300647 100644
> >--- a/drivers/gpu/drm/i915/intel_lspcon.c
> >+++ b/drivers/gpu/drm/i915/intel_lspcon.c
> >@@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
> >  static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >  {
> >  	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
> >+	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
> >+	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
> >  	unsigned long start = jiffies;
> >  	if (!lspcon->desc_valid)
> >@@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >  		if (!__intel_dp_read_desc(intel_dp, &desc))
> >  			return;
> >-		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >+		if (intel_digital_port_connected(dev_priv, dig_port) &&
> when in PCON mode, live_status is always up for LSPCON port, so this check
> will be always true, isn't it ?

Not at least in case of the MegaChips LSPCON I've seen, there it takes a
while for HPD to get asserted. And while it's not asserted AUX
transactions will either:
- return garbage in case of native AUX transactions
- hang the chip/FW until next cold reboot in case of I2C-over-AUX
  transactions
- simply not get a reply if the chip/FW initialization has reached a
  certain phase

Based on the DP specification the sink/branch device is not required to
respond in case the HPD is not asserted, so the 3rd scenario is
compliant, but the first two are not.

In PCON mode after initialization and HPD getting asserted, HPD will
stay asserted except for the short pulses signaling an output
connect/disconnect.

--Imre

> - Shashank
> >+		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >  			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
> >  				      jiffies_to_msecs(jiffies - start));
> >  			return;
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround
  2017-01-28  5:06   ` Sharma, Shashank
@ 2017-01-28  8:19     ` Imre Deak
  2017-02-02 10:54       ` Sharma, Shashank
  0 siblings, 1 reply; 29+ messages in thread
From: Imre Deak @ 2017-01-28  8:19 UTC (permalink / raw)
  To: Sharma, Shashank; +Cc: Daniel Vetter, intel-gfx

On Sat, Jan 28, 2017 at 10:36:16AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/27/2017 3:09 PM, Imre Deak wrote:
> >This effectively reverts
> >commit 489375c866c111f16cea93b2467ebe59c9022cc7
> >Author: Imre Deak <imre.deak@intel.com>
> >Date:   Mon Oct 24 19:33:31 2016 +0300
> >
> >     drm/i915/lspcon: Add workaround for resuming in PCON mode
> >
> >The workaround was added without considering that HPD is low during
> >the failed AUX transfers the WA fixed. Since the previous patch we
> >wait for HPD to get asserted. My tests also show that this happens
> >_after_ the DPCD reads start to return correct values. This
> >suggests that we don't need this WA any more, let's try to remove
> >it to reduce the clutter.
> >
> >Cc: Shashank Sharma <shashank.sharma@intel.com>
> >Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >Signed-off-by: Imre Deak <imre.deak@intel.com>
> >---
> >  drivers/gpu/drm/i915/intel_drv.h    |  1 -
> >  drivers/gpu/drm/i915/intel_lspcon.c | 17 ++---------------
> >  2 files changed, 2 insertions(+), 16 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> >index b9cde11..b2882ff 100644
> >--- a/drivers/gpu/drm/i915/intel_drv.h
> >+++ b/drivers/gpu/drm/i915/intel_drv.h
> >@@ -989,7 +989,6 @@ struct intel_dp {
> >  struct intel_lspcon {
> >  	bool active;
> >  	enum drm_lspcon_mode mode;
> >-	bool desc_valid;
> >  };
> >  struct intel_digital_port {
> >diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> >index c300647..71cbe9c 100644
> >--- a/drivers/gpu/drm/i915/intel_lspcon.c
> >+++ b/drivers/gpu/drm/i915/intel_lspcon.c
> >@@ -162,21 +162,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >  	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
> >  	unsigned long start = jiffies;
> >-	if (!lspcon->desc_valid)
> >-		return;
> >-
> >  	while (1) {
> >-		struct intel_dp_desc desc;
> >-
> >-		/*
> >-		 * The w/a only applies in PCON mode and we don't expect any
> >-		 * AUX errors.
> >-		 */
> >-		if (!__intel_dp_read_desc(intel_dp, &desc))
> >-			return;
> >-
> >-		if (intel_digital_port_connected(dev_priv, dig_port) &&
> >-		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >+		if (intel_digital_port_connected(dev_priv, dig_port)) {
> Again, does it matter, as in PCON mode live_status will be always true ?

See my answer for the previous patch.

> - Shashank
> >  			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
> >  				      jiffies_to_msecs(jiffies - start));
> >  			return;
> >@@ -253,7 +240,7 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
> >  		return false;
> >  	}
> >-	lspcon->desc_valid = intel_dp_read_desc(dp);
> >+	intel_dp_read_desc(dp);
> >  	DRM_DEBUG_KMS("Success: LSPCON init\n");
> >  	return true;
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
  2017-01-28  7:54       ` Imre Deak
@ 2017-01-29  4:56         ` Sharma, Shashank
  -1 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-29  4:56 UTC (permalink / raw)
  To: imre.deak
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

Regards

Shashank


On 1/28/2017 1:24 PM, Imre Deak wrote:
> On Sat, Jan 28, 2017 at 10:24:19AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>> For LSPCON resume time initialization we need to sample the
>>> corresponding pin's HPD level, but this is only available when HPD
>>> detection is enabled. Currently we enable detection only when enabling
>>> HPD interrupts which is too late, so bring the enabling of detection
>>> earlier.
>>>
>>> This is needed by the next patch.
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: <stable@vger.kernel.org> # v4.9+
>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
>>>   1 file changed, 51 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
>>> index 8440d8b..6daf522 100644
>>> --- a/drivers/gpu/drm/i915/i915_irq.c
>>> +++ b/drivers/gpu/drm/i915/i915_irq.c
>>> @@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>>   }
>>> +static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
>>> +{
>>> +	u32 hotplug;
>>> +
>>> +	/* Enable digital hotplug on the PCH */
>>> +	hotplug = I915_READ(PCH_PORT_HOTPLUG);
>>> +	hotplug |= PORTA_HOTPLUG_ENABLE |
>>> +		   PORTB_HOTPLUG_ENABLE |
>>> +		   PORTC_HOTPLUG_ENABLE |
>>> +		   PORTD_HOTPLUG_ENABLE;
>>> +	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>> +
>>> +	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
>>> +	hotplug |= PORTE_HOTPLUG_ENABLE;
>>> +	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
>>> +}
>>> +
>>>   static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   {
>>> -	u32 hotplug_irqs, hotplug, enabled_irqs;
>>> +	u32 hotplug_irqs, enabled_irqs;
>>>   	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
>>>   	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
>>>   	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
>>> -	/* Enable digital hotplug on the PCH */
>>> -	hotplug = I915_READ(PCH_PORT_HOTPLUG);
>>> -	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
>>> -		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
>>> -	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>> -
>>> -	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
>>> -	hotplug |= PORTE_HOTPLUG_ENABLE;
>>> -	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
>>> +	spt_hpd_detection_setup(dev_priv);
>>>   }
>>>   static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>> @@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	ibx_hpd_irq_setup(dev_priv);
>>>   }
>>> -static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>> +static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
>>> +					     u32 enabled_irqs)
>>>   {
>>> -	u32 hotplug_irqs, hotplug, enabled_irqs;
>>> -
>>> -	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
>>> -	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
>>> -
>>> -	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
>>> +	u32 hotplug;
>>>   	hotplug = I915_READ(PCH_PORT_HOTPLUG);
>>> -	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
>>> -		PORTA_HOTPLUG_ENABLE;
>>> +	hotplug |= PORTA_HOTPLUG_ENABLE |
>>> +		   PORTB_HOTPLUG_ENABLE |
>>> +		   PORTC_HOTPLUG_ENABLE;
>>>   	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
>>>   		      hotplug, enabled_irqs);
>>> @@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	 * For BXT invert bit has to be set based on AOB design
>>>   	 * for HPD detection logic, update it based on VBT fields.
>>>   	 */
>>> -
>>>   	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
>>>   	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
>>>   		hotplug |= BXT_DDIA_HPD_INVERT;
>>> @@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>>   }
>>> +static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
>>> +{
>>> +	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
>> Do we need another layer of internal function ? Why cant the content of
>> __bxt_hpd_detection_setup be here, just
>> like spd_hpd_detection_setup, as they both are static to the file ?
> The port configuration is platform specific and so I wanted to keep it
> close to where the rest of HPD setup is done. The caller of
> bxt_hpd_detection_setup() only cares about enabling detection on _all_
> ports as the other *_hpd_detection_setup() helpers.
I am not very convinced, but seems no harm too :)
>>> +}
>>> +
>>> +static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>> +{
>>> +	u32 hotplug_irqs, enabled_irqs;
>>> +
>>> +	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
>>> +	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
>>> +
>>> +	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
>>> +
>>> +	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
>>> +}
>>> +
>>>   static void ibx_irq_postinstall(struct drm_device *dev)
>>>   {
>>>   	struct drm_i915_private *dev_priv = to_i915(dev);
>>> @@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
>>>   	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
>>>   	I915_WRITE(SDEIMR, ~mask);
>>> +
>>> +	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
>>> +	    HAS_PCH_LPT(dev_priv))
>>> +		; /* TODO: Enable HPD detection on older PCH platforms too */
>>> +	else
>>> +		spt_hpd_detection_setup(dev_priv);
>>>   }
>>>   static void gen5_gt_irq_postinstall(struct drm_device *dev)
>>> @@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
>>>   	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
>>>   	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
>>> +
>>> +	if (IS_GEN9_LP(dev_priv))
>> I have not done the delta analysis between hotplug interrupts, but this will
>> be true for GLK too.
>> Should we bother ?
> The GLK HPD detection setup and interrupt setup and handling is the same as
> on BXT. See bxt_hpd_irq_setup() and bxt_hpd_irq_handler() that are
> called on GLK as well.
Yep, I was wandering about SCDC kind of interrupts, which are new in 
GLK, but probably I should
take care of it, while writing the code for that.

Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
>> - Shashank
>>> +		bxt_hpd_detection_setup(dev_priv);
>>>   }
>>>   static int gen8_irq_postinstall(struct drm_device *dev)


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

* Re: [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early
@ 2017-01-29  4:56         ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-29  4:56 UTC (permalink / raw)
  To: imre.deak; +Cc: Daniel Vetter, intel-gfx, stable

Regards

Shashank


On 1/28/2017 1:24 PM, Imre Deak wrote:
> On Sat, Jan 28, 2017 at 10:24:19AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>> For LSPCON resume time initialization we need to sample the
>>> corresponding pin's HPD level, but this is only available when HPD
>>> detection is enabled. Currently we enable detection only when enabling
>>> HPD interrupts which is too late, so bring the enabling of detection
>>> earlier.
>>>
>>> This is needed by the next patch.
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: <stable@vger.kernel.org> # v4.9+
>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/i915_irq.c | 71 +++++++++++++++++++++++++++++------------
>>>   1 file changed, 51 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
>>> index 8440d8b..6daf522 100644
>>> --- a/drivers/gpu/drm/i915/i915_irq.c
>>> +++ b/drivers/gpu/drm/i915/i915_irq.c
>>> @@ -3142,24 +3142,33 @@ static void ibx_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>>   }
>>> +static void spt_hpd_detection_setup(struct drm_i915_private *dev_priv)
>>> +{
>>> +	u32 hotplug;
>>> +
>>> +	/* Enable digital hotplug on the PCH */
>>> +	hotplug = I915_READ(PCH_PORT_HOTPLUG);
>>> +	hotplug |= PORTA_HOTPLUG_ENABLE |
>>> +		   PORTB_HOTPLUG_ENABLE |
>>> +		   PORTC_HOTPLUG_ENABLE |
>>> +		   PORTD_HOTPLUG_ENABLE;
>>> +	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>> +
>>> +	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
>>> +	hotplug |= PORTE_HOTPLUG_ENABLE;
>>> +	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
>>> +}
>>> +
>>>   static void spt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   {
>>> -	u32 hotplug_irqs, hotplug, enabled_irqs;
>>> +	u32 hotplug_irqs, enabled_irqs;
>>>   	hotplug_irqs = SDE_HOTPLUG_MASK_SPT;
>>>   	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_spt);
>>>   	ibx_display_interrupt_update(dev_priv, hotplug_irqs, enabled_irqs);
>>> -	/* Enable digital hotplug on the PCH */
>>> -	hotplug = I915_READ(PCH_PORT_HOTPLUG);
>>> -	hotplug |= PORTD_HOTPLUG_ENABLE | PORTC_HOTPLUG_ENABLE |
>>> -		PORTB_HOTPLUG_ENABLE | PORTA_HOTPLUG_ENABLE;
>>> -	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>> -
>>> -	hotplug = I915_READ(PCH_PORT_HOTPLUG2);
>>> -	hotplug |= PORTE_HOTPLUG_ENABLE;
>>> -	I915_WRITE(PCH_PORT_HOTPLUG2, hotplug);
>>> +	spt_hpd_detection_setup(dev_priv);
>>>   }
>>>   static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>> @@ -3196,18 +3205,15 @@ static void ilk_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	ibx_hpd_irq_setup(dev_priv);
>>>   }
>>> -static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>> +static void __bxt_hpd_detection_setup(struct drm_i915_private *dev_priv,
>>> +					     u32 enabled_irqs)
>>>   {
>>> -	u32 hotplug_irqs, hotplug, enabled_irqs;
>>> -
>>> -	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
>>> -	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
>>> -
>>> -	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
>>> +	u32 hotplug;
>>>   	hotplug = I915_READ(PCH_PORT_HOTPLUG);
>>> -	hotplug |= PORTC_HOTPLUG_ENABLE | PORTB_HOTPLUG_ENABLE |
>>> -		PORTA_HOTPLUG_ENABLE;
>>> +	hotplug |= PORTA_HOTPLUG_ENABLE |
>>> +		   PORTB_HOTPLUG_ENABLE |
>>> +		   PORTC_HOTPLUG_ENABLE;
>>>   	DRM_DEBUG_KMS("Invert bit setting: hp_ctl:%x hp_port:%x\n",
>>>   		      hotplug, enabled_irqs);
>>> @@ -3217,7 +3223,6 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	 * For BXT invert bit has to be set based on AOB design
>>>   	 * for HPD detection logic, update it based on VBT fields.
>>>   	 */
>>> -
>>>   	if ((enabled_irqs & BXT_DE_PORT_HP_DDIA) &&
>>>   	    intel_bios_is_port_hpd_inverted(dev_priv, PORT_A))
>>>   		hotplug |= BXT_DDIA_HPD_INVERT;
>>> @@ -3231,6 +3236,23 @@ static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>>   	I915_WRITE(PCH_PORT_HOTPLUG, hotplug);
>>>   }
>>> +static void bxt_hpd_detection_setup(struct drm_i915_private *dev_priv)
>>> +{
>>> +	__bxt_hpd_detection_setup(dev_priv, BXT_DE_PORT_HOTPLUG_MASK);
>> Do we need another layer of internal function ? Why cant the content of
>> __bxt_hpd_detection_setup be here, just
>> like spd_hpd_detection_setup, as they both are static to the file ?
> The port configuration is platform specific and so I wanted to keep it
> close to where the rest of HPD setup is done. The caller of
> bxt_hpd_detection_setup() only cares about enabling detection on _all_
> ports as the other *_hpd_detection_setup() helpers.
I am not very convinced, but seems no harm too :)
>>> +}
>>> +
>>> +static void bxt_hpd_irq_setup(struct drm_i915_private *dev_priv)
>>> +{
>>> +	u32 hotplug_irqs, enabled_irqs;
>>> +
>>> +	enabled_irqs = intel_hpd_enabled_irqs(dev_priv, hpd_bxt);
>>> +	hotplug_irqs = BXT_DE_PORT_HOTPLUG_MASK;
>>> +
>>> +	bdw_update_port_irq(dev_priv, hotplug_irqs, enabled_irqs);
>>> +
>>> +	__bxt_hpd_detection_setup(dev_priv, enabled_irqs);
>>> +}
>>> +
>>>   static void ibx_irq_postinstall(struct drm_device *dev)
>>>   {
>>>   	struct drm_i915_private *dev_priv = to_i915(dev);
>>> @@ -3246,6 +3268,12 @@ static void ibx_irq_postinstall(struct drm_device *dev)
>>>   	gen5_assert_iir_is_zero(dev_priv, SDEIIR);
>>>   	I915_WRITE(SDEIMR, ~mask);
>>> +
>>> +	if (HAS_PCH_IBX(dev_priv) || HAS_PCH_CPT(dev_priv) ||
>>> +	    HAS_PCH_LPT(dev_priv))
>>> +		; /* TODO: Enable HPD detection on older PCH platforms too */
>>> +	else
>>> +		spt_hpd_detection_setup(dev_priv);
>>>   }
>>>   static void gen5_gt_irq_postinstall(struct drm_device *dev)
>>> @@ -3457,6 +3485,9 @@ static void gen8_de_irq_postinstall(struct drm_i915_private *dev_priv)
>>>   	GEN5_IRQ_INIT(GEN8_DE_PORT_, ~de_port_masked, de_port_enables);
>>>   	GEN5_IRQ_INIT(GEN8_DE_MISC_, ~de_misc_masked, de_misc_masked);
>>> +
>>> +	if (IS_GEN9_LP(dev_priv))
>> I have not done the delta analysis between hotplug interrupts, but this will
>> be true for GLK too.
>> Should we bother ?
> The GLK HPD detection setup and interrupt setup and handling is the same as
> on BXT. See bxt_hpd_irq_setup() and bxt_hpd_irq_handler() that are
> called on GLK as well.
Yep, I was wandering about SCDC kind of interrupts, which are new in 
GLK, but probably I should
take care of it, while writing the code for that.

Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
>> - Shashank
>>> +		bxt_hpd_detection_setup(dev_priv);
>>>   }
>>>   static int gen8_irq_postinstall(struct drm_device *dev)

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

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  2017-01-28  8:17       ` Imre Deak
@ 2017-01-29  5:03         ` Sharma, Shashank
  -1 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-29  5:03 UTC (permalink / raw)
  To: imre.deak
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

Regards

Shashank


On 1/28/2017 1:47 PM, Imre Deak wrote:
> On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>> During system resume time initialization the HPD level on LSPCON ports
>>> can stay low for an extended amount of time, leading to failed AUX
>>> transfers and LSPCON initialization. Fix this by waiting for HPD to get
>>> asserted.
>>>
>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: <stable@vger.kernel.org> # v4.9+
>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
>>>   drivers/gpu/drm/i915/intel_drv.h    | 2 ++
>>>   drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
>>>   3 files changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
>>> index e0f9b9e..a7785ce 100644
>>> --- a/drivers/gpu/drm/i915/intel_dp.c
>>> +++ b/drivers/gpu/drm/i915/intel_dp.c
>>> @@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
>>>    *
>>>    * Return %true if @port is connected, %false otherwise.
>>>    */
>>> -static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>> -					 struct intel_digital_port *port)
>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>> +				  struct intel_digital_port *port)
>>>   {
>>>   	if (HAS_PCH_IBX(dev_priv))
>>>   		return ibx_digital_port_connected(dev_priv, port);
>>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>>> index b71fece..b9cde11 100644
>>> --- a/drivers/gpu/drm/i915/intel_drv.h
>>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>>> @@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
>>>   bool intel_dp_read_desc(struct intel_dp *intel_dp);
>>>   int intel_dp_link_required(int pixel_clock, int bpp);
>>>   int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>> +				  struct intel_digital_port *port);
>>>   /* intel_dp_aux_backlight.c */
>>>   int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
>>> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
>>> index f6d4e69..c300647 100644
>>> --- a/drivers/gpu/drm/i915/intel_lspcon.c
>>> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
>>> @@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
>>>   static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>   {
>>>   	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
>>> +	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
>>> +	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>>>   	unsigned long start = jiffies;
>>>   	if (!lspcon->desc_valid)
>>> @@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>   		if (!__intel_dp_read_desc(intel_dp, &desc))
>>>   			return;
>>> -		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>> +		if (intel_digital_port_connected(dev_priv, dig_port) &&
>> when in PCON mode, live_status is always up for LSPCON port, so this check
>> will be always true, isn't it ?
> Not at least in case of the MegaChips LSPCON I've seen, there it takes a
> while for HPD to get asserted. And while it's not asserted AUX
> transactions will either:
> - return garbage in case of native AUX transactions
> - hang the chip/FW until next cold reboot in case of I2C-over-AUX
>    transactions
> - simply not get a reply if the chip/FW initialization has reached a
>    certain phase
>
> Based on the DP specification the sink/branch device is not required to
> respond in case the HPD is not asserted, so the 3rd scenario is
> compliant, but the first two are not.
>
> In PCON mode after initialization and HPD getting asserted, HPD will
> stay asserted except for the short pulses signaling an output
> connect/disconnect.
The reason might be, that LSPCON resumes in LS type2 adapter state, 
where the live_status behavior is normal
and reflects the real HPD line, but the moment we move to PCON mode, HPD 
gets asserted low.
I know you would have tested this well, but I also want to test this 
code and logic first, before we go ahead with the patch.

Shashank
> --Imre
>
>> - Shashank
>>> +		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>>>   				      jiffies_to_msecs(jiffies - start));
>>>   			return;


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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
@ 2017-01-29  5:03         ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-01-29  5:03 UTC (permalink / raw)
  To: imre.deak; +Cc: Daniel Vetter, intel-gfx, stable

Regards

Shashank


On 1/28/2017 1:47 PM, Imre Deak wrote:
> On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>> During system resume time initialization the HPD level on LSPCON ports
>>> can stay low for an extended amount of time, leading to failed AUX
>>> transfers and LSPCON initialization. Fix this by waiting for HPD to get
>>> asserted.
>>>
>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Cc: <stable@vger.kernel.org> # v4.9+
>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
>>>   drivers/gpu/drm/i915/intel_drv.h    | 2 ++
>>>   drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
>>>   3 files changed, 8 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
>>> index e0f9b9e..a7785ce 100644
>>> --- a/drivers/gpu/drm/i915/intel_dp.c
>>> +++ b/drivers/gpu/drm/i915/intel_dp.c
>>> @@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
>>>    *
>>>    * Return %true if @port is connected, %false otherwise.
>>>    */
>>> -static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>> -					 struct intel_digital_port *port)
>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>> +				  struct intel_digital_port *port)
>>>   {
>>>   	if (HAS_PCH_IBX(dev_priv))
>>>   		return ibx_digital_port_connected(dev_priv, port);
>>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>>> index b71fece..b9cde11 100644
>>> --- a/drivers/gpu/drm/i915/intel_drv.h
>>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>>> @@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
>>>   bool intel_dp_read_desc(struct intel_dp *intel_dp);
>>>   int intel_dp_link_required(int pixel_clock, int bpp);
>>>   int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>> +				  struct intel_digital_port *port);
>>>   /* intel_dp_aux_backlight.c */
>>>   int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
>>> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
>>> index f6d4e69..c300647 100644
>>> --- a/drivers/gpu/drm/i915/intel_lspcon.c
>>> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
>>> @@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
>>>   static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>   {
>>>   	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
>>> +	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
>>> +	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>>>   	unsigned long start = jiffies;
>>>   	if (!lspcon->desc_valid)
>>> @@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>   		if (!__intel_dp_read_desc(intel_dp, &desc))
>>>   			return;
>>> -		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>> +		if (intel_digital_port_connected(dev_priv, dig_port) &&
>> when in PCON mode, live_status is always up for LSPCON port, so this check
>> will be always true, isn't it ?
> Not at least in case of the MegaChips LSPCON I've seen, there it takes a
> while for HPD to get asserted. And while it's not asserted AUX
> transactions will either:
> - return garbage in case of native AUX transactions
> - hang the chip/FW until next cold reboot in case of I2C-over-AUX
>    transactions
> - simply not get a reply if the chip/FW initialization has reached a
>    certain phase
>
> Based on the DP specification the sink/branch device is not required to
> respond in case the HPD is not asserted, so the 3rd scenario is
> compliant, but the first two are not.
>
> In PCON mode after initialization and HPD getting asserted, HPD will
> stay asserted except for the short pulses signaling an output
> connect/disconnect.
The reason might be, that LSPCON resumes in LS type2 adapter state, 
where the live_status behavior is normal
and reflects the real HPD line, but the moment we move to PCON mode, HPD 
gets asserted low.
I know you would have tested this well, but I also want to test this 
code and logic first, before we go ahead with the patch.

Shashank
> --Imre
>
>> - Shashank
>>> +		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>>>   				      jiffies_to_msecs(jiffies - start));
>>>   			return;

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

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  2017-01-29  5:03         ` Sharma, Shashank
@ 2017-01-29 16:13           ` Imre Deak
  -1 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-29 16:13 UTC (permalink / raw)
  To: Sharma, Shashank
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

On Sun, Jan 29, 2017 at 10:33:07AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/28/2017 1:47 PM, Imre Deak wrote:
> >On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
> >>Regards
> >>
> >>Shashank
> >>
> >>
> >>On 1/27/2017 3:09 PM, Imre Deak wrote:
> >>>During system resume time initialization the HPD level on LSPCON ports
> >>>can stay low for an extended amount of time, leading to failed AUX
> >>>transfers and LSPCON initialization. Fix this by waiting for HPD to get
> >>>asserted.
> >>>
> >>>Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
> >>>Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>>Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >>>Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>
> >>>Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >>>Cc: <stable@vger.kernel.org> # v4.9+
> >>>Signed-off-by: Imre Deak <imre.deak@intel.com>
> >>>---
> >>>  drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
> >>>  drivers/gpu/drm/i915/intel_drv.h    | 2 ++
> >>>  drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
> >>>  3 files changed, 8 insertions(+), 3 deletions(-)
> >>>
> >>>diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >>>index e0f9b9e..a7785ce 100644
> >>>--- a/drivers/gpu/drm/i915/intel_dp.c
> >>>+++ b/drivers/gpu/drm/i915/intel_dp.c
> >>>@@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>   *
> >>>   * Return %true if @port is connected, %false otherwise.
> >>>   */
> >>>-static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>-					 struct intel_digital_port *port)
> >>>+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>+				  struct intel_digital_port *port)
> >>>  {
> >>>  	if (HAS_PCH_IBX(dev_priv))
> >>>  		return ibx_digital_port_connected(dev_priv, port);
> >>>diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> >>>index b71fece..b9cde11 100644
> >>>--- a/drivers/gpu/drm/i915/intel_drv.h
> >>>+++ b/drivers/gpu/drm/i915/intel_drv.h
> >>>@@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
> >>>  bool intel_dp_read_desc(struct intel_dp *intel_dp);
> >>>  int intel_dp_link_required(int pixel_clock, int bpp);
> >>>  int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
> >>>+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>+				  struct intel_digital_port *port);
> >>>  /* intel_dp_aux_backlight.c */
> >>>  int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
> >>>diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> >>>index f6d4e69..c300647 100644
> >>>--- a/drivers/gpu/drm/i915/intel_lspcon.c
> >>>+++ b/drivers/gpu/drm/i915/intel_lspcon.c
> >>>@@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
> >>>  static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >>>  {
> >>>  	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
> >>>+	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
> >>>+	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
> >>>  	unsigned long start = jiffies;
> >>>  	if (!lspcon->desc_valid)
> >>>@@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >>>  		if (!__intel_dp_read_desc(intel_dp, &desc))
> >>>  			return;
> >>>-		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >>>+		if (intel_digital_port_connected(dev_priv, dig_port) &&
> >>when in PCON mode, live_status is always up for LSPCON port, so this check
> >>will be always true, isn't it ?
> >Not at least in case of the MegaChips LSPCON I've seen, there it takes a
> >while for HPD to get asserted. And while it's not asserted AUX
> >transactions will either:
> >- return garbage in case of native AUX transactions
> >- hang the chip/FW until next cold reboot in case of I2C-over-AUX
> >   transactions
> >- simply not get a reply if the chip/FW initialization has reached a
> >   certain phase
> >
> >Based on the DP specification the sink/branch device is not required to
> >respond in case the HPD is not asserted, so the 3rd scenario is
> >compliant, but the first two are not.
> >
> >In PCON mode after initialization and HPD getting asserted, HPD will
> >stay asserted except for the short pulses signaling an output
> >connect/disconnect.
> The reason might be, that LSPCON resumes in LS type2 adapter state, where
> the live_status behavior is normal
> and reflects the real HPD line, but the moment we move to PCON mode, HPD
> gets asserted low.

No, this chip/firmware resumes in PCON mode not in LS mode. Otherwise
native AUX transfers wouldn't return any reply (per LSPCON
specification) and HPD wouldn't get asserted on its own without a
display connected. Notice that we only check the LS/PCON state and
change it to PCON mode if necessary only after HPD gets asserted.

--Imre

> I know you would have tested this well, but I also want to test this code
> and logic first, before we go ahead with the patch.
> 
> Shashank
> >--Imre
> >
> >>- Shashank
> >>>+		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >>>  			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
> >>>  				      jiffies_to_msecs(jiffies - start));
> >>>  			return;
> 

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
@ 2017-01-29 16:13           ` Imre Deak
  0 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-01-29 16:13 UTC (permalink / raw)
  To: Sharma, Shashank; +Cc: Daniel Vetter, intel-gfx, stable

On Sun, Jan 29, 2017 at 10:33:07AM +0530, Sharma, Shashank wrote:
> Regards
> 
> Shashank
> 
> 
> On 1/28/2017 1:47 PM, Imre Deak wrote:
> >On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
> >>Regards
> >>
> >>Shashank
> >>
> >>
> >>On 1/27/2017 3:09 PM, Imre Deak wrote:
> >>>During system resume time initialization the HPD level on LSPCON ports
> >>>can stay low for an extended amount of time, leading to failed AUX
> >>>transfers and LSPCON initialization. Fix this by waiting for HPD to get
> >>>asserted.
> >>>
> >>>Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
> >>>Cc: Shashank Sharma <shashank.sharma@intel.com>
> >>>Cc: Jani Nikula <jani.nikula@linux.intel.com>
> >>>Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >>>Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> >>>Cc: <stable@vger.kernel.org> # v4.9+
> >>>Signed-off-by: Imre Deak <imre.deak@intel.com>
> >>>---
> >>>  drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
> >>>  drivers/gpu/drm/i915/intel_drv.h    | 2 ++
> >>>  drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
> >>>  3 files changed, 8 insertions(+), 3 deletions(-)
> >>>
> >>>diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> >>>index e0f9b9e..a7785ce 100644
> >>>--- a/drivers/gpu/drm/i915/intel_dp.c
> >>>+++ b/drivers/gpu/drm/i915/intel_dp.c
> >>>@@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>   *
> >>>   * Return %true if @port is connected, %false otherwise.
> >>>   */
> >>>-static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>-					 struct intel_digital_port *port)
> >>>+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>+				  struct intel_digital_port *port)
> >>>  {
> >>>  	if (HAS_PCH_IBX(dev_priv))
> >>>  		return ibx_digital_port_connected(dev_priv, port);
> >>>diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> >>>index b71fece..b9cde11 100644
> >>>--- a/drivers/gpu/drm/i915/intel_drv.h
> >>>+++ b/drivers/gpu/drm/i915/intel_drv.h
> >>>@@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
> >>>  bool intel_dp_read_desc(struct intel_dp *intel_dp);
> >>>  int intel_dp_link_required(int pixel_clock, int bpp);
> >>>  int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
> >>>+bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
> >>>+				  struct intel_digital_port *port);
> >>>  /* intel_dp_aux_backlight.c */
> >>>  int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
> >>>diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
> >>>index f6d4e69..c300647 100644
> >>>--- a/drivers/gpu/drm/i915/intel_lspcon.c
> >>>+++ b/drivers/gpu/drm/i915/intel_lspcon.c
> >>>@@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
> >>>  static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >>>  {
> >>>  	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
> >>>+	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
> >>>+	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
> >>>  	unsigned long start = jiffies;
> >>>  	if (!lspcon->desc_valid)
> >>>@@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
> >>>  		if (!__intel_dp_read_desc(intel_dp, &desc))
> >>>  			return;
> >>>-		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >>>+		if (intel_digital_port_connected(dev_priv, dig_port) &&
> >>when in PCON mode, live_status is always up for LSPCON port, so this check
> >>will be always true, isn't it ?
> >Not at least in case of the MegaChips LSPCON I've seen, there it takes a
> >while for HPD to get asserted. And while it's not asserted AUX
> >transactions will either:
> >- return garbage in case of native AUX transactions
> >- hang the chip/FW until next cold reboot in case of I2C-over-AUX
> >   transactions
> >- simply not get a reply if the chip/FW initialization has reached a
> >   certain phase
> >
> >Based on the DP specification the sink/branch device is not required to
> >respond in case the HPD is not asserted, so the 3rd scenario is
> >compliant, but the first two are not.
> >
> >In PCON mode after initialization and HPD getting asserted, HPD will
> >stay asserted except for the short pulses signaling an output
> >connect/disconnect.
> The reason might be, that LSPCON resumes in LS type2 adapter state, where
> the live_status behavior is normal
> and reflects the real HPD line, but the moment we move to PCON mode, HPD
> gets asserted low.

No, this chip/firmware resumes in PCON mode not in LS mode. Otherwise
native AUX transfers wouldn't return any reply (per LSPCON
specification) and HPD wouldn't get asserted on its own without a
display connected. Notice that we only check the LS/PCON state and
change it to PCON mode if necessary only after HPD gets asserted.

--Imre

> I know you would have tested this well, but I also want to test this code
> and logic first, before we go ahead with the patch.
> 
> Shashank
> >--Imre
> >
> >>- Shashank
> >>>+		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
> >>>  			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
> >>>  				      jiffies_to_msecs(jiffies - start));
> >>>  			return;
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
  2017-01-29 16:13           ` Imre Deak
@ 2017-02-02 10:53             ` Sharma, Shashank
  -1 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-02-02 10:53 UTC (permalink / raw)
  To: imre.deak
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

Reviewed-by: Shashank Sharma

Regards
Shashank
On 1/29/2017 9:43 PM, Imre Deak wrote:
> On Sun, Jan 29, 2017 at 10:33:07AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/28/2017 1:47 PM, Imre Deak wrote:
>>> On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
>>>> Regards
>>>>
>>>> Shashank
>>>>
>>>>
>>>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>>>> During system resume time initialization the HPD level on LSPCON ports
>>>>> can stay low for an extended amount of time, leading to failed AUX
>>>>> transfers and LSPCON initialization. Fix this by waiting for HPD to get
>>>>> asserted.
>>>>>
>>>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
>>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>>>> Cc: Ville Syrj�l� <ville.syrjala@linux.intel.com>
>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>> Cc: <stable@vger.kernel.org> # v4.9+
>>>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>>>> ---
>>>>>   drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
>>>>>   drivers/gpu/drm/i915/intel_drv.h    | 2 ++
>>>>>   drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
>>>>>   3 files changed, 8 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
>>>>> index e0f9b9e..a7785ce 100644
>>>>> --- a/drivers/gpu/drm/i915/intel_dp.c
>>>>> +++ b/drivers/gpu/drm/i915/intel_dp.c
>>>>> @@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>>    *
>>>>>    * Return %true if @port is connected, %false otherwise.
>>>>>    */
>>>>> -static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>> -					 struct intel_digital_port *port)
>>>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>> +				  struct intel_digital_port *port)
>>>>>   {
>>>>>   	if (HAS_PCH_IBX(dev_priv))
>>>>>   		return ibx_digital_port_connected(dev_priv, port);
>>>>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>>>>> index b71fece..b9cde11 100644
>>>>> --- a/drivers/gpu/drm/i915/intel_drv.h
>>>>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>>>>> @@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
>>>>>   bool intel_dp_read_desc(struct intel_dp *intel_dp);
>>>>>   int intel_dp_link_required(int pixel_clock, int bpp);
>>>>>   int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
>>>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>> +				  struct intel_digital_port *port);
>>>>>   /* intel_dp_aux_backlight.c */
>>>>>   int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
>>>>> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
>>>>> index f6d4e69..c300647 100644
>>>>> --- a/drivers/gpu/drm/i915/intel_lspcon.c
>>>>> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
>>>>> @@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
>>>>>   static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>>>   {
>>>>>   	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
>>>>> +	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
>>>>> +	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>>>>>   	unsigned long start = jiffies;
>>>>>   	if (!lspcon->desc_valid)
>>>>> @@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>>>   		if (!__intel_dp_read_desc(intel_dp, &desc))
>>>>>   			return;
>>>>> -		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>>>> +		if (intel_digital_port_connected(dev_priv, dig_port) &&
>>>> when in PCON mode, live_status is always up for LSPCON port, so this check
>>>> will be always true, isn't it ?
>>> Not at least in case of the MegaChips LSPCON I've seen, there it takes a
>>> while for HPD to get asserted. And while it's not asserted AUX
>>> transactions will either:
>>> - return garbage in case of native AUX transactions
>>> - hang the chip/FW until next cold reboot in case of I2C-over-AUX
>>>    transactions
>>> - simply not get a reply if the chip/FW initialization has reached a
>>>    certain phase
>>>
>>> Based on the DP specification the sink/branch device is not required to
>>> respond in case the HPD is not asserted, so the 3rd scenario is
>>> compliant, but the first two are not.
>>>
>>> In PCON mode after initialization and HPD getting asserted, HPD will
>>> stay asserted except for the short pulses signaling an output
>>> connect/disconnect.
>> The reason might be, that LSPCON resumes in LS type2 adapter state, where
>> the live_status behavior is normal
>> and reflects the real HPD line, but the moment we move to PCON mode, HPD
>> gets asserted low.
> No, this chip/firmware resumes in PCON mode not in LS mode. Otherwise
> native AUX transfers wouldn't return any reply (per LSPCON
> specification) and HPD wouldn't get asserted on its own without a
> display connected. Notice that we only check the LS/PCON state and
> change it to PCON mode if necessary only after HPD gets asserted.
>
> --Imre
>
>> I know you would have tested this well, but I also want to test this code
>> and logic first, before we go ahead with the patch.
>>
>> Shashank
>>> --Imre
>>>
>>>> - Shashank
>>>>> +		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>>>>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>>>>>   				      jiffies_to_msecs(jiffies - start));
>>>>>   			return;


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

* Re: [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
@ 2017-02-02 10:53             ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-02-02 10:53 UTC (permalink / raw)
  To: imre.deak
  Cc: intel-gfx, Jani Nikula, Ville Syrjälä, Daniel Vetter, stable

Reviewed-by: Shashank Sharma

Regards
Shashank
On 1/29/2017 9:43 PM, Imre Deak wrote:
> On Sun, Jan 29, 2017 at 10:33:07AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/28/2017 1:47 PM, Imre Deak wrote:
>>> On Sat, Jan 28, 2017 at 10:32:03AM +0530, Sharma, Shashank wrote:
>>>> Regards
>>>>
>>>> Shashank
>>>>
>>>>
>>>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>>>> During system resume time initialization the HPD level on LSPCON ports
>>>>> can stay low for an extended amount of time, leading to failed AUX
>>>>> transfers and LSPCON initialization. Fix this by waiting for HPD to get
>>>>> asserted.
>>>>>
>>>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99178
>>>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>>>> Cc: <stable@vger.kernel.org> # v4.9+
>>>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>>>> ---
>>>>>   drivers/gpu/drm/i915/intel_dp.c     | 4 ++--
>>>>>   drivers/gpu/drm/i915/intel_drv.h    | 2 ++
>>>>>   drivers/gpu/drm/i915/intel_lspcon.c | 5 ++++-
>>>>>   3 files changed, 8 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
>>>>> index e0f9b9e..a7785ce 100644
>>>>> --- a/drivers/gpu/drm/i915/intel_dp.c
>>>>> +++ b/drivers/gpu/drm/i915/intel_dp.c
>>>>> @@ -4400,8 +4400,8 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>>    *
>>>>>    * Return %true if @port is connected, %false otherwise.
>>>>>    */
>>>>> -static bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>> -					 struct intel_digital_port *port)
>>>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>> +				  struct intel_digital_port *port)
>>>>>   {
>>>>>   	if (HAS_PCH_IBX(dev_priv))
>>>>>   		return ibx_digital_port_connected(dev_priv, port);
>>>>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>>>>> index b71fece..b9cde11 100644
>>>>> --- a/drivers/gpu/drm/i915/intel_drv.h
>>>>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>>>>> @@ -1489,6 +1489,8 @@ bool __intel_dp_read_desc(struct intel_dp *intel_dp,
>>>>>   bool intel_dp_read_desc(struct intel_dp *intel_dp);
>>>>>   int intel_dp_link_required(int pixel_clock, int bpp);
>>>>>   int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
>>>>> +bool intel_digital_port_connected(struct drm_i915_private *dev_priv,
>>>>> +				  struct intel_digital_port *port);
>>>>>   /* intel_dp_aux_backlight.c */
>>>>>   int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
>>>>> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
>>>>> index f6d4e69..c300647 100644
>>>>> --- a/drivers/gpu/drm/i915/intel_lspcon.c
>>>>> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
>>>>> @@ -158,6 +158,8 @@ static bool lspcon_probe(struct intel_lspcon *lspcon)
>>>>>   static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>>>   {
>>>>>   	struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
>>>>> +	struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
>>>>> +	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>>>>>   	unsigned long start = jiffies;
>>>>>   	if (!lspcon->desc_valid)
>>>>> @@ -173,7 +175,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>>>   		if (!__intel_dp_read_desc(intel_dp, &desc))
>>>>>   			return;
>>>>> -		if (!memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>>>> +		if (intel_digital_port_connected(dev_priv, dig_port) &&
>>>> when in PCON mode, live_status is always up for LSPCON port, so this check
>>>> will be always true, isn't it ?
>>> Not at least in case of the MegaChips LSPCON I've seen, there it takes a
>>> while for HPD to get asserted. And while it's not asserted AUX
>>> transactions will either:
>>> - return garbage in case of native AUX transactions
>>> - hang the chip/FW until next cold reboot in case of I2C-over-AUX
>>>    transactions
>>> - simply not get a reply if the chip/FW initialization has reached a
>>>    certain phase
>>>
>>> Based on the DP specification the sink/branch device is not required to
>>> respond in case the HPD is not asserted, so the 3rd scenario is
>>> compliant, but the first two are not.
>>>
>>> In PCON mode after initialization and HPD getting asserted, HPD will
>>> stay asserted except for the short pulses signaling an output
>>> connect/disconnect.
>> The reason might be, that LSPCON resumes in LS type2 adapter state, where
>> the live_status behavior is normal
>> and reflects the real HPD line, but the moment we move to PCON mode, HPD
>> gets asserted low.
> No, this chip/firmware resumes in PCON mode not in LS mode. Otherwise
> native AUX transfers wouldn't return any reply (per LSPCON
> specification) and HPD wouldn't get asserted on its own without a
> display connected. Notice that we only check the LS/PCON state and
> change it to PCON mode if necessary only after HPD gets asserted.
>
> --Imre
>
>> I know you would have tested this well, but I also want to test this code
>> and logic first, before we go ahead with the patch.
>>
>> Shashank
>>> --Imre
>>>
>>>> - Shashank
>>>>> +		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>>>>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>>>>>   				      jiffies_to_msecs(jiffies - start));
>>>>>   			return;

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

* Re: [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround
  2017-01-28  8:19     ` Imre Deak
@ 2017-02-02 10:54       ` Sharma, Shashank
  0 siblings, 0 replies; 29+ messages in thread
From: Sharma, Shashank @ 2017-02-02 10:54 UTC (permalink / raw)
  To: imre.deak; +Cc: Daniel Vetter, intel-gfx

Reviewed-by: Shashank Sharma

Regards
Shashank
On 1/28/2017 1:49 PM, Imre Deak wrote:
> On Sat, Jan 28, 2017 at 10:36:16AM +0530, Sharma, Shashank wrote:
>> Regards
>>
>> Shashank
>>
>>
>> On 1/27/2017 3:09 PM, Imre Deak wrote:
>>> This effectively reverts
>>> commit 489375c866c111f16cea93b2467ebe59c9022cc7
>>> Author: Imre Deak <imre.deak@intel.com>
>>> Date:   Mon Oct 24 19:33:31 2016 +0300
>>>
>>>      drm/i915/lspcon: Add workaround for resuming in PCON mode
>>>
>>> The workaround was added without considering that HPD is low during
>>> the failed AUX transfers the WA fixed. Since the previous patch we
>>> wait for HPD to get asserted. My tests also show that this happens
>>> _after_ the DPCD reads start to return correct values. This
>>> suggests that we don't need this WA any more, let's try to remove
>>> it to reduce the clutter.
>>>
>>> Cc: Shashank Sharma <shashank.sharma@intel.com>
>>> Cc: Jani Nikula <jani.nikula@linux.intel.com>
>>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/intel_drv.h    |  1 -
>>>   drivers/gpu/drm/i915/intel_lspcon.c | 17 ++---------------
>>>   2 files changed, 2 insertions(+), 16 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>>> index b9cde11..b2882ff 100644
>>> --- a/drivers/gpu/drm/i915/intel_drv.h
>>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>>> @@ -989,7 +989,6 @@ struct intel_dp {
>>>   struct intel_lspcon {
>>>   	bool active;
>>>   	enum drm_lspcon_mode mode;
>>> -	bool desc_valid;
>>>   };
>>>   struct intel_digital_port {
>>> diff --git a/drivers/gpu/drm/i915/intel_lspcon.c b/drivers/gpu/drm/i915/intel_lspcon.c
>>> index c300647..71cbe9c 100644
>>> --- a/drivers/gpu/drm/i915/intel_lspcon.c
>>> +++ b/drivers/gpu/drm/i915/intel_lspcon.c
>>> @@ -162,21 +162,8 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
>>>   	struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
>>>   	unsigned long start = jiffies;
>>> -	if (!lspcon->desc_valid)
>>> -		return;
>>> -
>>>   	while (1) {
>>> -		struct intel_dp_desc desc;
>>> -
>>> -		/*
>>> -		 * The w/a only applies in PCON mode and we don't expect any
>>> -		 * AUX errors.
>>> -		 */
>>> -		if (!__intel_dp_read_desc(intel_dp, &desc))
>>> -			return;
>>> -
>>> -		if (intel_digital_port_connected(dev_priv, dig_port) &&
>>> -		    !memcmp(&intel_dp->desc, &desc, sizeof(desc))) {
>>> +		if (intel_digital_port_connected(dev_priv, dig_port)) {
>> Again, does it matter, as in PCON mode live_status will be always true ?
> See my answer for the previous patch.
>
>> - Shashank
>>>   			DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
>>>   				      jiffies_to_msecs(jiffies - start));
>>>   			return;
>>> @@ -253,7 +240,7 @@ bool lspcon_init(struct intel_digital_port *intel_dig_port)
>>>   		return false;
>>>   	}
>>> -	lspcon->desc_valid = intel_dp_read_desc(dp);
>>> +	intel_dp_read_desc(dp);
>>>   	DRM_DEBUG_KMS("Success: LSPCON init\n");
>>>   	return true;

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

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

* Re: ✓ Fi.CI.BAT: success for drm/i915/lspcon: Fix resume time init due to low HPD
  2017-01-27 11:24 ` ✓ Fi.CI.BAT: success for drm/i915/lspcon: Fix resume time init due to low HPD Patchwork
@ 2017-02-06 14:46   ` Imre Deak
  0 siblings, 0 replies; 29+ messages in thread
From: Imre Deak @ 2017-02-06 14:46 UTC (permalink / raw)
  To: intel-gfx, Shashank Sharma

On Fri, Jan 27, 2017 at 11:24:22AM +0000, Patchwork wrote:
> == Series Details ==
> 
> Series: drm/i915/lspcon: Fix resume time init due to low HPD
> URL   : https://patchwork.freedesktop.org/series/18656/
> State : success
> 
> == Summary ==
> 
> Series 18656v1 drm/i915/lspcon: Fix resume time init due to low HPD
> https://patchwork.freedesktop.org/api/1.0/series/18656/revisions/1/mbox/

Pushed the series to drm-tip, thanks for the review.

--Imre

> fi-bdw-5557u     total:247  pass:233  dwarn:0   dfail:0   fail:0   skip:14 
> fi-bsw-n3050     total:247  pass:208  dwarn:0   dfail:0   fail:0   skip:39 
> fi-bxt-j4205     total:247  pass:225  dwarn:0   dfail:0   fail:0   skip:22 
> fi-bxt-t5700     total:79   pass:66   dwarn:0   dfail:0   fail:0   skip:12 
> fi-byt-j1900     total:247  pass:220  dwarn:0   dfail:0   fail:0   skip:27 
> fi-byt-n2820     total:247  pass:216  dwarn:0   dfail:0   fail:0   skip:31 
> fi-hsw-4770      total:247  pass:228  dwarn:0   dfail:0   fail:0   skip:19 
> fi-hsw-4770r     total:247  pass:228  dwarn:0   dfail:0   fail:0   skip:19 
> fi-ivb-3520m     total:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
> fi-ivb-3770      total:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
> fi-kbl-7500u     total:247  pass:226  dwarn:0   dfail:0   fail:0   skip:21 
> fi-skl-6260u     total:247  pass:234  dwarn:0   dfail:0   fail:0   skip:13 
> fi-skl-6700hq    total:247  pass:227  dwarn:0   dfail:0   fail:0   skip:20 
> fi-skl-6700k     total:247  pass:222  dwarn:4   dfail:0   fail:0   skip:21 
> fi-skl-6770hq    total:247  pass:234  dwarn:0   dfail:0   fail:0   skip:13 
> fi-snb-2520m     total:247  pass:216  dwarn:0   dfail:0   fail:0   skip:31 
> fi-snb-2600      total:247  pass:215  dwarn:0   dfail:0   fail:0   skip:32 
> 
> 93cbdef9696bcaa1279ae05c418b2794b71c2398 drm-tip: 2017y-01m-27d-09h-55m-16s UTC integration manifest
> 910551d drm/i915/gen5+, pch: Enable hotplug detection early
> 4fbb08f drm/i915/lspcon: Remove DPCD compare based resume time workaround
> bd5876e drm/i915/lspcon: Fix resume time initialization due to unasserted HPD
> d4c554d drm/i915/gen9+: Enable hotplug detection early
> 
> == Logs ==
> 
> For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3620/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2017-02-06 14:46 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27  9:39 [PATCH 0/4] drm/i915/lspcon: Fix resume time init due to low HPD Imre Deak
2017-01-27  9:39 ` [PATCH 1/4] drm/i915/gen9+: Enable hotplug detection early Imre Deak
2017-01-27  9:39   ` Imre Deak
2017-01-28  4:54   ` Sharma, Shashank
2017-01-28  4:54     ` Sharma, Shashank
2017-01-28  7:54     ` Imre Deak
2017-01-28  7:54       ` Imre Deak
2017-01-29  4:56       ` Sharma, Shashank
2017-01-29  4:56         ` Sharma, Shashank
2017-01-27  9:39 ` [PATCH 2/4] drm/i915/lspcon: Fix resume time initialization due to unasserted HPD Imre Deak
2017-01-27  9:39   ` Imre Deak
2017-01-28  5:02   ` Sharma, Shashank
2017-01-28  5:02     ` Sharma, Shashank
2017-01-28  8:17     ` Imre Deak
2017-01-28  8:17       ` Imre Deak
2017-01-29  5:03       ` Sharma, Shashank
2017-01-29  5:03         ` Sharma, Shashank
2017-01-29 16:13         ` Imre Deak
2017-01-29 16:13           ` Imre Deak
2017-02-02 10:53           ` Sharma, Shashank
2017-02-02 10:53             ` Sharma, Shashank
2017-01-27  9:39 ` [PATCH 3/4] drm/i915/lspcon: Remove DPCD compare based resume time workaround Imre Deak
2017-01-28  5:06   ` Sharma, Shashank
2017-01-28  8:19     ` Imre Deak
2017-02-02 10:54       ` Sharma, Shashank
2017-01-27  9:39 ` [PATCH 4/4] drm/i915/gen5+, pch: Enable hotplug detection early Imre Deak
2017-01-28  5:09   ` Sharma, Shashank
2017-01-27 11:24 ` ✓ Fi.CI.BAT: success for drm/i915/lspcon: Fix resume time init due to low HPD Patchwork
2017-02-06 14:46   ` Imre Deak

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.