All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Manasi Navare <manasi.d.navare@intel.com>
Cc: jani.nikula@linux.intel.com, intel-gfx@lists.freedesktop.org,
	stable@vger.kernel.org,
	Ander Conselvande Oliveira
	<ander.conselvan.de.oliveira@intel.com>
Subject: Re: [PATCH v3] drm/i915/dp: Do not reset detect_done flag in intel_dp_detect
Date: Thu, 19 Jan 2017 21:59:54 +0200	[thread overview]
Message-ID: <20170119195954.GB31595@intel.com> (raw)
In-Reply-To: <20170119193855.GA30684@intel.com>

On Thu, Jan 19, 2017 at 11:38:56AM -0800, Manasi Navare wrote:
> On Thu, Jan 19, 2017 at 09:26:36PM +0200, Ville Syrj�l� wrote:
> > On Thu, Jan 19, 2017 at 11:01:01AM -0800, Manasi Navare wrote:
> > > On Thu, Jan 19, 2017 at 03:42:34PM +0200, Ville Syrj�l� wrote:
> > > > On Tue, Jan 17, 2017 at 09:40:42AM -0800, Manasi Navare wrote:
> > > > > I have verified this patch with the latest drm-tip and it is also
> > > > > absolutely necessary to ensure the link gets properly retrained
> > > > > after link-status is BAD and after anew modeset is triggered by
> > > > > userspace. Without this patch, since intel_dp_long_pulse gets called
> > > > > it resets the link failure values and link retraining does not happen
> > > > > at lower link rates.
> > > > 
> > > > Why are you resetting the failure values in this function? You should
> > > > only do that when a long pulse is actually detected IMO (and yes, 
> > > > calling the function intel_dp_long_pulse() name is pretty much wrong
> > > > now).
> > > >
> > > 
> > > Yes the values for link rate nd lane count get set to the intel_dp_max_link_bw()
> > > and drm_dp_max_lane_count() in intel_dp_long_pulse() assuming that this function would
> > > get called on hotplug and that we need reread the dpcd registers. So setting these to max values
> > > mean that we have lost the information about the link rate and lane count at which link training failed.
> > > 
> > > If detect_done is reset in intel_dp_detect() right after calling intel_dp_long_pulse() which is clearly a bug
> > > then it calls the intel_dp_long_pulse() during mode enumeration before the modeset and it never retrains at the 
> > > lower values since the max link rate/lane count get overwritten in intel_dp_long_pulse().
> > > So it is absolutely necessary to not reset detect_done flag here in intel_dp_detect()
> > 
> > No. What you're asking for is a change in behaviour (to call
> > intel_dp_long_pulse() from ->detect() only if it was just preceded by an
> > actual long pulse). That was never how this code worked. The point of
> > the flag was to avoid calling it twice when processing the HPD since it
> > was directly called from intel_dp_hpd_pulse() and then again from
> > ->detect(). Since we no longer call it directly from
> > intel_dp_hpd_pulse() the flag is in fact useless.
> >
> 
> No I think there is some confusion. I am not asking the change in behaviour. I dont
> want to call intel_dp_long_pulse from ->detect() only if it was just preceeded by an actual long pulse.

That is precisely what you're asking since intel_dp_hpd_pulse() would
be the only place left that would reset the flag.

> I want to avoid calling it twice and which exactly was the point of adding that flag.

The commit that added the flag did exactly what I stated above. It
didn't avoid any calls via mode enumeration, it only avoid the double
call during actual hpd handling.

Which is also how the code behaved before someone tried to move the
long hpd handling into the hpd pulse handler, and it's how the code
behaves now that I moved the long hpd handling back into ->detect().

> The long pulse should
> be called only when the full detect is not done, we shouldnt be doing full detect twice. In intel_dp_hpd_pulse()
> we do set the detect_done flag to false and it does a full detect through ->detect(). But then
> for mode enumeration, we do not need to do a full detect so that ->detect() call should actually not
> call intel_dp_long_pulse because that is exactly the behavour we were trying to avoid (calling it twice)
> 
> Manasi 
> > While the change you ask for may be desirable, history has shown
> > that the DP code is very fragile, so I don't think we should make
> > the link state property depend on something that may need to be
> > reverted if a regression crops up. And so I think you should just
> > change your new code to work with the existing scheme. We can push
> > the detect_done optimization in afterwards since we should then be
> > able to revert it without having to revert everything related to
> > the link status property.
> > 
> > > 
> > > Manasi 
> > > > > 
> > > > > Ville/Jani could you please review this patch?
> > > > > Thi is definitely a bug in the existing codebase and we need to get this merged
> > > > > soon to get it fixed.
> > > > > 
> > > > > Regards
> > > > > Manasi
> > > > > 
> > > > > On Thu, Dec 29, 2016 at 11:14:28PM -0800, Dhinakaran Pandiyan wrote:
> > > > > > From: "Navare, Manasi D" <manasi.d.navare@intel.com>
> > > > > > 
> > > > > > The detect_done flag was introduced in the 'commit 7d23e3c37bb3
> > > > > > ("drm/i915: Cleaning up intel_dp_hpd_pulse")' in order to avoid multiple
> > > > > > detects on hotplug where intel_dp_long_pulse() was called from HPD handler
> > > > > > as well as intel_dp_detect(). Later, 'commit 1015811609c0
> > > > > > ("drm/i915: Move long hpd handling into the hotplug work")' deferred long
> > > > > > hpd handling to hotplug work to avoid handling it twice. But, resetting the
> > > > > > flag after long hpd handling leads to the code being executed again during
> > > > > > mode enumeration.
> > > > > > 
> > > > > > So, do not reset the detect_done flag to False in intel_dp_detect(). The
> > > > > > flag is reset in intel_dp_hpd_pulse() to allow a full detect and set when
> > > > > > the hotplug work does a full DPCD detect. However if ->detect() gets called
> > > > > > during mode enumeration after a DPCD detect, return the cached connector
> > > > > > status.
> > > > > > 
> > > > > > Resetting the flag in the encoder's reset callback should take care of
> > > > > > hotplug between suspend/resume.
> > > > > > 
> > > > > > v2:
> > > > > > Allow full detect after encoder reset. (Ville)
> > > > > > Set the detect_done flag for connector disconnected case too. (DK)
> > > > > > Commit message changes.
> > > > > > 
> > > > > > Cc: stable@vger.kernel.org
> > > > > > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > > > > > Cc: Ander Conselvande Oliveira <ander.conselvan.de.oliveira@intel.com>
> > > > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > > > Fixes: commit 7d23e3c37bb3 ("drm/i915: Cleaning up intel_dp_hpd_pulse")
> > > > > > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > > > > > Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/i915/intel_dp.c | 9 +++++----
> > > > > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > > > > > index fb12896..6732c17 100644
> > > > > > --- a/drivers/gpu/drm/i915/intel_dp.c
> > > > > > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > > > > > @@ -4516,7 +4516,6 @@ intel_dp_long_pulse(struct intel_connector *intel_connector)
> > > > > >  	intel_dp_set_edid(intel_dp);
> > > > > >  	if (is_edp(intel_dp) || intel_connector->detect_edid)
> > > > > >  		status = connector_status_connected;
> > > > > > -	intel_dp->detect_done = true;
> > > > > >  
> > > > > >  	/* Try to read the source of the interrupt */
> > > > > >  	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 &&
> > > > > > @@ -4551,10 +4550,10 @@ intel_dp_detect(struct drm_connector *connector, bool force)
> > > > > >  		      connector->base.id, connector->name);
> > > > > >  
> > > > > >  	/* If full detect is not performed yet, do a full detect */
> > > > > > -	if (!intel_dp->detect_done)
> > > > > > +	if (!intel_dp->detect_done) {
> > > > > > +		intel_dp->detect_done = true;
> > > > > >  		status = intel_dp_long_pulse(intel_dp->attached_connector);
> > > > > > -
> > > > > > -	intel_dp->detect_done = false;
> > > > > > +	}
> > > > > >  
> > > > > >  	return status;
> > > > >  }
> > > > > > @@ -4859,6 +4858,8 @@ void intel_dp_encoder_reset(struct drm_encoder *encoder)
> > > > > >  	if (lspcon->active)
> > > > > >  		lspcon_resume(lspcon);
> > > > > >  
> > > > > > +	intel_dp->detect_done = false;
> > > > > > +
> > > > > >  	pps_lock(intel_dp);
> > > > > >  
> > > > > >  	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
> > > > > > -- 
> > > > > > 2.7.4
> > > > > > 
> > > > 
> > > > -- 
> > > > Ville Syrj�l�
> > > > Intel OTC
> > 
> > -- 
> > Ville Syrj�l�
> > Intel OTC

-- 
Ville Syrj�l�
Intel OTC

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Manasi Navare <manasi.d.navare@intel.com>
Cc: Ander Conselvande Oliveira
	<ander.conselvan.de.oliveira@intel.com>,
	intel-gfx@lists.freedesktop.org, stable@vger.kernel.org
Subject: Re: [PATCH v3] drm/i915/dp: Do not reset detect_done flag in intel_dp_detect
Date: Thu, 19 Jan 2017 21:59:54 +0200	[thread overview]
Message-ID: <20170119195954.GB31595@intel.com> (raw)
In-Reply-To: <20170119193855.GA30684@intel.com>

On Thu, Jan 19, 2017 at 11:38:56AM -0800, Manasi Navare wrote:
> On Thu, Jan 19, 2017 at 09:26:36PM +0200, Ville Syrjälä wrote:
> > On Thu, Jan 19, 2017 at 11:01:01AM -0800, Manasi Navare wrote:
> > > On Thu, Jan 19, 2017 at 03:42:34PM +0200, Ville Syrjälä wrote:
> > > > On Tue, Jan 17, 2017 at 09:40:42AM -0800, Manasi Navare wrote:
> > > > > I have verified this patch with the latest drm-tip and it is also
> > > > > absolutely necessary to ensure the link gets properly retrained
> > > > > after link-status is BAD and after anew modeset is triggered by
> > > > > userspace. Without this patch, since intel_dp_long_pulse gets called
> > > > > it resets the link failure values and link retraining does not happen
> > > > > at lower link rates.
> > > > 
> > > > Why are you resetting the failure values in this function? You should
> > > > only do that when a long pulse is actually detected IMO (and yes, 
> > > > calling the function intel_dp_long_pulse() name is pretty much wrong
> > > > now).
> > > >
> > > 
> > > Yes the values for link rate nd lane count get set to the intel_dp_max_link_bw()
> > > and drm_dp_max_lane_count() in intel_dp_long_pulse() assuming that this function would
> > > get called on hotplug and that we need reread the dpcd registers. So setting these to max values
> > > mean that we have lost the information about the link rate and lane count at which link training failed.
> > > 
> > > If detect_done is reset in intel_dp_detect() right after calling intel_dp_long_pulse() which is clearly a bug
> > > then it calls the intel_dp_long_pulse() during mode enumeration before the modeset and it never retrains at the 
> > > lower values since the max link rate/lane count get overwritten in intel_dp_long_pulse().
> > > So it is absolutely necessary to not reset detect_done flag here in intel_dp_detect()
> > 
> > No. What you're asking for is a change in behaviour (to call
> > intel_dp_long_pulse() from ->detect() only if it was just preceded by an
> > actual long pulse). That was never how this code worked. The point of
> > the flag was to avoid calling it twice when processing the HPD since it
> > was directly called from intel_dp_hpd_pulse() and then again from
> > ->detect(). Since we no longer call it directly from
> > intel_dp_hpd_pulse() the flag is in fact useless.
> >
> 
> No I think there is some confusion. I am not asking the change in behaviour. I dont
> want to call intel_dp_long_pulse from ->detect() only if it was just preceeded by an actual long pulse.

That is precisely what you're asking since intel_dp_hpd_pulse() would
be the only place left that would reset the flag.

> I want to avoid calling it twice and which exactly was the point of adding that flag.

The commit that added the flag did exactly what I stated above. It
didn't avoid any calls via mode enumeration, it only avoid the double
call during actual hpd handling.

Which is also how the code behaved before someone tried to move the
long hpd handling into the hpd pulse handler, and it's how the code
behaves now that I moved the long hpd handling back into ->detect().

> The long pulse should
> be called only when the full detect is not done, we shouldnt be doing full detect twice. In intel_dp_hpd_pulse()
> we do set the detect_done flag to false and it does a full detect through ->detect(). But then
> for mode enumeration, we do not need to do a full detect so that ->detect() call should actually not
> call intel_dp_long_pulse because that is exactly the behavour we were trying to avoid (calling it twice)
> 
> Manasi 
> > While the change you ask for may be desirable, history has shown
> > that the DP code is very fragile, so I don't think we should make
> > the link state property depend on something that may need to be
> > reverted if a regression crops up. And so I think you should just
> > change your new code to work with the existing scheme. We can push
> > the detect_done optimization in afterwards since we should then be
> > able to revert it without having to revert everything related to
> > the link status property.
> > 
> > > 
> > > Manasi 
> > > > > 
> > > > > Ville/Jani could you please review this patch?
> > > > > Thi is definitely a bug in the existing codebase and we need to get this merged
> > > > > soon to get it fixed.
> > > > > 
> > > > > Regards
> > > > > Manasi
> > > > > 
> > > > > On Thu, Dec 29, 2016 at 11:14:28PM -0800, Dhinakaran Pandiyan wrote:
> > > > > > From: "Navare, Manasi D" <manasi.d.navare@intel.com>
> > > > > > 
> > > > > > The detect_done flag was introduced in the 'commit 7d23e3c37bb3
> > > > > > ("drm/i915: Cleaning up intel_dp_hpd_pulse")' in order to avoid multiple
> > > > > > detects on hotplug where intel_dp_long_pulse() was called from HPD handler
> > > > > > as well as intel_dp_detect(). Later, 'commit 1015811609c0
> > > > > > ("drm/i915: Move long hpd handling into the hotplug work")' deferred long
> > > > > > hpd handling to hotplug work to avoid handling it twice. But, resetting the
> > > > > > flag after long hpd handling leads to the code being executed again during
> > > > > > mode enumeration.
> > > > > > 
> > > > > > So, do not reset the detect_done flag to False in intel_dp_detect(). The
> > > > > > flag is reset in intel_dp_hpd_pulse() to allow a full detect and set when
> > > > > > the hotplug work does a full DPCD detect. However if ->detect() gets called
> > > > > > during mode enumeration after a DPCD detect, return the cached connector
> > > > > > status.
> > > > > > 
> > > > > > Resetting the flag in the encoder's reset callback should take care of
> > > > > > hotplug between suspend/resume.
> > > > > > 
> > > > > > v2:
> > > > > > Allow full detect after encoder reset. (Ville)
> > > > > > Set the detect_done flag for connector disconnected case too. (DK)
> > > > > > Commit message changes.
> > > > > > 
> > > > > > Cc: stable@vger.kernel.org
> > > > > > Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> > > > > > Cc: Ander Conselvande Oliveira <ander.conselvan.de.oliveira@intel.com>
> > > > > > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > > > > > Fixes: commit 7d23e3c37bb3 ("drm/i915: Cleaning up intel_dp_hpd_pulse")
> > > > > > Signed-off-by: Manasi Navare <manasi.d.navare@intel.com>
> > > > > > Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
> > > > > > ---
> > > > > >  drivers/gpu/drm/i915/intel_dp.c | 9 +++++----
> > > > > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > > > > 
> > > > > > diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> > > > > > index fb12896..6732c17 100644
> > > > > > --- a/drivers/gpu/drm/i915/intel_dp.c
> > > > > > +++ b/drivers/gpu/drm/i915/intel_dp.c
> > > > > > @@ -4516,7 +4516,6 @@ intel_dp_long_pulse(struct intel_connector *intel_connector)
> > > > > >  	intel_dp_set_edid(intel_dp);
> > > > > >  	if (is_edp(intel_dp) || intel_connector->detect_edid)
> > > > > >  		status = connector_status_connected;
> > > > > > -	intel_dp->detect_done = true;
> > > > > >  
> > > > > >  	/* Try to read the source of the interrupt */
> > > > > >  	if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11 &&
> > > > > > @@ -4551,10 +4550,10 @@ intel_dp_detect(struct drm_connector *connector, bool force)
> > > > > >  		      connector->base.id, connector->name);
> > > > > >  
> > > > > >  	/* If full detect is not performed yet, do a full detect */
> > > > > > -	if (!intel_dp->detect_done)
> > > > > > +	if (!intel_dp->detect_done) {
> > > > > > +		intel_dp->detect_done = true;
> > > > > >  		status = intel_dp_long_pulse(intel_dp->attached_connector);
> > > > > > -
> > > > > > -	intel_dp->detect_done = false;
> > > > > > +	}
> > > > > >  
> > > > > >  	return status;
> > > > >  }
> > > > > > @@ -4859,6 +4858,8 @@ void intel_dp_encoder_reset(struct drm_encoder *encoder)
> > > > > >  	if (lspcon->active)
> > > > > >  		lspcon_resume(lspcon);
> > > > > >  
> > > > > > +	intel_dp->detect_done = false;
> > > > > > +
> > > > > >  	pps_lock(intel_dp);
> > > > > >  
> > > > > >  	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
> > > > > > -- 
> > > > > > 2.7.4
> > > > > > 
> > > > 
> > > > -- 
> > > > Ville Syrjälä
> > > > Intel OTC
> > 
> > -- 
> > Ville Syrjälä
> > Intel OTC

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-01-19 20:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-30  7:14 [PATCH v3] drm/i915/dp: Do not reset detect_done flag in intel_dp_detect Dhinakaran Pandiyan
2016-12-30  8:23 ` ✓ Fi.CI.BAT: success for drm/i915/dp: Do not reset detect_done flag in intel_dp_detect (rev2) Patchwork
2017-01-05  4:04 ` [Intel-gfx] [PATCH v3] drm/i915/dp: Do not reset detect_done flag in intel_dp_detect Pandiyan, Dhinakaran
2017-01-05  4:04   ` Pandiyan, Dhinakaran
2017-01-17 17:40 ` Manasi Navare
2017-01-17 17:40   ` Manasi Navare
2017-01-19 13:42   ` Ville Syrjälä
2017-01-19 13:42     ` Ville Syrjälä
2017-01-19 19:01     ` Manasi Navare
2017-01-19 19:01       ` Manasi Navare
2017-01-19 19:26       ` Ville Syrjälä
2017-01-19 19:26         ` Ville Syrjälä
2017-01-19 19:38         ` Manasi Navare
2017-01-19 19:38           ` Manasi Navare
2017-01-19 19:59           ` Ville Syrjälä [this message]
2017-01-19 19:59             ` Ville Syrjälä
2017-01-19 20:39             ` Manasi Navare
2017-01-19 20:39               ` Manasi Navare
  -- strict thread matches above, loose matches on Subject: below --
2016-12-21 21:59 Dhinakaran Pandiyan
2016-12-21 21:59 ` Dhinakaran Pandiyan
2016-12-20  8:08 [PATCH v2] " Jani Nikula
2016-12-21  1:57 ` [PATCH v3] " Dhinakaran Pandiyan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170119195954.GB31595@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=ander.conselvan.de.oliveira@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=manasi.d.navare@intel.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.