diff mbox series

[1/2] drm/i915: terminate reauth at stream management failure

Message ID 20200211093002.23894-1-ramalingam.c@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: terminate reauth at stream management failure | expand

Commit Message

Ramalingam C Feb. 11, 2020, 9:30 a.m. UTC
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]

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 drivers/gpu/drm/i915/display/intel_hdcp.c | 71 ++++++++++++++---------
 1 file changed, 42 insertions(+), 29 deletions(-)

Comments

Gupta, Anshuman Feb. 11, 2020, 4:23 p.m. UTC | #1
On 2020-02-11 at 15:00:01 +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]
> 
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_hdcp.c | 71 ++++++++++++++---------
>  1 file changed, 42 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 4d1a33d13105..fad220d5d105 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:
>  	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;
>  	}
>  
> -	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,46 @@ static int hdcp2_disable_encryption(struct intel_connector *connector)
>  	return ret;
>  }
>  
> +static int
> +hdcp2_propagate_stream_management_info(struct intel_connector *connector)
> +{
> +	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_DEBUG_KMS("HDCP2 stream management %d of %d Failed.(%d)\n",
> +			      i + 1, tries, ret);
intel_hdcp.c has already replced all DRM_DEBUG_KMD to drm_db_kms() so any new 
logging need to use drm_dbg_kms().
Thanks ,
Anshuman Gupta.
> +	}
> +
> +	return ret;
> +}
> +
>  static int hdcp2_authenticate_and_encrypt(struct intel_connector *connector)
>  {
> +	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_DEBUG_KMS("HDCP2 stream management failed\n");
> +				break;
> +			}
> +		}
>  
>  		/* Clearing the mei hdcp session */
>  		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",
> @@ -1642,7 +1655,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
>
Ramalingam C Feb. 12, 2020, 8:18 a.m. UTC | #2
On 2020-02-11 at 21:53:55 +0530, Anshuman Gupta wrote:
> On 2020-02-11 at 15:00:01 +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]
> > 
> > Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_hdcp.c | 71 ++++++++++++++---------
> >  1 file changed, 42 insertions(+), 29 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > index 4d1a33d13105..fad220d5d105 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:
> >  	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;
> >  	}
> >  
> > -	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,46 @@ static int hdcp2_disable_encryption(struct intel_connector *connector)
> >  	return ret;
> >  }
> >  
> > +static int
> > +hdcp2_propagate_stream_management_info(struct intel_connector *connector)
> > +{
> > +	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_DEBUG_KMS("HDCP2 stream management %d of %d Failed.(%d)\n",
> > +			      i + 1, tries, ret);
> intel_hdcp.c has already replced all DRM_DEBUG_KMD to drm_db_kms() so any new 
> logging need to use drm_dbg_kms().
Thanks for pointing that out. I will replace remaining DRM_DEBUG_KMS
prints too in separate patch. I hope they are not left for a purpose.

-Ram.
> Thanks ,
> Anshuman Gupta.
> > +	}
> > +
> > +	return ret;
> > +}
> > +
> >  static int hdcp2_authenticate_and_encrypt(struct intel_connector *connector)
> >  {
> > +	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_DEBUG_KMS("HDCP2 stream management failed\n");
> > +				break;
> > +			}
> > +		}
> >  
> >  		/* Clearing the mei hdcp session */
> >  		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",
> > @@ -1642,7 +1655,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
> >
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
index 4d1a33d13105..fad220d5d105 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:
 	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;
 	}
 
-	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,46 @@  static int hdcp2_disable_encryption(struct intel_connector *connector)
 	return ret;
 }
 
+static int
+hdcp2_propagate_stream_management_info(struct intel_connector *connector)
+{
+	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_DEBUG_KMS("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 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_DEBUG_KMS("HDCP2 stream management failed\n");
+				break;
+			}
+		}
 
 		/* Clearing the mei hdcp session */
 		DRM_DEBUG_KMS("HDCP2.2 Auth %d of %d Failed.(%d)\n",
@@ -1642,7 +1655,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.