diff mbox series

drm/i915: HDCP: retry link integrity check on failure

Message ID 20200504123524.7731-1-oliver.barta@aptiv.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: HDCP: retry link integrity check on failure | expand

Commit Message

Oliver Barta May 4, 2020, 12:35 p.m. UTC
From: Oliver Barta <oliver.barta@aptiv.com>

A single Ri mismatch doesn't automatically mean that the link integrity
is broken. Update and check of Ri and Ri' are done asynchronously. In
case an update happens just between the read of Ri' and the check against
Ri there will be a mismatch even if the link integrity is fine otherwise.

Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
---
 drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Comments

Sean Paul May 4, 2020, 8:24 p.m. UTC | #1
On Mon, May 4, 2020 at 1:32 PM Oliver Barta <o.barta89@gmail.com> wrote:
>
> From: Oliver Barta <oliver.barta@aptiv.com>
>
> A single Ri mismatch doesn't automatically mean that the link integrity
> is broken. Update and check of Ri and Ri' are done asynchronously. In
> case an update happens just between the read of Ri' and the check against
> Ri there will be a mismatch even if the link integrity is fine otherwise.
>
> Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
> ---
>  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index 010f37240710..3156fde392f2 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
>  }
>
>  static
> -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
>  {
>         struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
>         struct intel_connector *connector =
> @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>         if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
>                       (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
>                      (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {

Why doesn't the wait_for catch this?

Sean

> -               drm_err(&i915->drm,
> -                       "Ri' mismatch detected, link check failed (%x)\n",
> +               drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
>                         intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
>                                                         port)));
>                 return false;
> @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>         return true;
>  }
>
> +static
> +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> +{
> +       struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> +       int retry;
> +
> +       for (retry = 0; retry < 3; retry++)
> +               if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
> +                       return true;
> +
> +       drm_err(&i915->drm, "Link check failed\n");
> +       return false;
> +}
> +
>  struct hdcp2_hdmi_msg_timeout {
>         u8 msg_id;
>         u16 timeout;
> --
> 2.20.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Oliver Barta May 5, 2020, 7:27 a.m. UTC | #2
On Mon, May 4, 2020 at 10:24 PM Sean Paul <sean@poorly.run> wrote:
>
> On Mon, May 4, 2020 at 1:32 PM Oliver Barta <o.barta89@gmail.com> wrote:
> >
> > From: Oliver Barta <oliver.barta@aptiv.com>
> >
> > A single Ri mismatch doesn't automatically mean that the link integrity
> > is broken. Update and check of Ri and Ri' are done asynchronously. In
> > case an update happens just between the read of Ri' and the check against
> > Ri there will be a mismatch even if the link integrity is fine otherwise.
> >
> > Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > index 010f37240710..3156fde392f2 100644
> > --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> > +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
> >  }
> >
> >  static
> > -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
> >  {
> >         struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> >         struct intel_connector *connector =
> > @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> >         if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
> >                       (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
> >                      (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
>
> Why doesn't the wait_for catch this?
>
> Sean
>

Hello Sean,

thank you for having a look on my patch. The wait_for can't catch this
because it is Ri' which is outdated compared to Ri. Ri' however needs
to be read over DDC interface which is done only once during the check
sequence. It is not updated during the waiting time.

Oliver

> > -               drm_err(&i915->drm,
> > -                       "Ri' mismatch detected, link check failed (%x)\n",
> > +               drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
> >                         intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
> >                                                         port)));
> >                 return false;
> > @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> >         return true;
> >  }
> >
> > +static
> > +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > +{
> > +       struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> > +       int retry;
> > +
> > +       for (retry = 0; retry < 3; retry++)
> > +               if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
> > +                       return true;
> > +
> > +       drm_err(&i915->drm, "Link check failed\n");
> > +       return false;
> > +}
> > +
> >  struct hdcp2_hdmi_msg_timeout {
> >         u8 msg_id;
> >         u16 timeout;
> > --
> > 2.20.1
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Ramalingam C May 5, 2020, 7:38 a.m. UTC | #3
On 2020-05-04 at 14:35:24 +0200, Oliver Barta wrote:
> From: Oliver Barta <oliver.barta@aptiv.com>
> 
> A single Ri mismatch doesn't automatically mean that the link integrity
> is broken. Update and check of Ri and Ri' are done asynchronously. In
> case an update happens just between the read of Ri' and the check against
> Ri there will be a mismatch even if the link integrity is fine otherwise.

Thanks for working on this. Btw, did you face this sporadic link check
failure or theoretically you are fixing it?

IMO this change will rule out possible sporadic link check failures as
mentioned in the commit msg. Though I haven't faced this issue at my
testings.

Reviewed-by: Ramalingam C <ramalingam.c@intel.com>

> 
> Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
> ---
>  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
>  1 file changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index 010f37240710..3156fde392f2 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
>  }
>  
>  static
> -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
>  {
>  	struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
>  	struct intel_connector *connector =
> @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>  	if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
>  		      (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
>  		     (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
> -		drm_err(&i915->drm,
> -			"Ri' mismatch detected, link check failed (%x)\n",
> +		drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
>  			intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
>  							port)));
>  		return false;
> @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>  	return true;
>  }
>  
> +static
> +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> +{
> +	struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> +	int retry;
> +
> +	for (retry = 0; retry < 3; retry++)
> +		if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
> +			return true;
> +
> +	drm_err(&i915->drm, "Link check failed\n");
> +	return false;
> +}
> +
>  struct hdcp2_hdmi_msg_timeout {
>  	u8 msg_id;
>  	u16 timeout;
> -- 
> 2.20.1
>
Oliver Barta May 5, 2020, 12:06 p.m. UTC | #4
On Tue, May 5, 2020 at 9:38 AM Ramalingam C <ramalingam.c@intel.com> wrote:
>
> On 2020-05-04 at 14:35:24 +0200, Oliver Barta wrote:
> > From: Oliver Barta <oliver.barta@aptiv.com>
> >
> > A single Ri mismatch doesn't automatically mean that the link integrity
> > is broken. Update and check of Ri and Ri' are done asynchronously. In
> > case an update happens just between the read of Ri' and the check against
> > Ri there will be a mismatch even if the link integrity is fine otherwise.
>
> Thanks for working on this. Btw, did you face this sporadic link check
> failure or theoretically you are fixing it?
>
> IMO this change will rule out possible sporadic link check failures as
> mentioned in the commit msg. Though I haven't faced this issue at my
> testings.
>
> Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
>

I found it by code inspection, the probability for this to happen is
very low. In order to test the patch I'm decreasing the value of
DRM_HDCP_CHECK_PERIOD_MS to just a few ms. Once you do that it happens
every few seconds.

Thanks,
Oliver

> >
> > Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
> >  1 file changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > index 010f37240710..3156fde392f2 100644
> > --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> > +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
> >  }
> >
> >  static
> > -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
> >  {
> >       struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> >       struct intel_connector *connector =
> > @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> >       if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
> >                     (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
> >                    (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
> > -             drm_err(&i915->drm,
> > -                     "Ri' mismatch detected, link check failed (%x)\n",
> > +             drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
> >                       intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
> >                                                       port)));
> >               return false;
> > @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> >       return true;
> >  }
> >
> > +static
> > +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > +{
> > +     struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> > +     int retry;
> > +
> > +     for (retry = 0; retry < 3; retry++)
> > +             if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
> > +                     return true;
> > +
> > +     drm_err(&i915->drm, "Link check failed\n");
> > +     return false;
> > +}
> > +
> >  struct hdcp2_hdmi_msg_timeout {
> >       u8 msg_id;
> >       u16 timeout;
> > --
> > 2.20.1
> >
Ramalingam C May 5, 2020, 12:12 p.m. UTC | #5
On 2020-05-05 at 14:06:51 +0200, Oliver Barta wrote:
> On Tue, May 5, 2020 at 9:38 AM Ramalingam C <ramalingam.c@intel.com> wrote:
> >
> > On 2020-05-04 at 14:35:24 +0200, Oliver Barta wrote:
> > > From: Oliver Barta <oliver.barta@aptiv.com>
> > >
> > > A single Ri mismatch doesn't automatically mean that the link integrity
> > > is broken. Update and check of Ri and Ri' are done asynchronously. In
> > > case an update happens just between the read of Ri' and the check against
> > > Ri there will be a mismatch even if the link integrity is fine otherwise.
> >
> > Thanks for working on this. Btw, did you face this sporadic link check
> > failure or theoretically you are fixing it?
> >
> > IMO this change will rule out possible sporadic link check failures as
> > mentioned in the commit msg. Though I haven't faced this issue at my
> > testings.
> >
> > Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
> >
> 
> I found it by code inspection, the probability for this to happen is
> very low. In order to test the patch I'm decreasing the value of
> DRM_HDCP_CHECK_PERIOD_MS to just a few ms. Once you do that it happens
> every few seconds.
Ok. That make sense. Thanks for the explanation.

-Ram
> 
> Thanks,
> Oliver
> 
> > >
> > > Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
> > > ---
> > >  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
> > >  1 file changed, 16 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > > index 010f37240710..3156fde392f2 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > > @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
> > >  }
> > >
> > >  static
> > > -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > > +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
> > >  {
> > >       struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> > >       struct intel_connector *connector =
> > > @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > >       if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
> > >                     (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
> > >                    (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
> > > -             drm_err(&i915->drm,
> > > -                     "Ri' mismatch detected, link check failed (%x)\n",
> > > +             drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
> > >                       intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
> > >                                                       port)));
> > >               return false;
> > > @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > >       return true;
> > >  }
> > >
> > > +static
> > > +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > > +{
> > > +     struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> > > +     int retry;
> > > +
> > > +     for (retry = 0; retry < 3; retry++)
> > > +             if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
> > > +                     return true;
> > > +
> > > +     drm_err(&i915->drm, "Link check failed\n");
> > > +     return false;
> > > +}
> > > +
> > >  struct hdcp2_hdmi_msg_timeout {
> > >       u8 msg_id;
> > >       u16 timeout;
> > > --
> > > 2.20.1
> > >
Sean Paul May 5, 2020, 4:22 p.m. UTC | #6
On Tue, May 5, 2020 at 3:27 AM Oliver Barta <o.barta89@gmail.com> wrote:
>
> On Mon, May 4, 2020 at 10:24 PM Sean Paul <sean@poorly.run> wrote:
> >
> > On Mon, May 4, 2020 at 1:32 PM Oliver Barta <o.barta89@gmail.com> wrote:
> > >
> > > From: Oliver Barta <oliver.barta@aptiv.com>
> > >
> > > A single Ri mismatch doesn't automatically mean that the link integrity
> > > is broken. Update and check of Ri and Ri' are done asynchronously. In
> > > case an update happens just between the read of Ri' and the check against
> > > Ri there will be a mismatch even if the link integrity is fine otherwise.
> > >
> > > Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
> > > ---
> > >  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
> > >  1 file changed, 16 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > > index 010f37240710..3156fde392f2 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> > > @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
> > >  }
> > >
> > >  static
> > > -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > > +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
> > >  {
> > >         struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> > >         struct intel_connector *connector =
> > > @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > >         if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
> > >                       (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
> > >                      (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
> >
> > Why doesn't the wait_for catch this?
> >
> > Sean
> >
>
> Hello Sean,
>
> thank you for having a look on my patch. The wait_for can't catch this
> because it is Ri' which is outdated compared to Ri. Ri' however needs
> to be read over DDC interface which is done only once during the check
> sequence. It is not updated during the waiting time.
>

Ok, makes sense, thank you.

Reviewed-by: Sean Paul <sean@poorly.run>

> Oliver
>
> > > -               drm_err(&i915->drm,
> > > -                       "Ri' mismatch detected, link check failed (%x)\n",
> > > +               drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
> > >                         intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
> > >                                                         port)));
> > >                 return false;
> > > @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > >         return true;
> > >  }
> > >
> > > +static
> > > +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
> > > +{
> > > +       struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
> > > +       int retry;
> > > +
> > > +       for (retry = 0; retry < 3; retry++)
> > > +               if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
> > > +                       return true;
> > > +
> > > +       drm_err(&i915->drm, "Link check failed\n");
> > > +       return false;
> > > +}
> > > +
> > >  struct hdcp2_hdmi_msg_timeout {
> > >         u8 msg_id;
> > >         u16 timeout;
> > > --
> > > 2.20.1
> > >
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Jani Nikula June 30, 2020, 8:06 a.m. UTC | #7
On Tue, 05 May 2020, Ramalingam C <ramalingam.c@intel.com> wrote:
> On 2020-05-05 at 14:06:51 +0200, Oliver Barta wrote:
>> On Tue, May 5, 2020 at 9:38 AM Ramalingam C <ramalingam.c@intel.com> wrote:
>> >
>> > On 2020-05-04 at 14:35:24 +0200, Oliver Barta wrote:
>> > > From: Oliver Barta <oliver.barta@aptiv.com>
>> > >
>> > > A single Ri mismatch doesn't automatically mean that the link integrity
>> > > is broken. Update and check of Ri and Ri' are done asynchronously. In
>> > > case an update happens just between the read of Ri' and the check against
>> > > Ri there will be a mismatch even if the link integrity is fine otherwise.
>> >
>> > Thanks for working on this. Btw, did you face this sporadic link check
>> > failure or theoretically you are fixing it?
>> >
>> > IMO this change will rule out possible sporadic link check failures as
>> > mentioned in the commit msg. Though I haven't faced this issue at my
>> > testings.
>> >
>> > Reviewed-by: Ramalingam C <ramalingam.c@intel.com>
>> >
>> 
>> I found it by code inspection, the probability for this to happen is
>> very low. In order to test the patch I'm decreasing the value of
>> DRM_HDCP_CHECK_PERIOD_MS to just a few ms. Once you do that it happens
>> every few seconds.
> Ok. That make sense. Thanks for the explanation.

Finally pushed, thanks for the patch and reviews.

Ram, I was kind of expecting you to push this.

BR,
Jani.


>
> -Ram
>> 
>> Thanks,
>> Oliver
>> 
>> > >
>> > > Signed-off-by: Oliver Barta <oliver.barta@aptiv.com>
>> > > ---
>> > >  drivers/gpu/drm/i915/display/intel_hdmi.c | 19 ++++++++++++++++---
>> > >  1 file changed, 16 insertions(+), 3 deletions(-)
>> > >
>> > > diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
>> > > index 010f37240710..3156fde392f2 100644
>> > > --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
>> > > +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
>> > > @@ -1540,7 +1540,7 @@ int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
>> > >  }
>> > >
>> > >  static
>> > > -bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>> > > +bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
>> > >  {
>> > >       struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
>> > >       struct intel_connector *connector =
>> > > @@ -1563,8 +1563,7 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>> > >       if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
>> > >                     (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
>> > >                    (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
>> > > -             drm_err(&i915->drm,
>> > > -                     "Ri' mismatch detected, link check failed (%x)\n",
>> > > +             drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
>> > >                       intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
>> > >                                                       port)));
>> > >               return false;
>> > > @@ -1572,6 +1571,20 @@ bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>> > >       return true;
>> > >  }
>> > >
>> > > +static
>> > > +bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
>> > > +{
>> > > +     struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
>> > > +     int retry;
>> > > +
>> > > +     for (retry = 0; retry < 3; retry++)
>> > > +             if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
>> > > +                     return true;
>> > > +
>> > > +     drm_err(&i915->drm, "Link check failed\n");
>> > > +     return false;
>> > > +}
>> > > +
>> > >  struct hdcp2_hdmi_msg_timeout {
>> > >       u8 msg_id;
>> > >       u16 timeout;
>> > > --
>> > > 2.20.1
>> > >
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index 010f37240710..3156fde392f2 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -1540,7 +1540,7 @@  int intel_hdmi_hdcp_toggle_signalling(struct intel_digital_port *intel_dig_port,
 }
 
 static
-bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
+bool intel_hdmi_hdcp_check_link_once(struct intel_digital_port *intel_dig_port)
 {
 	struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
 	struct intel_connector *connector =
@@ -1563,8 +1563,7 @@  bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
 	if (wait_for((intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder, port)) &
 		      (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC)) ==
 		     (HDCP_STATUS_RI_MATCH | HDCP_STATUS_ENC), 1)) {
-		drm_err(&i915->drm,
-			"Ri' mismatch detected, link check failed (%x)\n",
+		drm_dbg_kms(&i915->drm, "Ri' mismatch detected (%x)\n",
 			intel_de_read(i915, HDCP_STATUS(i915, cpu_transcoder,
 							port)));
 		return false;
@@ -1572,6 +1571,20 @@  bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
 	return true;
 }
 
+static
+bool intel_hdmi_hdcp_check_link(struct intel_digital_port *intel_dig_port)
+{
+	struct drm_i915_private *i915 = to_i915(intel_dig_port->base.base.dev);
+	int retry;
+
+	for (retry = 0; retry < 3; retry++)
+		if (intel_hdmi_hdcp_check_link_once(intel_dig_port))
+			return true;
+
+	drm_err(&i915->drm, "Link check failed\n");
+	return false;
+}
+
 struct hdcp2_hdmi_msg_timeout {
 	u8 msg_id;
 	u16 timeout;