Re: [Intel-gfx] [PATCH v3 4/4] drm/i915: Implement Link Rate fallback on Link training failure

2016-11-09 Thread Manasi Navare
On Wed, Nov 09, 2016 at 03:04:05PM +0200, Jani Nikula wrote:
> On Wed, 02 Nov 2016, Manasi Navare  wrote:
> > If link training at a link rate optimal for a particular
> > mode fails during modeset's atomic commit phase, then we
> > let the modeset complete and then retry. We save the link rate
> > value at which link training failed, update the link status property
> > to "BAD" and use a lower link rate to prune the modes. It will redo
> > the modeset on the current mode at lower link rate or if the current
> > mode gets pruned due to lower link constraints then, it will send a
> > hotplug uevent for userspace to handle it.
> >
> > This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
> > 4.3.1.6.
> >
> > v3:
> > * Set link status property to BAd unconditionally (Jani Nikula)
> > * Dont use two separate variables link_train_failed and link_status
> > to indicate same thing (Jani Nikula)
> > v2:
> > * Squashed a few patches (Jani Nikula)
> >
> > Cc: Jani Nikula 
> > Cc: Daniel Vetter 
> > Cc: Ville Syrjala 
> > Signed-off-by: Manasi Navare 
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c   |  7 +++
> >  drivers/gpu/drm/i915/intel_ddi.c  | 22 -
> >  drivers/gpu/drm/i915/intel_dp.c   | 70 
> > ---
> >  drivers/gpu/drm/i915/intel_dp_link_training.c | 12 +++--
> >  drivers/gpu/drm/i915/intel_drv.h  |  6 ++-
> >  5 files changed, 105 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> > b/drivers/gpu/drm/drm_atomic_helper.c
> > index 75ad01d..94b0b3a 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -519,6 +519,13 @@ static int handle_conflicting_encoders(struct 
> > drm_atomic_state *state,
> >connector_state);
> > if (ret)
> > return ret;
> > +
> > +   if (connector->state->crtc) {
> > +   crtc_state = drm_atomic_get_existing_crtc_state(state,
> > +   
> > connector->state->crtc);
> > +   if (connector->link_status == DRM_MODE_LINK_STATUS_BAD)
> > +   crtc_state->connectors_changed = true;
> > +   }
> > }
> 
> Could this be a separate patch? Anyway needs to be posted on dri-devel.
>

Yes I agree, I will move this into a separate patch right after the patch
where I declare the connector link status.
 
> >  
> > /*
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
> > b/drivers/gpu/drm/i915/intel_ddi.c
> > index 938ac4d..a59f8d2 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct 
> > intel_encoder *encoder,
> > struct intel_dp *intel_dp = enc_to_intel_dp(>base);
> > struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> > enum port port = intel_ddi_get_encoder_port(encoder);
> > +   struct intel_connector *intel_connector = intel_dp->attached_connector;
> > +   struct drm_connector *connector = _connector->base;
> >  
> > intel_dp_set_link_params(intel_dp, link_rate, lane_count,
> >  link_mst);
> > @@ -1694,7 +1696,25 @@ static void intel_ddi_pre_enable_dp(struct 
> > intel_encoder *encoder,
> > intel_prepare_dp_ddi_buffers(encoder);
> > intel_ddi_init_dp_buf_reg(encoder);
> > intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> > -   intel_dp_start_link_train(intel_dp);
> > +   if (!intel_dp_start_link_train(intel_dp)) {
> > +   DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane 
> > count = %d",
> > + link_rate, lane_count);
> > +   connector->link_status = DRM_MODE_LINK_STATUS_BAD;
> 
> Why does this not use intel_dp_set_link_status_property()?
> 

I will move this connector->link_status setting inside the set_link_status 
function.


> > +   intel_dp_get_link_train_fallback_values(intel_dp, link_rate,
> > +   lane_count);
> > +   /* Schedule a Hotplug Uevent to userspace to start modeset */
> > +   schedule_work(_connector->modeset_retry_work);
> > +   } else {
> > +   DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane 
> > count = %d",
> > + link_rate, lane_count);
> > +   intel_dp->fallback_link_rate_index = -1;
> > +   intel_dp->fallback_link_rate = 0;
> > +   intel_dp->fallback_lane_count = 0;
> > +   connector->link_status = DRM_MODE_LINK_STATUS_GOOD;
> > +   intel_dp_set_link_status_property(connector,
> > + DRM_MODE_LINK_STATUS_GOOD);
> > +   }
> > +
> > 

Re: [Intel-gfx] [PATCH v3 4/4] drm/i915: Implement Link Rate fallback on Link training failure

2016-11-09 Thread Jani Nikula
On Mon, 07 Nov 2016, Manasi Navare  wrote:
> Jani, could you please take a look at this patch? 
> I have addressed your comments on the previous revision.
> The common_rates array can be moved into Intel dp
> structure in a follow up patch since that would require changes
> in a lot of places other than the link rate fallback implementation.

I think this is looking good. I think you need to put this together in a
series that doesn't add something first, and then remove it, i.e. build
a coherent story from the start. It's not that many patches. Then you
need to post all patches on both intel-gfx and dri-devel, preferrably in
a fresh thread, not replying to previous versions. The thread is too
confusing now with so many versions.

Then we need to get r-b and acks for the drm changes. Daniel, can you
help with the last part?

BR,
Jani.


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


Re: [Intel-gfx] [PATCH v3 4/4] drm/i915: Implement Link Rate fallback on Link training failure

2016-11-09 Thread Jani Nikula
On Wed, 02 Nov 2016, Manasi Navare  wrote:
> If link training at a link rate optimal for a particular
> mode fails during modeset's atomic commit phase, then we
> let the modeset complete and then retry. We save the link rate
> value at which link training failed, update the link status property
> to "BAD" and use a lower link rate to prune the modes. It will redo
> the modeset on the current mode at lower link rate or if the current
> mode gets pruned due to lower link constraints then, it will send a
> hotplug uevent for userspace to handle it.
>
> This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
> 4.3.1.6.
>
> v3:
> * Set link status property to BAd unconditionally (Jani Nikula)
> * Dont use two separate variables link_train_failed and link_status
> to indicate same thing (Jani Nikula)
> v2:
> * Squashed a few patches (Jani Nikula)
>
> Cc: Jani Nikula 
> Cc: Daniel Vetter 
> Cc: Ville Syrjala 
> Signed-off-by: Manasi Navare 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c   |  7 +++
>  drivers/gpu/drm/i915/intel_ddi.c  | 22 -
>  drivers/gpu/drm/i915/intel_dp.c   | 70 
> ---
>  drivers/gpu/drm/i915/intel_dp_link_training.c | 12 +++--
>  drivers/gpu/drm/i915/intel_drv.h  |  6 ++-
>  5 files changed, 105 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 75ad01d..94b0b3a 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -519,6 +519,13 @@ static int handle_conflicting_encoders(struct 
> drm_atomic_state *state,
>  connector_state);
>   if (ret)
>   return ret;
> +
> + if (connector->state->crtc) {
> + crtc_state = drm_atomic_get_existing_crtc_state(state,
> + 
> connector->state->crtc);
> + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD)
> + crtc_state->connectors_changed = true;
> + }
>   }

Could this be a separate patch? Anyway needs to be posted on dri-devel.

>  
>   /*
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
> b/drivers/gpu/drm/i915/intel_ddi.c
> index 938ac4d..a59f8d2 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct 
> intel_encoder *encoder,
>   struct intel_dp *intel_dp = enc_to_intel_dp(>base);
>   struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>   enum port port = intel_ddi_get_encoder_port(encoder);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = _connector->base;
>  
>   intel_dp_set_link_params(intel_dp, link_rate, lane_count,
>link_mst);
> @@ -1694,7 +1696,25 @@ static void intel_ddi_pre_enable_dp(struct 
> intel_encoder *encoder,
>   intel_prepare_dp_ddi_buffers(encoder);
>   intel_ddi_init_dp_buf_reg(encoder);
>   intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane 
> count = %d",
> +   link_rate, lane_count);
> + connector->link_status = DRM_MODE_LINK_STATUS_BAD;

Why does this not use intel_dp_set_link_status_property()?

> + intel_dp_get_link_train_fallback_values(intel_dp, link_rate,
> + lane_count);
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane 
> count = %d",
> +   link_rate, lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + connector->link_status = DRM_MODE_LINK_STATUS_GOOD;
> + intel_dp_set_link_status_property(connector,
> +   DRM_MODE_LINK_STATUS_GOOD);
> + }
> +
>   if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
>   intel_dp_stop_link_train(intel_dp);
>  }
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index fb4fcdd..659b17f 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -310,9 +310,6 @@ void intel_dp_get_link_train_fallback_values(struct 
> intel_dp 

Re: [Intel-gfx] [PATCH v3 4/4] drm/i915: Implement Link Rate fallback on Link training failure

2016-11-07 Thread Manasi Navare
Jani, could you please take a look at this patch? 
I have addressed your comments on the previous revision.
The common_rates array can be moved into Intel dp
structure in a follow up patch since that would require changes
in a lot of places other than the link rate fallback implementation.

Regards
Manasi

On Wed, Nov 02, 2016 at 01:55:39PM -0700, Manasi Navare wrote:
> If link training at a link rate optimal for a particular
> mode fails during modeset's atomic commit phase, then we
> let the modeset complete and then retry. We save the link rate
> value at which link training failed, update the link status property
> to "BAD" and use a lower link rate to prune the modes. It will redo
> the modeset on the current mode at lower link rate or if the current
> mode gets pruned due to lower link constraints then, it will send a
> hotplug uevent for userspace to handle it.
> 
> This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
> 4.3.1.6.
> 
> v3:
> * Set link status property to BAd unconditionally (Jani Nikula)
> * Dont use two separate variables link_train_failed and link_status
> to indicate same thing (Jani Nikula)
> v2:
> * Squashed a few patches (Jani Nikula)
> 
> Cc: Jani Nikula 
> Cc: Daniel Vetter 
> Cc: Ville Syrjala 
> Signed-off-by: Manasi Navare 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c   |  7 +++
>  drivers/gpu/drm/i915/intel_ddi.c  | 22 -
>  drivers/gpu/drm/i915/intel_dp.c   | 70 
> ---
>  drivers/gpu/drm/i915/intel_dp_link_training.c | 12 +++--
>  drivers/gpu/drm/i915/intel_drv.h  |  6 ++-
>  5 files changed, 105 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 75ad01d..94b0b3a 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -519,6 +519,13 @@ static int handle_conflicting_encoders(struct 
> drm_atomic_state *state,
>  connector_state);
>   if (ret)
>   return ret;
> +
> + if (connector->state->crtc) {
> + crtc_state = drm_atomic_get_existing_crtc_state(state,
> + 
> connector->state->crtc);
> + if (connector->link_status == DRM_MODE_LINK_STATUS_BAD)
> + crtc_state->connectors_changed = true;
> + }
>   }
>  
>   /*
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c 
> b/drivers/gpu/drm/i915/intel_ddi.c
> index 938ac4d..a59f8d2 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct 
> intel_encoder *encoder,
>   struct intel_dp *intel_dp = enc_to_intel_dp(>base);
>   struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
>   enum port port = intel_ddi_get_encoder_port(encoder);
> + struct intel_connector *intel_connector = intel_dp->attached_connector;
> + struct drm_connector *connector = _connector->base;
>  
>   intel_dp_set_link_params(intel_dp, link_rate, lane_count,
>link_mst);
> @@ -1694,7 +1696,25 @@ static void intel_ddi_pre_enable_dp(struct 
> intel_encoder *encoder,
>   intel_prepare_dp_ddi_buffers(encoder);
>   intel_ddi_init_dp_buf_reg(encoder);
>   intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> - intel_dp_start_link_train(intel_dp);
> + if (!intel_dp_start_link_train(intel_dp)) {
> + DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane 
> count = %d",
> +   link_rate, lane_count);
> + connector->link_status = DRM_MODE_LINK_STATUS_BAD;
> + intel_dp_get_link_train_fallback_values(intel_dp, link_rate,
> + lane_count);
> + /* Schedule a Hotplug Uevent to userspace to start modeset */
> + schedule_work(_connector->modeset_retry_work);
> + } else {
> + DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane 
> count = %d",
> +   link_rate, lane_count);
> + intel_dp->fallback_link_rate_index = -1;
> + intel_dp->fallback_link_rate = 0;
> + intel_dp->fallback_lane_count = 0;
> + connector->link_status = DRM_MODE_LINK_STATUS_GOOD;
> + intel_dp_set_link_status_property(connector,
> +   DRM_MODE_LINK_STATUS_GOOD);
> + }
> +
>   if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
>   intel_dp_stop_link_train(intel_dp);
>  }
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index fb4fcdd..659b17f 100644
> --- 

[Intel-gfx] [PATCH v3 4/4] drm/i915: Implement Link Rate fallback on Link training failure

2016-11-02 Thread Manasi Navare
If link training at a link rate optimal for a particular
mode fails during modeset's atomic commit phase, then we
let the modeset complete and then retry. We save the link rate
value at which link training failed, update the link status property
to "BAD" and use a lower link rate to prune the modes. It will redo
the modeset on the current mode at lower link rate or if the current
mode gets pruned due to lower link constraints then, it will send a
hotplug uevent for userspace to handle it.

This is also required to pass DP CTS tests 4.3.1.3, 4.3.1.4,
4.3.1.6.

v3:
* Set link status property to BAd unconditionally (Jani Nikula)
* Dont use two separate variables link_train_failed and link_status
to indicate same thing (Jani Nikula)
v2:
* Squashed a few patches (Jani Nikula)

Cc: Jani Nikula 
Cc: Daniel Vetter 
Cc: Ville Syrjala 
Signed-off-by: Manasi Navare 
---
 drivers/gpu/drm/drm_atomic_helper.c   |  7 +++
 drivers/gpu/drm/i915/intel_ddi.c  | 22 -
 drivers/gpu/drm/i915/intel_dp.c   | 70 ---
 drivers/gpu/drm/i915/intel_dp_link_training.c | 12 +++--
 drivers/gpu/drm/i915/intel_drv.h  |  6 ++-
 5 files changed, 105 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 75ad01d..94b0b3a 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -519,6 +519,13 @@ static int handle_conflicting_encoders(struct 
drm_atomic_state *state,
   connector_state);
if (ret)
return ret;
+
+   if (connector->state->crtc) {
+   crtc_state = drm_atomic_get_existing_crtc_state(state,
+   
connector->state->crtc);
+   if (connector->link_status == DRM_MODE_LINK_STATUS_BAD)
+   crtc_state->connectors_changed = true;
+   }
}
 
/*
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 938ac4d..a59f8d2 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1684,6 +1684,8 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder 
*encoder,
struct intel_dp *intel_dp = enc_to_intel_dp(>base);
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
enum port port = intel_ddi_get_encoder_port(encoder);
+   struct intel_connector *intel_connector = intel_dp->attached_connector;
+   struct drm_connector *connector = _connector->base;
 
intel_dp_set_link_params(intel_dp, link_rate, lane_count,
 link_mst);
@@ -1694,7 +1696,25 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder 
*encoder,
intel_prepare_dp_ddi_buffers(encoder);
intel_ddi_init_dp_buf_reg(encoder);
intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
-   intel_dp_start_link_train(intel_dp);
+   if (!intel_dp_start_link_train(intel_dp)) {
+   DRM_DEBUG_KMS("Link Training failed at link rate = %d, lane 
count = %d",
+ link_rate, lane_count);
+   connector->link_status = DRM_MODE_LINK_STATUS_BAD;
+   intel_dp_get_link_train_fallback_values(intel_dp, link_rate,
+   lane_count);
+   /* Schedule a Hotplug Uevent to userspace to start modeset */
+   schedule_work(_connector->modeset_retry_work);
+   } else {
+   DRM_DEBUG_KMS("Link Training Passed at Link Rate = %d, Lane 
count = %d",
+ link_rate, lane_count);
+   intel_dp->fallback_link_rate_index = -1;
+   intel_dp->fallback_link_rate = 0;
+   intel_dp->fallback_lane_count = 0;
+   connector->link_status = DRM_MODE_LINK_STATUS_GOOD;
+   intel_dp_set_link_status_property(connector,
+ DRM_MODE_LINK_STATUS_GOOD);
+   }
+
if (port != PORT_A || INTEL_GEN(dev_priv) >= 9)
intel_dp_stop_link_train(intel_dp);
 }
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index fb4fcdd..659b17f 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -310,9 +310,6 @@ void intel_dp_get_link_train_fallback_values(struct 
intel_dp *intel_dp,
int common_len;
int link_rate_index = -1;
 
-   if (!intel_dp->link_train_failed)
-   return;
-
common_len = intel_dp_common_rates(intel_dp, common_rates);
link_rate_index = intel_dp_link_rate_index(intel_dp,
   common_rates,
@@