diff mbox series

[v3] drm/i915/hdcp: Update CP as per the kernel internal state

Message ID 20200630082048.22308-1-anshuman.gupta@intel.com (mailing list archive)
State New, archived
Headers show
Series [v3] drm/i915/hdcp: Update CP as per the kernel internal state | expand

Commit Message

Gupta, Anshuman June 30, 2020, 8:20 a.m. UTC
Content Protection property should be updated as per the kernel
internal state. Let's say if Content protection is disabled
by userspace, CP property should be set to UNDESIRED so that
reauthentication will not happen until userspace request it again,
but when kernel disables the HDCP due to any DDI disabling sequences
like modeset/DPMS operation, kernel should set the property to
DESIRED, so that when opportunity arises, kernel will start the
HDCP authentication on its own.

Somewhere in the line, state machine to set content protection to
DESIRED from kernel was broken and IGT coverage was missing for it.
This patch fixes it.

v2:
- Fixing hdcp CP state in connector atomic check function
  intel_hdcp_atomic_check(). [Maarten]
  This will require to check hdcp->value in intel_hdcp_update_pipe()
  in order to avoid enabling hdcp, if it was already enabled.

v3:
- Rebased.

Cc: Ramalingam C <ramalingam.c@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
Link: https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2 #v1
Link: https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3 #v2
---
 drivers/gpu/drm/i915/display/intel_hdcp.c | 27 +++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

Comments

Jani Nikula June 30, 2020, 10 a.m. UTC | #1
Uma, is the R-b still valid? It's been a while.

BR,
Jani.


On Tue, 30 Jun 2020, Anshuman Gupta <anshuman.gupta@intel.com> wrote:
> Content Protection property should be updated as per the kernel
> internal state. Let's say if Content protection is disabled
> by userspace, CP property should be set to UNDESIRED so that
> reauthentication will not happen until userspace request it again,
> but when kernel disables the HDCP due to any DDI disabling sequences
> like modeset/DPMS operation, kernel should set the property to
> DESIRED, so that when opportunity arises, kernel will start the
> HDCP authentication on its own.
>
> Somewhere in the line, state machine to set content protection to
> DESIRED from kernel was broken and IGT coverage was missing for it.
> This patch fixes it.
>
> v2:
> - Fixing hdcp CP state in connector atomic check function
>   intel_hdcp_atomic_check(). [Maarten]
>   This will require to check hdcp->value in intel_hdcp_update_pipe()
>   in order to avoid enabling hdcp, if it was already enabled.
>
> v3:
> - Rebased.
>
> Cc: Ramalingam C <ramalingam.c@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> Link: https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2 #v1
> Link: https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3 #v2
> ---
>  drivers/gpu/drm/i915/display/intel_hdcp.c | 27 +++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 815b054bb167..0d410652e194 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
>  		(conn_state->hdcp_content_type != hdcp->content_type &&
>  		 conn_state->content_protection !=
>  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> +	bool desired_and_not_enabled = false;
>  
>  	/*
>  	 * During the HDCP encryption session if Type change is requested,
> @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
>  	}
>  
>  	if (conn_state->content_protection ==
> -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> -	    content_protection_type_changed)
> +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> +		mutex_lock(&hdcp->mutex);
> +		/* Avoid enabling hdcp, if it already ENABLED */
> +		desired_and_not_enabled =
> +			hdcp->value != DRM_MODE_CONTENT_PROTECTION_ENABLED;
> +		mutex_unlock(&hdcp->mutex);
> +	}
> +
> +	if (desired_and_not_enabled || content_protection_type_changed)
>  		intel_hdcp_enable(connector,
>  				  crtc_state->cpu_transcoder,
>  				  (u8)conn_state->hdcp_content_type);
> @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  		return;
>  	}
>  
> +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> +						   new_state->crtc);
> +	/*
> +	 * Fix the HDCP uapi content protection state in case of modeset.
> +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> +	 * need to be sent if there is transition from ENABLED->DESIRED.
> +	 */
> +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
> +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> +		new_state->content_protection =
> +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> +
>  	/*
>  	 * Nothing to do if the state didn't change, or HDCP was activated since
>  	 * the last commit. And also no change in hdcp content type.
> @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  			return;
>  	}
>  
> -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> -						   new_state->crtc);
>  	crtc_state->mode_changed = true;
>  }
Jani Nikula June 30, 2020, 10:01 a.m. UTC | #2
Sean, Ram, good to go?

BR,
Jani.


On Tue, 30 Jun 2020, Anshuman Gupta <anshuman.gupta@intel.com> wrote:
> Content Protection property should be updated as per the kernel
> internal state. Let's say if Content protection is disabled
> by userspace, CP property should be set to UNDESIRED so that
> reauthentication will not happen until userspace request it again,
> but when kernel disables the HDCP due to any DDI disabling sequences
> like modeset/DPMS operation, kernel should set the property to
> DESIRED, so that when opportunity arises, kernel will start the
> HDCP authentication on its own.
>
> Somewhere in the line, state machine to set content protection to
> DESIRED from kernel was broken and IGT coverage was missing for it.
> This patch fixes it.
>
> v2:
> - Fixing hdcp CP state in connector atomic check function
>   intel_hdcp_atomic_check(). [Maarten]
>   This will require to check hdcp->value in intel_hdcp_update_pipe()
>   in order to avoid enabling hdcp, if it was already enabled.
>
> v3:
> - Rebased.
>
> Cc: Ramalingam C <ramalingam.c@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> Link: https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2 #v1
> Link: https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3 #v2
> ---
>  drivers/gpu/drm/i915/display/intel_hdcp.c | 27 +++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 815b054bb167..0d410652e194 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
>  		(conn_state->hdcp_content_type != hdcp->content_type &&
>  		 conn_state->content_protection !=
>  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> +	bool desired_and_not_enabled = false;
>  
>  	/*
>  	 * During the HDCP encryption session if Type change is requested,
> @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
>  	}
>  
>  	if (conn_state->content_protection ==
> -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> -	    content_protection_type_changed)
> +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> +		mutex_lock(&hdcp->mutex);
> +		/* Avoid enabling hdcp, if it already ENABLED */
> +		desired_and_not_enabled =
> +			hdcp->value != DRM_MODE_CONTENT_PROTECTION_ENABLED;
> +		mutex_unlock(&hdcp->mutex);
> +	}
> +
> +	if (desired_and_not_enabled || content_protection_type_changed)
>  		intel_hdcp_enable(connector,
>  				  crtc_state->cpu_transcoder,
>  				  (u8)conn_state->hdcp_content_type);
> @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  		return;
>  	}
>  
> +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> +						   new_state->crtc);
> +	/*
> +	 * Fix the HDCP uapi content protection state in case of modeset.
> +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> +	 * need to be sent if there is transition from ENABLED->DESIRED.
> +	 */
> +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
> +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> +		new_state->content_protection =
> +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> +
>  	/*
>  	 * Nothing to do if the state didn't change, or HDCP was activated since
>  	 * the last commit. And also no change in hdcp content type.
> @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  			return;
>  	}
>  
> -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> -						   new_state->crtc);
>  	crtc_state->mode_changed = true;
>  }
Ramalingam C June 30, 2020, 1:30 p.m. UTC | #3
On 2020-06-30 at 13:50:48 +0530, Anshuman Gupta wrote:
> Content Protection property should be updated as per the kernel
> internal state. Let's say if Content protection is disabled
> by userspace, CP property should be set to UNDESIRED so that
> reauthentication will not happen until userspace request it again,
> but when kernel disables the HDCP due to any DDI disabling sequences
> like modeset/DPMS operation, kernel should set the property to
> DESIRED, so that when opportunity arises, kernel will start the
> HDCP authentication on its own.
> 
> Somewhere in the line, state machine to set content protection to
> DESIRED from kernel was broken and IGT coverage was missing for it.
> This patch fixes it.
> 
> v2:
> - Fixing hdcp CP state in connector atomic check function
>   intel_hdcp_atomic_check(). [Maarten]
>   This will require to check hdcp->value in intel_hdcp_update_pipe()
>   in order to avoid enabling hdcp, if it was already enabled.
> 
> v3:
> - Rebased.
> 
> Cc: Ramalingam C <ramalingam.c@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> Link: https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2 #v1
> Link: https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3 #v2
> ---
>  drivers/gpu/drm/i915/display/intel_hdcp.c | 27 +++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index 815b054bb167..0d410652e194 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
>  		(conn_state->hdcp_content_type != hdcp->content_type &&
>  		 conn_state->content_protection !=
>  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> +	bool desired_and_not_enabled = false;
>  
>  	/*
>  	 * During the HDCP encryption session if Type change is requested,
> @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
>  	}
>  
>  	if (conn_state->content_protection ==
> -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> -	    content_protection_type_changed)
> +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> +		mutex_lock(&hdcp->mutex);
> +		/* Avoid enabling hdcp, if it already ENABLED */
> +		desired_and_not_enabled =
> +			hdcp->value != DRM_MODE_CONTENT_PROTECTION_ENABLED;

It will be good to move before the hdcp->value modification as below,
if (content_protection_type_changed)
	hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;

But this will impact only when content_protection_type_changed is true.
But when content_protection_type_changed is true we dont care the state of
desired_and_not_enabled as we use them in logical OR.

Either way. looks good to me.

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

> +		mutex_unlock(&hdcp->mutex);
> +	}
> +
> +	if (desired_and_not_enabled || content_protection_type_changed)
>  		intel_hdcp_enable(connector,
>  				  crtc_state->cpu_transcoder,
>  				  (u8)conn_state->hdcp_content_type);
> @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  		return;
>  	}
>  
> +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> +						   new_state->crtc);
> +	/*
> +	 * Fix the HDCP uapi content protection state in case of modeset.
> +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> +	 * need to be sent if there is transition from ENABLED->DESIRED.
> +	 */
> +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
Based on the IGT test result I infer needs_modeset status wont change from No->yes
after this point.

-ram
> +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> +		new_state->content_protection =
> +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> +
>  	/*
>  	 * Nothing to do if the state didn't change, or HDCP was activated since
>  	 * the last commit. And also no change in hdcp content type.
> @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
>  			return;
>  	}
>  
> -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> -						   new_state->crtc);
>  	crtc_state->mode_changed = true;
>  }
>  
> -- 
> 2.26.2
>
Shankar, Uma July 1, 2020, 7:59 a.m. UTC | #4
> -----Original Message-----
> From: Jani Nikula <jani.nikula@intel.com>
> Sent: Tuesday, June 30, 2020 3:30 PM
> To: Gupta, Anshuman <anshuman.gupta@intel.com>; intel-
> gfx@lists.freedesktop.org
> Cc: Shankar, Uma <uma.shankar@intel.com>
> Subject: Re: [Intel-gfx] [PATCH v3] drm/i915/hdcp: Update CP as per the kernel
> internal state
> 
> 
> Uma, is the R-b still valid? It's been a while.

Yeah Jani, the changes look good. Will need a rebase and fresh CI results though.

Regards,
Uma Shankar

> BR,
> Jani.
> 
> 
> On Tue, 30 Jun 2020, Anshuman Gupta <anshuman.gupta@intel.com> wrote:
> > Content Protection property should be updated as per the kernel
> > internal state. Let's say if Content protection is disabled by
> > userspace, CP property should be set to UNDESIRED so that
> > reauthentication will not happen until userspace request it again, but
> > when kernel disables the HDCP due to any DDI disabling sequences like
> > modeset/DPMS operation, kernel should set the property to DESIRED, so
> > that when opportunity arises, kernel will start the HDCP
> > authentication on its own.
> >
> > Somewhere in the line, state machine to set content protection to
> > DESIRED from kernel was broken and IGT coverage was missing for it.
> > This patch fixes it.
> >
> > v2:
> > - Fixing hdcp CP state in connector atomic check function
> >   intel_hdcp_atomic_check(). [Maarten]
> >   This will require to check hdcp->value in intel_hdcp_update_pipe()
> >   in order to avoid enabling hdcp, if it was already enabled.
> >
> > v3:
> > - Rebased.
> >
> > Cc: Ramalingam C <ramalingam.c@intel.com>
> > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> > Link:
> > https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2 #v1
> > Link:
> > https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3 #v2
> > ---
> >  drivers/gpu/drm/i915/display/intel_hdcp.c | 27
> > +++++++++++++++++++----
> >  1 file changed, 23 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > index 815b054bb167..0d410652e194 100644
> > --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct
> intel_atomic_state *state,
> >  		(conn_state->hdcp_content_type != hdcp->content_type &&
> >  		 conn_state->content_protection !=
> >  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> > +	bool desired_and_not_enabled = false;
> >
> >  	/*
> >  	 * During the HDCP encryption session if Type change is requested,
> > @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct
> intel_atomic_state *state,
> >  	}
> >
> >  	if (conn_state->content_protection ==
> > -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> > -	    content_protection_type_changed)
> > +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> > +		mutex_lock(&hdcp->mutex);
> > +		/* Avoid enabling hdcp, if it already ENABLED */
> > +		desired_and_not_enabled =
> > +			hdcp->value !=
> DRM_MODE_CONTENT_PROTECTION_ENABLED;
> > +		mutex_unlock(&hdcp->mutex);
> > +	}
> > +
> > +	if (desired_and_not_enabled || content_protection_type_changed)
> >  		intel_hdcp_enable(connector,
> >  				  crtc_state->cpu_transcoder,
> >  				  (u8)conn_state->hdcp_content_type);
> > @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct
> drm_connector *connector,
> >  		return;
> >  	}
> >
> > +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > +						   new_state->crtc);
> > +	/*
> > +	 * Fix the HDCP uapi content protection state in case of modeset.
> > +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> > +	 * need to be sent if there is transition from ENABLED->DESIRED.
> > +	 */
> > +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
> > +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> > +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> > +		new_state->content_protection =
> > +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> > +
> >  	/*
> >  	 * Nothing to do if the state didn't change, or HDCP was activated since
> >  	 * the last commit. And also no change in hdcp content type.
> > @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct drm_connector
> *connector,
> >  			return;
> >  	}
> >
> > -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > -						   new_state->crtc);
> >  	crtc_state->mode_changed = true;
> >  }
> 
> --
> Jani Nikula, Intel Open Source Graphics Center
Shankar, Uma July 1, 2020, 8:01 a.m. UTC | #5
> > -----Original Message-----
> > From: Jani Nikula <jani.nikula@intel.com>
> > Sent: Tuesday, June 30, 2020 3:30 PM
> > To: Gupta, Anshuman <anshuman.gupta@intel.com>; intel-
> > gfx@lists.freedesktop.org
> > Cc: Shankar, Uma <uma.shankar@intel.com>
> > Subject: Re: [Intel-gfx] [PATCH v3] drm/i915/hdcp: Update CP as per
> > the kernel internal state
> >
> >
> > Uma, is the R-b still valid? It's been a while.
> 
> Yeah Jani, the changes look good. Will need a rebase and fresh CI results though.

Seems the CI results are already out and we are clean.

> Regards,
> Uma Shankar
> 
> > BR,
> > Jani.
> >
> >
> > On Tue, 30 Jun 2020, Anshuman Gupta <anshuman.gupta@intel.com> wrote:
> > > Content Protection property should be updated as per the kernel
> > > internal state. Let's say if Content protection is disabled by
> > > userspace, CP property should be set to UNDESIRED so that
> > > reauthentication will not happen until userspace request it again,
> > > but when kernel disables the HDCP due to any DDI disabling sequences
> > > like modeset/DPMS operation, kernel should set the property to
> > > DESIRED, so that when opportunity arises, kernel will start the HDCP
> > > authentication on its own.
> > >
> > > Somewhere in the line, state machine to set content protection to
> > > DESIRED from kernel was broken and IGT coverage was missing for it.
> > > This patch fixes it.
> > >
> > > v2:
> > > - Fixing hdcp CP state in connector atomic check function
> > >   intel_hdcp_atomic_check(). [Maarten]
> > >   This will require to check hdcp->value in intel_hdcp_update_pipe()
> > >   in order to avoid enabling hdcp, if it was already enabled.
> > >
> > > v3:
> > > - Rebased.
> > >
> > > Cc: Ramalingam C <ramalingam.c@intel.com>
> > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> > > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> > > Link:
> > > https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2
> > > #v1
> > > Link:
> > > https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3
> > > #v2
> > > ---
> > >  drivers/gpu/drm/i915/display/intel_hdcp.c | 27
> > > +++++++++++++++++++----
> > >  1 file changed, 23 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > index 815b054bb167..0d410652e194 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct
> > intel_atomic_state *state,
> > >  		(conn_state->hdcp_content_type != hdcp->content_type &&
> > >  		 conn_state->content_protection !=
> > >  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> > > +	bool desired_and_not_enabled = false;
> > >
> > >  	/*
> > >  	 * During the HDCP encryption session if Type change is requested,
> > > @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct
> > intel_atomic_state *state,
> > >  	}
> > >
> > >  	if (conn_state->content_protection ==
> > > -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> > > -	    content_protection_type_changed)
> > > +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> > > +		mutex_lock(&hdcp->mutex);
> > > +		/* Avoid enabling hdcp, if it already ENABLED */
> > > +		desired_and_not_enabled =
> > > +			hdcp->value !=
> > DRM_MODE_CONTENT_PROTECTION_ENABLED;
> > > +		mutex_unlock(&hdcp->mutex);
> > > +	}
> > > +
> > > +	if (desired_and_not_enabled || content_protection_type_changed)
> > >  		intel_hdcp_enable(connector,
> > >  				  crtc_state->cpu_transcoder,
> > >  				  (u8)conn_state->hdcp_content_type);
> > > @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct
> > drm_connector *connector,
> > >  		return;
> > >  	}
> > >
> > > +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > > +						   new_state->crtc);
> > > +	/*
> > > +	 * Fix the HDCP uapi content protection state in case of modeset.
> > > +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> > > +	 * need to be sent if there is transition from ENABLED->DESIRED.
> > > +	 */
> > > +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
> > > +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> > > +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> > > +		new_state->content_protection =
> > > +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> > > +
> > >  	/*
> > >  	 * Nothing to do if the state didn't change, or HDCP was activated since
> > >  	 * the last commit. And also no change in hdcp content type.
> > > @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct
> > > drm_connector
> > *connector,
> > >  			return;
> > >  	}
> > >
> > > -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > > -						   new_state->crtc);
> > >  	crtc_state->mode_changed = true;
> > >  }
> >
> > --
> > Jani Nikula, Intel Open Source Graphics Center
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Gupta, Anshuman July 8, 2020, 8:25 a.m. UTC | #6
On 2020-07-01 at 13:31:18 +0530, Shankar, Uma wrote:
> > > -----Original Message-----
> > > From: Jani Nikula <jani.nikula@intel.com>
> > > Sent: Tuesday, June 30, 2020 3:30 PM
> > > To: Gupta, Anshuman <anshuman.gupta@intel.com>; intel-
> > > gfx@lists.freedesktop.org
> > > Cc: Shankar, Uma <uma.shankar@intel.com>
> > > Subject: Re: [Intel-gfx] [PATCH v3] drm/i915/hdcp: Update CP as per
> > > the kernel internal state
> > >
> > >
> > > Uma, is the R-b still valid? It's been a while.
> > 
> > Yeah Jani, the changes look good. Will need a rebase and fresh CI results though.
> 
> Seems the CI results are already out and we are clean.
Hi Ram ,
CI results are clean for this rebase patch,
Could you please help with merging,
I belive your RB's are valid either-way wrt to your comment.
Thanks,
Anshuman Gupta.

> 
> > Regards,
> > Uma Shankar
> > 
> > > BR,
> > > Jani.
> > >
> > >
> > > On Tue, 30 Jun 2020, Anshuman Gupta <anshuman.gupta@intel.com> wrote:
> > > > Content Protection property should be updated as per the kernel
> > > > internal state. Let's say if Content protection is disabled by
> > > > userspace, CP property should be set to UNDESIRED so that
> > > > reauthentication will not happen until userspace request it again,
> > > > but when kernel disables the HDCP due to any DDI disabling sequences
> > > > like modeset/DPMS operation, kernel should set the property to
> > > > DESIRED, so that when opportunity arises, kernel will start the HDCP
> > > > authentication on its own.
> > > >
> > > > Somewhere in the line, state machine to set content protection to
> > > > DESIRED from kernel was broken and IGT coverage was missing for it.
> > > > This patch fixes it.
> > > >
> > > > v2:
> > > > - Fixing hdcp CP state in connector atomic check function
> > > >   intel_hdcp_atomic_check(). [Maarten]
> > > >   This will require to check hdcp->value in intel_hdcp_update_pipe()
> > > >   in order to avoid enabling hdcp, if it was already enabled.
> > > >
> > > > v3:
> > > > - Rebased.
> > > >
> > > > Cc: Ramalingam C <ramalingam.c@intel.com>
> > > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > > Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> > > > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> > > > Link:
> > > > https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2
> > > > #v1
> > > > Link:
> > > > https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3
> > > > #v2
> > > > ---
> > > >  drivers/gpu/drm/i915/display/intel_hdcp.c | 27
> > > > +++++++++++++++++++----
> > > >  1 file changed, 23 insertions(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > index 815b054bb167..0d410652e194 100644
> > > > --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct
> > > intel_atomic_state *state,
> > > >  		(conn_state->hdcp_content_type != hdcp->content_type &&
> > > >  		 conn_state->content_protection !=
> > > >  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> > > > +	bool desired_and_not_enabled = false;
> > > >
> > > >  	/*
> > > >  	 * During the HDCP encryption session if Type change is requested,
> > > > @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct
> > > intel_atomic_state *state,
> > > >  	}
> > > >
> > > >  	if (conn_state->content_protection ==
> > > > -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> > > > -	    content_protection_type_changed)
> > > > +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> > > > +		mutex_lock(&hdcp->mutex);
> > > > +		/* Avoid enabling hdcp, if it already ENABLED */
> > > > +		desired_and_not_enabled =
> > > > +			hdcp->value !=
> > > DRM_MODE_CONTENT_PROTECTION_ENABLED;
> > > > +		mutex_unlock(&hdcp->mutex);
> > > > +	}
> > > > +
> > > > +	if (desired_and_not_enabled || content_protection_type_changed)
> > > >  		intel_hdcp_enable(connector,
> > > >  				  crtc_state->cpu_transcoder,
> > > >  				  (u8)conn_state->hdcp_content_type);
> > > > @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct
> > > drm_connector *connector,
> > > >  		return;
> > > >  	}
> > > >
> > > > +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > > > +						   new_state->crtc);
> > > > +	/*
> > > > +	 * Fix the HDCP uapi content protection state in case of modeset.
> > > > +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> > > > +	 * need to be sent if there is transition from ENABLED->DESIRED.
> > > > +	 */
> > > > +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
> > > > +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> > > > +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> > > > +		new_state->content_protection =
> > > > +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> > > > +
> > > >  	/*
> > > >  	 * Nothing to do if the state didn't change, or HDCP was activated since
> > > >  	 * the last commit. And also no change in hdcp content type.
> > > > @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct
> > > > drm_connector
> > > *connector,
> > > >  			return;
> > > >  	}
> > > >
> > > > -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > > > -						   new_state->crtc);
> > > >  	crtc_state->mode_changed = true;
> > > >  }
> > >
> > > --
> > > Jani Nikula, Intel Open Source Graphics Center
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Ramalingam C July 8, 2020, 9:58 a.m. UTC | #7
On 2020-07-08 at 13:55:16 +0530, Anshuman Gupta wrote:
> On 2020-07-01 at 13:31:18 +0530, Shankar, Uma wrote:
> > > > -----Original Message-----
> > > > From: Jani Nikula <jani.nikula@intel.com>
> > > > Sent: Tuesday, June 30, 2020 3:30 PM
> > > > To: Gupta, Anshuman <anshuman.gupta@intel.com>; intel-
> > > > gfx@lists.freedesktop.org
> > > > Cc: Shankar, Uma <uma.shankar@intel.com>
> > > > Subject: Re: [Intel-gfx] [PATCH v3] drm/i915/hdcp: Update CP as per
> > > > the kernel internal state
> > > >
> > > >
> > > > Uma, is the R-b still valid? It's been a while.
> > > 
> > > Yeah Jani, the changes look good. Will need a rebase and fresh CI results though.
> > 
> > Seems the CI results are already out and we are clean.
> Hi Ram ,
> CI results are clean for this rebase patch,
> Could you please help with merging,
Pushed into dinq. Thanks for the change.

-Ram
> I belive your RB's are valid either-way wrt to your comment.
> Thanks,
> Anshuman Gupta.
> 
> > 
> > > Regards,
> > > Uma Shankar
> > > 
> > > > BR,
> > > > Jani.
> > > >
> > > >
> > > > On Tue, 30 Jun 2020, Anshuman Gupta <anshuman.gupta@intel.com> wrote:
> > > > > Content Protection property should be updated as per the kernel
> > > > > internal state. Let's say if Content protection is disabled by
> > > > > userspace, CP property should be set to UNDESIRED so that
> > > > > reauthentication will not happen until userspace request it again,
> > > > > but when kernel disables the HDCP due to any DDI disabling sequences
> > > > > like modeset/DPMS operation, kernel should set the property to
> > > > > DESIRED, so that when opportunity arises, kernel will start the HDCP
> > > > > authentication on its own.
> > > > >
> > > > > Somewhere in the line, state machine to set content protection to
> > > > > DESIRED from kernel was broken and IGT coverage was missing for it.
> > > > > This patch fixes it.
> > > > >
> > > > > v2:
> > > > > - Fixing hdcp CP state in connector atomic check function
> > > > >   intel_hdcp_atomic_check(). [Maarten]
> > > > >   This will require to check hdcp->value in intel_hdcp_update_pipe()
> > > > >   in order to avoid enabling hdcp, if it was already enabled.
> > > > >
> > > > > v3:
> > > > > - Rebased.
> > > > >
> > > > > Cc: Ramalingam C <ramalingam.c@intel.com>
> > > > > Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > > > > Reviewed-by: Uma Shankar <uma.shankar@intel.com>
> > > > > Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com>
> > > > > Link:
> > > > > https://patchwork.freedesktop.org/patch/350962/?series=72664&rev=2
> > > > > #v1
> > > > > Link:
> > > > > https://patchwork.freedesktop.org/patch/359396/?series=72251&rev=3
> > > > > #v2
> > > > > ---
> > > > >  drivers/gpu/drm/i915/display/intel_hdcp.c | 27
> > > > > +++++++++++++++++++----
> > > > >  1 file changed, 23 insertions(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > > b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > > index 815b054bb167..0d410652e194 100644
> > > > > --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > > +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> > > > > @@ -2086,6 +2086,7 @@ void intel_hdcp_update_pipe(struct
> > > > intel_atomic_state *state,
> > > > >  		(conn_state->hdcp_content_type != hdcp->content_type &&
> > > > >  		 conn_state->content_protection !=
> > > > >  		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
> > > > > +	bool desired_and_not_enabled = false;
> > > > >
> > > > >  	/*
> > > > >  	 * During the HDCP encryption session if Type change is requested,
> > > > > @@ -2108,8 +2109,15 @@ void intel_hdcp_update_pipe(struct
> > > > intel_atomic_state *state,
> > > > >  	}
> > > > >
> > > > >  	if (conn_state->content_protection ==
> > > > > -	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
> > > > > -	    content_protection_type_changed)
> > > > > +	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
> > > > > +		mutex_lock(&hdcp->mutex);
> > > > > +		/* Avoid enabling hdcp, if it already ENABLED */
> > > > > +		desired_and_not_enabled =
> > > > > +			hdcp->value !=
> > > > DRM_MODE_CONTENT_PROTECTION_ENABLED;
> > > > > +		mutex_unlock(&hdcp->mutex);
> > > > > +	}
> > > > > +
> > > > > +	if (desired_and_not_enabled || content_protection_type_changed)
> > > > >  		intel_hdcp_enable(connector,
> > > > >  				  crtc_state->cpu_transcoder,
> > > > >  				  (u8)conn_state->hdcp_content_type);
> > > > > @@ -2158,6 +2166,19 @@ void intel_hdcp_atomic_check(struct
> > > > drm_connector *connector,
> > > > >  		return;
> > > > >  	}
> > > > >
> > > > > +	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > > > > +						   new_state->crtc);
> > > > > +	/*
> > > > > +	 * Fix the HDCP uapi content protection state in case of modeset.
> > > > > +	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
> > > > > +	 * need to be sent if there is transition from ENABLED->DESIRED.
> > > > > +	 */
> > > > > +	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
> > > > > +	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
> > > > > +	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
> > > > > +		new_state->content_protection =
> > > > > +			DRM_MODE_CONTENT_PROTECTION_DESIRED;
> > > > > +
> > > > >  	/*
> > > > >  	 * Nothing to do if the state didn't change, or HDCP was activated since
> > > > >  	 * the last commit. And also no change in hdcp content type.
> > > > > @@ -2170,8 +2191,6 @@ void intel_hdcp_atomic_check(struct
> > > > > drm_connector
> > > > *connector,
> > > > >  			return;
> > > > >  	}
> > > > >
> > > > > -	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
> > > > > -						   new_state->crtc);
> > > > >  	crtc_state->mode_changed = true;
> > > > >  }
> > > >
> > > > --
> > > > Jani Nikula, Intel Open Source Graphics Center
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
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 815b054bb167..0d410652e194 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
@@ -2086,6 +2086,7 @@  void intel_hdcp_update_pipe(struct intel_atomic_state *state,
 		(conn_state->hdcp_content_type != hdcp->content_type &&
 		 conn_state->content_protection !=
 		 DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
+	bool desired_and_not_enabled = false;
 
 	/*
 	 * During the HDCP encryption session if Type change is requested,
@@ -2108,8 +2109,15 @@  void intel_hdcp_update_pipe(struct intel_atomic_state *state,
 	}
 
 	if (conn_state->content_protection ==
-	    DRM_MODE_CONTENT_PROTECTION_DESIRED ||
-	    content_protection_type_changed)
+	    DRM_MODE_CONTENT_PROTECTION_DESIRED) {
+		mutex_lock(&hdcp->mutex);
+		/* Avoid enabling hdcp, if it already ENABLED */
+		desired_and_not_enabled =
+			hdcp->value != DRM_MODE_CONTENT_PROTECTION_ENABLED;
+		mutex_unlock(&hdcp->mutex);
+	}
+
+	if (desired_and_not_enabled || content_protection_type_changed)
 		intel_hdcp_enable(connector,
 				  crtc_state->cpu_transcoder,
 				  (u8)conn_state->hdcp_content_type);
@@ -2158,6 +2166,19 @@  void intel_hdcp_atomic_check(struct drm_connector *connector,
 		return;
 	}
 
+	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
+						   new_state->crtc);
+	/*
+	 * Fix the HDCP uapi content protection state in case of modeset.
+	 * FIXME: As per HDCP content protection property uapi doc, an uevent()
+	 * need to be sent if there is transition from ENABLED->DESIRED.
+	 */
+	if (drm_atomic_crtc_needs_modeset(crtc_state) &&
+	    (old_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED &&
+	    new_cp != DRM_MODE_CONTENT_PROTECTION_UNDESIRED))
+		new_state->content_protection =
+			DRM_MODE_CONTENT_PROTECTION_DESIRED;
+
 	/*
 	 * Nothing to do if the state didn't change, or HDCP was activated since
 	 * the last commit. And also no change in hdcp content type.
@@ -2170,8 +2191,6 @@  void intel_hdcp_atomic_check(struct drm_connector *connector,
 			return;
 	}
 
-	crtc_state = drm_atomic_get_new_crtc_state(new_state->state,
-						   new_state->crtc);
 	crtc_state->mode_changed = true;
 }