intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Sean Paul <sean@poorly.run>
To: Ramalingam C <ramalingam.c@intel.com>
Cc: intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH v2 3/5] drm/i915: terminate reauth at stream management failure
Date: Tue, 18 Feb 2020 10:34:55 -0500	[thread overview]
Message-ID: <20200218153455.GA253734@art_vandelay> (raw)
In-Reply-To: <20200212102942.26568-4-ramalingam.c@intel.com>

On Wed, Feb 12, 2020 at 03:59:40PM +0530, Ramalingam C wrote:
> As per the HDCP2.2 compliance test 1B-10 expectation, when stream
> management for a repeater fails, we retry thrice and when it fails
> in all retries, HDCP2.2 reauthentication aborted at kernel.
> 
> v2:
>   seq_num_m++ is extended for steam management failures too.[Anshuman]
> v3:
>   use drm_dbg_kms instead of DRM_DEBUG_KMS [Anshuman]
> v4:
>   dev_priv is used as i915 [JaniN]
> 
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_hdcp.c | 75 ++++++++++++++---------
>  1 file changed, 46 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 30e0a3aa9d57..b24d12efae0a 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -1380,7 +1380,7 @@ static int hdcp2_session_key_exchange(struct intel_connector *connector)
>  }
>  
>  static
> -int hdcp2_propagate_stream_management_info(struct intel_connector *connector)
> +int _hdcp2_propagate_stream_management_info(struct intel_connector *connector)
>  {
>  	struct intel_digital_port *intel_dig_port = intel_attached_dig_port(connector);
>  	struct intel_hdcp *hdcp = &connector->hdcp;
> @@ -1406,28 +1406,25 @@ int hdcp2_propagate_stream_management_info(struct intel_connector *connector)
>  	ret = shim->write_2_2_msg(intel_dig_port, &msgs.stream_manage,
>  				  sizeof(msgs.stream_manage));
>  	if (ret < 0)
> -		return ret;
> +		goto err_exit;
>  
>  	ret = shim->read_2_2_msg(intel_dig_port, HDCP_2_2_REP_STREAM_READY,
>  				 &msgs.stream_ready, sizeof(msgs.stream_ready));
>  	if (ret < 0)
> -		return ret;
> +		goto err_exit;
>  
>  	hdcp->port_data.seq_num_m = hdcp->seq_num_m;
>  	hdcp->port_data.streams[0].stream_type = hdcp->content_type;
> -
>  	ret = hdcp2_verify_mprime(connector, &msgs.stream_ready);
> -	if (ret < 0)
> -		return ret;
>  
> +err_exit:

This isn't exclusively an error condition, I'd rather it named 'out' instead.

>  	hdcp->seq_num_m++;
> -
>  	if (hdcp->seq_num_m > HDCP_2_2_SEQ_NUM_MAX) {
>  		DRM_DEBUG_KMS("seq_num_m roll over.\n");
> -		return -1;
> +		ret = -1;

What does -1 mean? Please use an errno

>  	}
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static
> @@ -1492,17 +1489,6 @@ int hdcp2_authenticate_repeater_topology(struct intel_connector *connector)
>  	return 0;
>  }
>  
> -static int hdcp2_authenticate_repeater(struct intel_connector *connector)
> -{
> -	int ret;
> -
> -	ret = hdcp2_authenticate_repeater_topology(connector);
> -	if (ret < 0)
> -		return ret;
> -
> -	return hdcp2_propagate_stream_management_info(connector);
> -}
> -
>  static int hdcp2_authenticate_sink(struct intel_connector *connector)
>  {
>  	struct intel_digital_port *intel_dig_port = intel_attached_dig_port(connector);
> @@ -1537,18 +1523,13 @@ static int hdcp2_authenticate_sink(struct intel_connector *connector)
>  	}
>  
>  	if (hdcp->is_repeater) {
> -		ret = hdcp2_authenticate_repeater(connector);
> +		ret = hdcp2_authenticate_repeater_topology(connector);
>  		if (ret < 0) {
>  			DRM_DEBUG_KMS("Repeater Auth Failed. Err: %d\n", ret);
>  			return ret;
>  		}
>  	}
>  
> -	hdcp->port_data.streams[0].stream_type = hdcp->content_type;
> -	ret = hdcp2_authenticate_port(connector);
> -	if (ret < 0)
> -		return ret;
> -
>  	return ret;
>  }
>  
> @@ -1626,14 +1607,50 @@ static int hdcp2_disable_encryption(struct intel_connector *connector)
>  	return ret;
>  }
>  
> +static int
> +hdcp2_propagate_stream_management_info(struct intel_connector *connector)
> +{
> +	struct drm_i915_private *i915 = to_i915(connector->base.dev);
> +	int i, tries = 3, ret;
> +
> +	if (!connector->hdcp.is_repeater)
> +		return 0;
> +
> +	for (i = 0; i < tries; i++) {
> +		ret = _hdcp2_propagate_stream_management_info(connector);
> +		if (!ret)
> +			break;
> +
> +		drm_dbg_kms(&i915->drm,
> +			    "HDCP2 stream management %d of %d Failed.(%d)\n",
> +			    i + 1, tries, ret);
> +	}
> +
> +	return ret;
> +}
> +
>  static int hdcp2_authenticate_and_encrypt(struct intel_connector *connector)
>  {
> +	struct drm_i915_private *i915 = to_i915(connector->base.dev);
> +	struct intel_hdcp *hdcp = &connector->hdcp;
>  	int ret, i, tries = 3;
>  
>  	for (i = 0; i < tries; i++) {
>  		ret = hdcp2_authenticate_sink(connector);
> -		if (!ret)
> -			break;
> +		if (!ret) {
> +			ret = hdcp2_propagate_stream_management_info(connector);
> +			if (!ret) {
> +				hdcp->port_data.streams[0].stream_type =
> +							hdcp->content_type;
> +				ret = hdcp2_authenticate_port(connector);
> +				if (!ret)
> +					break;
> +			} else {
> +				drm_dbg_kms(&i915->drm,
> +					    "HDCP2 stream management failed\n");

Please print ret values on failures, always.

> +				break;
> +			}
> +		}

The nesting here is a bit awkward. How about:

                if (!ret) {
			ret = hdcp2_propagate_stream_management_info(connector);
                        if (ret) {
				drm_dbg_kms(&i915->drm,
					    "HDCP2 stream mgmt fail %d\n", ret);
				break;
                        }

                        hdcp->port_data.streams[0].stream_type =
                                                        hdcp->content_type;
                        ret = hdcp2_authenticate_port(connector);
                        if (ret)
				drm_dbg_kms(&i915->drm,
                                            "HDCP2 auth port failed %d\n", ret);
                        else
                                break;
                }

>  
>  		/* Clearing the mei hdcp session */
>  		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",
> @@ -1642,7 +1659,7 @@ static int hdcp2_authenticate_and_encrypt(struct intel_connector *connector)
>  			DRM_DEBUG_KMS("Port deauth failed.\n");
>  	}
>  
> -	if (i != tries) {
> +	if (!ret) {
>  		/*
>  		 * Ensuring the required 200mSec min time interval between
>  		 * Session Key Exchange and encryption.
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-02-18 15:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 10:29 [Intel-gfx] [PATCH v2 0/5] HDCP misc Ramalingam C
2020-02-12 10:29 ` [Intel-gfx] [PATCH v2 1/5] drm/hdcp: optimizing the srm handling Ramalingam C
2020-02-18 15:43   ` Sean Paul
2020-02-12 10:29 ` [Intel-gfx] [PATCH v2 2/5] drm/hdcp: fix DRM_HDCP_2_KSV_COUNT_2_LSBITS Ramalingam C
2020-02-13 11:37   ` Anshuman Gupta
2020-02-12 10:29 ` [Intel-gfx] [PATCH v2 3/5] drm/i915: terminate reauth at stream management failure Ramalingam C
2020-02-13  8:51   ` Anshuman Gupta
2020-02-18 15:34   ` Sean Paul [this message]
2020-02-12 10:29 ` [Intel-gfx] [PATCH v2 4/5] drm/i915: dont retry stream management at seq_num_m roll over Ramalingam C
2020-02-13 10:37   ` Anshuman Gupta
2020-02-18 15:40   ` Sean Paul
2020-02-12 10:29 ` [Intel-gfx] [PATCH v2 5/5] drm/i915/hdcp: conversion to struct drm_device based logging macros Ramalingam C
2020-02-12 11:31   ` Jani Nikula
2020-02-12 11:39     ` Ramalingam C
2020-02-13  0:27 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for HDCP misc (rev2) Patchwork
2020-02-13  0:53 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-02-15 23:32 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-03-04  1:58 ` [Intel-gfx] [PATCH v2 0/5] HDCP misc Ramalingam C

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=20200218153455.GA253734@art_vandelay \
    --to=sean@poorly.run \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ramalingam.c@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).